Skip to content

Commit 5a3d22b

Browse files
author
Mengqi Yu
authored
add e2e test for distroless image (#3078)
1 parent 9902281 commit 5a3d22b

File tree

1 file changed

+77
-0
lines changed

1 file changed

+77
-0
lines changed

porch/test/e2e/e2e_test.go

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -958,6 +958,83 @@ for resource in ctx.resource_list["items"]:
958958
}
959959
}
960960

961+
func (t *PorchSuite) TestPodFunctionEvaluatorWithDistrolessImage(ctx context.Context) {
962+
t.registerMainGitRepositoryF(ctx, "git-fn-distroless")
963+
964+
// Create Package Revision
965+
pr := &porchapi.PackageRevision{
966+
ObjectMeta: metav1.ObjectMeta{
967+
Namespace: t.namespace,
968+
},
969+
Spec: porchapi.PackageRevisionSpec{
970+
PackageName: "test-fn-redis-bucket",
971+
Revision: "v1",
972+
RepositoryName: "git-fn-distroless",
973+
Tasks: []porchapi.Task{
974+
{
975+
Type: "clone",
976+
Clone: &porchapi.PackageCloneTaskSpec{
977+
Upstream: porchapi.UpstreamPackage{
978+
Type: "git",
979+
Git: &porchapi.GitPackage{
980+
Repo: "https://github.com/GoogleCloudPlatform/blueprints.git",
981+
Ref: "redis-bucket-blueprint-v0.3.2",
982+
Directory: "catalog/redis-bucket",
983+
},
984+
},
985+
},
986+
},
987+
{
988+
Type: "patch",
989+
Patch: &porchapi.PackagePatchTaskSpec{
990+
Patches: []porchapi.PatchSpec{
991+
{
992+
File: "configmap.yaml",
993+
Contents: `apiVersion: v1
994+
kind: ConfigMap
995+
metadata:
996+
name: kptfile.kpt.dev
997+
data:
998+
name: bucket-namespace
999+
`,
1000+
PatchType: porchapi.PatchTypeCreateFile,
1001+
},
1002+
},
1003+
},
1004+
},
1005+
{
1006+
Type: "eval",
1007+
Eval: &porchapi.FunctionEvalTaskSpec{
1008+
// This image is a mirror of gcr.io/cad-demo-sdk/set-namespace@sha256:462e44020221e72e3eb337ee59bc4bc3e5cb50b5ed69d377f55e05bec3a93d11
1009+
// which uses gcr.io/distroless/base-debian11:latest as the base image.
1010+
Image: "gcr.io/kpt-fn-demo/set-namespace:v0.1.0",
1011+
},
1012+
},
1013+
},
1014+
},
1015+
}
1016+
t.CreateF(ctx, pr)
1017+
1018+
// Get package resources
1019+
var resources porchapi.PackageRevisionResources
1020+
t.GetF(ctx, client.ObjectKey{
1021+
Namespace: t.namespace,
1022+
Name: pr.Name,
1023+
}, &resources)
1024+
1025+
bucket, ok := resources.Spec.Resources["bucket.yaml"]
1026+
if !ok {
1027+
t.Errorf("'bucket.yaml' not found among package resources")
1028+
}
1029+
node, err := yaml.Parse(bucket)
1030+
if err != nil {
1031+
t.Errorf("yaml.Parse(\"bucket.yaml\") failed: %v", err)
1032+
}
1033+
if got, want := node.GetNamespace(), "bucket-namespace"; got != want {
1034+
t.Errorf("StorageBucket namespace: got %q, want %q", got, want)
1035+
}
1036+
}
1037+
9611038
func (t *PorchSuite) TestPodEvaluator(ctx context.Context) {
9621039
if t.local {
9631040
t.Skipf("Skipping due to not having pod evalutor in local mode")

0 commit comments

Comments
 (0)