Skip to content

Commit

Permalink
fixup linter issues and missing flags
Browse files Browse the repository at this point in the history
  • Loading branch information
bschimke95 committed Jun 26, 2024
1 parent 0f93432 commit e216b50
Show file tree
Hide file tree
Showing 12 changed files with 20 additions and 30 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ RUN --mount=type=cache,target=/root/.cache/go-build \
-o manager ${package}

# Production image
FROM gcr.io/
FROM gcr.io/distroless/static:nonroot
WORKDIR /
COPY --from=builder /workspace/manager .
# Use uid of nonroot user (65532) because kubernetes expects numeric user when applying pod security policies
Expand Down
2 changes: 1 addition & 1 deletion pkg/ck8s/workload_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ func (w *Workload) GetK8sdProxyForControlPlane(ctx context.Context, options k8sd
continue
}

proxy, err := w.K8sdClientGenerator.forNode(ctx, &node)
proxy, err := w.K8sdClientGenerator.forNode(ctx, &node) // #nosec G601
if err != nil {
continue
}
Expand Down
14 changes: 3 additions & 11 deletions pkg/ck8s/workload_cluster_k8sd.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,13 @@ import (
"net/http"
"time"

"github.com/canonical/cluster-api-k8s/pkg/proxy"
"github.com/pkg/errors"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/client-go/kubernetes"
"k8s.io/client-go/rest"

"github.com/canonical/cluster-api-k8s/pkg/proxy"
)

type K8sdClient struct {
Expand All @@ -40,15 +41,6 @@ func NewK8sdClientGenerator(restConfig *rest.Config, proxyClientTimeout time.Dur
}, nil
}

func (g *k8sdClientGenerator) forNodeName(ctx context.Context, nodeName string) (*K8sdClient, error) {
node, err := g.clientset.CoreV1().Nodes().Get(ctx, nodeName, metav1.GetOptions{})
if err != nil {
return nil, errors.Wrap(err, "unable to get node in target cluster")
}

return g.forNode(ctx, node)
}

func (g *k8sdClientGenerator) forNode(ctx context.Context, node *corev1.Node) (*K8sdClient, error) {
podmap, err := g.getProxyPods(ctx)
if err != nil {
Expand Down Expand Up @@ -121,7 +113,7 @@ func (g *k8sdClientGenerator) NewHTTPClient(ctx context.Context, podName string)
ExpectContinueTimeout: http.DefaultTransport.(*http.Transport).ExpectContinueTimeout,
// TODO: Workaround for now, address later on
// get the certificate fingerprint from the matching node through a resource in the cluster (TBD), and validate it in the TLSClientConfig
TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
TLSClientConfig: &tls.Config{InsecureSkipVerify: true}, // #nosec G402
},
Timeout: g.proxyClientTimeout,
}, nil
Expand Down
2 changes: 0 additions & 2 deletions test/e2e/cluster_upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,8 @@ import (

. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"

corev1 "k8s.io/api/core/v1"
"k8s.io/utils/ptr"

"sigs.k8s.io/cluster-api/test/framework"
"sigs.k8s.io/cluster-api/test/framework/clusterctl"
"sigs.k8s.io/cluster-api/util"
Expand Down
1 change: 0 additions & 1 deletion test/e2e/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import (

. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"

corev1 "k8s.io/api/core/v1"
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
"sigs.k8s.io/cluster-api/test/framework"
Expand Down
2 changes: 0 additions & 2 deletions test/e2e/create_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,8 @@ import (

. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"

corev1 "k8s.io/api/core/v1"
"k8s.io/utils/pointer"

"sigs.k8s.io/cluster-api/test/framework/clusterctl"
"sigs.k8s.io/cluster-api/util"
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ spec:
replicas: ${CONTROL_PLANE_MACHINE_COUNT}
version: ${KUBERNETES_VERSION}
spec:
airGapped: true
controlPlane:
extraKubeAPIServerArgs:
--anonymous-auth: "true"
files:
- path: /wait-signal.sh
content: |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@ spec:
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
kind: DockerMachineTemplate
name: ${CLUSTER_NAME}-control-plane
spec:
airGapped: true
controlPlane:
extraKubeAPIServerArgs:
--anonymous-auth: "true"
replicas: ${CONTROL_PLANE_MACHINE_COUNT}
version: ${KUBERNETES_VERSION}
---
Expand Down
5 changes: 2 additions & 3 deletions test/e2e/e2e_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,16 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/klog/v2"
ctrl "sigs.k8s.io/controller-runtime"

clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
"sigs.k8s.io/cluster-api/test/framework"
"sigs.k8s.io/cluster-api/test/framework/bootstrap"
"sigs.k8s.io/cluster-api/test/framework/clusterctl"
"sigs.k8s.io/cluster-api/test/framework/ginkgoextensions"
dockerinfrav1 "sigs.k8s.io/cluster-api/test/infrastructure/docker/api/v1beta1"
ctrl "sigs.k8s.io/controller-runtime"

bootstrapv1 "github.com/canonical/cluster-api-k8s/bootstrap/api/v1beta2"
controlplanev1 "github.com/canonical/cluster-api-k8s/controlplane/api/v1beta2"
dockerinfrav1 "sigs.k8s.io/cluster-api/test/infrastructure/docker/api/v1beta1"
)

// Test suite flags.
Expand Down
9 changes: 4 additions & 5 deletions test/e2e/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,17 @@ import (
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
"github.com/pkg/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/sets"
"k8s.io/klog/v2"

clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
expv1 "sigs.k8s.io/cluster-api/exp/api/v1beta1"
"sigs.k8s.io/cluster-api/test/framework"
"sigs.k8s.io/cluster-api/test/framework/clusterctl"
"sigs.k8s.io/cluster-api/util/patch"
"sigs.k8s.io/controller-runtime/pkg/client"

controlplanev1 "github.com/canonical/cluster-api-k8s/controlplane/api/v1beta2"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/sets"
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
expv1 "sigs.k8s.io/cluster-api/exp/api/v1beta1"
)

// NOTE: the code in this file is largely copied from the cluster-api test framework.
Expand Down
2 changes: 0 additions & 2 deletions test/e2e/md_remediation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,8 @@ import (

. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"

corev1 "k8s.io/api/core/v1"
"k8s.io/utils/pointer"

"sigs.k8s.io/cluster-api/test/framework"
"sigs.k8s.io/cluster-api/test/framework/clusterctl"
"sigs.k8s.io/cluster-api/util"
Expand Down
2 changes: 0 additions & 2 deletions test/e2e/node_scale_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,8 @@ import (

. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"

corev1 "k8s.io/api/core/v1"
"k8s.io/utils/pointer"

"sigs.k8s.io/cluster-api/test/framework/clusterctl"
"sigs.k8s.io/cluster-api/util"
)
Expand Down

0 comments on commit e216b50

Please sign in to comment.