Skip to content

Commit

Permalink
refactor: remove unneeded parameter that can also be inferred from DR
Browse files Browse the repository at this point in the history
  • Loading branch information
metacosm committed May 23, 2023
1 parent fa25f53 commit dec4a9a
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ private GenericKubernetesResourceMatcher(KubernetesDependentResource<R, P> depen

@SuppressWarnings({"unchecked", "rawtypes"})
static <R extends HasMetadata, P extends HasMetadata> Matcher<R, P> matcherFor(
Class<R> resourceType, KubernetesDependentResource<R, P> dependentResource) {
KubernetesDependentResource<R, P> dependentResource) {
return new GenericKubernetesResourceMatcher(dependentResource);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public abstract class KubernetesDependentResource<R extends HasMetadata, P exten
public KubernetesDependentResource(Class<R> resourceType) {
super(resourceType);
matcher = this instanceof Matcher ? (Matcher<R, P>) this
: GenericKubernetesResourceMatcher.matcherFor(resourceType, this);
: GenericKubernetesResourceMatcher.matcherFor(this);

processor = this instanceof ResourceUpdatePreProcessor
? (ResourceUpdatePreProcessor<R>) this
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@ void checksIfDesiredValuesAreTheSame() {
var actual = createDeployment();
final var desired = createDeployment();
final var dependentResource = new TestDependentResource(desired);
final var matcher =
GenericKubernetesResourceMatcher.matcherFor(Deployment.class, dependentResource);
final var matcher = GenericKubernetesResourceMatcher.matcherFor(dependentResource);
assertThat(matcher.match(actual, null, context).matched()).isTrue();
assertThat(matcher.match(actual, null, context).computedDesired().isPresent()).isTrue();
assertThat(matcher.match(actual, null, context).computedDesired().get()).isEqualTo(desired);
Expand Down Expand Up @@ -86,8 +85,7 @@ void checkServiceAccount() {
.addNewImagePullSecret("imagePullSecret3")
.build();

final var matcher = GenericKubernetesResourceMatcher.matcherFor(ServiceAccount.class,
serviceAccountDR);
final var matcher = GenericKubernetesResourceMatcher.matcherFor(serviceAccountDR);
assertThat(matcher.match(actual, null, context).matched()).isFalse();
}

Expand Down

0 comments on commit dec4a9a

Please sign in to comment.