Skip to content

Commit

Permalink
fix key value
Browse files Browse the repository at this point in the history
Signed-off-by: Ryan Tay <[email protected]>
  • Loading branch information
Ryan Tay committed Aug 16, 2024
1 parent f86c135 commit afd5f8a
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 12 deletions.
1 change: 0 additions & 1 deletion admiral/cmd/admiral/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,6 @@ func GetRootCmd(args []string) *cobra.Command {
rootCmd.PersistentFlags().BoolVar(&params.AdmiralOperatorMode, "admiral_operator_mode", false, "Enable/Disable admiral operator functionality")
rootCmd.PersistentFlags().StringVar(&params.OperatorSyncNamespace, "operator_sync_namespace", "admiral-operator-sync",
"Namespace in which Admiral Operator will put its generated configurations")
rootCmd.PersistentFlags().StringVar(&params.LabelSet.OperatorIdentityLabelKey, "operator_identity_label_key", "admiral.io/operatorIdentity", "used to filter which shard Admiral Operator will watch")
rootCmd.PersistentFlags().StringVar(&params.LabelSet.ShardIdentityLabelKey, "shard_identity_label_key", "admiral.io/shardIdentity", "used to filter which shard Admiral Operator will watch")
rootCmd.PersistentFlags().StringVar(&params.OperatorIdentityValue, "operator_identity_value", "", "Admiral operator should watch shards where operatorIdentityLabelKey == operatorIdentityValue")
rootCmd.PersistentFlags().StringVar(&params.ShardIdentityValue, "shard_identity_value", "", "Admiral operator should watch shards where shardIdentityLabelKey == shardIdentityValue")
Expand Down
4 changes: 0 additions & 4 deletions admiral/pkg/clusters/shard_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,6 @@ func (sh *ShardHandler) Added(ctx context.Context, obj *admiralapiv1.Shard) erro
}

func (sh *ShardHandler) Deleted(ctx context.Context, obj *admiralapiv1.Shard) error {
//err := HandleEventForShard(ctx, admiral.Delete, obj, sh.RemoteRegistry)
//if err != nil {
// return fmt.Errorf(LogErrFormat, common.Delete, common.ShardResourceType, obj.Name, "", err)
//}
ctxLogger := common.GetCtxLogger(ctx, obj.Name, "")
ctxLogger.Warnf(common.CtxLogFormat, "ShardHandlerDeleted", obj.Name, obj.Namespace, "", "", "Shard object was deleted")
return nil
Expand Down
6 changes: 4 additions & 2 deletions admiral/pkg/controller/admiral/shard.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ import (
"time"
)

const OperatorIdentityLabelKey = "admiral.io/operatorIdentity"

type ShardHandler interface {
Added(ctx context.Context, obj *admiralapiv1.Shard) error
Deleted(ctx context.Context, obj *admiralapiv1.Shard) error
Expand Down Expand Up @@ -150,9 +152,9 @@ func NewShardController(stopCh <-chan struct{}, handler ShardHandler, configPath
return nil, fmt.Errorf("failed to create shard controller crd client: %v", err)
}
labelOptions := informers.WithTweakListOptions(func(opts *metav1.ListOptions) {
opIdLabel, opIdValue := common.GetOperatorIdentityLabelKeyValueSet()
opIdValue := common.GetOperatorIdentityLabelValue()
shardIdLabel, shardIdValue := common.GetShardIdentityLabelKeyValueSet()
opts.LabelSelector = fmt.Sprintf("%s=%s, %s=%s", opIdLabel, opIdValue, shardIdLabel, shardIdValue)
opts.LabelSelector = fmt.Sprintf("%s=%s, %s=%s", OperatorIdentityLabelKey, opIdValue, shardIdLabel, shardIdValue)
})
informerFactory := informers.NewSharedInformerFactoryWithOptions(shardController.K8sClient, resyncPeriod, labelOptions)
informerFactory.Start(stopCh)
Expand Down
4 changes: 2 additions & 2 deletions admiral/pkg/controller/admiral/shard_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ func GetMockShard() *admiralapiv1.Shard {
LastUpdatedTime: v1.Time{},
},
}
opIdLabel, opIdValue := common.GetOperatorIdentityLabelKeyValueSet()
opIdValue := common.GetOperatorIdentityLabelValue()
shardIdLabel, shardIdValue := common.GetShardIdentityLabelKeyValueSet()
shard.Labels = map[string]string{opIdLabel: opIdValue, shardIdLabel: shardIdValue}
shard.Labels = map[string]string{OperatorIdentityLabelKey: opIdValue, shardIdLabel: shardIdValue}
return &shard
}

Expand Down
4 changes: 2 additions & 2 deletions admiral/pkg/controller/common/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -471,10 +471,10 @@ func GetOperatorSyncNamespace() string {
return wrapper.params.OperatorSyncNamespace
}

func GetOperatorIdentityLabelKeyValueSet() (string, string) {
func GetOperatorIdentityLabelValue() string {
wrapper.RLock()
defer wrapper.RUnlock()
return wrapper.params.LabelSet.OperatorIdentityLabelKey, wrapper.params.OperatorIdentityValue
return wrapper.params.OperatorIdentityValue
}

func GetShardIdentityLabelKeyValueSet() (string, string) {
Expand Down
1 change: 0 additions & 1 deletion admiral/pkg/controller/common/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,6 @@ type LabelSet struct {
GatewayApp string //the value for `app` key that will be used to fetch the loadblancer for cross cluster calls, also referred to as east west gateway
AdmiralCRDIdentityLabel string //Label Used to identify identity label for crd
IdentityPartitionKey string //Label used for partitioning assets with same identity into groups
OperatorIdentityLabelKey string
ShardIdentityLabelKey string
}

Expand Down

0 comments on commit afd5f8a

Please sign in to comment.