Skip to content

Commit 3572c6a

Browse files
author
scrungus
committed
don't return error and don't convert to lowercase
1 parent bddc345 commit 3572c6a

File tree

3 files changed

+4
-8
lines changed

3 files changed

+4
-8
lines changed

pkg/openstack/instancesv2.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -134,10 +134,7 @@ func (i *InstancesV2) InstanceMetadata(ctx context.Context, node *v1.Node) (*clo
134134
return nil, err
135135
}
136136

137-
availabilityZone, err := util.SanitizeLabel(server.AvailabilityZone)
138-
if err != nil {
139-
return nil, err
140-
}
137+
availabilityZone := util.SanitizeLabel(server.AvailabilityZone)
141138

142139
return &cloudprovider.InstanceMetadata{
143140
ProviderID: i.makeInstanceID(&server),

pkg/util/metadata/metadata.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ func (m *metadataService) GetAvailabilityZone() (string, error) {
306306
if err != nil {
307307
return "", err
308308
}
309-
return util.SanitizeLabel(md.AvailabilityZone)
309+
return util.SanitizeLabel(md.AvailabilityZone), nil
310310
}
311311

312312
func CheckMetadataSearchOrder(order string) error {

pkg/util/util.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ func GetAZFromTopology(topologyKey string, requirement *csi.TopologyRequirement)
169169
return zone
170170
}
171171

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

185-
// Convert to lowercase
186-
return strings.ToLower(sanitized), nil
185+
return sanitized
187186
}

0 commit comments

Comments
 (0)