From 6e130d1af63e7a7f688b79558e88e6feb37e35e8 Mon Sep 17 00:00:00 2001 From: Mikhail Sakhnov Date: Thu, 15 Jun 2023 11:40:31 +0000 Subject: [PATCH] Rebase fixes: go mod tidy, copyright messages Signed-off-by: Mikhail Sakhnov --- .../controller/windowsstackcomponent.go | 7 +++---- pkg/component/worker/containerd.go | 2 -- pkg/node/nodehostname.go | 20 +++++++++++++++++-- pkg/node/nodehostname_test.go | 20 +++++++++++++++++-- 4 files changed, 39 insertions(+), 10 deletions(-) diff --git a/pkg/component/controller/windowsstackcomponent.go b/pkg/component/controller/windowsstackcomponent.go index 267f0cea763e..5824a6bb622d 100644 --- a/pkg/component/controller/windowsstackcomponent.go +++ b/pkg/component/controller/windowsstackcomponent.go @@ -120,20 +120,19 @@ func (n *WindowsStackComponent) handleWindowsNode(ctx context.Context, cfg windo if err := n.createWindowsStack(n.prevRenderingContext); err != nil { n.log.Errorf("failed to create windows stack: %v", err) return fmt.Errorf("failed to create windows stack: %v", err) - } else { - n.log.Infof("successfully created windows stack") } + n.log.Infof("successfully created windows stack") return nil } func (n *WindowsStackComponent) Reconcile(_ context.Context, cfg *v1beta1.ClusterConfig) error { if cfg.Spec.Network.Provider != "calico" { - return fmt.Errorf("windows node controller available only for %s", constant.CNIProviderCalico) + return nil } existingCNI := existingCNIProvider(n.k0sVars.ManifestsDir) if existingCNI != "" && existingCNI != constant.CNIProviderCalico { - return fmt.Errorf("windows node controller available only for %s", constant.CNIProviderCalico) + return nil } newConfig, err := n.makeRenderingContext(cfg) if err != nil { diff --git a/pkg/component/worker/containerd.go b/pkg/component/worker/containerd.go index e6214e3ce7f7..fc0ba90d1a12 100644 --- a/pkg/component/worker/containerd.go +++ b/pkg/component/worker/containerd.go @@ -75,8 +75,6 @@ type ContainerD struct { K0sVars *config.CfgVars Profile *workerconfig.Profile binaries []string - confPath string - importsPath string OCIBundlePath string } diff --git a/pkg/node/nodehostname.go b/pkg/node/nodehostname.go index 54d166d649a4..6e133cde30e5 100644 --- a/pkg/node/nodehostname.go +++ b/pkg/node/nodehostname.go @@ -1,3 +1,19 @@ +/* +Copyright 2023 k0s authors + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + package node import ( @@ -40,14 +56,14 @@ func getHostnameFromAwsMeta(url string) string { return s } -func getNodeNameWindows(override string, metadataUrl string) (string, error) { +func getNodeNameWindows(override string, metadataURL string) (string, error) { // if we have explicit hostnameOverride, we use it as is even on windows if override != "" { return nodeutil.GetHostname(override) } // we need to check if we have EC2 dns name available - if h := getHostnameFromAwsMeta(metadataUrl); h != "" { + if h := getHostnameFromAwsMeta(metadataURL); h != "" { return h, nil } // otherwise we use the k8s hostname helper diff --git a/pkg/node/nodehostname_test.go b/pkg/node/nodehostname_test.go index a9fc0ea2bb18..766212fe2860 100644 --- a/pkg/node/nodehostname_test.go +++ b/pkg/node/nodehostname_test.go @@ -1,3 +1,19 @@ +/* +Copyright 2023 k0s authors + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + package node import ( @@ -53,12 +69,12 @@ func TestGetNodename(t *testing.T) { func startFakeMetadataServer(listenOn string) { go func() { http.HandleFunc("/latest/meta-data/local-hostname", func(w http.ResponseWriter, r *http.Request) { - w.Write([]byte("some-hostname-from-metadata")) + _, _ = w.Write([]byte("some-hostname-from-metadata")) w.WriteHeader(http.StatusOK) }) http.HandleFunc("/not-found", func(w http.ResponseWriter, r *http.Request) { w.WriteHeader(http.StatusNotFound) }) - http.ListenAndServe(listenOn, nil) + _ = http.ListenAndServe(listenOn, nil) }() }