Skip to content

Commit

Permalink
Merge pull request kubeedge#5564 from HT0403/master
Browse files Browse the repository at this point in the history
Keadm Tool Enhancement
  • Loading branch information
kubeedge-bot authored May 28, 2024
2 parents 04eb67d + 6ab8576 commit 5efd287
Show file tree
Hide file tree
Showing 5 changed files with 980 additions and 0 deletions.
1 change: 1 addition & 0 deletions keadm/cmd/keadm/app/cmd/common/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ type JoinOptions struct {
CertPort string
CGroupDriver string
Labels []string
Sets string

// WithMQTT ...
// Deprecated: the mqtt broker is alreay managed by the DaemonSet in the cloud
Expand Down
8 changes: 8 additions & 0 deletions keadm/cmd/keadm/app/cmd/edge/join_others.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,9 @@ func AddJoinOtherFlags(cmd *cobra.Command, joinOptions *common.JoinOptions) {

cmd.Flags().StringVar(&joinOptions.HubProtocol, common.HubProtocol, joinOptions.HubProtocol,
`Use this key to decide which communication protocol the edge node adopts.`)

cmd.Flags().StringVar(&joinOptions.Sets, common.FlagNameSet, joinOptions.Sets,
`Set values on the command line (can specify multiple or separate values with commas: key1=val1,key2=val2)`)
}

func createEdgeConfigFiles(opt *common.JoinOptions) error {
Expand Down Expand Up @@ -165,6 +168,11 @@ func createEdgeConfigFiles(opt *common.JoinOptions) error {
if len(opt.Labels) > 0 {
edgeCoreConfig.Modules.Edged.NodeLabels = setEdgedNodeLabels(opt)
}
if len(opt.Sets) > 0 {
if err := util.ParseSet(edgeCoreConfig, opt.Sets); err != nil {
return err
}
}

if errs := validation.ValidateEdgeCoreConfiguration(edgeCoreConfig); len(errs) > 0 {
return errors.New(pkgutil.SpliceErrors(errs.ToAggregate().Errors()))
Expand Down
9 changes: 9 additions & 0 deletions keadm/cmd/keadm/app/cmd/edge/join_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,9 @@ func AddJoinOtherFlags(cmd *cobra.Command, joinOptions *common.JoinOptions) {

cmd.Flags().StringVar(&joinOptions.HubProtocol, common.HubProtocol, joinOptions.HubProtocol,
`Use this key to decide which communication protocol the edge node adopts.`)

cmd.Flags().StringVar(&joinOptions.Sets, common.FlagNameSet, joinOptions.Sets,
`Set values on the command line (can specify multiple or separate values with commas: key1=val1,key2=val2)`)
}

func createEdgeConfigFiles(opt *common.JoinOptions) error {
Expand Down Expand Up @@ -153,6 +156,12 @@ func createEdgeConfigFiles(opt *common.JoinOptions) error {
edgeCoreConfig.Modules.Edged.NodeLabels = setEdgedNodeLabels(opt)
}

if len(opt.Sets) > 0 {
if err := util.ParseSet(edgeCoreConfig, opt.Sets); err != nil {
return err
}
}

if errs := validation.ValidateEdgeCoreConfiguration(edgeCoreConfig); len(errs) > 0 {
return errors.New(pkgutil.SpliceErrors(errs.ToAggregate().Errors()))
}
Expand Down
Loading

0 comments on commit 5efd287

Please sign in to comment.