From 94c696b2f6ef6f82dc51f4871500600925370165 Mon Sep 17 00:00:00 2001 From: Kam D Kasravi Date: Thu, 10 Oct 2019 19:51:31 -0700 Subject: [PATCH 1/3] add spartakus --- .../overlays/application/application.yaml | 33 +++ .../overlays/application/kustomization.yaml | 13 ++ tests/spartakus-overlays-application_test.go | 196 ++++++++++++++++++ 3 files changed, 242 insertions(+) create mode 100644 common/spartakus/overlays/application/application.yaml create mode 100644 common/spartakus/overlays/application/kustomization.yaml create mode 100644 tests/spartakus-overlays-application_test.go diff --git a/common/spartakus/overlays/application/application.yaml b/common/spartakus/overlays/application/application.yaml new file mode 100644 index 00000000000..4cf6095c64c --- /dev/null +++ b/common/spartakus/overlays/application/application.yaml @@ -0,0 +1,33 @@ +apiVersion: app.k8s.io/v1beta1 +kind: Application +metadata: + name: spartakus +spec: + selector: + matchLabels: + app.kubernetes.io/name: spartakus + app.kubernetes.io/instance: spartakus-v0.7.0 + app.kubernetes.io/managed-by: kfctl + app.kubernetes.io/component: spartakus + app.kubernetes.io/part-of: kubeflow + app.kubernetes.io/version: v0.7.0 + componentKinds: + - group: core + kind: ConfigMap + - group: apps + kind: Deployment + - group: core + kind: ServiceAccount + descriptor: + type: spartakus + version: v1beta1 + description: "" + maintainers: [] + owners: [] + keywords: + - spartakus + - kubeflow + links: + - description: About + url: "" + addOwnerRef: true diff --git a/common/spartakus/overlays/application/kustomization.yaml b/common/spartakus/overlays/application/kustomization.yaml new file mode 100644 index 00000000000..a469fc38283 --- /dev/null +++ b/common/spartakus/overlays/application/kustomization.yaml @@ -0,0 +1,13 @@ +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization +bases: +- ../../base +resources: +- application.yaml +commonLabels: + app.kubernetes.io/name: spartakus + app.kubernetes.io/instance: spartakus-v0.7.0 + app.kubernetes.io/managed-by: kfctl + app.kubernetes.io/component: spartakus + app.kubernetes.io/part-of: kubeflow + app.kubernetes.io/version: v0.7.0 diff --git a/tests/spartakus-overlays-application_test.go b/tests/spartakus-overlays-application_test.go new file mode 100644 index 00000000000..f473eb49868 --- /dev/null +++ b/tests/spartakus-overlays-application_test.go @@ -0,0 +1,196 @@ +package tests_test + +import ( + "sigs.k8s.io/kustomize/v3/k8sdeps/kunstruct" + "sigs.k8s.io/kustomize/v3/k8sdeps/transformer" + "sigs.k8s.io/kustomize/v3/pkg/fs" + "sigs.k8s.io/kustomize/v3/pkg/loader" + "sigs.k8s.io/kustomize/v3/pkg/plugins" + "sigs.k8s.io/kustomize/v3/pkg/resmap" + "sigs.k8s.io/kustomize/v3/pkg/resource" + "sigs.k8s.io/kustomize/v3/pkg/target" + "sigs.k8s.io/kustomize/v3/pkg/validators" + "testing" +) + +func writeSpartakusOverlaysApplication(th *KustTestHarness) { + th.writeF("/manifests/common/spartakus/overlays/application/application.yaml", ` +apiVersion: app.k8s.io/v1beta1 +kind: Application +metadata: + name: spartakus +spec: + selector: + matchLabels: + app.kubernetes.io/name: spartakus + app.kubernetes.io/instance: spartakus-v0.7.0 + app.kubernetes.io/managed-by: kfctl + app.kubernetes.io/component: spartakus + app.kubernetes.io/part-of: kubeflow + app.kubernetes.io/version: v0.7.0 + componentKinds: + - group: core + kind: ConfigMap + - group: apps + kind: Deployment + descriptor: + type: spartakus + version: v1beta1 + description: "" + maintainers: [] + owners: [] + keywords: + - spartakus + - kubeflow + links: + - description: About + url: "" + addOwnerRef: true +`) + th.writeK("/manifests/common/spartakus/overlays/application", ` +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization +bases: +- ../../base +resources: +- application.yaml +commonLabels: + app.kubernetes.io/name: spartakus + app.kubernetes.io/instance: spartakus-v0.7.0 + app.kubernetes.io/managed-by: kfctl + app.kubernetes.io/component: spartakus + app.kubernetes.io/part-of: kubeflow + app.kubernetes.io/version: v0.7.0 +`) + th.writeF("/manifests/common/spartakus/base/cluster-role-binding.yaml", ` +apiVersion: rbac.authorization.k8s.io/v1beta1 +kind: ClusterRoleBinding +metadata: + labels: + app: spartakus + name: spartakus +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: ClusterRole + name: spartakus +subjects: +- kind: ServiceAccount + name: spartakus +`) + th.writeF("/manifests/common/spartakus/base/cluster-role.yaml", ` +apiVersion: rbac.authorization.k8s.io/v1beta1 +kind: ClusterRole +metadata: + labels: + app: spartakus + name: spartakus +rules: +- apiGroups: + - "" + resources: + - nodes + verbs: + - get + - list +`) + th.writeF("/manifests/common/spartakus/base/deployment.yaml", ` +apiVersion: apps/v1 +kind: Deployment +metadata: + labels: + app: spartakus + name: spartakus-volunteer +spec: + replicas: 1 + template: + metadata: + labels: + app: spartakus-volunteer + spec: + containers: + - args: + - volunteer + - --cluster-id=$(usageId) + - --database=https://stats-collector.kubeflow.org + image: gcr.io/google_containers/spartakus-amd64:v1.1.0 + name: volunteer + serviceAccountName: spartakus +`) + th.writeF("/manifests/common/spartakus/base/service-account.yaml", ` +apiVersion: v1 +kind: ServiceAccount +metadata: + labels: + app: spartakus + name: spartakus +`) + th.writeF("/manifests/common/spartakus/base/params.yaml", ` +varReference: +- path: spec/template/spec/containers/0/args/1 + kind: Deployment +`) + th.writeF("/manifests/common/spartakus/base/params.env", ` +usageId=unknown_cluster +`) + th.writeK("/manifests/common/spartakus/base", ` +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization +resources: +- cluster-role-binding.yaml +- cluster-role.yaml +- deployment.yaml +- service-account.yaml +commonLabels: + kustomize.component: spartakus +images: +- name: gcr.io/google_containers/spartakus-amd64 + newName: gcr.io/google_containers/spartakus-amd64 + newTag: v1.1.0 +configMapGenerator: +- name: spartakus-parameters + env: params.env +generatorOptions: + disableNameSuffixHash: true +vars: +- name: usageId + objref: + kind: ConfigMap + name: spartakus-parameters + apiVersion: v1 + fieldref: + fieldpath: data.usageId +configurations: +- params.yaml +`) +} + +func TestSpartakusOverlaysApplication(t *testing.T) { + th := NewKustTestHarness(t, "/manifests/common/spartakus/overlays/application") + writeSpartakusOverlaysApplication(th) + m, err := th.makeKustTarget().MakeCustomizedResMap() + if err != nil { + t.Fatalf("Err: %v", err) + } + expected, err := m.AsYaml() + if err != nil { + t.Fatalf("Err: %v", err) + } + targetPath := "../common/spartakus/overlays/application" + fsys := fs.MakeRealFS() + lrc := loader.RestrictionRootOnly + _loader, loaderErr := loader.NewLoader(lrc, validators.MakeFakeValidator(), targetPath, fsys) + if loaderErr != nil { + t.Fatalf("could not load kustomize loader: %v", loaderErr) + } + rf := resmap.NewFactory(resource.NewFactory(kunstruct.NewKunstructuredFactoryImpl()), transformer.NewFactoryImpl()) + pc := plugins.DefaultPluginConfig() + kt, err := target.NewKustTarget(_loader, rf, transformer.NewFactoryImpl(), plugins.NewLoader(pc, rf)) + if err != nil { + th.t.Fatalf("Unexpected construction error %v", err) + } + actual, err := kt.MakeCustomizedResMap() + if err != nil { + t.Fatalf("Err: %v", err) + } + th.assertActualEqualsExpected(actual, string(expected)) +} From 0f990d65a7a12b1412364c4f11dd471fd4ba4fba Mon Sep 17 00:00:00 2001 From: Kam D Kasravi Date: Thu, 10 Oct 2019 21:32:50 -0700 Subject: [PATCH 2/3] update unit test, add application to config files --- kfdef/kfctl_anthos.yaml | 2 ++ kfdef/kfctl_aws.yaml | 2 ++ kfdef/kfctl_aws_cognito.yaml | 2 ++ kfdef/kfctl_existing_arrikto.yaml | 2 ++ kfdef/kfctl_gcp_basic_auth.yaml | 2 ++ kfdef/kfctl_gcp_iap.yaml | 2 ++ kfdef/kfctl_k8s_istio.yaml | 2 ++ tests/spartakus-overlays-application_test.go | 2 ++ 8 files changed, 16 insertions(+) diff --git a/kfdef/kfctl_anthos.yaml b/kfdef/kfctl_anthos.yaml index 625fd07b3ed..d4d79363455 100644 --- a/kfdef/kfctl_anthos.yaml +++ b/kfdef/kfctl_anthos.yaml @@ -148,6 +148,8 @@ spec: path: kfserving/kfserving-install name: kfserving-install - kustomizeConfig: + overlays: + - application parameters: - initRequired: true name: usageId diff --git a/kfdef/kfctl_aws.yaml b/kfdef/kfctl_aws.yaml index 6600e870195..201b417648d 100644 --- a/kfdef/kfctl_aws.yaml +++ b/kfdef/kfctl_aws.yaml @@ -123,6 +123,8 @@ spec: path: pytorch-job/pytorch-operator name: pytorch-operator - kustomizeConfig: + overlays: + - application parameters: - initRequired: true name: usageId diff --git a/kfdef/kfctl_aws_cognito.yaml b/kfdef/kfctl_aws_cognito.yaml index 652f47d19cb..b3db7d8e3f9 100644 --- a/kfdef/kfctl_aws_cognito.yaml +++ b/kfdef/kfctl_aws_cognito.yaml @@ -123,6 +123,8 @@ spec: path: pytorch-job/pytorch-operator name: pytorch-operator - kustomizeConfig: + overlays: + - application parameters: - initRequired: true name: usageId diff --git a/kfdef/kfctl_existing_arrikto.yaml b/kfdef/kfctl_existing_arrikto.yaml index d2bca40bad9..5203d47b768 100644 --- a/kfdef/kfctl_existing_arrikto.yaml +++ b/kfdef/kfctl_existing_arrikto.yaml @@ -103,6 +103,8 @@ spec: path: pytorch-job/pytorch-operator name: pytorch-operator - kustomizeConfig: + overlays: + - application parameters: - initRequired: true name: usageId diff --git a/kfdef/kfctl_gcp_basic_auth.yaml b/kfdef/kfctl_gcp_basic_auth.yaml index c870c84f4c4..0b46425a7be 100644 --- a/kfdef/kfctl_gcp_basic_auth.yaml +++ b/kfdef/kfctl_gcp_basic_auth.yaml @@ -171,6 +171,8 @@ spec: path: kfserving/kfserving-install name: kfserving-install - kustomizeConfig: + overlays: + - application parameters: - initRequired: true name: usageId diff --git a/kfdef/kfctl_gcp_iap.yaml b/kfdef/kfctl_gcp_iap.yaml index 5eaaa853913..fd7dbb5a7fb 100644 --- a/kfdef/kfctl_gcp_iap.yaml +++ b/kfdef/kfctl_gcp_iap.yaml @@ -177,6 +177,8 @@ spec: path: kfserving/kfserving-install name: kfserving-install - kustomizeConfig: + overlays: + - application parameters: - initRequired: true name: usageId diff --git a/kfdef/kfctl_k8s_istio.yaml b/kfdef/kfctl_k8s_istio.yaml index 709c9b4ebd7..a5f0339323c 100644 --- a/kfdef/kfctl_k8s_istio.yaml +++ b/kfdef/kfctl_k8s_istio.yaml @@ -162,6 +162,8 @@ spec: path: kfserving/kfserving-install name: kfserving-install - kustomizeConfig: + overlays: + - application parameters: - initRequired: true name: usageId diff --git a/tests/spartakus-overlays-application_test.go b/tests/spartakus-overlays-application_test.go index f473eb49868..ce228be53a6 100644 --- a/tests/spartakus-overlays-application_test.go +++ b/tests/spartakus-overlays-application_test.go @@ -33,6 +33,8 @@ spec: kind: ConfigMap - group: apps kind: Deployment + - group: core + kind: ServiceAccount descriptor: type: spartakus version: v1beta1 From f23d5792059558eba171e19cb36ffbaac72aa72d Mon Sep 17 00:00:00 2001 From: Kam D Kasravi Date: Fri, 11 Oct 2019 08:31:49 -0700 Subject: [PATCH 3/3] update unit tests --- ...ss-controller-overlays-application_test.go | 92 +++++++++--------- ...lb-ingress-controller-overlays-vpc_test.go | 94 +++++++++---------- ...device-plugin-overlays-application_test.go | 84 ++++++++--------- 3 files changed, 135 insertions(+), 135 deletions(-) diff --git a/tests/aws-alb-ingress-controller-overlays-application_test.go b/tests/aws-alb-ingress-controller-overlays-application_test.go index c6e9fceeffd..3f4cad595b3 100644 --- a/tests/aws-alb-ingress-controller-overlays-application_test.go +++ b/tests/aws-alb-ingress-controller-overlays-application_test.go @@ -1,20 +1,20 @@ package tests_test import ( - "sigs.k8s.io/kustomize/v3/k8sdeps/kunstruct" - "sigs.k8s.io/kustomize/v3/k8sdeps/transformer" - "sigs.k8s.io/kustomize/v3/pkg/fs" - "sigs.k8s.io/kustomize/v3/pkg/loader" - "sigs.k8s.io/kustomize/v3/pkg/plugins" - "sigs.k8s.io/kustomize/v3/pkg/resmap" - "sigs.k8s.io/kustomize/v3/pkg/resource" - "sigs.k8s.io/kustomize/v3/pkg/target" - "sigs.k8s.io/kustomize/v3/pkg/validators" - "testing" + "sigs.k8s.io/kustomize/v3/k8sdeps/kunstruct" + "sigs.k8s.io/kustomize/v3/k8sdeps/transformer" + "sigs.k8s.io/kustomize/v3/pkg/fs" + "sigs.k8s.io/kustomize/v3/pkg/loader" + "sigs.k8s.io/kustomize/v3/pkg/plugins" + "sigs.k8s.io/kustomize/v3/pkg/resmap" + "sigs.k8s.io/kustomize/v3/pkg/resource" + "sigs.k8s.io/kustomize/v3/pkg/target" + "sigs.k8s.io/kustomize/v3/pkg/validators" + "testing" ) func writeAwsAlbIngressControllerOverlaysApplication(th *KustTestHarness) { - th.writeF("/manifests/aws/aws-alb-ingress-controller/overlays/application/application.yaml", ` + th.writeF("/manifests/aws/aws-alb-ingress-controller/overlays/application/application.yaml", ` apiVersion: app.k8s.io/v1beta1 kind: Application metadata: @@ -50,7 +50,7 @@ spec: addOwnerRef: true `) - th.writeK("/manifests/aws/aws-alb-ingress-controller/overlays/application", ` + th.writeK("/manifests/aws/aws-alb-ingress-controller/overlays/application", ` apiVersion: kustomize.config.k8s.io/v1beta1 kind: Kustomization bases: @@ -66,7 +66,7 @@ commonLabels: app.kubernetes.io/version: v0.6.2 `) - th.writeF("/manifests/aws/aws-alb-ingress-controller/base/cluster-role.yaml", ` + th.writeF("/manifests/aws/aws-alb-ingress-controller/base/cluster-role.yaml", ` apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRole metadata: @@ -104,7 +104,7 @@ rules: - list - watch `) - th.writeF("/manifests/aws/aws-alb-ingress-controller/base/cluster-role-binding.yaml", ` + th.writeF("/manifests/aws/aws-alb-ingress-controller/base/cluster-role-binding.yaml", ` apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRoleBinding metadata: @@ -117,7 +117,7 @@ subjects: - kind: ServiceAccount name: alb-ingress-controller `) - th.writeF("/manifests/aws/aws-alb-ingress-controller/base/deployment.yaml", ` + th.writeF("/manifests/aws/aws-alb-ingress-controller/base/deployment.yaml", ` # Application Load Balancer (ALB) Ingress Controller Deployment Manifest. # This manifest details sensible defaults for deploying an ALB Ingress Controller. # GitHub: https://github.com/kubernetes-sigs/aws-alb-ingress-controller @@ -170,16 +170,16 @@ spec: imagePullPolicy: Always serviceAccountName: alb-ingress-controller `) - th.writeF("/manifests/aws/aws-alb-ingress-controller/base/service-account.yaml", ` + th.writeF("/manifests/aws/aws-alb-ingress-controller/base/service-account.yaml", ` apiVersion: v1 kind: ServiceAccount metadata: name: alb-ingress-controller `) - th.writeF("/manifests/aws/aws-alb-ingress-controller/base/params.env", ` + th.writeF("/manifests/aws/aws-alb-ingress-controller/base/params.env", ` clusterName= `) - th.writeK("/manifests/aws/aws-alb-ingress-controller/base", ` + th.writeK("/manifests/aws/aws-alb-ingress-controller/base", ` apiVersion: kustomize.config.k8s.io/v1beta1 kind: Kustomization namespace: kubeflow @@ -211,32 +211,32 @@ vars: } func TestAwsAlbIngressControllerOverlaysApplication(t *testing.T) { - th := NewKustTestHarness(t, "/manifests/aws/aws-alb-ingress-controller/overlays/application") - writeAwsAlbIngressControllerOverlaysApplication(th) - m, err := th.makeKustTarget().MakeCustomizedResMap() - if err != nil { - t.Fatalf("Err: %v", err) - } - expected, err := m.AsYaml() - if err != nil { - t.Fatalf("Err: %v", err) - } - targetPath := "../aws/aws-alb-ingress-controller/overlays/application" - fsys := fs.MakeRealFS() - lrc := loader.RestrictionRootOnly - _loader, loaderErr := loader.NewLoader(lrc, validators.MakeFakeValidator(), targetPath, fsys) - if loaderErr != nil { - t.Fatalf("could not load kustomize loader: %v", loaderErr) - } - rf := resmap.NewFactory(resource.NewFactory(kunstruct.NewKunstructuredFactoryImpl()), transformer.NewFactoryImpl()) - pc := plugins.DefaultPluginConfig() - kt, err := target.NewKustTarget(_loader, rf, transformer.NewFactoryImpl(), plugins.NewLoader(pc, rf)) - if err != nil { - th.t.Fatalf("Unexpected construction error %v", err) - } - actual, err := kt.MakeCustomizedResMap() - if err != nil { - t.Fatalf("Err: %v", err) - } - th.assertActualEqualsExpected(actual, string(expected)) + th := NewKustTestHarness(t, "/manifests/aws/aws-alb-ingress-controller/overlays/application") + writeAwsAlbIngressControllerOverlaysApplication(th) + m, err := th.makeKustTarget().MakeCustomizedResMap() + if err != nil { + t.Fatalf("Err: %v", err) + } + expected, err := m.AsYaml() + if err != nil { + t.Fatalf("Err: %v", err) + } + targetPath := "../aws/aws-alb-ingress-controller/overlays/application" + fsys := fs.MakeRealFS() + lrc := loader.RestrictionRootOnly + _loader, loaderErr := loader.NewLoader(lrc, validators.MakeFakeValidator(), targetPath, fsys) + if loaderErr != nil { + t.Fatalf("could not load kustomize loader: %v", loaderErr) + } + rf := resmap.NewFactory(resource.NewFactory(kunstruct.NewKunstructuredFactoryImpl()), transformer.NewFactoryImpl()) + pc := plugins.DefaultPluginConfig() + kt, err := target.NewKustTarget(_loader, rf, transformer.NewFactoryImpl(), plugins.NewLoader(pc, rf)) + if err != nil { + th.t.Fatalf("Unexpected construction error %v", err) + } + actual, err := kt.MakeCustomizedResMap() + if err != nil { + t.Fatalf("Err: %v", err) + } + th.assertActualEqualsExpected(actual, string(expected)) } diff --git a/tests/aws-alb-ingress-controller-overlays-vpc_test.go b/tests/aws-alb-ingress-controller-overlays-vpc_test.go index e09150ad877..84e75e14203 100644 --- a/tests/aws-alb-ingress-controller-overlays-vpc_test.go +++ b/tests/aws-alb-ingress-controller-overlays-vpc_test.go @@ -1,20 +1,20 @@ package tests_test import ( - "sigs.k8s.io/kustomize/v3/k8sdeps/kunstruct" - "sigs.k8s.io/kustomize/v3/k8sdeps/transformer" - "sigs.k8s.io/kustomize/v3/pkg/fs" - "sigs.k8s.io/kustomize/v3/pkg/loader" - "sigs.k8s.io/kustomize/v3/pkg/plugins" - "sigs.k8s.io/kustomize/v3/pkg/resmap" - "sigs.k8s.io/kustomize/v3/pkg/resource" - "sigs.k8s.io/kustomize/v3/pkg/target" - "sigs.k8s.io/kustomize/v3/pkg/validators" - "testing" + "sigs.k8s.io/kustomize/v3/k8sdeps/kunstruct" + "sigs.k8s.io/kustomize/v3/k8sdeps/transformer" + "sigs.k8s.io/kustomize/v3/pkg/fs" + "sigs.k8s.io/kustomize/v3/pkg/loader" + "sigs.k8s.io/kustomize/v3/pkg/plugins" + "sigs.k8s.io/kustomize/v3/pkg/resmap" + "sigs.k8s.io/kustomize/v3/pkg/resource" + "sigs.k8s.io/kustomize/v3/pkg/target" + "sigs.k8s.io/kustomize/v3/pkg/validators" + "testing" ) func writeAwsAlbIngressControllerOverlaysVpc(th *KustTestHarness) { - th.writeF("/manifests/aws/aws-alb-ingress-controller/overlays/vpc/vpc.yaml", ` + th.writeF("/manifests/aws/aws-alb-ingress-controller/overlays/vpc/vpc.yaml", ` apiVersion: apps/v1 kind: Deployment metadata: @@ -42,11 +42,11 @@ spec: # List of regions: http://docs.aws.amazon.com/general/latest/gr/rande.html#vpc_region - --aws-region=$(REGION) `) - th.writeF("/manifests/aws/aws-alb-ingress-controller/overlays/vpc/params.env", ` + th.writeF("/manifests/aws/aws-alb-ingress-controller/overlays/vpc/params.env", ` vpcId= region=us-west-2 `) - th.writeK("/manifests/aws/aws-alb-ingress-controller/overlays/vpc", ` + th.writeK("/manifests/aws/aws-alb-ingress-controller/overlays/vpc", ` apiVersion: kustomize.config.k8s.io/v1beta1 kind: Kustomization bases: @@ -72,7 +72,7 @@ vars: fieldref: fieldpath: data.region `) - th.writeF("/manifests/aws/aws-alb-ingress-controller/base/cluster-role.yaml", ` + th.writeF("/manifests/aws/aws-alb-ingress-controller/base/cluster-role.yaml", ` apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRole metadata: @@ -110,7 +110,7 @@ rules: - list - watch `) - th.writeF("/manifests/aws/aws-alb-ingress-controller/base/cluster-role-binding.yaml", ` + th.writeF("/manifests/aws/aws-alb-ingress-controller/base/cluster-role-binding.yaml", ` apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRoleBinding metadata: @@ -123,7 +123,7 @@ subjects: - kind: ServiceAccount name: alb-ingress-controller `) - th.writeF("/manifests/aws/aws-alb-ingress-controller/base/deployment.yaml", ` + th.writeF("/manifests/aws/aws-alb-ingress-controller/base/deployment.yaml", ` # Application Load Balancer (ALB) Ingress Controller Deployment Manifest. # This manifest details sensible defaults for deploying an ALB Ingress Controller. # GitHub: https://github.com/kubernetes-sigs/aws-alb-ingress-controller @@ -176,16 +176,16 @@ spec: imagePullPolicy: Always serviceAccountName: alb-ingress-controller `) - th.writeF("/manifests/aws/aws-alb-ingress-controller/base/service-account.yaml", ` + th.writeF("/manifests/aws/aws-alb-ingress-controller/base/service-account.yaml", ` apiVersion: v1 kind: ServiceAccount metadata: name: alb-ingress-controller `) - th.writeF("/manifests/aws/aws-alb-ingress-controller/base/params.env", ` + th.writeF("/manifests/aws/aws-alb-ingress-controller/base/params.env", ` clusterName= `) - th.writeK("/manifests/aws/aws-alb-ingress-controller/base", ` + th.writeK("/manifests/aws/aws-alb-ingress-controller/base", ` apiVersion: kustomize.config.k8s.io/v1beta1 kind: Kustomization namespace: kubeflow @@ -217,32 +217,32 @@ vars: } func TestAwsAlbIngressControllerOverlaysVpc(t *testing.T) { - th := NewKustTestHarness(t, "/manifests/aws/aws-alb-ingress-controller/overlays/vpc") - writeAwsAlbIngressControllerOverlaysVpc(th) - m, err := th.makeKustTarget().MakeCustomizedResMap() - if err != nil { - t.Fatalf("Err: %v", err) - } - expected, err := m.AsYaml() - if err != nil { - t.Fatalf("Err: %v", err) - } - targetPath := "../aws/aws-alb-ingress-controller/overlays/vpc" - fsys := fs.MakeRealFS() - lrc := loader.RestrictionRootOnly - _loader, loaderErr := loader.NewLoader(lrc, validators.MakeFakeValidator(), targetPath, fsys) - if loaderErr != nil { - t.Fatalf("could not load kustomize loader: %v", loaderErr) - } - rf := resmap.NewFactory(resource.NewFactory(kunstruct.NewKunstructuredFactoryImpl()), transformer.NewFactoryImpl()) - pc := plugins.DefaultPluginConfig() - kt, err := target.NewKustTarget(_loader, rf, transformer.NewFactoryImpl(), plugins.NewLoader(pc, rf)) - if err != nil { - th.t.Fatalf("Unexpected construction error %v", err) - } - actual, err := kt.MakeCustomizedResMap() - if err != nil { - t.Fatalf("Err: %v", err) - } - th.assertActualEqualsExpected(actual, string(expected)) + th := NewKustTestHarness(t, "/manifests/aws/aws-alb-ingress-controller/overlays/vpc") + writeAwsAlbIngressControllerOverlaysVpc(th) + m, err := th.makeKustTarget().MakeCustomizedResMap() + if err != nil { + t.Fatalf("Err: %v", err) + } + expected, err := m.AsYaml() + if err != nil { + t.Fatalf("Err: %v", err) + } + targetPath := "../aws/aws-alb-ingress-controller/overlays/vpc" + fsys := fs.MakeRealFS() + lrc := loader.RestrictionRootOnly + _loader, loaderErr := loader.NewLoader(lrc, validators.MakeFakeValidator(), targetPath, fsys) + if loaderErr != nil { + t.Fatalf("could not load kustomize loader: %v", loaderErr) + } + rf := resmap.NewFactory(resource.NewFactory(kunstruct.NewKunstructuredFactoryImpl()), transformer.NewFactoryImpl()) + pc := plugins.DefaultPluginConfig() + kt, err := target.NewKustTarget(_loader, rf, transformer.NewFactoryImpl(), plugins.NewLoader(pc, rf)) + if err != nil { + th.t.Fatalf("Unexpected construction error %v", err) + } + actual, err := kt.MakeCustomizedResMap() + if err != nil { + t.Fatalf("Err: %v", err) + } + th.assertActualEqualsExpected(actual, string(expected)) } diff --git a/tests/nvidia-device-plugin-overlays-application_test.go b/tests/nvidia-device-plugin-overlays-application_test.go index d480a114081..af32e26ee58 100644 --- a/tests/nvidia-device-plugin-overlays-application_test.go +++ b/tests/nvidia-device-plugin-overlays-application_test.go @@ -1,20 +1,20 @@ package tests_test import ( - "sigs.k8s.io/kustomize/v3/k8sdeps/kunstruct" - "sigs.k8s.io/kustomize/v3/k8sdeps/transformer" - "sigs.k8s.io/kustomize/v3/pkg/fs" - "sigs.k8s.io/kustomize/v3/pkg/loader" - "sigs.k8s.io/kustomize/v3/pkg/plugins" - "sigs.k8s.io/kustomize/v3/pkg/resmap" - "sigs.k8s.io/kustomize/v3/pkg/resource" - "sigs.k8s.io/kustomize/v3/pkg/target" - "sigs.k8s.io/kustomize/v3/pkg/validators" - "testing" + "sigs.k8s.io/kustomize/v3/k8sdeps/kunstruct" + "sigs.k8s.io/kustomize/v3/k8sdeps/transformer" + "sigs.k8s.io/kustomize/v3/pkg/fs" + "sigs.k8s.io/kustomize/v3/pkg/loader" + "sigs.k8s.io/kustomize/v3/pkg/plugins" + "sigs.k8s.io/kustomize/v3/pkg/resmap" + "sigs.k8s.io/kustomize/v3/pkg/resource" + "sigs.k8s.io/kustomize/v3/pkg/target" + "sigs.k8s.io/kustomize/v3/pkg/validators" + "testing" ) func writeNvidiaDevicePluginOverlaysApplication(th *KustTestHarness) { - th.writeF("/manifests/aws/nvidia-device-plugin/overlays/application/application.yaml", ` + th.writeF("/manifests/aws/nvidia-device-plugin/overlays/application/application.yaml", ` apiVersion: app.k8s.io/v1beta1 kind: Application metadata: @@ -49,7 +49,7 @@ spec: addOwnerRef: true `) - th.writeK("/manifests/aws/nvidia-device-plugin/overlays/application", ` + th.writeK("/manifests/aws/nvidia-device-plugin/overlays/application", ` apiVersion: kustomize.config.k8s.io/v1beta1 kind: Kustomization bases: @@ -64,7 +64,7 @@ commonLabels: app.kubernetes.io/part-of: kubeflow app.kubernetes.io/version: v1.0.0-beta `) - th.writeF("/manifests/aws/nvidia-device-plugin/base/daemonset.yaml", ` + th.writeF("/manifests/aws/nvidia-device-plugin/base/daemonset.yaml", ` apiVersion: apps/v1 kind: DaemonSet metadata: @@ -103,7 +103,7 @@ spec: hostPath: path: /var/lib/kubelet/device-plugins `) - th.writeK("/manifests/aws/nvidia-device-plugin/base", ` + th.writeK("/manifests/aws/nvidia-device-plugin/base", ` apiVersion: kustomize.config.k8s.io/v1beta1 kind: Kustomization namespace: kube-system @@ -119,32 +119,32 @@ images: } func TestNvidiaDevicePluginOverlaysApplication(t *testing.T) { - th := NewKustTestHarness(t, "/manifests/aws/nvidia-device-plugin/overlays/application") - writeNvidiaDevicePluginOverlaysApplication(th) - m, err := th.makeKustTarget().MakeCustomizedResMap() - if err != nil { - t.Fatalf("Err: %v", err) - } - expected, err := m.AsYaml() - if err != nil { - t.Fatalf("Err: %v", err) - } - targetPath := "../aws/nvidia-device-plugin/overlays/application" - fsys := fs.MakeRealFS() - lrc := loader.RestrictionRootOnly - _loader, loaderErr := loader.NewLoader(lrc, validators.MakeFakeValidator(), targetPath, fsys) - if loaderErr != nil { - t.Fatalf("could not load kustomize loader: %v", loaderErr) - } - rf := resmap.NewFactory(resource.NewFactory(kunstruct.NewKunstructuredFactoryImpl()), transformer.NewFactoryImpl()) - pc := plugins.DefaultPluginConfig() - kt, err := target.NewKustTarget(_loader, rf, transformer.NewFactoryImpl(), plugins.NewLoader(pc, rf)) - if err != nil { - th.t.Fatalf("Unexpected construction error %v", err) - } - actual, err := kt.MakeCustomizedResMap() - if err != nil { - t.Fatalf("Err: %v", err) - } - th.assertActualEqualsExpected(actual, string(expected)) + th := NewKustTestHarness(t, "/manifests/aws/nvidia-device-plugin/overlays/application") + writeNvidiaDevicePluginOverlaysApplication(th) + m, err := th.makeKustTarget().MakeCustomizedResMap() + if err != nil { + t.Fatalf("Err: %v", err) + } + expected, err := m.AsYaml() + if err != nil { + t.Fatalf("Err: %v", err) + } + targetPath := "../aws/nvidia-device-plugin/overlays/application" + fsys := fs.MakeRealFS() + lrc := loader.RestrictionRootOnly + _loader, loaderErr := loader.NewLoader(lrc, validators.MakeFakeValidator(), targetPath, fsys) + if loaderErr != nil { + t.Fatalf("could not load kustomize loader: %v", loaderErr) + } + rf := resmap.NewFactory(resource.NewFactory(kunstruct.NewKunstructuredFactoryImpl()), transformer.NewFactoryImpl()) + pc := plugins.DefaultPluginConfig() + kt, err := target.NewKustTarget(_loader, rf, transformer.NewFactoryImpl(), plugins.NewLoader(pc, rf)) + if err != nil { + th.t.Fatalf("Unexpected construction error %v", err) + } + actual, err := kt.MakeCustomizedResMap() + if err != nil { + t.Fatalf("Err: %v", err) + } + th.assertActualEqualsExpected(actual, string(expected)) }