From 3f67e33333ab3487dae0d24b0647d4e310f49955 Mon Sep 17 00:00:00 2001 From: Lorenzo Felletti Date: Sat, 24 Jan 2026 01:36:14 +0000 Subject: [PATCH 1/9] build: allow ldflags to be passed --- .dagger/build_publish.go | 8 ++++++-- .dagger/main.go | 32 ++++++++------------------------ .dagger/testing_pipelines.go | 8 +++++--- semver | 2 +- 4 files changed, 20 insertions(+), 30 deletions(-) diff --git a/.dagger/build_publish.go b/.dagger/build_publish.go index 1652e34..f263e49 100644 --- a/.dagger/build_publish.go +++ b/.dagger/build_publish.go @@ -11,6 +11,8 @@ func (m *Cuestomize) Build( buildContext *dagger.Directory, // +default="" platform string, + // +default="" + ldflags string, ) (*dagger.Container, error) { containerOpts := dagger.ContainerOpts{} if platform != "" { @@ -18,7 +20,7 @@ func (m *Cuestomize) Build( } // Build stage: compile the Go binary - builder := cuestomizeBuilderContainer(buildContext, containerOpts) + builder := cuestomizeBuilderContainer(buildContext, ldflags, containerOpts) // Final stage: create the runtime container with distroless container := dag.Container(containerOpts). @@ -39,6 +41,8 @@ func (m *Cuestomize) BuildAndPublish( // +default="ghcr.io" registry string, repository string, + // +default="-s -w" + ldflags string, tag string, // +default=false alsoTagAsLatest bool, @@ -69,7 +73,7 @@ func (m *Cuestomize) BuildAndPublish( platformVariants := make([]*dagger.Container, 0, len(platforms)) for _, platform := range platforms { - container, err := m.Build(ctx, buildContext, string(platform)) + container, err := m.Build(ctx, buildContext, string(platform), ldflags) if err != nil { return err } diff --git a/.dagger/main.go b/.dagger/main.go index 4a12cb5..30bcb6c 100644 --- a/.dagger/main.go +++ b/.dagger/main.go @@ -3,33 +3,11 @@ package main import ( - "context" "dagger/cuestomize/internal/dagger" - "strings" ) type Cuestomize struct{} -func (m *Cuestomize) CuestomizeVersion( - ctx context.Context, - // +defaultPath=./ - src *dagger.Directory, - // +default=version - filePath string, -) error { - version, err := cuestomizeBuilderContainer(src). - WithExec([]string{"/workspace/cuestomize", "--version"}).Stdout(ctx) - if err != nil { - return err - } - - version = strings.Trim(version, "\n ") - version = "diomaialw" - - _, err = dag.File("version", version).Export(ctx, filePath) - return err -} - // repoBaseContainer creates a container with the repository files in it and go dependencies installed. // The working directory is set to `/workspace` and contains the root of the repository. func repoBaseContainer(buildContext *dagger.Directory, excludedOpts *dagger.ContainerWithDirectoryOpts, containerOpts ...dagger.ContainerOpts) *dagger.Container { @@ -51,9 +29,15 @@ func repoBaseContainer(buildContext *dagger.Directory, excludedOpts *dagger.Cont } // cuestomizeBuilderContainer returns a container that can be used to build the cuestomize binary. -func cuestomizeBuilderContainer(buildContext *dagger.Directory, containerOpts ...dagger.ContainerOpts) *dagger.Container { +func cuestomizeBuilderContainer(buildContext *dagger.Directory, ldflags string, containerOpts ...dagger.ContainerOpts) *dagger.Container { + buildCmd := []string{"go", "build", "-o", "cuestomize"} + if ldflags != "" { + buildCmd = append(buildCmd, "-ldflags", ldflags) + } + buildCmd = append(buildCmd, "main.go") + return repoBaseContainer(buildContext, nil, containerOpts...). WithEnvVariable("CGO_ENABLED", "0"). WithEnvVariable("GO111MODULE", "on"). - WithExec([]string{"go", "build", "-o", "cuestomize", "main.go"}) + WithExec(buildCmd) } diff --git a/.dagger/testing_pipelines.go b/.dagger/testing_pipelines.go index 8952951..f1a16cf 100644 --- a/.dagger/testing_pipelines.go +++ b/.dagger/testing_pipelines.go @@ -40,7 +40,7 @@ func (m *Cuestomize) E2E_Test( buildContext *dagger.Directory, ) error { // build cuestomize - cuestomize, err := cuestomizeBuilderContainer(buildContext).Sync(ctx) + cuestomize, err := cuestomizeBuilderContainer(buildContext, "").Sync(ctx) if err != nil { return fmt.Errorf("failed to build cuestomize: %w", err) } @@ -83,11 +83,13 @@ func (m *Cuestomize) E2E_Test( "/testdata/kustomize-auth/.env.secret", fmt.Sprintf(e2eCredSecretContentFmt, username, password), ) - if _, err := kustomize.WithExec([]string{"kustomize", "build", "--enable-alpha-plugins", "--network", "--enable-exec", "/testdata/kustomize"}).Sync(ctx); err != nil { + if _, err := kustomize.WithExec([]string{"kustomize", "build", "--enable-alpha-plugins", "--network", "/testdata/kustomize"}).Sync(ctx); err != nil { return fmt.Errorf("kustomize with no auth e2e failed: %w", err) } - if _, err := kustomize.WithExec([]string{"kustomize", "build", "--enable-alpha-plugins", "--network", "--enable-exec", "/testdata/kustomize-auth"}).Sync(ctx); err != nil { + kustomize = kustomize.WithoutDirectory("/cue-resources").WithDirectory("/cue-resources", dag.Directory()) + + if _, err := kustomize.WithExec([]string{"kustomize", "build", "--enable-alpha-plugins", "--network", "/testdata/kustomize-auth"}).Sync(ctx); err != nil { return fmt.Errorf("kustomize with auth e2e failed: %w", err) } diff --git a/semver b/semver index 9fc80f9..87a0871 100644 --- a/semver +++ b/semver @@ -1 +1 @@ -0.3.2 \ No newline at end of file +0.3.3 \ No newline at end of file From 28d0d59df73a9c2b07d8c479c20a0d1482d6e43c Mon Sep 17 00:00:00 2001 From: Lorenzo Felletti Date: Sat, 24 Jan 2026 01:38:34 +0000 Subject: [PATCH 2/9] ci: use ldflags -w -s on PR merge --- .github/workflows/ci-merge.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci-merge.yaml b/.github/workflows/ci-merge.yaml index 7726488..a5c4ae3 100644 --- a/.github/workflows/ci-merge.yaml +++ b/.github/workflows/ci-merge.yaml @@ -19,7 +19,7 @@ jobs: with: version: "0.19.10" verb: call - args: build + args: build --ldflags="-s -w" test: name: Test From 8813882ce1bd492c2e97e351022307b278a5e9f4 Mon Sep 17 00:00:00 2001 From: Lorenzo Felletti Date: Sat, 24 Jan 2026 20:12:02 +0000 Subject: [PATCH 3/9] wip --- .dagger/testing_pipelines.go | 32 +++++++++++++++++++- e2e/testdata/kustomize-auth/krm-func.yaml | 9 +++--- examples/simple/kustomize/krm-func.yaml | 2 ++ examples/simple/kustomize/kustomization.yaml | 19 ++++++++++-- 4 files changed, 54 insertions(+), 8 deletions(-) diff --git a/.dagger/testing_pipelines.go b/.dagger/testing_pipelines.go index f1a16cf..23d84fd 100644 --- a/.dagger/testing_pipelines.go +++ b/.dagger/testing_pipelines.go @@ -38,6 +38,7 @@ func (m *Cuestomize) E2E_Test( ctx context.Context, // +defaultPath=./ buildContext *dagger.Directory, + // sock *dagger.Socket, ) error { // build cuestomize cuestomize, err := cuestomizeBuilderContainer(buildContext, "").Sync(ctx) @@ -55,6 +56,14 @@ func (m *Cuestomize) E2E_Test( } defer registryService.Stop(ctx) + _, err = dag.Container().WithServiceBinding("registry", registryService). + Publish(ctx, "registry:5000/cuestomize:latest", dagger.ContainerPublishOpts{ + PlatformVariants: []*dagger.Container{cuestomize}, + }) + if err != nil { + return fmt.Errorf("failed to publish cuestomize to registry: %w", err) + } + // setup registryWithAuth with authentication username := "registryuser" password := "password" @@ -71,18 +80,24 @@ func (m *Cuestomize) E2E_Test( return fmt.Errorf("failed to run e2e tests: %w", err) } + dockerCli := dag.Container().From("docker:cli") + // run e2e tests // TODO: save output to file and extract it for comparison kustomize := dag.Container().From(KustomizeImage). WithServiceBinding("registry", registryService). WithServiceBinding("registry_auth", registryWithAuthService). + WithServiceBinding("docker-host", m.dind()). + // WithUnixSocket("unix:///var/run/docker.sock", sock). + WithEnvVariable("DOCKER_HOST", "tcp://docker-host:2375"). WithDirectory("/testdata", testdataDir). WithFile("/bin/cuestomize", cuestomizeBinary). + WithFile("/usr/local/bin/docker", dockerCli.File("/usr/local/bin/docker")). WithDirectory("/cue-resources", dag.Directory()). WithNewFile( "/testdata/kustomize-auth/.env.secret", fmt.Sprintf(e2eCredSecretContentFmt, username, password), - ) + ).WithExec([]string{"docker", "image", "ls"}) if _, err := kustomize.WithExec([]string{"kustomize", "build", "--enable-alpha-plugins", "--network", "/testdata/kustomize"}).Sync(ctx); err != nil { return fmt.Errorf("kustomize with no auth e2e failed: %w", err) } @@ -145,6 +160,21 @@ func setupRegistryServiceWithAuth(ctx context.Context, username, password string return registryWithAuth.AsService().Start(ctx) } +func (m *Cuestomize) dind() *dagger.Service { + return dag.Container(). + From("docker:dind"). + WithEnvVariable("TINI_SUBREAPER", "true"). + WithMountedCache("/var/lib/docker", dag.CacheVolume("dind-data")). + WithExposedPort(2375).AsService(dagger.ContainerAsServiceOpts{ + Args: []string{ + "dockerd", "--tls=false", "--host=tcp://0.0.0.0:2375", + }, + InsecureRootCapabilities: true, + UseEntrypoint: true, + }) + +} + // testContainerWithRegistryServices returns a repoBaseContainer with registry and registry_auth services bound. func testContainerWithRegistryServices(buildContext *dagger.Directory, registryService, registryWithAuthService *dagger.Service, username, password string) *dagger.Container { return repoBaseContainer(buildContext, nil). diff --git a/e2e/testdata/kustomize-auth/krm-func.yaml b/e2e/testdata/kustomize-auth/krm-func.yaml index 6e322c2..8cc3424 100644 --- a/e2e/testdata/kustomize-auth/krm-func.yaml +++ b/e2e/testdata/kustomize-auth/krm-func.yaml @@ -5,8 +5,9 @@ metadata: annotations: config.kubernetes.io/local-config: "true" config.kubernetes.io/function: | - exec: - path: /bin/cuestomize + container: + image: registry:5000/cuestomize:latest + network: true input: configMapName: example-configmap includes: @@ -20,9 +21,7 @@ includes: name: example-service namespace: example-namespace remoteModule: - registry: registry_auth:5000 - repo: sample-module - tag: latest + ref: registry_auth:5000/sample-module:latest auth: kind: Secret name: regcred diff --git a/examples/simple/kustomize/krm-func.yaml b/examples/simple/kustomize/krm-func.yaml index b19c7dd..0371287 100644 --- a/examples/simple/kustomize/krm-func.yaml +++ b/examples/simple/kustomize/krm-func.yaml @@ -21,6 +21,8 @@ includes: name: example-service namespace: example-namespace remoteModule: + # ref: ghcr.io/workday/cuestomize/cuemodules/cuestomize-examples-simple:latest registry: ghcr.io repo: workday/cuestomize/cuemodules/cuestomize-examples-simple tag: latest + plainHTTP: true diff --git a/examples/simple/kustomize/kustomization.yaml b/examples/simple/kustomize/kustomization.yaml index eaccef4..986f538 100644 --- a/examples/simple/kustomize/kustomization.yaml +++ b/examples/simple/kustomize/kustomization.yaml @@ -7,5 +7,20 @@ resources: namespace: example-namespace -transformers: -- krm-func.yaml +# transformers: +# - krm-func.yaml + +functions: +- type: transformer + spec: + container: + image: myimage:latest #ghcr.io/workday/cuestomize:0.3.0 + network: true + path: krm-func.yaml + +# functions: +# - type: transformer +# spec: +# image: ghcr.io/workday/cuestomize:latest +# network: true +# path: krm-func.yaml From a08e4fc866b00713cdcf81957beb7637efab764b Mon Sep 17 00:00:00 2001 From: Lorenzo Felletti Date: Sat, 24 Jan 2026 20:12:10 +0000 Subject: [PATCH 4/9] wip --- .dagger/testing_pipelines.go | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/.dagger/testing_pipelines.go b/.dagger/testing_pipelines.go index 23d84fd..8a7e873 100644 --- a/.dagger/testing_pipelines.go +++ b/.dagger/testing_pipelines.go @@ -47,6 +47,8 @@ func (m *Cuestomize) E2E_Test( } cuestomizeBinary := cuestomize.File("/workspace/cuestomize") + cuestomizeTar := cuestomize.AsTarball() + testdataDir := buildContext.Directory("e2e/testdata") // setup registryNoAuth without authentication @@ -56,13 +58,13 @@ func (m *Cuestomize) E2E_Test( } defer registryService.Stop(ctx) - _, err = dag.Container().WithServiceBinding("registry", registryService). - Publish(ctx, "registry:5000/cuestomize:latest", dagger.ContainerPublishOpts{ - PlatformVariants: []*dagger.Container{cuestomize}, - }) - if err != nil { - return fmt.Errorf("failed to publish cuestomize to registry: %w", err) - } + // _, err = dag.Container().WithServiceBinding("registry", registryService). + // Publish(ctx, "registry:5000/cuestomize:latest", dagger.ContainerPublishOpts{ + // PlatformVariants: []*dagger.Container{cuestomize}, + // }) + // if err != nil { + // return fmt.Errorf("failed to publish cuestomize to registry: %w", err) + // } // setup registryWithAuth with authentication username := "registryuser" @@ -80,14 +82,26 @@ func (m *Cuestomize) E2E_Test( return fmt.Errorf("failed to run e2e tests: %w", err) } + dindService := m.dind() + dockerCli := dag.Container().From("docker:cli") + // Load the image into DIND and tag it + _, err = dockerCli. + WithServiceBinding("docker-host", dindService). + WithEnvVariable("DOCKER_HOST", "tcp://docker-host:2375"). + WithFile("/tmp/image.tar", cuestomizeTar). + WithExec([]string{"docker", "load", "-i", "/tmp.image.tar"}). + WithExec([]string{"docker", "tag", ref, "ghcr.io/workday/cuestomize:latest"}).Sync(ctx) + if err != nil { + return fmt.Errorf("failed to load cuestomize image into dind: %w", err) + } // run e2e tests // TODO: save output to file and extract it for comparison kustomize := dag.Container().From(KustomizeImage). WithServiceBinding("registry", registryService). WithServiceBinding("registry_auth", registryWithAuthService). - WithServiceBinding("docker-host", m.dind()). + WithServiceBinding("docker-host", dindService). // WithUnixSocket("unix:///var/run/docker.sock", sock). WithEnvVariable("DOCKER_HOST", "tcp://docker-host:2375"). WithDirectory("/testdata", testdataDir). From f78c64068be0a90e243aa65b3bb00db316f69293 Mon Sep 17 00:00:00 2001 From: Lorenzo Felletti Date: Sat, 24 Jan 2026 20:51:46 +0000 Subject: [PATCH 5/9] bit of a mess, but works --- .dagger/build_publish.go | 13 ++++++++ .dagger/testing_pipelines.go | 39 ++++++++++++++++------- e2e/testdata/kustomize-auth/krm-func.yaml | 2 +- 3 files changed, 42 insertions(+), 12 deletions(-) diff --git a/.dagger/build_publish.go b/.dagger/build_publish.go index f263e49..dffa3d5 100644 --- a/.dagger/build_publish.go +++ b/.dagger/build_publish.go @@ -32,6 +32,19 @@ func (m *Cuestomize) Build( return container, nil } +func (m *Cuestomize) Save( + ctx context.Context, + // +defaultPath=./ + buildContext *dagger.Directory, + // +default="" + platform string, + // +default="" + ldflags string) *dagger.File { + container, _ := m.Build(ctx, buildContext, string(platform), ldflags) + + return container.AsTarball() +} + func (m *Cuestomize) BuildAndPublish( ctx context.Context, username string, diff --git a/.dagger/testing_pipelines.go b/.dagger/testing_pipelines.go index 8a7e873..66f9a5e 100644 --- a/.dagger/testing_pipelines.go +++ b/.dagger/testing_pipelines.go @@ -41,11 +41,11 @@ func (m *Cuestomize) E2E_Test( // sock *dagger.Socket, ) error { // build cuestomize - cuestomize, err := cuestomizeBuilderContainer(buildContext, "").Sync(ctx) + cuestomize, err := m.Build(ctx, buildContext, "", "") if err != nil { return fmt.Errorf("failed to build cuestomize: %w", err) } - cuestomizeBinary := cuestomize.File("/workspace/cuestomize") + cuestomizeBinary := cuestomize.File("/usr/local/bin/cuestomize") cuestomizeTar := cuestomize.AsTarball() @@ -82,7 +82,24 @@ func (m *Cuestomize) E2E_Test( return fmt.Errorf("failed to run e2e tests: %w", err) } - dindService := m.dind() + dind := dag.Container(). + From("docker:dind"). + WithEnvVariable("TINI_SUBREAPER", "true"). + WithServiceBinding("registry_auth", registryWithAuthService). + WithMountedCache("/var/lib/docker", dag.CacheVolume("dind-data")). + WithExposedPort(2375).AsService(dagger.ContainerAsServiceOpts{ + Args: []string{ + "dockerd", "--tls=false", "--host=tcp://0.0.0.0:2375", + }, + InsecureRootCapabilities: true, + UseEntrypoint: true, + }) + + dindService, err := dind.Start(ctx) + if err != nil { + return fmt.Errorf("failed to start dind: %w", err) + } + defer dindService.Stop(ctx) dockerCli := dag.Container().From("docker:cli") // Load the image into DIND and tag it @@ -90,8 +107,12 @@ func (m *Cuestomize) E2E_Test( WithServiceBinding("docker-host", dindService). WithEnvVariable("DOCKER_HOST", "tcp://docker-host:2375"). WithFile("/tmp/image.tar", cuestomizeTar). - WithExec([]string{"docker", "load", "-i", "/tmp.image.tar"}). - WithExec([]string{"docker", "tag", ref, "ghcr.io/workday/cuestomize:latest"}).Sync(ctx) + WithExec([]string{"sh", "-c", ` + SOURCE=$(docker load -i /tmp/image.tar -q | cut -d' ' -f 4) + docker tag $SOURCE cuestomize:latest + `}).Sync(ctx) + // WithExec([]string{"docker", "load", "-i", "/tmp.image.tar"}). + // WithExec([]string{"docker", "tag", "", "ghcr.io/workday/cuestomize:latest"}).Sync(ctx) if err != nil { return fmt.Errorf("failed to load cuestomize image into dind: %w", err) } @@ -102,7 +123,6 @@ func (m *Cuestomize) E2E_Test( WithServiceBinding("registry", registryService). WithServiceBinding("registry_auth", registryWithAuthService). WithServiceBinding("docker-host", dindService). - // WithUnixSocket("unix:///var/run/docker.sock", sock). WithEnvVariable("DOCKER_HOST", "tcp://docker-host:2375"). WithDirectory("/testdata", testdataDir). WithFile("/bin/cuestomize", cuestomizeBinary). @@ -111,14 +131,12 @@ func (m *Cuestomize) E2E_Test( WithNewFile( "/testdata/kustomize-auth/.env.secret", fmt.Sprintf(e2eCredSecretContentFmt, username, password), - ).WithExec([]string{"docker", "image", "ls"}) + ) if _, err := kustomize.WithExec([]string{"kustomize", "build", "--enable-alpha-plugins", "--network", "/testdata/kustomize"}).Sync(ctx); err != nil { return fmt.Errorf("kustomize with no auth e2e failed: %w", err) } - kustomize = kustomize.WithoutDirectory("/cue-resources").WithDirectory("/cue-resources", dag.Directory()) - - if _, err := kustomize.WithExec([]string{"kustomize", "build", "--enable-alpha-plugins", "--network", "/testdata/kustomize-auth"}).Sync(ctx); err != nil { + if _, err := kustomize.Terminal().WithExec([]string{"kustomize", "build", "--enable-alpha-plugins", "--network", "/testdata/kustomize-auth"}).Sync(ctx); err != nil { return fmt.Errorf("kustomize with auth e2e failed: %w", err) } @@ -186,7 +204,6 @@ func (m *Cuestomize) dind() *dagger.Service { InsecureRootCapabilities: true, UseEntrypoint: true, }) - } // testContainerWithRegistryServices returns a repoBaseContainer with registry and registry_auth services bound. diff --git a/e2e/testdata/kustomize-auth/krm-func.yaml b/e2e/testdata/kustomize-auth/krm-func.yaml index 8cc3424..498aa4d 100644 --- a/e2e/testdata/kustomize-auth/krm-func.yaml +++ b/e2e/testdata/kustomize-auth/krm-func.yaml @@ -6,7 +6,7 @@ metadata: config.kubernetes.io/local-config: "true" config.kubernetes.io/function: | container: - image: registry:5000/cuestomize:latest + image: cuestomize:latest network: true input: configMapName: example-configmap From 71f007bda2a0e5db0afcb4e9eab25380e42f349b Mon Sep 17 00:00:00 2001 From: Lorenzo Felletti Date: Sat, 24 Jan 2026 21:02:31 +0000 Subject: [PATCH 6/9] chore: remove terminal and commented code --- .dagger/testing_pipelines.go | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.dagger/testing_pipelines.go b/.dagger/testing_pipelines.go index 66f9a5e..4ed05d5 100644 --- a/.dagger/testing_pipelines.go +++ b/.dagger/testing_pipelines.go @@ -111,8 +111,6 @@ func (m *Cuestomize) E2E_Test( SOURCE=$(docker load -i /tmp/image.tar -q | cut -d' ' -f 4) docker tag $SOURCE cuestomize:latest `}).Sync(ctx) - // WithExec([]string{"docker", "load", "-i", "/tmp.image.tar"}). - // WithExec([]string{"docker", "tag", "", "ghcr.io/workday/cuestomize:latest"}).Sync(ctx) if err != nil { return fmt.Errorf("failed to load cuestomize image into dind: %w", err) } @@ -136,7 +134,7 @@ func (m *Cuestomize) E2E_Test( return fmt.Errorf("kustomize with no auth e2e failed: %w", err) } - if _, err := kustomize.Terminal().WithExec([]string{"kustomize", "build", "--enable-alpha-plugins", "--network", "/testdata/kustomize-auth"}).Sync(ctx); err != nil { + if _, err := kustomize.WithExec([]string{"kustomize", "build", "--enable-alpha-plugins", "--network", "/testdata/kustomize-auth"}).Sync(ctx); err != nil { return fmt.Errorf("kustomize with auth e2e failed: %w", err) } From 77b58b81bff3f11c9ac8cb7eefc3c7d756203999 Mon Sep 17 00:00:00 2001 From: Lorenzo Felletti Date: Sat, 24 Jan 2026 21:25:55 +0000 Subject: [PATCH 7/9] minor --- .dagger/build_publish.go | 22 +++------------------- .dagger/constants.go | 2 ++ .dagger/main.go | 11 ++++------- .dagger/testing_pipelines.go | 20 ++------------------ .dagger/toolchain.go | 6 +----- 5 files changed, 12 insertions(+), 49 deletions(-) diff --git a/.dagger/build_publish.go b/.dagger/build_publish.go index dffa3d5..31a7f23 100644 --- a/.dagger/build_publish.go +++ b/.dagger/build_publish.go @@ -13,7 +13,7 @@ func (m *Cuestomize) Build( platform string, // +default="" ldflags string, -) (*dagger.Container, error) { +) *dagger.Container { containerOpts := dagger.ContainerOpts{} if platform != "" { containerOpts.Platform = dagger.Platform(platform) @@ -29,20 +29,7 @@ func (m *Cuestomize) Build( WithFile("/usr/local/bin/cuestomize", builder.File("/workspace/cuestomize")). WithEntrypoint([]string{"/usr/local/bin/cuestomize"}) - return container, nil -} - -func (m *Cuestomize) Save( - ctx context.Context, - // +defaultPath=./ - buildContext *dagger.Directory, - // +default="" - platform string, - // +default="" - ldflags string) *dagger.File { - container, _ := m.Build(ctx, buildContext, string(platform), ldflags) - - return container.AsTarball() + return container } func (m *Cuestomize) BuildAndPublish( @@ -86,10 +73,7 @@ func (m *Cuestomize) BuildAndPublish( platformVariants := make([]*dagger.Container, 0, len(platforms)) for _, platform := range platforms { - container, err := m.Build(ctx, buildContext, string(platform), ldflags) - if err != nil { - return err - } + container := m.Build(ctx, buildContext, string(platform), ldflags) platformVariants = append(platformVariants, container) } diff --git a/.dagger/constants.go b/.dagger/constants.go index 17cefde..b1fbe17 100644 --- a/.dagger/constants.go +++ b/.dagger/constants.go @@ -29,6 +29,8 @@ var ( Exclude: []string{ ".go-version", "README.md", ".vscode", "examples", + ".dagger", "docs", }, + Gitignore: true, } ) diff --git a/.dagger/main.go b/.dagger/main.go index 30bcb6c..2ebdfdb 100644 --- a/.dagger/main.go +++ b/.dagger/main.go @@ -10,10 +10,9 @@ type Cuestomize struct{} // repoBaseContainer creates a container with the repository files in it and go dependencies installed. // The working directory is set to `/workspace` and contains the root of the repository. -func repoBaseContainer(buildContext *dagger.Directory, excludedOpts *dagger.ContainerWithDirectoryOpts, containerOpts ...dagger.ContainerOpts) *dagger.Container { - var exOpts dagger.ContainerWithDirectoryOpts - if excludedOpts == nil { - exOpts = DefaultExcludedOpts +func repoBaseContainer(buildContext *dagger.Directory, dirOpts *dagger.ContainerWithDirectoryOpts, containerOpts ...dagger.ContainerOpts) *dagger.Container { + if dirOpts == nil { + dirOpts = &DefaultExcludedOpts } // Create a container to run the tests @@ -22,10 +21,8 @@ func repoBaseContainer(buildContext *dagger.Directory, excludedOpts *dagger.Cont WithWorkdir("/workspace"). WithFile("/workspace/go.mod", buildContext.File("go.mod")). WithFile("/workspace/go.sum", buildContext.File("go.sum")). - WithFile("/workspace/.dagger/go.mod", buildContext.File(".dagger/go.mod")). - WithFile("/workspace/.dagger/go.sum", buildContext.File(".dagger/go.sum")). WithExec([]string{"go", "mod", "download"}). - WithDirectory("/workspace", buildContext, exOpts) + WithDirectory("/workspace", buildContext, *dirOpts) } // cuestomizeBuilderContainer returns a container that can be used to build the cuestomize binary. diff --git a/.dagger/testing_pipelines.go b/.dagger/testing_pipelines.go index 4ed05d5..3e0ce02 100644 --- a/.dagger/testing_pipelines.go +++ b/.dagger/testing_pipelines.go @@ -41,10 +41,8 @@ func (m *Cuestomize) E2E_Test( // sock *dagger.Socket, ) error { // build cuestomize - cuestomize, err := m.Build(ctx, buildContext, "", "") - if err != nil { - return fmt.Errorf("failed to build cuestomize: %w", err) - } + cuestomize := m.Build(ctx, buildContext, "", "") + cuestomizeBinary := cuestomize.File("/usr/local/bin/cuestomize") cuestomizeTar := cuestomize.AsTarball() @@ -190,20 +188,6 @@ func setupRegistryServiceWithAuth(ctx context.Context, username, password string return registryWithAuth.AsService().Start(ctx) } -func (m *Cuestomize) dind() *dagger.Service { - return dag.Container(). - From("docker:dind"). - WithEnvVariable("TINI_SUBREAPER", "true"). - WithMountedCache("/var/lib/docker", dag.CacheVolume("dind-data")). - WithExposedPort(2375).AsService(dagger.ContainerAsServiceOpts{ - Args: []string{ - "dockerd", "--tls=false", "--host=tcp://0.0.0.0:2375", - }, - InsecureRootCapabilities: true, - UseEntrypoint: true, - }) -} - // testContainerWithRegistryServices returns a repoBaseContainer with registry and registry_auth services bound. func testContainerWithRegistryServices(buildContext *dagger.Directory, registryService, registryWithAuthService *dagger.Service, username, password string) *dagger.Container { return repoBaseContainer(buildContext, nil). diff --git a/.dagger/toolchain.go b/.dagger/toolchain.go index 45f5976..9b8e290 100644 --- a/.dagger/toolchain.go +++ b/.dagger/toolchain.go @@ -12,11 +12,7 @@ func (m *Cuestomize) GoGenerate( // +defaultPath=./ buildContext *dagger.Directory, ) *dagger.Container { - container := repoBaseContainer(buildContext, &dagger.ContainerWithDirectoryOpts{ - Exclude: []string{ - ".go-version", "README.md", ".vscode", - }, - }). + container := repoBaseContainer(buildContext, nil). WithExec([]string{"go", "install", fmt.Sprintf("cuelang.org/go/cmd/cue@%s", CuelangVersion)}). WithExec([]string{"go", "generate", "./..."}) return container From 4cfdd7fb1359785e850fbdc6fc8dcde94b43e86e Mon Sep 17 00:00:00 2001 From: Lorenzo Felletti Date: Sun, 25 Jan 2026 20:56:18 +0000 Subject: [PATCH 8/9] chore: revert change --- examples/simple/kustomize/krm-func.yaml | 2 -- examples/simple/kustomize/kustomization.yaml | 19 ++----------------- 2 files changed, 2 insertions(+), 19 deletions(-) diff --git a/examples/simple/kustomize/krm-func.yaml b/examples/simple/kustomize/krm-func.yaml index 0371287..b19c7dd 100644 --- a/examples/simple/kustomize/krm-func.yaml +++ b/examples/simple/kustomize/krm-func.yaml @@ -21,8 +21,6 @@ includes: name: example-service namespace: example-namespace remoteModule: - # ref: ghcr.io/workday/cuestomize/cuemodules/cuestomize-examples-simple:latest registry: ghcr.io repo: workday/cuestomize/cuemodules/cuestomize-examples-simple tag: latest - plainHTTP: true diff --git a/examples/simple/kustomize/kustomization.yaml b/examples/simple/kustomize/kustomization.yaml index 986f538..eaccef4 100644 --- a/examples/simple/kustomize/kustomization.yaml +++ b/examples/simple/kustomize/kustomization.yaml @@ -7,20 +7,5 @@ resources: namespace: example-namespace -# transformers: -# - krm-func.yaml - -functions: -- type: transformer - spec: - container: - image: myimage:latest #ghcr.io/workday/cuestomize:0.3.0 - network: true - path: krm-func.yaml - -# functions: -# - type: transformer -# spec: -# image: ghcr.io/workday/cuestomize:latest -# network: true -# path: krm-func.yaml +transformers: +- krm-func.yaml From a53182989cbb3e77e408642da1f68eedae083d35 Mon Sep 17 00:00:00 2001 From: Lorenzo Felletti <60483783+lorenzofelletti@users.noreply.github.com> Date: Mon, 26 Jan 2026 16:01:05 +0000 Subject: [PATCH 9/9] style: remove commented code --- .dagger/testing_pipelines.go | 8 -------- 1 file changed, 8 deletions(-) diff --git a/.dagger/testing_pipelines.go b/.dagger/testing_pipelines.go index 3e0ce02..6bf86e9 100644 --- a/.dagger/testing_pipelines.go +++ b/.dagger/testing_pipelines.go @@ -56,14 +56,6 @@ func (m *Cuestomize) E2E_Test( } defer registryService.Stop(ctx) - // _, err = dag.Container().WithServiceBinding("registry", registryService). - // Publish(ctx, "registry:5000/cuestomize:latest", dagger.ContainerPublishOpts{ - // PlatformVariants: []*dagger.Container{cuestomize}, - // }) - // if err != nil { - // return fmt.Errorf("failed to publish cuestomize to registry: %w", err) - // } - // setup registryWithAuth with authentication username := "registryuser" password := "password"