Skip to content

Commit da4bcd6

Browse files
committed
refactor: Fix/ignore linter errors
1 parent 4210c7f commit da4bcd6

File tree

5 files changed

+29
-30
lines changed

5 files changed

+29
-30
lines changed

ionoscloud/data_source_container_registry.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ func dataSourceContainerRegistry() *schema.Resource {
120120
}
121121
}
122122

123+
//nolint:gocyclo
123124
func dataSourceContainerRegistryRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
124125
client := meta.(services.SdkBundle).ContainerClient
125126

@@ -173,7 +174,7 @@ func dataSourceContainerRegistryRead(ctx context.Context, d *schema.ResourceData
173174
registriesByName = append(registriesByName, registryItem)
174175
}
175176
}
176-
if registriesByName != nil && len(registriesByName) > 0 {
177+
if len(registriesByName) > 0 {
177178
results = registriesByName
178179
} else {
179180
return diag.FromErr(fmt.Errorf("no registry found with the specified criteria: name = %v", name))
@@ -188,7 +189,7 @@ func dataSourceContainerRegistryRead(ctx context.Context, d *schema.ResourceData
188189
registriesByLocation = append(registriesByLocation, registryItem)
189190
}
190191
}
191-
if registriesByLocation != nil && len(registriesByLocation) > 0 {
192+
if len(registriesByLocation) > 0 {
192193
results = registriesByLocation
193194
} else {
194195
return diag.FromErr(fmt.Errorf("no registry found with the specified criteria: location = %v", location))

ionoscloud/data_source_container_registry_token.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ func dataSourceContainerRegistryTokenRead(ctx context.Context, d *schema.Resourc
138138
}
139139
}
140140

141-
if results == nil || len(results) == 0 {
141+
if len(results) == 0 {
142142
return diag.FromErr(fmt.Errorf("no token found with the specified name = %s", name))
143143
} else if len(results) > 1 {
144144
return diag.FromErr(fmt.Errorf("more than one token found with the specified criteria: name = %s", name))

services/containerregistry/client.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ func NewClient(username, password, token, url, version, terraformVersion string,
2525
newConfigRegistry.MaxWaitTime = constant.MaxWaitTime
2626
newConfigRegistry.UserAgent = fmt.Sprintf(
2727
"terraform-provider/%s_ionos-cloud-sdk-go-container-cr/%s_hashicorp-terraform/%s_terraform-plugin-sdk/%s_os/%s_arch/%s",
28-
version, cr.Version, terraformVersion, meta.SDKVersionString(), runtime.GOOS, runtime.GOARCH)
28+
version, cr.Version, terraformVersion, meta.SDKVersionString(), runtime.GOOS, runtime.GOARCH) //nolint:staticcheck
2929
client := &Client{
3030
sdkClient: *cr.NewAPIClient(newConfigRegistry),
3131
}

services/containerregistry/registries.go

Lines changed: 23 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -364,35 +364,33 @@ func GetScopes(d *schema.ResourceData) []cr.Scope {
364364

365365
if scopeValue, ok := d.GetOk("scopes"); ok {
366366
scopeValue := scopeValue.([]interface{})
367-
if scopeValue != nil {
368-
for _, item := range scopeValue {
369-
370-
scopeContent := item.(map[string]interface{})
371-
connection := cr.Scope{}
372-
373-
if actions, ok := scopeContent["actions"]; ok {
374-
actions := actions.([]interface{})
375-
var actionsToAdd []string
376-
if actions != nil && len(actions) > 0 {
377-
for _, action := range actions {
378-
actionsToAdd = append(actionsToAdd, action.(string))
379-
}
380-
}
381-
connection.Actions = actionsToAdd
382-
}
367+
for _, item := range scopeValue {
383368

384-
if name, ok := scopeContent["name"]; ok {
385-
name := name.(string)
386-
connection.Name = name
387-
}
369+
scopeContent := item.(map[string]interface{})
370+
connection := cr.Scope{}
388371

389-
if scopeType, ok := scopeContent["type"]; ok {
390-
scopeType := scopeType.(string)
391-
connection.Type = scopeType
372+
if actions, ok := scopeContent["actions"]; ok {
373+
actions := actions.([]interface{})
374+
var actionsToAdd []string
375+
if len(actions) > 0 {
376+
for _, action := range actions {
377+
actionsToAdd = append(actionsToAdd, action.(string))
378+
}
392379
}
380+
connection.Actions = actionsToAdd
381+
}
382+
383+
if name, ok := scopeContent["name"]; ok {
384+
name := name.(string)
385+
connection.Name = name
386+
}
393387

394-
scopes = append(scopes, connection)
388+
if scopeType, ok := scopeContent["type"]; ok {
389+
scopeType := scopeType.(string)
390+
connection.Type = scopeType
395391
}
392+
393+
scopes = append(scopes, connection)
396394
}
397395

398396
}
@@ -451,7 +449,7 @@ func SetCredentials(credentials cr.Credentials) map[string]interface{} {
451449
//nolint:golint
452450
func SetScopes(scopes []cr.Scope) []interface{} {
453451

454-
var tokenScopes []interface{}
452+
var tokenScopes []interface{} //nolint:prealloc
455453
for _, scope := range scopes {
456454
scopeEntry := make(map[string]interface{})
457455

utils/constant/constants.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,7 @@ const (
334334
DataplatformNodePoolsTestDataSource = "test_dataplatform_node_pools"
335335
DataplatformVersionsTestDataSource = "test_dataplatform_versions"
336336
// DataPlatformVersion lowest 'available' version is now 24.3
337-
DataPlatformVersion = "24.3"
337+
DataPlatformVersion = "24.11"
338338
DataPlatformNameRegexConstraint = "^[A-Za-z0-9][-A-Za-z0-9_.]*[A-Za-z0-9]$"
339339
DataPlatformRegexNameError = "name should match " + DataPlatformNameRegexConstraint
340340
)

0 commit comments

Comments
 (0)