Skip to content

Commit

Permalink
lints
Browse files Browse the repository at this point in the history
  • Loading branch information
matmerr committed Mar 19, 2024
1 parent 526a4b1 commit 3097216
Show file tree
Hide file tree
Showing 10 changed files with 42 additions and 21 deletions.
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
pkg/plugin/lib/** linguist-vendored=true

*.go text eol=lf
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,6 @@ site/.docusaurus/
site/node_modules/

hack/tools/bin

#vscode
.vscode/
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ require (
k8s.io/apiserver v0.29.3 // indirect
k8s.io/component-base v0.29.3 // indirect
k8s.io/cri-api v0.29.2 // indirect
oras.land/oras-go v1.2.4 // indirect
oras.land/oras-go v1.2.5 // indirect
sigs.k8s.io/kustomize/api v0.14.0 // indirect
sigs.k8s.io/kustomize/kyaml v0.14.3 // indirect
)
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1121,8 +1121,8 @@ k8s.io/kubectl v0.29.3 h1:RuwyyIU42MAISRIePaa8Q7A3U74Q9P4MoJbDFz9o3us=
k8s.io/kubectl v0.29.3/go.mod h1:yCxfY1dbwgVdEt2zkJ6d5NNLOhhWgTyrqACIoFhpdd4=
k8s.io/utils v0.0.0-20231127182322-b307cd553661 h1:FepOBzJ0GXm8t0su67ln2wAZjbQ6RxQGZDnzuLcrUTI=
k8s.io/utils v0.0.0-20231127182322-b307cd553661/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0=
oras.land/oras-go v1.2.4 h1:djpBY2/2Cs1PV87GSJlxv4voajVOMZxqqtq9AB8YNvY=
oras.land/oras-go v1.2.4/go.mod h1:DYcGfb3YF1nKjcezfX2SNlDAeQFKSXmf+qrFmrh4324=
oras.land/oras-go v1.2.5 h1:XpYuAwAb0DfQsunIyMfeET92emK8km3W4yEzZvUbsTo=
oras.land/oras-go v1.2.5/go.mod h1:PuAwRShRZCsZb7g8Ar3jKKQR/2A/qN+pkYxIOd/FAoo=
sigs.k8s.io/controller-runtime v0.13.1-0.20230315234915-a26de2d610c3 h1:fic0YtUGSr79nv8vn3ziNZJrPZsm64KT/Fd/bc7Q6xY=
sigs.k8s.io/controller-runtime v0.13.1-0.20230315234915-a26de2d610c3/go.mod h1:Qox07m8Gh7skSeOfppEWllPxNMhA7+b93D8Qjj6rBlQ=
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd h1:EDPBXCAspyGV4jQlpZSudPeMmr1bNJefnuqLsRAsHZo=
Expand Down
21 changes: 13 additions & 8 deletions test/e2e/framework/azure/create-cluster-with-npm.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,11 @@ var (
)

const (
clusterTimeout = 10 * time.Minute
AgentARMSKU = "Standard_D4pls_v5"
AuxilaryNodeCount = 1
clusterTimeout = 10 * time.Minute
clusterCreateTicker = 30 * time.Second
pollFrequency = 5 * time.Second
AgentARMSKU = "Standard_D4pls_v5"
AuxilaryNodeCount = 1
)

type CreateNPMCluster struct {
Expand Down Expand Up @@ -49,7 +51,8 @@ func (c *CreateNPMCluster) Run() error {

npmCluster.Properties.NetworkProfile.NetworkPolicy = to.Ptr(armcontainerservice.NetworkPolicyAzure)

npmCluster.Properties.AgentPoolProfiles = append(npmCluster.Properties.AgentPoolProfiles, &armcontainerservice.ManagedClusterAgentPoolProfile{
//nolint:appendCombine // separate for verbosity
npmCluster.Properties.AgentPoolProfiles = append(npmCluster.Properties.AgentPoolProfiles, &armcontainerservice.ManagedClusterAgentPoolProfile{ //nolint:all
Type: to.Ptr(armcontainerservice.AgentPoolTypeVirtualMachineScaleSets),
AvailabilityZones: []*string{to.Ptr("1")},
Count: to.Ptr[int32](AuxilaryNodeCount),
Expand All @@ -64,6 +67,7 @@ func (c *CreateNPMCluster) Run() error {
})

/* todo: add azlinux node pool
//nolint:appendCombine // separate for verbosity
npmCluster.Properties.AgentPoolProfiles = append(npmCluster.Properties.AgentPoolProfiles, &armcontainerservice.ManagedClusterAgentPoolProfile{
Type: to.Ptr(armcontainerservice.AgentPoolTypeVirtualMachineScaleSets),
AvailabilityZones: []*string{to.Ptr("1")},
Expand All @@ -78,7 +82,8 @@ func (c *CreateNPMCluster) Run() error {
MaxPods: to.Ptr(int32(azure.MaxPodsPerNode)),
})
*/
npmCluster.Properties.AgentPoolProfiles = append(npmCluster.Properties.AgentPoolProfiles, &armcontainerservice.ManagedClusterAgentPoolProfile{
//nolint:appendCombine // separate for verbosity
npmCluster.Properties.AgentPoolProfiles = append(npmCluster.Properties.AgentPoolProfiles, &armcontainerservice.ManagedClusterAgentPoolProfile{ //nolint:all
Type: to.Ptr(armcontainerservice.AgentPoolTypeVirtualMachineScaleSets),
AvailabilityZones: []*string{to.Ptr("1")},
Count: to.Ptr[int32](AuxilaryNodeCount),
Expand Down Expand Up @@ -116,7 +121,7 @@ func (c *CreateNPMCluster) Run() error {
notifychan := make(chan struct{})
go func() {
_, err = poller.PollUntilDone(ctx, &runtime.PollUntilDoneOptions{
Frequency: 5 * time.Second,
Frequency: pollFrequency,
})
if err != nil {
log.Printf("failed to create cluster: %v\n", err)
Expand All @@ -126,7 +131,7 @@ func (c *CreateNPMCluster) Run() error {
close(notifychan)
}()

ticker := time.NewTicker(30 * time.Second)
ticker := time.NewTicker(clusterCreateTicker)
defer ticker.Stop()
for {
select {
Expand All @@ -135,7 +140,7 @@ func (c *CreateNPMCluster) Run() error {
case <-ticker.C:
log.Printf("waiting for cluster %s to be ready...\n", c.ClusterName)
case <-notifychan:
return err
return fmt.Errorf("received notification, failed to create cluster: %w", err)
}
}
}
5 changes: 3 additions & 2 deletions test/e2e/framework/generic/load-tag.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import (

const DefaultTagEnv = "TAG"

var ErrTagNotSet = fmt.Errorf("tag not set")

type LoadTag struct {
TagEnv string
}
Expand All @@ -32,9 +34,8 @@ func (s *LoadTag) Prevalidate() error {
log.Printf("using version \"%s\" from flag", tag)
os.Setenv(s.TagEnv, tag)
return nil
} else {
return fmt.Errorf("tag is not set from flag nor env %s", s.TagEnv)
}
return fmt.Errorf("tag is not set from flag nor env %s: %w", s.TagEnv, ErrTagNotSet)
}
return nil
}
Expand Down
8 changes: 5 additions & 3 deletions test/e2e/framework/kubernetes/get-logs.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
"k8s.io/client-go/tools/clientcmd"
)

func PrintPodLogs(kubeconfigpath string, namespace string, labelSelector string) {
func PrintPodLogs(kubeconfigpath, namespace, labelSelector string) {
// Load the kubeconfig file to get the configuration to access the cluster
config, err := clientcmd.BuildConfigFromFlags("", kubeconfigpath)
if err != nil {
Expand All @@ -34,7 +34,8 @@ func PrintPodLogs(kubeconfigpath string, namespace string, labelSelector string)
}

// Iterate over the pods and get the logs for each pod
for _, pod := range pods.Items {
for i := range pods.Items {
pod := pods.Items[i]
fmt.Printf("############################## logs for pod %s #########################\n", pod.Name)

// Get the logs for the pod
Expand All @@ -43,14 +44,15 @@ func PrintPodLogs(kubeconfigpath string, namespace string, labelSelector string)
if err != nil {
fmt.Printf("error getting logs for pod %s: %s\n", pod.Name, err)
}
defer podLogs.Close()

// Read the logs
buf, err := io.ReadAll(podLogs)
if err != nil {
log.Printf("error reading logs for pod %s: %s\n", pod.Name, err)
}

podLogs.Close()

// Print the logs
log.Println(string(buf))
}
Expand Down
9 changes: 6 additions & 3 deletions test/e2e/framework/kubernetes/install-retina-helm.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@ const (
deleteTimeout = 60 * time.Second
)

var errEmptyTag = fmt.Errorf("tag is empty")
var (
errEmptyTag = fmt.Errorf("tag is empty")
errDirectoryNotFound = fmt.Errorf("directory not found")
)

type InstallHelmChart struct {
Namespace string
Expand Down Expand Up @@ -99,8 +102,8 @@ func (i *InstallHelmChart) Prevalidate() error {
if err != nil {
return fmt.Errorf("failed to get current working directory %s: %w", cwd, err)
}
fmt.Printf("the current working directory %s", cwd)
return fmt.Errorf("directory not found at %s: working directory: %s", i.ChartPath, cwd)
log.Printf("the current working directory %s", cwd)
return fmt.Errorf("directory not found at %s: working directory: %s: %w", i.ChartPath, cwd, errDirectoryNotFound)
}
log.Printf("found chart at %s", i.ChartPath)

Expand Down
2 changes: 1 addition & 1 deletion test/e2e/framework/prometheus/prometheus.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ var (
defaultRetryAttempts = 60
)

func CheckMetric(promAddress string, metricName string, validMetric map[string]string) error {
func CheckMetric(promAddress, metricName string, validMetric map[string]string) error {
defaultRetrier := retry.Retrier{Attempts: defaultRetryAttempts, Delay: defaultRetryDelay}

ctx := context.Background()
Expand Down
7 changes: 6 additions & 1 deletion test/retry/retry.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package retry

import (
"context"
"fmt"
"time"
)

Expand Down Expand Up @@ -32,7 +33,11 @@ func (r Retrier) Do(ctx context.Context, f func() error) error {

select {
case <-ctx.Done():
return ctx.Err()
ctxErr := ctx.Err()
if ctxErr != nil {
return fmt.Errorf("context error: %w", ctxErr)
}
return nil
case <-done:
return err
}
Expand Down

0 comments on commit 3097216

Please sign in to comment.