Skip to content

Commit

Permalink
fix new issues point by golangci-lint
Browse files Browse the repository at this point in the history
  • Loading branch information
uturunku1 committed Sep 28, 2021
1 parent be0ed9d commit 771ab13
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 19 deletions.
6 changes: 3 additions & 3 deletions admin_setting_saml.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,14 @@ type AdminSAMLSetting struct {
}

// Read returns the SAML settings.
func (s *adminSAMLSettings) Read(ctx context.Context) (*AdminSAMLSetting, error) {
req, err := s.client.newRequest("GET", "admin/saml-settings", nil)
func (a *adminSAMLSettings) Read(ctx context.Context) (*AdminSAMLSetting, error) {
req, err := a.client.newRequest("GET", "admin/saml-settings", nil)
if err != nil {
return nil, err
}

saml := &AdminSAMLSetting{}
err = s.client.do(ctx, req, saml)
err = a.client.do(ctx, req, saml)
if err != nil {
return nil, err
}
Expand Down
3 changes: 1 addition & 2 deletions helper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -561,9 +561,8 @@ func createRunWithStatus(t *testing.T, client *Client, w *Workspace, timeout int
func createPlannedRun(t *testing.T, client *Client, w *Workspace) (*Run, func()) {
if paidFeaturesDisabled() {
return createRunWithStatus(t, client, w, 45, RunPlanned)
} else {
return createRunWithStatus(t, client, w, 45, RunCostEstimated)
}
return createRunWithStatus(t, client, w, 45, RunCostEstimated)
}

func createCostEstimatedRun(t *testing.T, client *Client, w *Workspace) (*Run, func()) {
Expand Down
2 changes: 1 addition & 1 deletion ip_ranges.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ func (i *ipRanges) customDo(ctx context.Context, req *retryablehttp.Request, ir
defer resp.Body.Close()

if resp.StatusCode < 200 && resp.StatusCode >= 400 {
return fmt.Errorf("Error HTTP response while retrieving IP ranges: %d", resp.StatusCode)
return fmt.Errorf("error HTTP response while retrieving IP ranges: %d", resp.StatusCode)
} else if resp.StatusCode == 304 {
return nil
}
Expand Down
2 changes: 1 addition & 1 deletion oauth_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ func (o OAuthClientCreateOptions) valid() error {
return errors.New("service provider is required")
}
if validString(o.PrivateKey) && *o.ServiceProvider != *ServiceProvider(ServiceProviderAzureDevOpsServer) {
return errors.New("Private Key can only be present with Azure DevOps Server service provider")
return errors.New("private Key can only be present with Azure DevOps Server service provider")
}
return nil
}
Expand Down
4 changes: 2 additions & 2 deletions policy_set_version.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,11 @@ type PolicySetVersion struct {
func (p PolicySetVersion) uploadURL() (string, error) {
uploadURL, ok := p.Links["upload"].(string)
if !ok {
return uploadURL, fmt.Errorf("The Policy Set Version does not contain an upload link.")
return uploadURL, fmt.Errorf("the Policy Set Version does not contain an upload link")
}

if uploadURL == "" {
return uploadURL, fmt.Errorf("The Policy Set Version upload URL is empty.")
return uploadURL, fmt.Errorf("the Policy Set Version upload URL is empty")
}

return uploadURL, nil
Expand Down
2 changes: 1 addition & 1 deletion registry_module.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ type RegistryModuleVersion struct {
func (r *registryModules) Upload(ctx context.Context, rmv RegistryModuleVersion, path string) error {
uploadURL, ok := rmv.Links["upload"].(string)
if !ok {
return fmt.Errorf("Provided RegistryModuleVersion does not contain an upload link")
return fmt.Errorf("provided RegistryModuleVersion does not contain an upload link")
}

body, err := packContents(path)
Expand Down
17 changes: 8 additions & 9 deletions tfe.go
Original file line number Diff line number Diff line change
Expand Up @@ -531,18 +531,18 @@ func serializeRequestBody(v interface{}) (interface{}, error) {

// Infer whether the request uses jsonapi or regular json
// serialization based on how the fields are tagged.
jsonApiFields := 0
jsonAPIFields := 0
jsonFields := 0
for i := 0; i < modelType.NumField(); i++ {
structField := modelType.Field(i)
if structField.Tag.Get("jsonapi") != "" {
jsonApiFields++
jsonAPIFields++
}
if structField.Tag.Get("json") != "" {
jsonFields++
}
}
if jsonApiFields > 0 && jsonFields > 0 {
if jsonAPIFields > 0 && jsonFields > 0 {
// Defining a struct with both json and jsonapi tags doesn't
// make sense, because a struct can only be serialized
// as one or another. If this does happen, it's a bug
Expand All @@ -552,13 +552,12 @@ func serializeRequestBody(v interface{}) (interface{}, error) {

if jsonFields > 0 {
return json.Marshal(v)
} else {
buf := bytes.NewBuffer(nil)
if err := jsonapi.MarshalPayloadWithoutIncluded(buf, v); err != nil {
return nil, err
}
return buf, nil
}
buf := bytes.NewBuffer(nil)
if err := jsonapi.MarshalPayloadWithoutIncluded(buf, v); err != nil {
return nil, err
}
return buf, nil
}

// do sends an API request and returns the API response. The API response
Expand Down

0 comments on commit 771ab13

Please sign in to comment.