-
Notifications
You must be signed in to change notification settings - Fork 171
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add --why for zarf dev find-images
Add --why flag to `zarf dev find-images` which takes a image tag as an argument. This command with the `why` flag will output the component, manifest/chart name and the yaml which matches the given image. Signed-off-by: Vibhav Bobade <vibhav.bobde@gmail.com>
- Loading branch information
1 parent
84b673e
commit 279f24d
Showing
9 changed files
with
339 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
package test | ||
|
||
import ( | ||
"github.com/stretchr/testify/require" | ||
"os" | ||
"path/filepath" | ||
"testing" | ||
) | ||
|
||
func TestFindImages(t *testing.T) { | ||
t.Log("E2E: Find Images") | ||
|
||
//t.Run("zarf test find images success", func(t *testing.T) { | ||
// t.Log("E2E: Test Find Images") | ||
// | ||
// testPackagePath := filepath.Join("examples", "dos-games") | ||
// expectedOutput := []byte{} | ||
// f, err := os.Open("src/test/packages/13-find-images/dos-games-find-images-expected.txt") | ||
// defer f.Close() | ||
// | ||
// _, err = f.Read(expectedOutput) | ||
// require.NoError(t, err, "Expect no error here while reading expectedOutput of the expected output file") | ||
// | ||
// stdout, _, err := e2e.Zarf("dev", "find-images", testPackagePath) | ||
// require.NoError(t, err, "Expect no error here") | ||
// require.Contains(t, stdout, string(expectedOutput)) | ||
//}) | ||
|
||
t.Run("zarf test find images --why w/ helm chart success", func(t *testing.T) { | ||
t.Log("E2E: Test Find Images against a helm chart with why flag") | ||
|
||
testPackagePath := filepath.Join("examples", "helm-charts") | ||
expectedOutput := []byte{} | ||
f, err := os.Open("src/test/packages/13-find-images/helm-charts-find-images-why-expected.txt") | ||
defer f.Close() | ||
|
||
_, err = f.Read(expectedOutput) | ||
require.NoError(t, err, "Expect no error here while reading expectedOutput of the expected output file") | ||
|
||
stdout, _, err := e2e.Zarf("dev", "find-images", testPackagePath, "--why", "curlimages/curl:7.69.0") | ||
require.NoError(t, err, "Expect no error here") | ||
require.Contains(t, stdout, string(expectedOutput)) | ||
}) | ||
|
||
t.Run("zarf test find images --why w/ manifests success", func(t *testing.T) { | ||
t.Log("E2E: Test Find Images against a helm chart with why flag") | ||
|
||
testPackagePath := filepath.Join("examples", "manifests") | ||
expectedOutput := []byte{} | ||
f, err := os.Open("src/test/packages/13-find-images/manifests-find-images-why-expected.txt") | ||
defer f.Close() | ||
|
||
_, err = f.Read(expectedOutput) | ||
require.NoError(t, err, "Expect no error here while reading expectedOutput of the expected output file") | ||
|
||
stdout, _, err := e2e.Zarf("dev", "find-images", testPackagePath, "--why", "httpd:alpine3.18") | ||
require.NoError(t, err, "Expect no error here") | ||
require.Contains(t, stdout, string(expectedOutput)) | ||
}) | ||
|
||
} |
7 changes: 7 additions & 0 deletions
7
src/test/packages/13-find-images/dos-games-find-images-expected.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
components: | ||
|
||
- name: baseline | ||
images: | ||
- defenseunicorns/zarf-game:multi-tile-dark | ||
# Cosign artifacts for images - dos-games - baseline | ||
- index.docker.io/defenseunicorns/zarf-game:sha256-0b694ca1c33afae97b7471488e07968599f1d2470c629f76af67145ca64428af.sig |
197 changes: 197 additions & 0 deletions
197
src/test/packages/13-find-images/helm-charts-find-images-why-expected.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,197 @@ | ||
component: demo-helm-charts | ||
chart: podinfo-oci | ||
resource: podinfo-oci-service-test-wlxqz | ||
|
||
apiVersion: v1 | ||
kind: Pod | ||
metadata: | ||
annotations: | ||
appmesh.k8s.aws/sidecarInjectorWebhook: disabled | ||
helm.sh/hook: test-success | ||
helm.sh/hook-delete-policy: before-hook-creation,hook-succeeded | ||
linkerd.io/inject: disabled | ||
sidecar.istio.io/inject: "false" | ||
labels: | ||
app.kubernetes.io/managed-by: Helm | ||
app.kubernetes.io/name: podinfo-oci | ||
app.kubernetes.io/version: 6.4.0 | ||
helm.sh/chart: podinfo-6.4.0 | ||
name: podinfo-oci-service-test-wlxqz | ||
spec: | ||
containers: | ||
- command: | ||
- sh | ||
- -c | ||
- | | ||
curl -s ${PODINFO_SVC}/api/info | grep version | ||
env: | ||
- name: PODINFO_SVC | ||
value: podinfo-oci.podinfo-from-oci:9898 | ||
image: curlimages/curl:7.69.0 | ||
name: curl | ||
restartPolicy: Never | ||
|
||
component: demo-helm-charts | ||
chart: podinfo-git | ||
resource: podinfo-oci-service-test-wlxqz | ||
|
||
apiVersion: v1 | ||
kind: Pod | ||
metadata: | ||
annotations: | ||
appmesh.k8s.aws/sidecarInjectorWebhook: disabled | ||
helm.sh/hook: test-success | ||
helm.sh/hook-delete-policy: before-hook-creation,hook-succeeded | ||
linkerd.io/inject: disabled | ||
sidecar.istio.io/inject: "false" | ||
labels: | ||
app.kubernetes.io/managed-by: Helm | ||
app.kubernetes.io/name: podinfo-oci | ||
app.kubernetes.io/version: 6.4.0 | ||
helm.sh/chart: podinfo-6.4.0 | ||
name: podinfo-oci-service-test-wlxqz | ||
spec: | ||
containers: | ||
- command: | ||
- sh | ||
- -c | ||
- | | ||
curl -s ${PODINFO_SVC}/api/info | grep version | ||
env: | ||
- name: PODINFO_SVC | ||
value: podinfo-oci.podinfo-from-oci:9898 | ||
image: curlimages/curl:7.69.0 | ||
name: curl | ||
restartPolicy: Never | ||
|
||
component: demo-helm-charts | ||
chart: podinfo-git | ||
resource: podinfo-git-service-test-gtb1y | ||
|
||
apiVersion: v1 | ||
kind: Pod | ||
metadata: | ||
annotations: | ||
appmesh.k8s.aws/sidecarInjectorWebhook: disabled | ||
helm.sh/hook: test-success | ||
helm.sh/hook-delete-policy: before-hook-creation,hook-succeeded | ||
linkerd.io/inject: disabled | ||
sidecar.istio.io/inject: "false" | ||
labels: | ||
app.kubernetes.io/managed-by: Helm | ||
app.kubernetes.io/name: podinfo-git | ||
app.kubernetes.io/version: 6.4.0 | ||
helm.sh/chart: podinfo-6.4.0 | ||
name: podinfo-git-service-test-gtb1y | ||
spec: | ||
containers: | ||
- command: | ||
- sh | ||
- -c | ||
- | | ||
curl -s ${PODINFO_SVC}/api/info | grep version | ||
env: | ||
- name: PODINFO_SVC | ||
value: podinfo-git.podinfo-from-git:9898 | ||
image: curlimages/curl:7.69.0 | ||
name: curl | ||
restartPolicy: Never | ||
|
||
component: demo-helm-charts | ||
chart: podinfo-repo | ||
resource: podinfo-oci-service-test-wlxqz | ||
|
||
apiVersion: v1 | ||
kind: Pod | ||
metadata: | ||
annotations: | ||
appmesh.k8s.aws/sidecarInjectorWebhook: disabled | ||
helm.sh/hook: test-success | ||
helm.sh/hook-delete-policy: before-hook-creation,hook-succeeded | ||
linkerd.io/inject: disabled | ||
sidecar.istio.io/inject: "false" | ||
labels: | ||
app.kubernetes.io/managed-by: Helm | ||
app.kubernetes.io/name: podinfo-oci | ||
app.kubernetes.io/version: 6.4.0 | ||
helm.sh/chart: podinfo-6.4.0 | ||
name: podinfo-oci-service-test-wlxqz | ||
spec: | ||
containers: | ||
- command: | ||
- sh | ||
- -c | ||
- | | ||
curl -s ${PODINFO_SVC}/api/info | grep version | ||
env: | ||
- name: PODINFO_SVC | ||
value: podinfo-oci.podinfo-from-oci:9898 | ||
image: curlimages/curl:7.69.0 | ||
name: curl | ||
restartPolicy: Never | ||
|
||
component: demo-helm-charts | ||
chart: podinfo-repo | ||
resource: podinfo-git-service-test-gtb1y | ||
|
||
apiVersion: v1 | ||
kind: Pod | ||
metadata: | ||
annotations: | ||
appmesh.k8s.aws/sidecarInjectorWebhook: disabled | ||
helm.sh/hook: test-success | ||
helm.sh/hook-delete-policy: before-hook-creation,hook-succeeded | ||
linkerd.io/inject: disabled | ||
sidecar.istio.io/inject: "false" | ||
labels: | ||
app.kubernetes.io/managed-by: Helm | ||
app.kubernetes.io/name: podinfo-git | ||
app.kubernetes.io/version: 6.4.0 | ||
helm.sh/chart: podinfo-6.4.0 | ||
name: podinfo-git-service-test-gtb1y | ||
spec: | ||
containers: | ||
- command: | ||
- sh | ||
- -c | ||
- | | ||
curl -s ${PODINFO_SVC}/api/info | grep version | ||
env: | ||
- name: PODINFO_SVC | ||
value: podinfo-git.podinfo-from-git:9898 | ||
image: curlimages/curl:7.69.0 | ||
name: curl | ||
restartPolicy: Never | ||
|
||
component: demo-helm-charts | ||
chart: podinfo-repo | ||
resource: cool-release-name-podinfo-service-test-aabrx | ||
|
||
apiVersion: v1 | ||
kind: Pod | ||
metadata: | ||
annotations: | ||
appmesh.k8s.aws/sidecarInjectorWebhook: disabled | ||
helm.sh/hook: test-success | ||
helm.sh/hook-delete-policy: before-hook-creation,hook-succeeded | ||
linkerd.io/inject: disabled | ||
sidecar.istio.io/inject: "false" | ||
labels: | ||
app.kubernetes.io/managed-by: Helm | ||
app.kubernetes.io/name: cool-release-name-podinfo | ||
app.kubernetes.io/version: 6.4.0 | ||
helm.sh/chart: podinfo-6.4.0 | ||
name: cool-release-name-podinfo-service-test-aabrx | ||
spec: | ||
containers: | ||
- command: | ||
- sh | ||
- -c | ||
- | | ||
curl -s ${PODINFO_SVC}/api/info | grep version | ||
env: | ||
- name: PODINFO_SVC | ||
value: cool-release-name-podinfo.podinfo-from-repo:9898 | ||
image: curlimages/curl:7.69.0 | ||
name: curl | ||
restartPolicy: Never |
Oops, something went wrong.