chore: enable noctx linter (#24765)

Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
This commit is contained in:
Matthieu MOREL
2025-09-29 20:20:53 +02:00
committed by GitHub
parent 116707bed1
commit 7357465ea6
60 changed files with 507 additions and 383 deletions

View File

@@ -1,6 +1,7 @@
package main
import (
"context"
"encoding/json"
"errors"
"fmt"
@@ -22,8 +23,8 @@ var kindToCRDPath = map[string]string{
application.ApplicationSetFullName: "manifests/crds/applicationset-crd.yaml",
}
func getCustomResourceDefinitions() map[string]*apiextensionsv1.CustomResourceDefinition {
crdYamlBytes, err := exec.Command(
func getCustomResourceDefinitions(ctx context.Context) map[string]*apiextensionsv1.CustomResourceDefinition {
crdYamlBytes, err := exec.CommandContext(ctx,
"controller-gen",
"paths=./pkg/apis/application/...",
"crd:crdVersions=v1",
@@ -124,7 +125,7 @@ func checkErr(err error) {
}
func main() {
crdsapp := getCustomResourceDefinitions()
crdsapp := getCustomResourceDefinitions(context.Background())
for kind, path := range kindToCRDPath {
crd := crdsapp[kind]
if crd == nil {

View File

@@ -31,11 +31,10 @@ func NewRepoGenerator(clientSet *kubernetes.Clientset) Generator {
return &RepoGenerator{clientSet: clientSet, bar: &util.Bar{}}
}
func fetchRepos(token string, page int) ([]Repo, error) {
client := &http.Client{}
req, _ := http.NewRequest(http.MethodGet, fmt.Sprintf("https://api.github.com/repos/argoproj/argocd-example-apps/forks?per_page=100&page=%v", page), http.NoBody)
func fetchRepos(ctx context.Context, token string, page int) ([]Repo, error) {
req, _ := http.NewRequestWithContext(ctx, http.MethodGet, fmt.Sprintf("https://api.github.com/repos/argoproj/argocd-example-apps/forks?per_page=100&page=%v", page), http.NoBody)
req.Header.Set("Authorization", token)
resp, err := client.Do(req)
resp, err := http.DefaultClient.Do(req)
if err != nil {
return nil, err
}
@@ -54,6 +53,7 @@ func fetchRepos(token string, page int) ([]Repo, error) {
func FetchRepos(token string, samples int) ([]Repo, error) {
log.Print("Fetch repos started")
var (
ctx = context.Background()
repos []Repo
page = 1
)
@@ -62,7 +62,7 @@ func FetchRepos(token string, samples int) ([]Repo, error) {
if page%10 == 0 {
log.Printf("Fetch repos, page: %v", page)
}
fetchedRepos, err := fetchRepos(token, page)
fetchedRepos, err := fetchRepos(ctx, token, page)
if err != nil {
return nil, err
}

View File

@@ -1,12 +1,14 @@
package main
import (
"context"
"fmt"
"golang.org/x/mod/semver"
"os"
"os/exec"
"regexp"
"strings"
"golang.org/x/mod/semver"
)
/**
@@ -22,7 +24,7 @@ func main() {
proposedTag := os.Args[1]
tags, err := getGitTags()
tags, err := getGitTags(context.Background())
if err != nil {
fmt.Printf("Error getting git tags: %v\n", err)
return
@@ -110,8 +112,8 @@ func findPreviousTag(proposedTag string, tags []string) (string, error) {
return previousTag, nil
}
func getGitTags() ([]string, error) {
cmd := exec.Command("git", "tag", "--sort=-v:refname")
func getGitTags(ctx context.Context) ([]string, error) {
cmd := exec.CommandContext(ctx, "git", "tag", "--sort=-v:refname")
output, err := cmd.Output()
if err != nil {
return nil, fmt.Errorf("error executing git command: %v", err)

View File

@@ -44,7 +44,7 @@ func main() {
}
errors.CheckError(err)
cmd := exec.Command("kubectl", "apply", "-k", "manifests/base/config")
cmd := exec.CommandContext(context.Background(), "kubectl", "apply", "-k", "manifests/base/config")
cmd.Env = []string{"KUBECONFIG=" + kubeConfigPath}
errors.CheckError(cmd.Run())
<-context.Background().Done()