Skip to content

Commit

Permalink
Expand kustomize test coverage and update for later kustomize format
Browse files Browse the repository at this point in the history
  • Loading branch information
gavinbunney committed Dec 9, 2024
1 parent c0eb6c2 commit 03bde77
Show file tree
Hide file tree
Showing 2 changed files with 75 additions and 4 deletions.
70 changes: 68 additions & 2 deletions kubernetes/data_source_kubectl_kustomize_documents_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"testing"
)

var kustTargetUrl = "https://github.com/kubernetes-sigs/kustomize/examples/multibases?ref=v1.0.6"
var kustTargetUrl = "https://github.com/kubernetes-sigs/kustomize/examples/multibases?ref=v3.3.1"

func TestAccKubectlDataSourceKustomizeDocuments_url(t *testing.T) {
resource.Test(t, resource.TestCase{
Expand All @@ -28,7 +28,73 @@ func TestAccKubectlDataSourceKustomizeDocuments_localDir(t *testing.T) {
Steps: []resource.TestStep{
{
Config: kubectlKustomizeDocumentsConfig("../test/data/kustomize/helloWorld"),
Check: resource.TestCheckResourceAttr("data.kubectl_kustomize_documents.test", "documents.#", "3"),
Check: resource.ComposeAggregateTestCheckFunc(
resource.TestCheckResourceAttr("data.kubectl_kustomize_documents.test", "documents.#", "3"),
resource.TestCheckResourceAttr("data.kubectl_kustomize_documents.test", "documents.0", `apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app: hello
name: the-deployment
spec:
replicas: 3
selector:
matchLabels:
app: hello
template:
metadata:
labels:
app: hello
deployment: hello
spec:
containers:
- command:
- /hello
- --port=8080
- --enableRiskyFeature=$(ENABLE_RISKY)
env:
- name: ALT_GREETING
valueFrom:
configMapKeyRef:
key: altGreeting
name: the-map
- name: ENABLE_RISKY
valueFrom:
configMapKeyRef:
key: enableRisky
name: the-map
image: monopole/hello:1
name: the-container
ports:
- containerPort: 8080
`),
resource.TestCheckResourceAttr("data.kubectl_kustomize_documents.test", "documents.1", `apiVersion: v1
kind: Service
metadata:
labels:
app: hello
name: the-service
spec:
ports:
- port: 8666
protocol: TCP
targetPort: 8080
selector:
app: hello
deployment: hello
type: LoadBalancer
`),
resource.TestCheckResourceAttr("data.kubectl_kustomize_documents.test", "documents.2", `apiVersion: v1
data:
altGreeting: Good Morning!
enableRisky: "false"
kind: ConfigMap
metadata:
labels:
app: hello
name: the-map
`),
),
},
},
})
Expand Down
9 changes: 7 additions & 2 deletions test/data/kustomize/helloWorld/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
# Example configuration for the webserver
# at https://github.com/monopole/hello
commonLabels:
app: hello

apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
labels:
- includeSelectors: true
pairs:
app: hello

resources:
- deployment.yaml
Expand Down

0 comments on commit 03bde77

Please sign in to comment.