Skip to content

Commit

Permalink
Fixing build errors.
Browse files Browse the repository at this point in the history
  • Loading branch information
Tzrlk committed Aug 13, 2024
1 parent 528c33a commit e2cf4b4
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 21 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,6 @@ dist/
*.tfstate
*.tfstate.backup
*.tfvars

# Examples
examples/**/*.json
7 changes: 5 additions & 2 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
# Visit https://golangci-lint.run/ for usage documentation
# and information on other useful linters
issues:
max-per-linter: 0
max-same-issues: 0
max-issues-per-linter: 0
max-same-issues: 0
exclude-rules:
- source: '//.+</?editor-fold'
linters: [ godot ]

linters:
disable-all: true
Expand Down
16 changes: 8 additions & 8 deletions internal/idmc/common/client_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ type ClientConfig struct {
Editors ClientConfigEditor
}

// NewClientConfig sets up a new ClientConfig with reasonable defaults
// NewClientConfig sets up a new ClientConfig with reasonable defaults.
func NewClientConfig(server string, opts ...ClientOption) (*ClientConfig, error) {
config := ClientConfig{
Server: server,
Expand All @@ -34,19 +34,19 @@ func NewClientConfig(server string, opts ...ClientOption) (*ClientConfig, error)
},
}

// mutate client and add all optional params
// mutate client and add all optional params.
for _, opt := range opts {
if err := opt(&config); err != nil {
return nil, err
}
}

// ensure the server URL always has a trailing slash
// ensure the server URL always has a trailing slash.
if !strings.HasSuffix(config.Server, "/") {
config.Server += "/"
}

// create httpClient, if not already present
// create httpClient, if not already present.
if config.Client == nil {
config.Client = &http.Client{}
}
Expand All @@ -66,7 +66,7 @@ func (c *ClientConfig) HandleRequest(
return nil, err
}

// Enrich request with
// Enrich request with the current context.
req = req.WithContext(ctx)

// Merge editors for this request in prep for usage.
Expand All @@ -77,17 +77,17 @@ func (c *ClientConfig) HandleRequest(
return nil, err
}

// Perform the request
// Perform the request.
res, err := c.Client.Do(req)
if err != nil {
return nil, err
}

// Apply response editors
// Apply response editors.
if err := editor.EditHttpResponse(ctx, res); err != nil {
return nil, err
}

// Return the response
// Return the response.
return res, nil
}
4 changes: 2 additions & 2 deletions internal/idmc/common/client_config_editor.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ import (
"terraform-provider-idmc/internal/utils"
)

// RequestEditorFn is the function signature for the RequestEditor callback function
// RequestEditorFn is the function signature for the RequestEditor callback function.
type RequestEditorFn func(ctx context.Context, req *http.Request) error

// ResponseEditorFn is the function signature for the ResponseEditor callback function
// ResponseEditorFn is the function signature for the ResponseEditor callback function.
type ResponseEditorFn func(ctx context.Context, res *http.Response) error

// ApiResponseEditorFn are functions that inspect or alter api-wrapped http responses.
Expand Down
12 changes: 6 additions & 6 deletions internal/idmc/v3/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ func (i *IdmcAdminV3Api) GetRolePrivileges(ctx context.Context, status *string)
}

return nil, fmt.Errorf(MsgGetRolePrivilegesFailed,
fmt.Errorf("recieved api error response: %s", *errBody))
fmt.Errorf("received api error response: %s", *errBody))

}

Expand All @@ -107,7 +107,7 @@ func (i *IdmcAdminV3Api) GetRolePrivileges(ctx context.Context, status *string)
func (i *IdmcAdminV3Api) lookupRolePrivilegeNames(ctx context.Context, privIds []string) ([]string, error) {

// Exit early if we don't have anything to do.
if privIds == nil || len(privIds) == 0 {
if len(privIds) == 0 {
return make([]string, 0), nil
}

Expand All @@ -131,7 +131,7 @@ const MsgAddRolePrivilegesFailed = "unable to add %d privileges to role %s: %v"
func (i *IdmcAdminV3Api) AddRolePrivileges(ctx context.Context, roleId string, privIds []string) error {

// Exit early if we don't have anything to do.
if privIds == nil || len(privIds) == 0 {
if len(privIds) == 0 {
return nil
}

Expand Down Expand Up @@ -173,7 +173,7 @@ func (i *IdmcAdminV3Api) AddRolePrivileges(ctx context.Context, roleId string, p
}

return fmt.Errorf(MsgAddRolePrivilegesFailed, len(privIds), roleId,
fmt.Errorf("recieved api error response: %s", *errBody))
fmt.Errorf("received api error response: %s", *errBody))

}

Expand All @@ -182,7 +182,7 @@ const MsgRemoveRolePrivilegesFailed = "unable to remove %d privileges from role
func (i *IdmcAdminV3Api) RemoveRolePrivileges(ctx context.Context, roleId string, privIds []string) error {

// Exit early if we don't have anything to do.
if privIds == nil || len(privIds) == 0 {
if len(privIds) == 0 {
return nil
}

Expand Down Expand Up @@ -224,7 +224,7 @@ func (i *IdmcAdminV3Api) RemoveRolePrivileges(ctx context.Context, roleId string
}

return fmt.Errorf(MsgRemoveRolePrivilegesFailed, len(privIds), roleId,
fmt.Errorf("recieved api error response: %s", *errBody))
fmt.Errorf("received api error response: %s", *errBody))

}

Expand Down
6 changes: 3 additions & 3 deletions internal/utils/hash_set.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ func (set *HashSet[T]) put(item T) {
// Filter returns a subset, that contains only the values that satisfies the given filter.
func (set *HashSet[T]) Filter(filter func(item T) bool) *HashSet[T] {
result := NewHashSet[T]()
for item, _ := range set.table {
for item := range set.table {
if filter(item) {
result.table[item] = struct{}{}
}
Expand All @@ -116,12 +116,12 @@ func (set *HashSet[T]) Union(other *HashSet[T]) *HashSet[T] {
result := NewHashSet[T]()

// First add all the items from the first table
for item, _ := range set.table {
for item := range set.table {
result.table[item] = struct{}{}
}

// Then do the same for the second.
for item, _ := range other.table {
for item := range other.table {
result.table[item] = struct{}{}
}

Expand Down

0 comments on commit e2cf4b4

Please sign in to comment.