Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expand kustomize test coverage and update for later kustomize format #328

Merged
merged 1 commit into from
Dec 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading