-
Notifications
You must be signed in to change notification settings - Fork 174
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
## Description Add a `--why` flag for `zarf dev find-images` ## Related Issue Fixes #2272 ## Type of change - [ ] Bug fix (non-breaking change which fixes an issue) - [x] New feature (non-breaking change which adds functionality) - [ ] Other (security config, docs update, etc) ## Checklist before merging - [x] Test, docs, adr added or updated as needed - [x] [Contributor Guide Steps](https://github.com/defenseunicorns/zarf/blob/main/CONTRIBUTING.md#developer-workflow) followed --------- Signed-off-by: Vibhav Bobade <[email protected]> Co-authored-by: Wayne Starr <[email protected]> Co-authored-by: Lucas Rodriguez <[email protected]> Co-authored-by: Lucas Rodriguez <[email protected]>
- Loading branch information
1 parent
21ccaaa
commit 5efcb35
Showing
9 changed files
with
322 additions
and
0 deletions.
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,50 @@ | ||
package test | ||
|
||
import ( | ||
"os" | ||
"path/filepath" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
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, err := os.ReadFile("src/test/packages/13-find-images/dos-games-find-images-expected.txt") | ||
require.NoError(t, err) | ||
|
||
stdout, _, err := e2e.Zarf("dev", "find-images", testPackagePath) | ||
require.NoError(t, err) | ||
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", "wordpress") | ||
expectedOutput, err := os.ReadFile("src/test/packages/13-find-images/helm-charts-find-images-why-expected.txt") | ||
require.NoError(t, err) | ||
|
||
stdout, _, err := e2e.Zarf("dev", "find-images", testPackagePath, "--why", "docker.io/bitnami/apache-exporter:0.13.3-debian-11-r2") | ||
require.NoError(t, err) | ||
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 manifests with why flag") | ||
|
||
testPackagePath := filepath.Join("examples", "manifests") | ||
expectedOutput, err := os.ReadFile("src/test/packages/13-find-images/manifests-find-images-why-expected.txt") | ||
require.NoError(t, err) | ||
|
||
stdout, _, err := e2e.Zarf("dev", "find-images", testPackagePath, "--why", "httpd:alpine3.18") | ||
require.NoError(t, err) | ||
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 |
187 changes: 187 additions & 0 deletions
187
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,187 @@ | ||
component: wordpress | ||
chart: wordpress | ||
resource: | ||
|
||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
labels: | ||
app.kubernetes.io/instance: wordpress | ||
app.kubernetes.io/managed-by: Helm | ||
app.kubernetes.io/name: wordpress | ||
helm.sh/chart: wordpress-16.0.4 | ||
name: wordpress | ||
namespace: wordpress | ||
spec: | ||
replicas: 1 | ||
selector: | ||
matchLabels: | ||
app.kubernetes.io/instance: wordpress | ||
app.kubernetes.io/name: wordpress | ||
strategy: | ||
type: RollingUpdate | ||
template: | ||
metadata: | ||
annotations: null | ||
labels: | ||
app.kubernetes.io/instance: wordpress | ||
app.kubernetes.io/managed-by: Helm | ||
app.kubernetes.io/name: wordpress | ||
helm.sh/chart: wordpress-16.0.4 | ||
spec: | ||
affinity: | ||
nodeAffinity: null | ||
podAffinity: null | ||
podAntiAffinity: | ||
preferredDuringSchedulingIgnoredDuringExecution: | ||
- podAffinityTerm: | ||
labelSelector: | ||
matchLabels: | ||
app.kubernetes.io/instance: wordpress | ||
app.kubernetes.io/name: wordpress | ||
topologyKey: kubernetes.io/hostname | ||
weight: 1 | ||
containers: | ||
- env: | ||
- name: BITNAMI_DEBUG | ||
value: "false" | ||
- name: ALLOW_EMPTY_PASSWORD | ||
value: "yes" | ||
- name: MARIADB_HOST | ||
value: wordpress-mariadb | ||
- name: MARIADB_PORT_NUMBER | ||
value: "3306" | ||
- name: WORDPRESS_DATABASE_NAME | ||
value: bitnami_wordpress | ||
- name: WORDPRESS_DATABASE_USER | ||
value: bn_wordpress | ||
- name: WORDPRESS_DATABASE_PASSWORD | ||
valueFrom: | ||
secretKeyRef: | ||
key: mariadb-password | ||
name: wordpress-mariadb | ||
- name: WORDPRESS_USERNAME | ||
value: null | ||
- name: WORDPRESS_PASSWORD | ||
valueFrom: | ||
secretKeyRef: | ||
key: wordpress-password | ||
name: wordpress | ||
- name: WORDPRESS_EMAIL | ||
value: null | ||
- name: WORDPRESS_FIRST_NAME | ||
value: null | ||
- name: WORDPRESS_LAST_NAME | ||
value: null | ||
- name: WORDPRESS_HTACCESS_OVERRIDE_NONE | ||
value: "no" | ||
- name: WORDPRESS_ENABLE_HTACCESS_PERSISTENCE | ||
value: "no" | ||
- name: WORDPRESS_BLOG_NAME | ||
value: null | ||
- name: WORDPRESS_SKIP_BOOTSTRAP | ||
value: "no" | ||
- name: WORDPRESS_TABLE_PREFIX | ||
value: wp_ | ||
- name: WORDPRESS_SCHEME | ||
value: http | ||
- name: WORDPRESS_EXTRA_WP_CONFIG_CONTENT | ||
value: "" | ||
- name: WORDPRESS_PLUGINS | ||
value: none | ||
- name: APACHE_HTTP_PORT_NUMBER | ||
value: "8080" | ||
- name: APACHE_HTTPS_PORT_NUMBER | ||
value: "8443" | ||
envFrom: null | ||
image: docker.io/bitnami/wordpress:6.2.0-debian-11-r18 | ||
imagePullPolicy: IfNotPresent | ||
livenessProbe: | ||
failureThreshold: 6 | ||
httpGet: | ||
httpHeaders: [] | ||
path: /wp-admin/install.php | ||
port: http | ||
scheme: HTTP | ||
initialDelaySeconds: 120 | ||
periodSeconds: 10 | ||
successThreshold: 1 | ||
timeoutSeconds: 5 | ||
name: wordpress | ||
ports: | ||
- containerPort: 8080 | ||
name: http | ||
- containerPort: 8443 | ||
name: https | ||
readinessProbe: | ||
failureThreshold: 6 | ||
httpGet: | ||
httpHeaders: [] | ||
path: /wp-login.php | ||
port: http | ||
scheme: HTTP | ||
initialDelaySeconds: 30 | ||
periodSeconds: 10 | ||
successThreshold: 1 | ||
timeoutSeconds: 5 | ||
resources: | ||
limits: {} | ||
requests: | ||
cpu: 300m | ||
memory: 512Mi | ||
securityContext: | ||
allowPrivilegeEscalation: false | ||
capabilities: | ||
drop: | ||
- ALL | ||
runAsNonRoot: true | ||
runAsUser: 1001 | ||
volumeMounts: | ||
- mountPath: /bitnami/wordpress | ||
name: wordpress-data | ||
subPath: wordpress | ||
- command: | ||
- /bin/apache_exporter | ||
- --scrape_uri | ||
- http://status.localhost:8080/server-status/?auto | ||
image: docker.io/bitnami/apache-exporter:0.13.3-debian-11-r2 | ||
imagePullPolicy: IfNotPresent | ||
livenessProbe: | ||
failureThreshold: 3 | ||
httpGet: | ||
path: /metrics | ||
port: metrics | ||
initialDelaySeconds: 15 | ||
periodSeconds: 10 | ||
successThreshold: 1 | ||
timeoutSeconds: 5 | ||
name: metrics | ||
ports: | ||
- containerPort: 9117 | ||
name: metrics | ||
readinessProbe: | ||
failureThreshold: 3 | ||
httpGet: | ||
path: /metrics | ||
port: metrics | ||
initialDelaySeconds: 5 | ||
periodSeconds: 10 | ||
successThreshold: 1 | ||
timeoutSeconds: 3 | ||
resources: | ||
limits: {} | ||
requests: {} | ||
hostAliases: | ||
- hostnames: | ||
- status.localhost | ||
ip: 127.0.0.1 | ||
securityContext: | ||
fsGroup: 1001 | ||
seccompProfile: | ||
type: RuntimeDefault | ||
serviceAccountName: default | ||
volumes: | ||
- name: wordpress-data | ||
persistentVolumeClaim: | ||
claimName: wordpress | ||
|
24 changes: 24 additions & 0 deletions
24
src/test/packages/13-find-images/manifests-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,24 @@ | ||
component: httpd-local | ||
manifest: simple-httpd-deployment | ||
resource: | ||
|
||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: httpd-deployment | ||
spec: | ||
replicas: 2 | ||
selector: | ||
matchLabels: | ||
app: httpd | ||
template: | ||
metadata: | ||
labels: | ||
app: httpd | ||
spec: | ||
containers: | ||
- image: httpd:alpine3.18 | ||
name: httpd | ||
ports: | ||
- containerPort: 80 | ||
|
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