Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 0 additions & 19 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,25 +14,6 @@ concurrency:
cancel-in-progress: false

jobs:
test-go:
name: Test Go
uses: alphagov/govuk-infrastructure/.github/workflows/go-test.yml@main
permissions:
packages: write
pull-requests: write

golangci-lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
show-progress: false
- uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6.4.0
with:
go-version-file: go.mod
- uses: golangci/golangci-lint-action@1e7e51e771db61008b38414a730f564565cf7c20 # v9.2.0
with:
version: v2.11
codeql-sast:
name: CodeQL SAST scan
uses: alphagov/govuk-infrastructure/.github/workflows/codeql-analysis.yml@main
Expand Down
22 changes: 14 additions & 8 deletions test/utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package utils
import (
"bufio"
"bytes"
"context"
"fmt"
"os"
"os/exec"
Expand All @@ -41,6 +42,7 @@ func warnError(err error) {

// Run executes the provided command within this context
func Run(cmd *exec.Cmd) (string, error) {

dir, _ := GetProjectDir()
cmd.Dir = dir

Expand All @@ -62,7 +64,8 @@ func Run(cmd *exec.Cmd) (string, error) {
// UninstallCertManager uninstalls the cert manager
func UninstallCertManager() {
url := fmt.Sprintf(certmanagerURLTmpl, certmanagerVersion)
cmd := exec.Command("kubectl", "delete", "-f", url)
backgroundContext := context.Background()
cmd := exec.CommandContext(backgroundContext, "kubectl", "delete", "-f", url) //gosec:disable G204 -- We intentionally want to exec a sub process with a var
if _, err := Run(cmd); err != nil {
warnError(err)
}
Expand All @@ -73,8 +76,8 @@ func UninstallCertManager() {
"cert-manager-controller",
}
for _, lease := range kubeSystemLeases {
cmd = exec.Command("kubectl", "delete", "lease", lease,
"-n", "kube-system", "--ignore-not-found", "--force", "--grace-period=0")
cmd := exec.CommandContext(backgroundContext, "kubectl", "delete", "lease", lease,
"-n", "kube-system", "--ignore-not-found", "--force", "--grace-period=0") //gosec:disable G204 -- We intentionally want to exec a sub process with a var
if _, err := Run(cmd); err != nil {
warnError(err)
}
Expand All @@ -83,18 +86,19 @@ func UninstallCertManager() {

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

_, err := Run(cmd)
return err
Expand All @@ -114,7 +118,8 @@ func IsCertManagerCRDsInstalled() bool {
}

// Execute the kubectl command to get all CRDs
cmd := exec.Command("kubectl", "get", "crds")
backgroundContext := context.Background()
cmd := exec.CommandContext(backgroundContext, "kubectl", "get", "crds") //gosec:disable G204 -- We intentionally want to exec a sub process
output, err := Run(cmd)
if err != nil {
return false
Expand Down Expand Up @@ -144,7 +149,8 @@ func LoadImageToKindClusterWithName(name string) error {
if v, ok := os.LookupEnv("KIND"); ok {
kindBinary = v
}
cmd := exec.Command(kindBinary, kindOptions...)
backgroundContext := context.Background()
cmd := exec.CommandContext(backgroundContext, kindBinary, kindOptions...) //gosec:disable G204 -- We intentionally want to exec a sub process with a var
_, err := Run(cmd)
return err
}
Expand Down