Skip to content

Commit

Permalink
Merge pull request #80 from umich-vci/fix_lint
Browse files Browse the repository at this point in the history
Fix lint
  • Loading branch information
adarobin authored Mar 25, 2024
2 parents 1045df2 + b42c4b3 commit da80b2a
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 9 deletions.
18 changes: 15 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,16 @@ on:
pull_request:
paths-ignore:
- 'README.md'
push:
paths-ignore:
- 'README.md'
# push:
# paths-ignore:
# - 'README.md'

# For systems with an upstream API that could drift unexpectedly (like most SaaS systems, etc.),
# we recommend testing at a regular interval not necessarily tied to code changes. This will
# ensure you are alerted to something breaking due to an API change, even if the code did not
# change.
schedule:
- cron: '0 13 * * *'

# Testing only needs permissions to read the repository contents.
permissions:
Expand Down Expand Up @@ -78,5 +85,10 @@ jobs:
- run: go mod download
- env:
TF_ACC: "1"

# Set whatever additional acceptance test env vars here. You can
# optionally use data from your repository secrets using the
# following syntax:
RHSM_REFRESH_TOKEN: ${{ secrets.RHSM_REFRESH_TOKEN }}
run: go test -v -cover ./internal/provider/
timeout-minutes: 10
29 changes: 29 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Visit https://golangci-lint.run/ for usage documentation
# and information on other useful linters
issues:
max-per-linter: 0
max-same-issues: 0
exclude-dirs:
- internal/sdkprovider

linters:
disable-all: true
enable:
- durationcheck
- errcheck
- exportloopref
- forcetypeassert
- godot
- gofmt
- gosimple
- ineffassign
- makezero
- misspell
- nilerr
- predeclared
- staticcheck
- tenv
- unconvert
- unparam
- unused
- vet
2 changes: 1 addition & 1 deletion docs/data-sources/cloud_access.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ Read-Only:
- `accounts` (Attributes List) A list of cloud accounts that are enabled for cloud access in the cloud provider. (see [below for nested schema](#nestedatt--enabled_accounts--accounts))
- `name` (String) The name of the cloud provider.
- `products` (Attributes List) A list of products that are entitled to the cloud provider. (see [below for nested schema](#nestedatt--enabled_accounts--products))
- `short_name` (String) An abreviation of the cloud provider name. Used when adding or removing accounts.
- `short_name` (String) An abbreviation of the cloud provider name. Used when adding or removing accounts.

<a id="nestedatt--enabled_accounts--accounts"></a>
### Nested Schema for `enabled_accounts.accounts`
Expand Down
14 changes: 10 additions & 4 deletions internal/provider/data_source_cloud_access.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ func (d *CloudAccessDataSource) Schema(ctx context.Context, req datasource.Schem
},
},
"short_name": schema.StringAttribute{
Description: "An abreviation of the cloud provider name. Used when adding or removing accounts.",
Description: "An abbreviation of the cloud provider name. Used when adding or removing accounts.",
Computed: true,
},
},
Expand All @@ -205,7 +205,13 @@ func (d *CloudAccessDataSource) Configure(ctx context.Context, req datasource.Co
return
}

d.client = req.ProviderData.(*apiClient)
client, ok := req.ProviderData.(*apiClient)
if !ok {
resp.Diagnostics.AddError("Failed to configure Cloud Access datasource", "Invalid provider data")
return
}

d.client = client
}

func (d *CloudAccessDataSource) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) {
Expand All @@ -221,15 +227,15 @@ func (d *CloudAccessDataSource) Read(ctx context.Context, req datasource.ReadReq
client := d.client.Client
auth := d.client.Auth

cap, _, err := client.CloudaccessAPI.ListEnabledCloudAccessProviders(auth).Execute()
ecap, _, err := client.CloudaccessAPI.ListEnabledCloudAccessProviders(auth).Execute()
if err != nil {
resp.Diagnostics.AddError("failed to list enabled cloud access providers", err.Error())
return
}

cloudProviders := []EnabledAccountsModel{}

for _, x := range cap.GetBody() {
for _, x := range ecap.GetBody() {
// cloudProvider := make(map[string]interface{})
cloudProvider := EnabledAccountsModel{
Name: types.StringValue(x.GetName()),
Expand Down
8 changes: 7 additions & 1 deletion internal/provider/resource_cloud_access_account.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,13 @@ func (r *CloudAccessAccountResource) Configure(ctx context.Context, req resource
return
}

r.client = req.ProviderData.(*apiClient)
client, ok := req.ProviderData.(*apiClient)
if !ok {
resp.Diagnostics.AddError("Failed to configure Cloud Access Account resource", "Invalid provider data")
return
}

r.client = client
}

func (r *CloudAccessAccountResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) {
Expand Down

0 comments on commit da80b2a

Please sign in to comment.