Skip to content

Commit 8816f44

Browse files
committed
fix(lint): solve linting issues
1 parent 8d0c789 commit 8816f44

File tree

116 files changed

+1207
-327
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

116 files changed

+1207
-327
lines changed

main.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,21 @@
11
package main
22

33
import (
4+
"log/slog"
5+
46
"github.com/hashicorp/terraform-plugin-sdk/v2/plugin"
57

68
"github.com/draios/terraform-provider-sysdig/sysdig"
79
)
810

911
func main() {
1012
sysdigClient := sysdig.NewSysdigClients()
11-
defer sysdigClient.Close()
13+
defer func() {
14+
err := sysdigClient.Close()
15+
if err != nil {
16+
slog.Default().Error("error closing the provider", "error", err)
17+
}
18+
}()
1219

1320
provider := &sysdig.SysdigProvider{SysdigClient: sysdigClient}
1421
plugin.Serve(&plugin.ServeOpts{ProviderFunc: provider.Provider})

scripts/oanc/main.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,12 @@ func main() {
9898
if err != nil {
9999
log.Fatal(err)
100100
}
101-
defer response.Body.Close()
101+
defer func() {
102+
err := response.Body.Close()
103+
if err != nil {
104+
log.Fatalf("error closing response body: %s", err)
105+
}
106+
}()
102107

103108
if response.StatusCode != http.StatusOK {
104109
log.Fatal(errors.New(response.Status))

sysdig/cfn_preprocess_template.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ func terraformPreModifications(ctx context.Context, patchedStack []byte) ([]byte
8787
passthrough, _ := GetValueFromTemplate(container.S("image"))
8888
_, err = container.Set(passthrough, "Image")
8989
if err != nil {
90-
return nil, fmt.Errorf("Could not update Image field: %v", err)
90+
return nil, fmt.Errorf("could not update Image field: %v", err)
9191
}
9292

9393
err = container.Delete("image")
@@ -100,7 +100,7 @@ func terraformPreModifications(ctx context.Context, patchedStack []byte) ([]byte
100100
passthrough, _ := GetValueFromTemplate(container.S("name"))
101101
_, err = container.Set(passthrough, "Name")
102102
if err != nil {
103-
return nil, fmt.Errorf("Could not update Name field: %v", err)
103+
return nil, fmt.Errorf("could not update Name field: %v", err)
104104
}
105105

106106
err = container.Delete("name")
@@ -115,22 +115,22 @@ func terraformPreModifications(ctx context.Context, patchedStack []byte) ([]byte
115115
name, _ := env.S("name").Data().(string)
116116
err = env.Delete("name")
117117
if err != nil {
118-
return nil, fmt.Errorf("Could not delete \"name\" key in Environment: %v", err)
118+
return nil, fmt.Errorf("could not delete \"name\" key in Environment: %v", err)
119119
}
120120
_, err = env.Set(name, "Name")
121121
if err != nil {
122-
return nil, fmt.Errorf("Could not assign \"Name\" key in Environment: %v", err)
122+
return nil, fmt.Errorf("could not assign \"Name\" key in Environment: %v", err)
123123
}
124124
}
125125
if env.Exists("value") {
126126
value, _ := env.S("value").Data().(string)
127127
err = env.Delete("value")
128128
if err != nil {
129-
return nil, fmt.Errorf("Could not delete \"value\" key in Environment: %v", err)
129+
return nil, fmt.Errorf("could not delete \"value\" key in Environment: %v", err)
130130
}
131131
_, err = env.Set(value, "Value")
132132
if err != nil {
133-
return nil, fmt.Errorf("Could not assign \"Value\" key in Environment: %v", err)
133+
return nil, fmt.Errorf("could not assign \"Value\" key in Environment: %v", err)
134134
}
135135
}
136136
}
@@ -139,7 +139,7 @@ func terraformPreModifications(ctx context.Context, patchedStack []byte) ([]byte
139139
parsedPassthrough, _ := gabs.ParseJSON([]byte(passthrough))
140140
_, err = container.Set(parsedPassthrough, "Environment")
141141
if err != nil {
142-
return nil, fmt.Errorf("Could not update Environment field: %v", err)
142+
return nil, fmt.Errorf("could not update Environment field: %v", err)
143143
}
144144

145145
err = container.Delete("environment")
@@ -153,7 +153,7 @@ func terraformPreModifications(ctx context.Context, patchedStack []byte) ([]byte
153153
parsedPassthrough, _ := gabs.ParseJSON([]byte(passthrough))
154154
_, err = container.Set(parsedPassthrough, "EntryPoint")
155155
if err != nil {
156-
return nil, fmt.Errorf("Could not update EntryPoint field: %v", err)
156+
return nil, fmt.Errorf("could not update EntryPoint field: %v", err)
157157
}
158158

159159
err = container.Delete("entryPoint")
@@ -167,7 +167,7 @@ func terraformPreModifications(ctx context.Context, patchedStack []byte) ([]byte
167167
parsedPassthrough, _ := gabs.ParseJSON([]byte(passthrough))
168168
_, err = container.Set(parsedPassthrough, "Command")
169169
if err != nil {
170-
return nil, fmt.Errorf("Could not update Command field: %v", err)
170+
return nil, fmt.Errorf("could not update Command field: %v", err)
171171
}
172172

173173
err = container.Delete("command")

sysdig/data_source_sysdig_monitor_teams_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@ package sysdig_test
44

55
import (
66
"fmt"
7+
"testing"
8+
79
"github.com/draios/terraform-provider-sysdig/sysdig"
810
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
9-
"testing"
1011

1112
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
1213
)

sysdig/data_source_sysdig_secure_ml_policy.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ func createMLPolicyDataSourceSchema() map[string]*schema.Schema {
6262
}
6363

6464
func mlPolicyDataSourceRead(ctx context.Context, d *schema.ResourceData, meta interface{}, resourceName string, validationFunc func(v2.PolicyRulesComposite) bool) diag.Diagnostics {
65-
6665
policy, err := compositePolicyDataSourceRead(ctx, d, meta, resourceName, policyTypeML, validationFunc)
6766
if err != nil {
6867
return diag.FromErr(err)

sysdig/data_source_sysdig_secure_policy.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,8 @@ func policyDataSourceToResourceData(policy v2.Policy, d *schema.ResourceData) {
144144
actions := []map[string]interface{}{{}}
145145

146146
for _, action := range policy.Actions {
147-
if action.Type == "POLICY_ACTION_CAPTURE" {
147+
switch action.Type {
148+
case "POLICY_ACTION_CAPTURE":
148149
actions[0]["capture"] = []map[string]interface{}{{
149150
"seconds_after_event": action.AfterEventNs / 1000000000,
150151
"seconds_before_event": action.BeforeEventNs / 1000000000,
@@ -154,9 +155,9 @@ func policyDataSourceToResourceData(policy v2.Policy, d *schema.ResourceData) {
154155
"folder": action.Folder,
155156
}}
156157

157-
} else if action.Type == "POLICY_ACTION_KILL_PROCESS" {
158+
case "POLICY_ACTION_KILL_PROCESS":
158159
actions[0]["kill_process"] = "true"
159-
} else {
160+
default:
160161
action := strings.Replace(action.Type, "POLICY_ACTION_", "", 1)
161162
actions[0]["container"] = strings.ToLower(action)
162163
}

sysdig/data_source_sysdig_secure_posture_zone_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,11 @@ package sysdig_test
44

55
import (
66
"fmt"
7+
"testing"
8+
79
"github.com/draios/terraform-provider-sysdig/sysdig"
810
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest"
911
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
10-
"testing"
1112

1213
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
1314
"github.com/hashicorp/terraform-plugin-sdk/v2/terraform"

sysdig/data_source_sysdig_secure_rule_stateful_count_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ import (
1515
)
1616

1717
func TestAccRuleStatefulCountDataSource(t *testing.T) {
18-
1918
if strings.HasSuffix(os.Getenv("SYSDIG_SECURE_URL"), "ibm.com") {
2019
t.Skip("Skipping stateful tests for IBM Cloud")
2120
return

sysdig/data_source_sysdig_secure_rule_stateful_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ import (
1515
)
1616

1717
func TestAccRuleStatefulDataSource(t *testing.T) {
18-
1918
if strings.HasSuffix(os.Getenv("SYSDIG_SECURE_URL"), "ibm.com") {
2019
t.Skip("Skipping stateful tests for IBM Cloud")
2120
return

sysdig/data_source_sysdig_secure_teams_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@ package sysdig_test
44

55
import (
66
"fmt"
7+
"testing"
8+
79
"github.com/draios/terraform-provider-sysdig/sysdig"
810
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
9-
"testing"
1011

1112
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
1213
)

0 commit comments

Comments
 (0)