File tree Expand file tree Collapse file tree 4 files changed +14
-5
lines changed Expand file tree Collapse file tree 4 files changed +14
-5
lines changed Original file line number Diff line number Diff line change @@ -21,3 +21,4 @@ vendor/
2121
2222# IDE
2323.vscode
24+ .idea
Original file line number Diff line number Diff line change 2727linters :
2828 enable-all : true
2929 disable :
30+ - nestif
3031 - depguard
3132 - dupl
3233 - gochecknoglobals
Original file line number Diff line number Diff line change @@ -540,9 +540,13 @@ func (p *Plugin) createPlacementRule(policyConf *types.PolicyConfig) (
540540 matchExpressions := []map [string ]interface {}{}
541541 for _ , label := range keys {
542542 matchExpression := map [string ]interface {}{
543- "key" : label ,
544- "operator" : "In" ,
545- "values" : []string {policyConf .Placement .ClusterSelectors [label ]},
543+ "key" : label ,
544+ }
545+ if policyConf .Placement .ClusterSelectors [label ] == "" {
546+ matchExpression ["operator" ] = "Exist"
547+ } else {
548+ matchExpression ["operator" ] = "In"
549+ matchExpression ["values" ] = []string {policyConf .Placement .ClusterSelectors [label ]}
546550 }
547551 matchExpressions = append (matchExpressions , matchExpression )
548552 }
Original file line number Diff line number Diff line change @@ -575,8 +575,9 @@ func TestCreatePlacementRuleClusterSelectors(t *testing.T) {
575575 p .PolicyDefaults .Namespace = "my-policies"
576576 policyConf := types.PolicyConfig {Name : "policy-app-config" }
577577 policyConf .Placement .ClusterSelectors = map [string ]string {
578- "cloud" : "red hat" ,
579- "game" : "pacman" ,
578+ "cloud" : "red hat" ,
579+ "doesIt" : "" ,
580+ "game" : "pacman" ,
580581 }
581582
582583 name , err := p .createPlacementRule (& policyConf )
@@ -603,6 +604,8 @@ spec:
603604 operator: In
604605 values:
605606 - red hat
607+ - key: doesIt
608+ operator: Exist
606609 - key: game
607610 operator: In
608611 values:
You can’t perform that action at this time.
0 commit comments