Skip to content

Commit

Permalink
allow uppercase in labels and properly handle parsing errors
Browse files Browse the repository at this point in the history
  • Loading branch information
thecodeassassin committed Nov 20, 2022
1 parent ab238f0 commit 98174a0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 4 additions & 0 deletions commands/cluster/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ func (c *CreateClusterCommand) Command() *cobra.Command {

nodeTaints, nodeLabels, err := util.ParseTaintsAndLabels(taints, labels)

if err != nil {
return err
}

clusterName := args[0]
c.CommandOpts.Logger.Info().Msgf("Creating cluster %s", clusterName)

Expand Down
4 changes: 2 additions & 2 deletions pkg/util/kubernetes.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func ParseTaintsAndLabels(taints []string, labels []string) ([]symbiosis.NodeTai

for i, taint := range taints {

re := regexp.MustCompile(`([a-z0-9\-\_]+)\=([a-z0-9\-\_]+)\=(NoSchedule|NoExecute|PreferNoSchedule)`)
re := regexp.MustCompile(`([a-z0-9\-\_]+)\=([a-zA-Z0-9\-\_]+)\=(NoSchedule|NoExecute|PreferNoSchedule)`)
if ok := re.Match([]byte(taint)); !ok {
return nil, nil, fmt.Errorf("Taint %s could not be parsed. Format: key=value=NoSchedule. Types currently supported are: NoSchedule, NoExecute and PreferNoSchedule.", taint)
}
Expand All @@ -45,7 +45,7 @@ func ParseTaintsAndLabels(taints []string, labels []string) ([]symbiosis.NodeTai
}

for x, label := range labels {
re := regexp.MustCompile(`([a-z0-9\-\_]+)\=([a-z0-9\-\_]+)`)
re := regexp.MustCompile(`([a-z0-9\-\_]+)\=([a-zA-Z0-9\-\_]+)`)
if ok := re.Match([]byte(label)); !ok {
return nil, nil, fmt.Errorf("Label %s could not be parsed. Format: key=value", label)
}
Expand Down

0 comments on commit 98174a0

Please sign in to comment.