Skip to content

Commit

Permalink
Fix lint errors & update formatting
Browse files Browse the repository at this point in the history
Lint error on Go 1.18:

```
provider/generate_test.go:250:18: strings.Title has been deprecated since Go 1.18 and an alternative has been available since Go 1.0: The rule Title uses for word boundaries does not handle Unicode punctuation properly. Use golang.org/x/text/cases instead.  (SA1019)
qa/testing.go:458:17: strings.Title has been deprecated since Go 1.18 and an alternative has been available since Go 1.0: The rule Title uses for word boundaries does not handle Unicode punctuation properly. Use golang.org/x/text/cases instead.  (SA1019)
```
  • Loading branch information
alexott committed May 3, 2022
1 parent 36c961d commit f02bfd2
Show file tree
Hide file tree
Showing 9 changed files with 28 additions and 26 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ fmt-docs:

lint: vendor
@echo "✓ Linting source code with https://staticcheck.io/ ..."
@staticcheck ./...
@staticcheck -go 1.18 ./...

test: lint
@echo "✓ Running tests ..."
Expand Down
12 changes: 6 additions & 6 deletions catalog/data_views_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@ func TestViewsData(t *testing.T) {
Tables: []TableInfo{
{
CatalogName: "a",
SchemaName: "b",
Name: "c",
TableType: "MANAGED",
SchemaName: "b",
Name: "c",
TableType: "MANAGED",
},
{
CatalogName: "a",
SchemaName: "b",
Name: "d",
TableType: "VIEW",
SchemaName: "b",
Name: "d",
TableType: "VIEW",
},
},
},
Expand Down
26 changes: 13 additions & 13 deletions catalog/resource_grants.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,29 +157,29 @@ func (sm securableMapping) validate(d attributeGetter, pl PermissionsList) error
var mapping = securableMapping{
// add other securable mappings once needed
"table": {
"MODIFY": true,
"SELECT": true,
"MODIFY": true,
"SELECT": true,
},
"view": {
"SELECT": true,
"SELECT": true,
},
"catalog": {
"CREATE": true,
"USAGE": true,
"CREATE": true,
"USAGE": true,
},
"schema": {
"CREATE": true,
"USAGE": true,
"CREATE": true,
"USAGE": true,
},
"storage_credential": {
"CREATE_TABLE": true,
"READ_FILES": true,
"WRITE_FILES": true,
"CREATE_TABLE": true,
"READ_FILES": true,
"WRITE_FILES": true,
},
"external_location": {
"CREATE_TABLE": true,
"READ_FILES": true,
"WRITE_FILES": true,
"CREATE_TABLE": true,
"READ_FILES": true,
"WRITE_FILES": true,
},
}

Expand Down
4 changes: 2 additions & 2 deletions common/resource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func TestHTTP404TriggersResourceRemovalForReadAndDelete(t *testing.T) {
}
r := Resource{
Create: nope,
Read: nope,
Read: nope,
Update: nope,
Delete: nope,
Schema: map[string]*schema.Schema{
Expand All @@ -59,7 +59,7 @@ func TestHTTP404TriggersResourceRemovalForReadAndDelete(t *testing.T) {
client := &DatabricksClient{}
ctx := context.Background()
d := r.TestResourceData()

// Create propagates 404 error
diags := r.CreateContext(ctx, d, client)
assert.True(t, diags.HasError())
Expand Down
2 changes: 1 addition & 1 deletion permissions/resource_permissions.go
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ func (a PermissionsAPI) Read(objectID string) (objectACL ObjectACL, err error) {
err = a.client.Get(a.context, urlPathForObjectID(objectID), nil, &objectACL)
apiErr, ok := err.(common.APIError)
// https://github.com/databrickslabs/terraform-provider-databricks/issues/1227
// platform propagates INVALID_STATE error for auto-purged clusters in
// platform propagates INVALID_STATE error for auto-purged clusters in
// the permissions api. this adds "a logical fix" also here, not to introduce
// cross-package dependency on "clusters".
if ok && strings.Contains(apiErr.Message, "Cannot access cluster") && apiErr.StatusCode == 400 {
Expand Down
4 changes: 2 additions & 2 deletions permissions/resource_permissions_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -799,7 +799,7 @@ func TestResourcePermissionsCreate_PathIdRetriever_Error(t *testing.T) {
qa.HTTPFailures[0],
},
Resource: ResourcePermissions(),
Create: true,
Create: true,
HCL: `notebook_path = "/foo/bar"
access_control {
Expand All @@ -816,7 +816,7 @@ func TestResourcePermissionsCreate_ActualUpdate_Error(t *testing.T) {
qa.HTTPFailures[0],
},
Resource: ResourcePermissions(),
Create: true,
Create: true,
HCL: `cluster_id = "abc"
access_control {
Expand Down
1 change: 1 addition & 0 deletions provider/generate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,7 @@ func TestGenerateTestCodeStubs(t *testing.T) {
if part == "acl" || part == "mws" {
stub.Name += strings.ToUpper(part)
} else {
//lint:ignore SA1019 wait until full porting to Go 1.18 is done
stub.Name += strings.Title(part)
}
}
Expand Down
1 change: 1 addition & 0 deletions qa/testing.go
Original file line number Diff line number Diff line change
Expand Up @@ -455,6 +455,7 @@ func HttpFixtureClientWithToken(t *testing.T, fixtures []HTTPFixture, token stri
// golang styles, meh...
camel += strings.ToUpper(key)
} else {
//lint:ignore SA1019 wait until full porting to Go 1.18 is done
camel += strings.Title(part)
}
}
Expand Down
2 changes: 1 addition & 1 deletion storage/resource_mount.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ func ResourceMount() *schema.Resource {
r.DeleteContext = mountCallback(mountDelete).preProcess(r)
r.Importer = nil
r.Timeouts = &schema.ResourceTimeout{
Default: schema.DefaultTimeout(20*time.Minute),
Default: schema.DefaultTimeout(20 * time.Minute),
}
return r
}

0 comments on commit f02bfd2

Please sign in to comment.