Skip to content

Commit

Permalink
address go vet failures
Browse files Browse the repository at this point in the history
  • Loading branch information
radeksimko committed Feb 12, 2025
1 parent 162ae72 commit 4833c96
Show file tree
Hide file tree
Showing 10 changed files with 25 additions and 24 deletions.
8 changes: 4 additions & 4 deletions internal/backend/remote/backend_common.go
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ func (b *Remote) costEstimate(stopCtx, cancelCtx context.Context, op *backendrun
b.CLI.Output("\n------------------------------------------------------------------------")
return nil
case tfe.CostEstimateCanceled:
return fmt.Errorf(msgPrefix + " canceled.")
return fmt.Errorf("%s canceled.", msgPrefix)
default:
return fmt.Errorf("Unknown or unexpected cost estimate state: %s", ce.Status)
}
Expand Down Expand Up @@ -416,15 +416,15 @@ func (b *Remote) checkPolicy(stopCtx, cancelCtx context.Context, op *backendrun.
}
continue
case tfe.PolicyErrored:
return fmt.Errorf(msgPrefix + " errored.")
return fmt.Errorf("%s errored.", msgPrefix)
case tfe.PolicyHardFailed:
return fmt.Errorf(msgPrefix + " hard failed.")
return fmt.Errorf("%s hard failed.", msgPrefix)
case tfe.PolicySoftFailed:
runURL := fmt.Sprintf(runHeaderErr, b.hostname, b.organization, op.Workspace, r.ID)

if op.Type == backendrun.OperationTypePlan || op.UIOut == nil || op.UIIn == nil ||
!pc.Actions.IsOverridable || !pc.Permissions.CanOverride {
return fmt.Errorf(msgPrefix + " soft failed.\n" + runURL)
return fmt.Errorf("%s soft failed.\n%s", msgPrefix, runURL)
}

if op.AutoApprove {
Expand Down
8 changes: 4 additions & 4 deletions internal/cloud/backend_common.go
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ func (b *Cloud) costEstimate(stopCtx, cancelCtx context.Context, op *backendrun.
b.CLI.Output("\n------------------------------------------------------------------------")
return nil
case tfe.CostEstimateCanceled:
return fmt.Errorf(msgPrefix + " canceled.")
return fmt.Errorf("%s canceled.", msgPrefix)
default:
return fmt.Errorf("Unknown or unexpected cost estimate state: %s", ce.Status)
}
Expand Down Expand Up @@ -387,15 +387,15 @@ func (b *Cloud) checkPolicy(stopCtx, cancelCtx context.Context, op *backendrun.O
}
continue
case tfe.PolicyErrored:
return fmt.Errorf(msgPrefix + " errored.")
return fmt.Errorf("%s errored.", msgPrefix)
case tfe.PolicyHardFailed:
return fmt.Errorf(msgPrefix + " hard failed.")
return fmt.Errorf("%s hard failed.", msgPrefix)
case tfe.PolicySoftFailed:
runURL := fmt.Sprintf(runHeaderErr, b.Hostname, b.Organization, op.Workspace, r.ID)

if op.Type == backendrun.OperationTypePlan || op.UIOut == nil || op.UIIn == nil ||
!pc.Actions.IsOverridable || !pc.Permissions.CanOverride {
return fmt.Errorf(msgPrefix + " soft failed.\n" + runURL)
return fmt.Errorf("%s soft failed.\n%s", msgPrefix, runURL)
}

if op.AutoApprove {
Expand Down
6 changes: 3 additions & 3 deletions internal/command/jsonformat/plan_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7849,12 +7849,12 @@ func runTestCases(t *testing.T, testCases map[string]testCase) {

beforeDynamicValue, err := plans.NewDynamicValue(beforeVal, ty)
if err != nil {
t.Fatalf("failed to create dynamic before value: " + err.Error())
t.Fatalf("failed to create dynamic before value: %s", err.Error())
}

afterDynamicValue, err := plans.NewDynamicValue(afterVal, ty)
if err != nil {
t.Fatalf("failed to create dynamic after value: " + err.Error())
t.Fatalf("failed to create dynamic after value: %s", err.Error())
}

src := &plans.ResourceInstanceChangeSrc{
Expand Down Expand Up @@ -7895,7 +7895,7 @@ func runTestCases(t *testing.T, testCases map[string]testCase) {
}
jsonchanges, err := jsonplan.MarshalResourceChanges([]*plans.ResourceInstanceChangeSrc{src}, tfschemas)
if err != nil {
t.Errorf("failed to marshal resource changes: " + err.Error())
t.Errorf("failed to marshal resource changes: %s", err.Error())
return
}

Expand Down
12 changes: 6 additions & 6 deletions internal/command/views/operation.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,26 +146,26 @@ func (v *OperationHuman) PlanNextStep(planPath string, genConfigPath string) {
v.view.outputHorizRule()

if genConfigPath != "" {
v.view.streams.Printf(
v.view.streams.Println(
format.WordWrap(
"\n"+strings.TrimSpace(fmt.Sprintf(planHeaderGenConfig, genConfigPath)),
v.view.outputColumns(),
) + "\n")
))
}

if planPath == "" {
v.view.streams.Print(
v.view.streams.Println(
format.WordWrap(
"\n"+strings.TrimSpace(planHeaderNoOutput),
v.view.outputColumns(),
) + "\n",
),
)
} else {
v.view.streams.Printf(
v.view.streams.Println(
format.WordWrap(
"\n"+strings.TrimSpace(fmt.Sprintf(planHeaderYesOutput, planPath, planPath)),
v.view.outputColumns(),
) + "\n",
),
)
}
}
Expand Down
2 changes: 1 addition & 1 deletion internal/lang/funcs/collection.go
Original file line number Diff line number Diff line change
Expand Up @@ -515,7 +515,7 @@ var SumFunc = function.New(&function.Spec{
ty := args[0].Type()

if !ty.IsListType() && !ty.IsSetType() && !ty.IsTupleType() {
return cty.NilVal, function.NewArgErrorf(0, fmt.Sprintf("argument must be list, set, or tuple. Received %s", ty.FriendlyName()))
return cty.NilVal, function.NewArgErrorf(0, "argument must be list, set, or tuple. Received %s", ty.FriendlyName())
}

if !args[0].IsWhollyKnown() {
Expand Down
3 changes: 2 additions & 1 deletion internal/lang/funcs/crypto.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"encoding/asn1"
"encoding/base64"
"encoding/hex"
"errors"
"fmt"
"hash"
"io"
Expand Down Expand Up @@ -175,7 +176,7 @@ var RsaDecryptFunc = function.New(&function.Spec{
default:
errStr = fmt.Sprintf("invalid private key: %s", e)
}
return cty.UnknownVal(cty.String), function.NewArgErrorf(1, errStr)
return cty.UnknownVal(cty.String), function.NewArgError(1, errors.New(errStr))
}
privateKey, ok := rawKey.(*rsa.PrivateKey)
if !ok {
Expand Down
4 changes: 2 additions & 2 deletions internal/plans/objchange/compatible.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@ func assertObjectCompatible(schema *configschema.Block, planned, actual cty.Valu
}

if planned.IsNull() && !actual.IsNull() {
errs = append(errs, path.NewErrorf(fmt.Sprintf("%swas absent, but now present", atRoot)))
errs = append(errs, path.NewErrorf("%swas absent, but now present", atRoot))
return errs
}
if actual.IsNull() && !planned.IsNull() {
errs = append(errs, path.NewErrorf(fmt.Sprintf("%swas present, but now absent", atRoot)))
errs = append(errs, path.NewErrorf("%swas present, but now absent", atRoot))
return errs
}
if planned.IsNull() {
Expand Down
2 changes: 1 addition & 1 deletion internal/plugin/grpc_provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@ func (p *GRPCProvider) ReadResource(r providers.ReadResourceRequest) (resp provi

resSchema, ok := schema.ResourceTypes[r.TypeName]
if !ok {
resp.Diagnostics = resp.Diagnostics.Append(fmt.Errorf("unknown resource type " + r.TypeName))
resp.Diagnostics = resp.Diagnostics.Append(fmt.Errorf("unknown resource type %s", r.TypeName))
return resp
}

Expand Down
2 changes: 1 addition & 1 deletion internal/plugin6/grpc_provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ func (p *GRPCProvider) ReadResource(r providers.ReadResourceRequest) (resp provi

resSchema, ok := schema.ResourceTypes[r.TypeName]
if !ok {
resp.Diagnostics = resp.Diagnostics.Append(fmt.Errorf("unknown resource type " + r.TypeName))
resp.Diagnostics = resp.Diagnostics.Append(fmt.Errorf("unknown resource type %s", r.TypeName))
return resp
}

Expand Down
2 changes: 1 addition & 1 deletion internal/rpcapi/dependencies.go
Original file line number Diff line number Diff line change
Expand Up @@ -566,7 +566,7 @@ func (s *dependenciesServer) GetProviderSchema(ctx context.Context, req *depende

schemaResp, err := loadProviderSchema(providerAddr, providerVersion, cacheDir)
if err != nil {
return nil, status.Errorf(codes.Internal, err.Error())
return nil, status.Error(codes.Internal, err.Error())
}

return &dependencies.GetProviderSchema_Response{
Expand Down

0 comments on commit 4833c96

Please sign in to comment.