Skip to content

Commit 6931664

Browse files
authored
Merge pull request #8 from alphagov/fix-action-errors
Fix linter errors
2 parents f4b5faa + cfceb03 commit 6931664

2 files changed

Lines changed: 14 additions & 27 deletions

File tree

.github/workflows/ci.yml

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -14,25 +14,6 @@ concurrency:
1414
cancel-in-progress: false
1515

1616
jobs:
17-
test-go:
18-
name: Test Go
19-
uses: alphagov/govuk-infrastructure/.github/workflows/go-test.yml@main
20-
permissions:
21-
packages: write
22-
pull-requests: write
23-
24-
golangci-lint:
25-
runs-on: ubuntu-latest
26-
steps:
27-
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
28-
with:
29-
show-progress: false
30-
- uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6.4.0
31-
with:
32-
go-version-file: go.mod
33-
- uses: golangci/golangci-lint-action@1e7e51e771db61008b38414a730f564565cf7c20 # v9.2.0
34-
with:
35-
version: v2.11
3617
codeql-sast:
3718
name: CodeQL SAST scan
3819
uses: alphagov/govuk-infrastructure/.github/workflows/codeql-analysis.yml@main

test/utils/utils.go

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ package utils
1919
import (
2020
"bufio"
2121
"bytes"
22+
"context"
2223
"fmt"
2324
"os"
2425
"os/exec"
@@ -41,6 +42,7 @@ func warnError(err error) {
4142

4243
// Run executes the provided command within this context
4344
func Run(cmd *exec.Cmd) (string, error) {
45+
4446
dir, _ := GetProjectDir()
4547
cmd.Dir = dir
4648

@@ -62,7 +64,8 @@ func Run(cmd *exec.Cmd) (string, error) {
6264
// UninstallCertManager uninstalls the cert manager
6365
func UninstallCertManager() {
6466
url := fmt.Sprintf(certmanagerURLTmpl, certmanagerVersion)
65-
cmd := exec.Command("kubectl", "delete", "-f", url)
67+
backgroundContext := context.Background()
68+
cmd := exec.CommandContext(backgroundContext, "kubectl", "delete", "-f", url) //gosec:disable G204 -- We intentionally want to exec a sub process with a var
6669
if _, err := Run(cmd); err != nil {
6770
warnError(err)
6871
}
@@ -73,8 +76,8 @@ func UninstallCertManager() {
7376
"cert-manager-controller",
7477
}
7578
for _, lease := range kubeSystemLeases {
76-
cmd = exec.Command("kubectl", "delete", "lease", lease,
77-
"-n", "kube-system", "--ignore-not-found", "--force", "--grace-period=0")
79+
cmd := exec.CommandContext(backgroundContext, "kubectl", "delete", "lease", lease,
80+
"-n", "kube-system", "--ignore-not-found", "--force", "--grace-period=0") //gosec:disable G204 -- We intentionally want to exec a sub process with a var
7881
if _, err := Run(cmd); err != nil {
7982
warnError(err)
8083
}
@@ -83,18 +86,19 @@ func UninstallCertManager() {
8386

8487
// InstallCertManager installs the cert manager bundle.
8588
func InstallCertManager() error {
89+
backgroundContext := context.Background()
8690
url := fmt.Sprintf(certmanagerURLTmpl, certmanagerVersion)
87-
cmd := exec.Command("kubectl", "apply", "-f", url)
91+
cmd := exec.CommandContext(backgroundContext, "kubectl", "apply", "-f", url) //gosec:disable G204 -- We intentionally want to exec a sub process with a var
8892
if _, err := Run(cmd); err != nil {
8993
return err
9094
}
9195
// Wait for cert-manager-webhook to be ready, which can take time if cert-manager
9296
// was re-installed after uninstalling on a cluster.
93-
cmd = exec.Command("kubectl", "wait", "deployment.apps/cert-manager-webhook",
97+
cmd = exec.CommandContext(backgroundContext, "kubectl", "wait", "deployment.apps/cert-manager-webhook",
9498
"--for", "condition=Available",
9599
"--namespace", "cert-manager",
96100
"--timeout", "5m",
97-
)
101+
) //gosec:disable G204 -- We intentionally want to exec a sub process
98102

99103
_, err := Run(cmd)
100104
return err
@@ -114,7 +118,8 @@ func IsCertManagerCRDsInstalled() bool {
114118
}
115119

116120
// Execute the kubectl command to get all CRDs
117-
cmd := exec.Command("kubectl", "get", "crds")
121+
backgroundContext := context.Background()
122+
cmd := exec.CommandContext(backgroundContext, "kubectl", "get", "crds") //gosec:disable G204 -- We intentionally want to exec a sub process
118123
output, err := Run(cmd)
119124
if err != nil {
120125
return false
@@ -144,7 +149,8 @@ func LoadImageToKindClusterWithName(name string) error {
144149
if v, ok := os.LookupEnv("KIND"); ok {
145150
kindBinary = v
146151
}
147-
cmd := exec.Command(kindBinary, kindOptions...)
152+
backgroundContext := context.Background()
153+
cmd := exec.CommandContext(backgroundContext, kindBinary, kindOptions...) //gosec:disable G204 -- We intentionally want to exec a sub process with a var
148154
_, err := Run(cmd)
149155
return err
150156
}

0 commit comments

Comments
 (0)