Skip to content

Commit

Permalink
Fix golangci lint issues
Browse files Browse the repository at this point in the history
  • Loading branch information
nikhilsbhat committed Sep 22, 2023
1 parent 9a3c62d commit bfa8caa
Show file tree
Hide file tree
Showing 30 changed files with 54 additions and 60 deletions.
1 change: 1 addition & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ linters:
- goconst
- varnamelen
- goerr113
- depguard

issues:
exclude-rules:
Expand Down
2 changes: 1 addition & 1 deletion internal/provider/data_agent_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ func dataSourceAgentConfig() *schema.Resource {
}
}

func datasourceAgentRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
func datasourceAgentRead(_ context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
defaultConfig := meta.(gocd.GoCd)

id := d.Id()
Expand Down
2 changes: 1 addition & 1 deletion internal/provider/data_artifact_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func dataSourceArtifactStore() *schema.Resource {
}
}

func datasourceArtifactStoreRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
func datasourceArtifactStoreRead(_ context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
defaultConfig := meta.(gocd.GoCd)

id := d.Id()
Expand Down
2 changes: 1 addition & 1 deletion internal/provider/data_auth_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ func dataSourceAuthConfig() *schema.Resource {
}
}

func datasourceAuthConfigRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
func datasourceAuthConfigRead(_ context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
defaultConfig := meta.(gocd.GoCd)

id := d.Id()
Expand Down
2 changes: 1 addition & 1 deletion internal/provider/data_cluster_profile.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func dataSourceClusterProfile() *schema.Resource {
}
}

func datasourceClusterProfileRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
func datasourceClusterProfileRead(_ context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
defaultConfig := meta.(gocd.GoCd)

id := d.Id()
Expand Down
2 changes: 1 addition & 1 deletion internal/provider/data_config_repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ func dataSourceConfigRepository() *schema.Resource {
}
}

func dataSourceConfigRepositoryRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
func dataSourceConfigRepositoryRead(_ context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
defaultConfig := meta.(gocd.GoCd)

id := d.Id()
Expand Down
2 changes: 1 addition & 1 deletion internal/provider/data_elastic_agent_profile.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func dataSourceElasticAgentProfile() *schema.Resource {
}
}

func datasourceElasticAgentProfileRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
func datasourceElasticAgentProfileRead(_ context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
defaultConfig := meta.(gocd.GoCd)

id := d.Id()
Expand Down
2 changes: 1 addition & 1 deletion internal/provider/data_environment.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func dataSourceEnvironment() *schema.Resource {
}
}

func datasourceEnvironmentRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
func datasourceEnvironmentRead(_ context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
defaultConfig := meta.(gocd.GoCd)

id := d.Id()
Expand Down
2 changes: 1 addition & 1 deletion internal/provider/data_pipeline.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func dataSourcePipeline() *schema.Resource {
}
}

func datasourcePipelineRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
func datasourcePipelineRead(_ context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
defaultConfig := meta.(gocd.GoCd)

id := d.Id()
Expand Down
15 changes: 4 additions & 11 deletions internal/provider/data_pipeline_group.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func dataSourcePipelineGroup() *schema.Resource {
}
}

func datasourcePipelineGroupRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
func datasourcePipelineGroupRead(_ context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
defaultConfig := meta.(gocd.GoCd)

id := d.Id()
Expand All @@ -69,14 +69,7 @@ func datasourcePipelineGroupRead(ctx context.Context, d *schema.ResourceData, me
return diag.Errorf(settingAttrErrorTmp, utils.TerraformResourceEtag, err)
}

flattenedAuthorization, err := flattenAuthorization(response.Authorization)
if err != nil {
d.SetId("")

return diag.Errorf("errored while flattening Authorization obtained: %v", err)
}

if err = d.Set(utils.TerraformResourceAuthorization, flattenedAuthorization); err != nil {
if err = d.Set(utils.TerraformResourceAuthorization, flattenAuthorization(response.Authorization)); err != nil {
return diag.Errorf(settingAttrErrorTmp, err, utils.TerraformResourceAuthorization)
}

Expand All @@ -85,14 +78,14 @@ func datasourcePipelineGroupRead(ctx context.Context, d *schema.ResourceData, me
return nil
}

func flattenAuthorization(authorization gocd.PipelineGroupAuthorizationConfig) ([]map[string]interface{}, error) {
func flattenAuthorization(authorization gocd.PipelineGroupAuthorizationConfig) []map[string]interface{} {
return []map[string]interface{}{
{
"admins": getUsersNRoles(authorization.Admins),
"operate": getUsersNRoles(authorization.Operate),
"view": getUsersNRoles(authorization.View),
},
}, nil
}
}

func getUsersNRoles(authorization gocd.AuthorizationConfig) []map[string]interface{} {
Expand Down
2 changes: 1 addition & 1 deletion internal/provider/data_plugin_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ func dataSourcePluginInfo() *schema.Resource {
}
}

func datasourcePluginInfoRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
func datasourcePluginInfoRead(_ context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
defaultConfig := meta.(gocd.GoCd)

id := d.Id()
Expand Down
2 changes: 1 addition & 1 deletion internal/provider/data_plugin_setting.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func dataSourcePluginsSetting() *schema.Resource {
}
}

func dataSourcePluginsSettingRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
func dataSourcePluginsSettingRead(_ context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
defaultConfig := meta.(gocd.GoCd)

id := d.Id()
Expand Down
2 changes: 1 addition & 1 deletion internal/provider/data_role.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ func dataSourceRole() *schema.Resource {
}
}

func datasourceRoleRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
func datasourceRoleRead(_ context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
defaultConfig := meta.(gocd.GoCd)

id := d.Id()
Expand Down
2 changes: 1 addition & 1 deletion internal/provider/data_secret_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ func dataSourceSecretConfig() *schema.Resource {
}
}

func dataSourceSecretConfigRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
func dataSourceSecretConfigRead(_ context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
defaultConfig := meta.(gocd.GoCd)

id := d.Id()
Expand Down
4 changes: 2 additions & 2 deletions internal/provider/resource_agent_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ func resourceAgentConfigCreate(ctx context.Context, d *schema.ResourceData, meta
return resourceAgentConfigRead(ctx, d, meta)
}

func resourceAgentConfigRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
func resourceAgentConfigRead(_ context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
defaultConfig := meta.(gocd.GoCd)

response, err := defaultConfig.GetAgent(d.Id())
Expand All @@ -120,7 +120,7 @@ func resourceAgentConfigRead(ctx context.Context, d *schema.ResourceData, meta i
return nil
}

func resourceAgentConfigDelete(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
func resourceAgentConfigDelete(_ context.Context, d *schema.ResourceData, _ interface{}) diag.Diagnostics {
id := d.Id()
if len(d.Id()) == 0 {
return diag.Errorf("resource with the ID '%s' not found", id)
Expand Down
6 changes: 3 additions & 3 deletions internal/provider/resource_artifact_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ func resourceArtifactStoreCreate(ctx context.Context, d *schema.ResourceData, me
return resourceArtifactStoreRead(ctx, d, meta)
}

func resourceArtifactStoreRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
func resourceArtifactStoreRead(_ context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
defaultConfig := meta.(gocd.GoCd)

storeID := utils.String(d.Get(utils.TerraformResourceStoreID))
Expand Down Expand Up @@ -116,7 +116,7 @@ func resourceArtifactStoreUpdate(ctx context.Context, d *schema.ResourceData, me
return resourceArtifactStoreRead(ctx, d, meta)
}

func resourceArtifactStoreDelete(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
func resourceArtifactStoreDelete(_ context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
defaultConfig := meta.(gocd.GoCd)

id := d.Id()
Expand All @@ -136,7 +136,7 @@ func resourceArtifactStoreDelete(ctx context.Context, d *schema.ResourceData, me
return nil
}

func resourceArtifactStoreImport(ctx context.Context, d *schema.ResourceData, meta interface{}) ([]*schema.ResourceData, error) {
func resourceArtifactStoreImport(_ context.Context, d *schema.ResourceData, meta interface{}) ([]*schema.ResourceData, error) {
defaultConfig := meta.(gocd.GoCd)

storeID := utils.String(d.Id())
Expand Down
6 changes: 3 additions & 3 deletions internal/provider/resource_auth_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ func resourceAuthConfigCreate(ctx context.Context, d *schema.ResourceData, meta
return nil
}

func resourceAuthConfigRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
func resourceAuthConfigRead(_ context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
defaultConfig := meta.(gocd.GoCd)

profileID := utils.String(d.Get(utils.TerraformResourceProfileID))
Expand Down Expand Up @@ -141,7 +141,7 @@ func resourceAuthConfigUpdate(ctx context.Context, d *schema.ResourceData, meta
return resourceAuthConfigRead(ctx, d, meta)
}

func resourceAuthConfigDelete(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
func resourceAuthConfigDelete(_ context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
defaultConfig := meta.(gocd.GoCd)

id := d.Id()
Expand All @@ -161,7 +161,7 @@ func resourceAuthConfigDelete(ctx context.Context, d *schema.ResourceData, meta
return nil
}

func resourceAuthConfigImport(ctx context.Context, d *schema.ResourceData, meta interface{}) ([]*schema.ResourceData, error) {
func resourceAuthConfigImport(_ context.Context, d *schema.ResourceData, meta interface{}) ([]*schema.ResourceData, error) {
defaultConfig := meta.(gocd.GoCd)

profileID := utils.String(d.Id())
Expand Down
4 changes: 2 additions & 2 deletions internal/provider/resource_backup_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ func resourceBackupConfigCreate(ctx context.Context, d *schema.ResourceData, met
return resourceBackupConfigRead(ctx, d, meta)
}

func resourceBackupConfigRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
func resourceBackupConfigRead(_ context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
defaultConfig := meta.(gocd.GoCd)

response, err := defaultConfig.GetBackupConfig()
Expand Down Expand Up @@ -130,7 +130,7 @@ func resourceBackupConfigUpdate(ctx context.Context, d *schema.ResourceData, met
return resourceBackupConfigRead(ctx, d, meta)
}

func resourceBackupConfigDelete(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
func resourceBackupConfigDelete(_ context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
defaultConfig := meta.(gocd.GoCd)

id := d.Id()
Expand Down
4 changes: 2 additions & 2 deletions internal/provider/resource_backup_schedule.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ func resourceBackupScheduleCreate(ctx context.Context, d *schema.ResourceData, m
return resourceBackupScheduleRead(ctx, d, meta)
}

func resourceBackupScheduleRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
func resourceBackupScheduleRead(_ context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
defaultConfig := meta.(gocd.GoCd)

retryAfter := d.Get(utils.TerraformResourceRetryAfter).(int)
Expand Down Expand Up @@ -155,7 +155,7 @@ func resourceBackupScheduleRead(ctx context.Context, d *schema.ResourceData, met
return nil
}

func resourceBackupScheduleDelete(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
func resourceBackupScheduleDelete(_ context.Context, d *schema.ResourceData, _ interface{}) diag.Diagnostics {
id := d.Id()
if len(d.Id()) == 0 {
return diag.Errorf("resource with the ID '%s' not found", id)
Expand Down
6 changes: 3 additions & 3 deletions internal/provider/resource_cluster_profile.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ func resourceClusterProfileCreate(ctx context.Context, d *schema.ResourceData, m
return resourceClusterProfileRead(ctx, d, meta)
}

func resourceClusterProfileRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
func resourceClusterProfileRead(_ context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
defaultConfig := meta.(gocd.GoCd)

profileID := utils.String(d.Get(utils.TerraformResourceProfileID))
Expand Down Expand Up @@ -132,7 +132,7 @@ func resourceClusterProfileUpdate(ctx context.Context, d *schema.ResourceData, m
return resourceClusterProfileRead(ctx, d, meta)
}

func resourceClusterProfileDelete(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
func resourceClusterProfileDelete(_ context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
defaultConfig := meta.(gocd.GoCd)

id := d.Id()
Expand All @@ -152,7 +152,7 @@ func resourceClusterProfileDelete(ctx context.Context, d *schema.ResourceData, m
return nil
}

func resourceClusterProfileImport(ctx context.Context, d *schema.ResourceData, meta interface{}) ([]*schema.ResourceData, error) {
func resourceClusterProfileImport(_ context.Context, d *schema.ResourceData, meta interface{}) ([]*schema.ResourceData, error) {
defaultConfig := meta.(gocd.GoCd)

profileID := utils.String(d.Id())
Expand Down
4 changes: 2 additions & 2 deletions internal/provider/resource_config_repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ func resourceConfigRepoCreate(ctx context.Context, d *schema.ResourceData, meta
return resourceConfigRepoRead(ctx, d, meta)
}

func resourceConfigRepoRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
func resourceConfigRepoRead(_ context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
defaultConfig := meta.(gocd.GoCd)

profileID := utils.String(d.Get(utils.TerraformResourceProfileID))
Expand Down Expand Up @@ -154,7 +154,7 @@ func resourceConfigRepoUpdate(ctx context.Context, d *schema.ResourceData, meta
return nil
}

func resourceConfigRepoDelete(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
func resourceConfigRepoDelete(_ context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
defaultConfig := meta.(gocd.GoCd)

if id := d.Id(); len(id) == 0 {
Expand Down
6 changes: 3 additions & 3 deletions internal/provider/resource_elastic_agent_profile.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ func resourceElasticAgentProfileCreate(ctx context.Context, d *schema.ResourceDa
return nil
}

func resourceElasticAgentProfileRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
func resourceElasticAgentProfileRead(_ context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
defaultConfig := meta.(gocd.GoCd)

profileID := utils.String(d.Get(utils.TerraformResourceProfileID))
Expand Down Expand Up @@ -117,7 +117,7 @@ func resourceElasticAgentProfileUpdate(ctx context.Context, d *schema.ResourceDa
return resourceElasticAgentProfileRead(ctx, d, meta)
}

func resourceElasticAgentProfileDelete(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
func resourceElasticAgentProfileDelete(_ context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
defaultConfig := meta.(gocd.GoCd)

if id := d.Id(); len(id) == 0 {
Expand All @@ -136,7 +136,7 @@ func resourceElasticAgentProfileDelete(ctx context.Context, d *schema.ResourceDa
return nil
}

func resourceElasticAgentProfileImport(ctx context.Context, d *schema.ResourceData, meta interface{}) ([]*schema.ResourceData, error) {
func resourceElasticAgentProfileImport(_ context.Context, d *schema.ResourceData, meta interface{}) ([]*schema.ResourceData, error) {
defaultConfig := meta.(gocd.GoCd)

profileID := utils.String(d.Id())
Expand Down
6 changes: 3 additions & 3 deletions internal/provider/resource_encrypt_value.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func resourceEncryptValue() *schema.Resource {
}
}

func resourceEncryptValueCreate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
func resourceEncryptValueCreate(_ context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
defaultConfig := meta.(gocd.GoCd)

if !d.IsNewResource() {
Expand Down Expand Up @@ -67,11 +67,11 @@ func resourceEncryptValueCreate(ctx context.Context, d *schema.ResourceData, met
return nil
}

func resourceEncryptValueRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
func resourceEncryptValueRead(_ context.Context, _ *schema.ResourceData, _ interface{}) diag.Diagnostics {
return nil
}

func resourceEncryptValueDelete(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
func resourceEncryptValueDelete(_ context.Context, d *schema.ResourceData, _ interface{}) diag.Diagnostics {
id := d.Id()
if len(d.Id()) == 0 {
return diag.Errorf("resource with the ID '%s' not found", id)
Expand Down
6 changes: 3 additions & 3 deletions internal/provider/resource_environments.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ func resourceEnvironmentCreate(ctx context.Context, d *schema.ResourceData, meta
return resourceEnvironmentRead(ctx, d, meta)
}

func resourceEnvironmentRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
func resourceEnvironmentRead(_ context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
defaultConfig := meta.(gocd.GoCd)

envName := utils.String(d.Get(utils.TerraformResourceName))
Expand Down Expand Up @@ -137,7 +137,7 @@ func resourceEnvironmentUpdate(ctx context.Context, d *schema.ResourceData, meta
return nil
}

func resourceEnvironmentDelete(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
func resourceEnvironmentDelete(_ context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
defaultConfig := meta.(gocd.GoCd)

if id := d.Id(); len(id) == 0 {
Expand All @@ -156,7 +156,7 @@ func resourceEnvironmentDelete(ctx context.Context, d *schema.ResourceData, meta
return nil
}

func resourceEnvironmentImport(ctx context.Context, d *schema.ResourceData, meta interface{}) ([]*schema.ResourceData, error) {
func resourceEnvironmentImport(_ context.Context, d *schema.ResourceData, meta interface{}) ([]*schema.ResourceData, error) {
defaultConfig := meta.(gocd.GoCd)

envName := utils.String(d.Id())
Expand Down
Loading

0 comments on commit bfa8caa

Please sign in to comment.