diff --git a/app/kumactl/cmd/install/install_control_plane.go b/app/kumactl/cmd/install/install_control_plane.go index b82c09251e71..64f13f5b3d59 100644 --- a/app/kumactl/cmd/install/install_control_plane.go +++ b/app/kumactl/cmd/install/install_control_plane.go @@ -14,7 +14,6 @@ import ( kumactl_cmd "github.com/kumahq/kuma/app/kumactl/pkg/cmd" "github.com/kumahq/kuma/app/kumactl/pkg/install/data" controlplane "github.com/kumahq/kuma/app/kumactl/pkg/install/k8s/control-plane" - kumacni "github.com/kumahq/kuma/app/kumactl/pkg/install/k8s/kuma-cni" kuma_cmd "github.com/kumahq/kuma/pkg/cmd" "github.com/kumahq/kuma/pkg/config/core" "github.com/kumahq/kuma/pkg/tls" @@ -225,12 +224,6 @@ func InstallCpTemplateFiles(args InstallControlPlaneArgs) (data.FileList, error) if err != nil { return nil, err } - if args.Cni_enabled { - templateCNI, err := data.ReadFiles(kumacni.Templates) - if err != nil { - return nil, err - } - templateFiles = append(templateFiles, templateCNI...) - } + return templateFiles, nil } diff --git a/app/kumactl/data/install/k8s/kuma-cni/all-in-one-template.yaml b/app/kumactl/data/install/k8s/kuma-cni/all-in-one-template.yaml deleted file mode 100644 index 9af9bfef808f..000000000000 --- a/app/kumactl/data/install/k8s/kuma-cni/all-in-one-template.yaml +++ /dev/null @@ -1,137 +0,0 @@ ---- -apiVersion: v1 -kind: ServiceAccount -metadata: - name: kuma-cni - namespace: kube-system - labels: - app: kuma-cni ---- -kind: ConfigMap -apiVersion: v1 -metadata: - name: kuma-cni-config - namespace: kube-system - labels: - app: kuma-cni -data: - # The CNI network configuration to add to the plugin chain on each node. The special - # values in this config will be automatically populated. - cni_network_config: |- - { - "cniVersion": "0.3.1", - "name": "kuma-cni", - "type": "kuma-cni", - "log_level": "info", - "kubernetes": { - "kubeconfig": "__KUBECONFIG_FILEPATH__", - "cni_bin_dir": "/var/lib/cni/bin", - "exclude_namespaces": [ "kube-system" ] - } - } ---- -apiVersion: rbac.authorization.k8s.io/v1 -kind: ClusterRole -metadata: - name: kuma-cni - labels: - app: kuma-cni -rules: - - apiGroups: [""] - resources: - - pods - - nodes - verbs: - - get ---- -apiVersion: rbac.authorization.k8s.io/v1 -kind: ClusterRoleBinding -metadata: - name: kuma-cni - labels: - app: kuma-cni -roleRef: - apiGroup: rbac.authorization.k8s.io - kind: ClusterRole - name: kuma-cni -subjects: - - kind: ServiceAccount - name: kuma-cni - namespace: kube-system ---- -kind: DaemonSet -apiVersion: apps/v1 -metadata: - name: kuma-cni-node - namespace: kube-system - labels: - k8s-app: kuma-cni-node -spec: - selector: - matchLabels: - k8s-app: kuma-cni-node - updateStrategy: - type: RollingUpdate - rollingUpdate: - maxUnavailable: 1 - template: - metadata: - labels: - k8s-app: kuma-cni-node - annotations: - # This, along with the CriticalAddonsOnly toleration below, - # marks the pod as a critical add-on, ensuring it gets - # priority scheduling and that its resources are reserved - # if it ever gets evicted. - scheduler.alpha.kubernetes.io/critical-pod: '' - spec: - nodeSelector: - beta.kubernetes.io/os: linux - hostNetwork: true - tolerations: - # Make sure kuma-cni-node gets scheduled on all nodes. - - effect: NoSchedule - operator: Exists - # Mark the pod as a critical add-on for rescheduling. - - key: CriticalAddonsOnly - operator: Exists - - effect: NoExecute - operator: Exists - priorityClassName: system-cluster-critical - serviceAccountName: kuma-cni - # Minimize downtime during a rolling upgrade or deletion; tell Kubernetes to do a "force - # deletion": https://kubernetes.io/docs/concepts/workloads/pods/pod/#termination-of-pods. - terminationGracePeriodSeconds: 5 - containers: - - name: install-cni - image: {{ .CNIImage }}:{{ .CNIVersion }} - imagePullPolicy: Always - command: ["/install-cni.sh"] - env: - # Name of the CNI config file to create. - - name: CNI_CONF_NAME - value: "kuma-cni.conf" - # The CNI network config to install on each node. - - name: CNI_NETWORK_CONFIG - valueFrom: - configMapKeyRef: - name: kuma-cni-config - key: cni_network_config - - name: CNI_NET_DIR - value: /etc/cni/multus/net.d - # If true, deploy as a chained CNI plugin, otherwise deploy as a standalone CNI - - name: CHAINED_CNI_PLUGIN - value: "false" - volumeMounts: - - mountPath: /host/opt/cni/bin - name: cni-bin-dir - - mountPath: /host/etc/cni/net.d - name: cni-net-dir - volumes: - # Used to install CNI. - - name: cni-bin-dir - hostPath: - path: /var/lib/cni/bin - - name: cni-net-dir - hostPath: - path: /etc/cni/multus/net.d diff --git a/app/kumactl/pkg/install/k8s/kuma-cni/kumacni_suite_test.go b/app/kumactl/pkg/install/k8s/kuma-cni/kumacni_suite_test.go deleted file mode 100644 index 3a30ea00a75c..000000000000 --- a/app/kumactl/pkg/install/k8s/kuma-cni/kumacni_suite_test.go +++ /dev/null @@ -1,13 +0,0 @@ -package kumacni - -import ( - "testing" - - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" -) - -func TestKumaCNI(t *testing.T) { - RegisterFailHandler(Fail) - RunSpecs(t, "KumaCNI Suite") -} diff --git a/app/kumactl/pkg/install/k8s/kuma-cni/templates.go b/app/kumactl/pkg/install/k8s/kuma-cni/templates.go deleted file mode 100644 index a32e451de9bb..000000000000 --- a/app/kumactl/pkg/install/k8s/kuma-cni/templates.go +++ /dev/null @@ -1,11 +0,0 @@ -package kumacni - -//go:generate go run github.com/shurcooL/vfsgen/cmd/vfsgendev -source="github.com/kumahq/kuma/app/kumactl/pkg/install/k8s/kuma-cni".Templates - -import ( - "path/filepath" -) - -func TemplatesDir(kumactlSrcDir string) string { - return filepath.Join(kumactlSrcDir, "data", "install", "k8s", "kuma-cni") -} diff --git a/app/kumactl/pkg/install/k8s/kuma-cni/templates_dev.go b/app/kumactl/pkg/install/k8s/kuma-cni/templates_dev.go deleted file mode 100644 index 1438f7f16d35..000000000000 --- a/app/kumactl/pkg/install/k8s/kuma-cni/templates_dev.go +++ /dev/null @@ -1,19 +0,0 @@ -// +build dev - -package kumacni - -import ( - "net/http" - "path/filepath" - "runtime" -) - -var Templates http.FileSystem = http.Dir(TemplatesDir(kumactlSrcDir())) - -func kumactlSrcDir() string { - _, thisFile, _, _ := runtime.Caller(1) - - thisDir := filepath.Dir(thisFile) - - return filepath.Join(thisDir, "..", "..", "..", "..") -} diff --git a/app/kumactl/pkg/install/k8s/kuma-cni/templates_vfsdata.go b/app/kumactl/pkg/install/k8s/kuma-cni/templates_vfsdata.go deleted file mode 100644 index c3fa04a24867..000000000000 --- a/app/kumactl/pkg/install/k8s/kuma-cni/templates_vfsdata.go +++ /dev/null @@ -1,186 +0,0 @@ -// Code generated by vfsgen; DO NOT EDIT. - -// +build !dev - -package kumacni - -import ( - "bytes" - "compress/gzip" - "fmt" - "io" - "io/ioutil" - "net/http" - "os" - pathpkg "path" - "time" -) - -// Templates statically implements the virtual filesystem provided to vfsgen. -var Templates = func() http.FileSystem { - fs := vfsgen۰FS{ - "/": &vfsgen۰DirInfo{ - name: "/", - modTime: time.Date(2020, 7, 13, 13, 16, 2, 922467546, time.UTC), - }, - "/all-in-one-template.yaml": &vfsgen۰CompressedFileInfo{ - name: "all-in-one-template.yaml", - modTime: time.Date(2020, 7, 13, 13, 16, 2, 922541378, time.UTC), - uncompressedSize: 3775, - - compressedContent: []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x02\xff\xa4\x56\x4b\x6f\xdb\xba\x12\xde\xfb\x57\x0c\xdc\x45\x37\x91\x74\x8b\x8b\x0b\x14\xba\xab\xd4\x4d\x53\x23\x8d\x1a\x24\xcd\x39\x8b\xa2\x10\xc6\xe4\xd8\xe2\x31\xc5\x11\x48\xca\x89\xdb\x93\xff\x7e\x40\x3d\x1c\xc9\x8f\xb4\xe8\xd1\xc2\x86\xc4\x79\x7c\xfc\x66\xf8\x71\xa2\x28\x9a\x60\xa5\xfe\x20\xeb\x14\x9b\x14\x36\x6f\x26\x6b\x65\x64\x0a\x77\x64\x37\x4a\xd0\xb9\x10\x5c\x1b\x3f\x29\xc9\xa3\x44\x8f\xe9\x04\xc0\x60\x49\x29\xac\xeb\x12\x23\x61\x54\xf7\xc1\x55\x28\x9a\xaf\x0b\x8a\xdc\xd6\x79\x2a\x27\x00\x1a\x17\xa4\x5d\xf0\x01\xc0\xaa\x1a\x38\x85\xbc\x6d\xa2\x19\x9b\xa5\x5a\x5d\x63\xb5\x8f\xe3\x74\xca\x48\x34\x3e\xbf\x97\xb9\x0f\xf9\x0a\xbe\x14\x04\xb3\x6c\x0e\x86\xfc\x03\xdb\x35\xb4\x51\x6b\x8b\x5e\xb1\x01\xcf\x80\x52\x86\x3f\x5f\x10\x54\xba\x5e\x29\x03\xa2\x40\x65\x80\x0d\x10\x8a\x02\x0c\x4b\x8a\xa1\x89\xe3\x2a\x12\x0a\x75\x13\x77\x83\xba\x26\x07\xca\x80\x2f\x94\xeb\xc2\xc2\x83\xd2\x1a\x16\x04\x58\x7b\x2e\xd1\x2b\x81\x5a\x6f\xa1\xe2\xaa\xd6\xe8\x49\xc6\x13\x00\x61\x54\xde\x81\xc9\x5b\xaf\x14\xfe\x8e\x9a\x3d\xfc\x68\x7e\x01\xa6\xc2\xf4\x24\x4d\x53\x98\xfe\x27\xfe\x6f\xfc\x66\x7a\xd6\x2f\x06\x3a\xc2\xe7\x7e\xb3\xcf\x2b\x7e\x5b\x9d\x58\xd1\xbc\xca\x35\x6d\x48\x87\x65\x65\x96\xfc\xbc\x14\x28\xb5\x86\x3c\xb9\x69\xba\x43\xb0\x5b\x69\x11\x06\xaf\x3c\xbf\xba\x7f\x77\x31\xfb\x9c\x7d\x98\x5f\xe6\x1f\xe6\x9f\x2e\x6e\xce\xbf\x7c\xcc\xf3\x5d\xa0\x1e\x78\xbe\x50\x26\x97\xca\x06\x9f\x64\x83\x36\xd1\x6a\x91\x08\xa3\x92\x85\x32\x63\x63\x7a\x14\xba\x96\x94\xef\xea\x1b\x10\x7c\x6d\xf3\x76\x45\x9e\xc2\xb7\xce\xe3\x69\xd2\xfe\xee\xf7\xb2\x5d\xa0\x88\xb1\xf6\x05\x5b\xf5\xbd\x29\x6a\xbc\x7e\xeb\x62\xc5\xc9\xae\xcb\x67\xba\x76\x9e\xec\x2d\x6b\x7a\xb9\xc5\x4f\xf7\x93\xad\x35\x35\x0b\x11\x60\xa5\x2e\x2d\xd7\x95\x4b\xe1\xeb\x74\xda\xc2\xb3\xe4\xb8\xb6\x82\x3a\xdf\x60\x56\xb1\x74\xbb\x97\xd0\x43\xed\xdb\x86\xec\x62\x60\xb5\x22\xff\x2f\x77\xf4\x4e\x19\xa9\xcc\xea\xb7\x37\xc6\x9a\x6e\x69\x19\x96\xfa\x8d\xbd\x80\x60\x02\x70\x48\xe9\x41\x3e\x57\x2f\xfe\x22\xe1\x3b\xbe\x8e\x2a\x4d\x00\x72\x80\xf2\xe4\x49\x7f\xd6\x91\xf7\x48\x25\x9b\x3b\xf2\x23\xc6\xb0\xaa\x5c\xf2\xb2\x98\x84\x0a\xfc\xaa\x94\xac\xdf\xba\x68\xc4\x52\xeb\x1d\x4e\x7f\x30\x70\xa4\x49\x78\xb6\xad\x71\x89\x5e\x14\x9f\x06\xde\x27\xfd\x01\xea\x4a\xa2\xa7\x3b\x6f\xd1\xd3\x6a\xdb\x9a\x87\x33\x9b\xc2\x2d\x6b\xad\xcc\xea\xbe\x31\x68\x5b\x6a\xf8\xa5\x8f\x5c\xe2\xe3\xbd\xc1\x0d\x2a\x8d\x0b\x4d\x29\xbc\x99\x00\x78\x2a\x2b\xbd\xb3\x19\x52\x10\x1e\x3d\x42\xf6\x02\xb6\xa6\x35\x8c\x61\xdf\xd4\x7b\xe0\x11\x24\x54\xb9\x33\x40\xcd\x26\x08\x9c\x2f\x1a\xad\x9c\x59\xd5\xc8\xdb\xb9\x94\x6c\xdc\x67\xa3\xb7\xe0\x59\x53\xa7\xab\x0b\xd2\xfc\x70\x36\x88\x51\xa2\x5d\xbb\x56\x64\x59\x02\x3a\x40\x10\x5d\x84\xa0\xc0\x11\x9b\x33\x20\xe3\x6a\xab\xcc\x0a\x94\x0f\x07\xc3\x0d\xdc\x2b\xab\xd8\x2a\xbf\x05\x27\x0a\x92\x75\x60\x06\xd0\x48\xf0\x05\x7a\x50\xde\x3d\x9f\x40\x40\x4b\xe1\x8d\xec\x86\xe4\x20\x82\x5a\x86\xb0\xb4\x21\xdb\xc4\x06\xda\x28\xd1\x29\x72\xfb\x74\x91\xc9\xc6\xa8\xab\x02\xe3\x67\x5d\x0c\x47\xaf\x07\x1b\x55\x2c\x53\x78\xfd\xba\x71\xeb\x3b\xa2\x69\x5d\x96\x74\x37\xea\x8c\xf0\x2c\xc8\xef\x47\x62\x97\x82\x56\xa6\x7e\xec\x8c\x0a\x76\x3e\x6b\xef\x83\x14\xbc\xad\xfb\x62\x3c\xb3\x39\x2a\xc6\x35\xae\x09\x5c\x6d\x69\x5c\xc1\x76\x53\xfd\x1e\x64\xb8\xbd\x50\xeb\x56\x78\x9e\xf7\x18\x01\x2d\x97\x24\x7c\x0a\x19\xdf\x75\xb6\x03\x45\xe6\x2a\x64\x64\x9b\xc2\xc5\xa3\x72\xa3\x02\x5c\xa3\x5d\xbf\x58\x3e\x58\xb2\x0d\xbc\xef\xea\x33\xcc\xba\xa6\x6d\x7a\xa4\x63\x7e\x25\xf5\x10\xf2\xc5\x23\x89\xda\xff\x02\xe2\xbe\x5d\x66\x1a\x9d\xcb\x1a\x25\x68\x4f\x7a\x24\x5a\xe1\x8a\x7a\xf4\x9d\x83\x1b\xc9\x53\x76\xa8\x4c\x0d\x07\xca\xa8\x52\x7d\x27\x90\xfc\x60\xbc\x2a\x09\x64\xdb\xaf\xd8\x9f\x56\xa8\xab\x95\x45\x49\xc0\x16\x24\x69\x0a\xd5\xfb\x3f\x78\xd2\x1a\xae\x76\x4d\x10\xa6\x0d\xc9\x80\x30\x5d\xb2\x15\xb4\x0b\xdf\x3b\x4c\x53\x28\xbc\xaf\x5c\x9a\x24\xe3\xce\x91\x2c\x5c\x22\xd8\x08\xaa\xbc\x4b\x42\xc3\x68\x46\xe9\x92\x70\xd5\x84\x9f\xe4\x95\x27\x5b\x2a\xd3\x34\x4d\xc4\xcb\xd0\xab\xbb\xe2\x0f\x96\x2e\x2d\x0a\xba\x21\xab\x58\xde\x85\x0b\x5e\xba\x14\xfe\xd7\x99\x09\x36\x1e\x95\x21\x3b\x68\xba\xa8\x13\x53\x65\x9c\x47\xad\x07\x9c\x84\x47\x95\xb8\xa2\x14\x7e\xfc\x80\x78\x96\xcd\xe7\xe1\x0d\x9e\x9e\xd2\xee\xbd\xd3\x68\x78\x7a\xda\x77\xb9\xa9\xb5\xbe\x61\xad\xc4\x36\x85\x73\xfd\x80\x5b\x37\xb0\x10\x5c\x96\x18\x04\xff\xeb\x34\x19\xa4\x8d\x5d\x31\xfd\x36\x30\x23\xb3\x49\x07\xaf\x81\xc5\x50\x3b\xe0\x65\xab\x51\xd9\xbc\x1f\xcc\x96\x4a\x53\x20\x5e\x58\x42\x4f\xf1\xc8\xa9\xdf\xdf\x2c\x9b\xe7\x61\xbe\xc9\xb3\xf3\xeb\x8b\x91\x05\xb4\xe3\xde\x60\xb4\x8a\x43\xdc\xe9\x5e\xee\xe3\xb3\x66\x48\xdb\xed\x61\x3c\x54\x9e\x04\x91\x5d\x7c\xf9\xf3\xf3\xed\x55\xde\x0e\x5b\xc7\x90\x7c\xb0\x5c\xa6\x7b\x0b\xd0\xe5\xbb\xc6\xea\x8a\xb6\xdd\xa5\xbe\xff\x9c\x9a\xb1\xf7\x9f\xe6\xc4\x1e\x8e\xaa\x2f\x41\xce\xdf\xcf\x6f\x8f\xb3\x96\x90\x17\xcd\x08\x58\xd6\xda\xd7\x2e\x31\xe4\x63\xb9\xc7\xdd\x7c\xd9\x88\xdf\x19\x48\xaa\x34\x6f\x3b\x8d\x09\x93\x38\xc9\x86\xd4\x76\x38\x3f\x03\xf6\x05\xd9\x07\xe5\x68\x64\xe9\x3c\x1a\x19\xae\xa8\xa6\x02\xc7\x61\x7e\x3c\x9f\x67\x17\xef\xf3\x00\xf7\xe6\xd3\xfd\xe5\x3c\x3b\x51\xe3\x25\x6a\x47\xc3\xda\x6e\x58\xd7\x25\x5d\x07\x69\x70\xe9\x5e\xec\x32\x7c\xbd\x41\x5f\xa4\x90\x04\x29\x4f\xb8\xf2\xfd\xb8\x3b\x39\xc6\x7d\xa0\x7d\xa1\x4c\x24\x95\xfd\x59\xa8\x9e\xb6\x43\xbe\x86\xc1\x0c\xf9\x41\xb0\x16\xeb\xe8\xca\xb8\x77\x24\x87\x4d\x38\xcb\xe6\xf1\xc1\xe1\x3e\x0e\x2b\xc0\x68\x10\x8d\xb2\x57\x2d\xc6\xbd\xe1\xfe\x68\xc8\x31\xb8\x9f\x86\x3c\xda\x28\xff\x04\x00\x00\xff\xff\xa8\x78\x41\xa5\xbf\x0e\x00\x00"), - }, - } - fs["/"].(*vfsgen۰DirInfo).entries = []os.FileInfo{ - fs["/all-in-one-template.yaml"].(os.FileInfo), - } - - return fs -}() - -type vfsgen۰FS map[string]interface{} - -func (fs vfsgen۰FS) Open(path string) (http.File, error) { - path = pathpkg.Clean("/" + path) - f, ok := fs[path] - if !ok { - return nil, &os.PathError{Op: "open", Path: path, Err: os.ErrNotExist} - } - - switch f := f.(type) { - case *vfsgen۰CompressedFileInfo: - gr, err := gzip.NewReader(bytes.NewReader(f.compressedContent)) - if err != nil { - // This should never happen because we generate the gzip bytes such that they are always valid. - panic("unexpected error reading own gzip compressed bytes: " + err.Error()) - } - return &vfsgen۰CompressedFile{ - vfsgen۰CompressedFileInfo: f, - gr: gr, - }, nil - case *vfsgen۰DirInfo: - return &vfsgen۰Dir{ - vfsgen۰DirInfo: f, - }, nil - default: - // This should never happen because we generate only the above types. - panic(fmt.Sprintf("unexpected type %T", f)) - } -} - -// vfsgen۰CompressedFileInfo is a static definition of a gzip compressed file. -type vfsgen۰CompressedFileInfo struct { - name string - modTime time.Time - compressedContent []byte - uncompressedSize int64 -} - -func (f *vfsgen۰CompressedFileInfo) Readdir(count int) ([]os.FileInfo, error) { - return nil, fmt.Errorf("cannot Readdir from file %s", f.name) -} -func (f *vfsgen۰CompressedFileInfo) Stat() (os.FileInfo, error) { return f, nil } - -func (f *vfsgen۰CompressedFileInfo) GzipBytes() []byte { - return f.compressedContent -} - -func (f *vfsgen۰CompressedFileInfo) Name() string { return f.name } -func (f *vfsgen۰CompressedFileInfo) Size() int64 { return f.uncompressedSize } -func (f *vfsgen۰CompressedFileInfo) Mode() os.FileMode { return 0444 } -func (f *vfsgen۰CompressedFileInfo) ModTime() time.Time { return f.modTime } -func (f *vfsgen۰CompressedFileInfo) IsDir() bool { return false } -func (f *vfsgen۰CompressedFileInfo) Sys() interface{} { return nil } - -// vfsgen۰CompressedFile is an opened compressedFile instance. -type vfsgen۰CompressedFile struct { - *vfsgen۰CompressedFileInfo - gr *gzip.Reader - grPos int64 // Actual gr uncompressed position. - seekPos int64 // Seek uncompressed position. -} - -func (f *vfsgen۰CompressedFile) Read(p []byte) (n int, err error) { - if f.grPos > f.seekPos { - // Rewind to beginning. - err = f.gr.Reset(bytes.NewReader(f.compressedContent)) - if err != nil { - return 0, err - } - f.grPos = 0 - } - if f.grPos < f.seekPos { - // Fast-forward. - _, err = io.CopyN(ioutil.Discard, f.gr, f.seekPos-f.grPos) - if err != nil { - return 0, err - } - f.grPos = f.seekPos - } - n, err = f.gr.Read(p) - f.grPos += int64(n) - f.seekPos = f.grPos - return n, err -} -func (f *vfsgen۰CompressedFile) Seek(offset int64, whence int) (int64, error) { - switch whence { - case io.SeekStart: - f.seekPos = 0 + offset - case io.SeekCurrent: - f.seekPos += offset - case io.SeekEnd: - f.seekPos = f.uncompressedSize + offset - default: - panic(fmt.Errorf("invalid whence value: %v", whence)) - } - return f.seekPos, nil -} -func (f *vfsgen۰CompressedFile) Close() error { - return f.gr.Close() -} - -// vfsgen۰DirInfo is a static definition of a directory. -type vfsgen۰DirInfo struct { - name string - modTime time.Time - entries []os.FileInfo -} - -func (d *vfsgen۰DirInfo) Read([]byte) (int, error) { - return 0, fmt.Errorf("cannot Read from directory %s", d.name) -} -func (d *vfsgen۰DirInfo) Close() error { return nil } -func (d *vfsgen۰DirInfo) Stat() (os.FileInfo, error) { return d, nil } - -func (d *vfsgen۰DirInfo) Name() string { return d.name } -func (d *vfsgen۰DirInfo) Size() int64 { return 0 } -func (d *vfsgen۰DirInfo) Mode() os.FileMode { return 0755 | os.ModeDir } -func (d *vfsgen۰DirInfo) ModTime() time.Time { return d.modTime } -func (d *vfsgen۰DirInfo) IsDir() bool { return true } -func (d *vfsgen۰DirInfo) Sys() interface{} { return nil } - -// vfsgen۰Dir is an opened dir instance. -type vfsgen۰Dir struct { - *vfsgen۰DirInfo - pos int // Position within entries for Seek and Readdir. -} - -func (d *vfsgen۰Dir) Seek(offset int64, whence int) (int64, error) { - if offset == 0 && whence == io.SeekStart { - d.pos = 0 - return 0, nil - } - return 0, fmt.Errorf("unsupported Seek in directory %s", d.name) -} - -func (d *vfsgen۰Dir) Readdir(count int) ([]os.FileInfo, error) { - if d.pos >= len(d.entries) && count > 0 { - return nil, io.EOF - } - if count <= 0 || count > len(d.entries)-d.pos { - count = len(d.entries) - d.pos - } - e := d.entries[d.pos : d.pos+count] - d.pos += count - return e, nil -} diff --git a/app/kumactl/pkg/install/k8s/kuma-cni/templates_vfsdata_test.go b/app/kumactl/pkg/install/k8s/kuma-cni/templates_vfsdata_test.go deleted file mode 100644 index 5691f50427bc..000000000000 --- a/app/kumactl/pkg/install/k8s/kuma-cni/templates_vfsdata_test.go +++ /dev/null @@ -1,39 +0,0 @@ -// +build !dev - -package kumacni_test - -import ( - "io/ioutil" - "path/filepath" - - . "github.com/onsi/ginkgo" - . "github.com/onsi/ginkgo/extensions/table" - . "github.com/onsi/gomega" - - kumacni "github.com/kumahq/kuma/app/kumactl/pkg/install/k8s/kuma-cni" - "github.com/kumahq/kuma/pkg/test/vfsgen" -) - -var _ = Describe("Templates", func() { - - kumactlSrcDir := filepath.Join("..", "..", "..", "..") - kumacniTemplatesDir := kumacni.TemplatesDir(kumactlSrcDir) - kumacniTemplatesTestEntries := vfsgen.GenerateEntries(kumacniTemplatesDir) - - DescribeTable("generated Go code must be in sync with the original template files", - func(given vfsgen.FileTestCase) { - // when - file, err := kumacni.Templates.Open(given.Filename) - // then - Expect(err).ToNot(HaveOccurred()) - - // when - actualContents, err := ioutil.ReadAll(file) - // then - Expect(err).ToNot(HaveOccurred()) - // and - Expect(string(actualContents)).To(Equal(string(given.ExpectedContents)), "generated Go code is no longer in sync with the original template files. To re-generate it, run `make generate/kumactl/install/k8s/kuma-cni`") - }, - kumacniTemplatesTestEntries..., - ) -}) diff --git a/mk/generate.mk b/mk/generate.mk index 1771344b8640..0f77dc9b091c 100644 --- a/mk/generate.mk +++ b/mk/generate.mk @@ -42,11 +42,6 @@ protoc/plugins: generate/kumactl/install/k8s/control-plane: GOFLAGS='${GOFLAGS}' go generate ./app/kumactl/pkg/install/k8s/control-plane/... -# Notice that this command is not include into `make generate` by intention (since generated code differs between dev host and ci server) -.PHONY: generate/kumactl/install/k8s/kuma-cni -generate/kumactl/install/k8s/kuma-cni: - GOFLAGS='${GOFLAGS}' go generate ./app/kumactl/pkg/install/k8s/kuma-cni/... - # Notice that this command is not include into `make generate` by intention (since generated code differs between dev host and ci server) .PHONY: generate/kumactl/install/k8s/metrics generate/kumactl/install/k8s/metrics: