Skip to content

Commit

Permalink
don't return error and don't convert to lowercase
Browse files Browse the repository at this point in the history
  • Loading branch information
scrungus committed Sep 3, 2024
1 parent bddc345 commit 3572c6a
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 8 deletions.
5 changes: 1 addition & 4 deletions pkg/openstack/instancesv2.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,10 +134,7 @@ func (i *InstancesV2) InstanceMetadata(ctx context.Context, node *v1.Node) (*clo
return nil, err
}

availabilityZone, err := util.SanitizeLabel(server.AvailabilityZone)
if err != nil {
return nil, err
}
availabilityZone := util.SanitizeLabel(server.AvailabilityZone)

return &cloudprovider.InstanceMetadata{
ProviderID: i.makeInstanceID(&server),
Expand Down
2 changes: 1 addition & 1 deletion pkg/util/metadata/metadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ func (m *metadataService) GetAvailabilityZone() (string, error) {
if err != nil {
return "", err
}
return util.SanitizeLabel(md.AvailabilityZone)
return util.SanitizeLabel(md.AvailabilityZone), nil
}

func CheckMetadataSearchOrder(order string) error {
Expand Down
5 changes: 2 additions & 3 deletions pkg/util/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ func GetAZFromTopology(topologyKey string, requirement *csi.TopologyRequirement)
return zone
}

func SanitizeLabel(input string) (string, error) {
func SanitizeLabel(input string) string {
// Replace non-alphanumeric characters (except '-', '_', '.') with '-'
reg := regexp.MustCompile(`[^-a-zA-Z0-9_.]+`)
sanitized := reg.ReplaceAllString(input, "-")
Expand All @@ -182,6 +182,5 @@ func SanitizeLabel(input string) (string, error) {
sanitized = sanitized[:63]
}

// Convert to lowercase
return strings.ToLower(sanitized), nil
return sanitized
}

0 comments on commit 3572c6a

Please sign in to comment.