Skip to content
This repository has been archived by the owner on Jul 31, 2023. It is now read-only.

Commit

Permalink
Merge pull request #85 from kappnav/paulOwnerVars
Browse files Browse the repository at this point in the history
Onwer variables for KAM
  • Loading branch information
paulben authored Apr 30, 2020
2 parents 4f3466c + c8f31ed commit 2c52761
Showing 1 changed file with 18 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ public class KindActionMappingProcessor {
private String compName;
private String compSubkind;
private String compKind;
private OwnerRef compMatchingOwner;

public KindActionMappingProcessor(String namespace, OwnerRef[] owners, String apiVersion, String name,
String subkind, String kind) {
Expand All @@ -91,6 +92,7 @@ public KindActionMappingProcessor(String namespace, OwnerRef[] owners, String ap
this.compName = name;
this.compSubkind = subkind;
this.compKind = kind;
this.compMatchingOwner = null;
}

/**
Expand Down Expand Up @@ -477,7 +479,13 @@ else if ( resourceOwnerReferences == null ) {
// (false) and mapping rule api(Version) and uid do not match resource owner
// apiVersion and uid.
else {
return uidMatches(resourceOwnerReferences[i],mappingRuleOwnerUID) && apiMatches(resourceOwnerReferences[i],mappingRuleOwnerAPI);
if (uidMatches(resourceOwnerReferences[i],mappingRuleOwnerUID) &&
apiMatches(resourceOwnerReferences[i],mappingRuleOwnerAPI)) {
this.compMatchingOwner = resourceOwnerReferences[i];
return true;
} else {
return false;
}
}
}
}
Expand Down Expand Up @@ -694,6 +702,15 @@ private String mapNameSubstitute(String rawMapName, String namespace) {
this.compSubkind.toLowerCase(Locale.ENGLISH);
} else if ( parts[i].equals("${kind}") ) {
actualMapName = actualMapName + this.compKind.toLowerCase(Locale.ENGLISH);
} else if ( parts[i].equals("${owner.apiVersion}") &&
this.compMatchingOwner != null ) {
actualMapName = actualMapName + this.compMatchingOwner.getApiVersion().replace('/','-');
} else if ( parts[i].equals("${owner.kind}") &&
this.compMatchingOwner != null ) {
actualMapName = actualMapName + this.compMatchingOwner.getKind().toLowerCase(Locale.ENGLISH);
} else if ( parts[i].equals("${owner.uid}") &&
this.compMatchingOwner != null ) {
actualMapName = actualMapName + this.compMatchingOwner.getUID();
} else {
actualMapName = actualMapName + parts[i];
}
Expand Down

0 comments on commit 2c52761

Please sign in to comment.