Skip to content

Commit 1e68265

Browse files
committed
Merge remote-tracking branch 'origin/main' into k0s-1-28
2 parents 3d967ea + 41cdc9f commit 1e68265

File tree

13 files changed

+110
-200
lines changed

13 files changed

+110
-200
lines changed

.github/actions/setup-melange/action.yml

Lines changed: 0 additions & 100 deletions
This file was deleted.

.github/workflows/ci.yaml

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -122,19 +122,6 @@ jobs:
122122
go-version-file: go.mod
123123
cache-dependency-path: "**/*.sum"
124124

125-
- name: Cache melange
126-
uses: actions/cache@v4
127-
with:
128-
path: |
129-
local-artifact-mirror/cache/.melange-cache
130-
operator/cache/.melange-cache
131-
key: melange-cache
132-
133-
- name: Setup melange
134-
uses: ./.github/actions/setup-melange
135-
with:
136-
setup-go: false
137-
138125
- name: Install dagger
139126
run: |
140127
curl -fsSL https://dl.dagger.io/dagger/install.sh | sh
@@ -203,19 +190,6 @@ jobs:
203190
go-version-file: go.mod
204191
cache-dependency-path: "**/*.sum"
205192

206-
- name: Cache melange
207-
uses: actions/cache@v4
208-
with:
209-
path: |
210-
local-artifact-mirror/cache/.melange-cache
211-
operator/cache/.melange-cache
212-
key: melange-cache
213-
214-
- name: Setup melange
215-
uses: ./.github/actions/setup-melange
216-
with:
217-
setup-go: false
218-
219193
- name: Install dagger
220194
run: |
221195
curl -fsSL https://dl.dagger.io/dagger/install.sh | sh
@@ -282,19 +256,6 @@ jobs:
282256
go-version-file: go.mod
283257
cache-dependency-path: "**/*.sum"
284258

285-
- name: Cache melange
286-
uses: actions/cache@v4
287-
with:
288-
path: |
289-
local-artifact-mirror/cache/.melange-cache
290-
operator/cache/.melange-cache
291-
key: melange-cache
292-
293-
- name: Setup melange
294-
uses: ./.github/actions/setup-melange
295-
with:
296-
setup-go: false
297-
298259
- name: Install dagger
299260
run: |
300261
curl -fsSL https://dl.dagger.io/dagger/install.sh | sh

.github/workflows/image-scan.yaml

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -28,17 +28,6 @@ jobs:
2828
with:
2929
fetch-depth: 0 # fetch all history so that we can get the previous tag
3030

31-
- name: Cache Melange
32-
uses: actions/cache@v4
33-
with:
34-
path: |
35-
local-artifact-mirror/cache/.melange-cache
36-
operator/cache/.melange-cache
37-
key: melange-cache
38-
39-
- name: Setup melange
40-
uses: ./.github/actions/setup-melange
41-
4231
- name: Install dagger
4332
run: |
4433
curl -fsSL https://dl.dagger.io/dagger/install.sh | sh

.github/workflows/release-prod.yaml

Lines changed: 8 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -59,16 +59,6 @@ jobs:
5959
- name: Checkout
6060
uses: actions/checkout@v4
6161

62-
- name: Cache Melange
63-
uses: actions/cache@v4
64-
with:
65-
path: |
66-
operator/cache/.melange-cache
67-
key: melange-cache
68-
69-
- name: Setup melange
70-
uses: ./.github/actions/setup-melange
71-
7262
- name: Install dagger
7363
run: |
7464
curl -fsSL https://dl.dagger.io/dagger/install.sh | sh
@@ -77,11 +67,11 @@ jobs:
7767
- name: Build and push operator image
7868
id: operator-image
7969
env:
80-
REGISTRY: docker.io
81-
USERNAME: ${{ secrets.DOCKERHUB_USER }}
82-
PASSWORD: ${{ secrets.DOCKERHUB_PASSWORD }}
70+
REGISTRY_SERVER: docker.io
71+
REGISTRY_USERNAME: ${{ secrets.DOCKERHUB_USER }}
72+
REGISTRY_PASSWORD: ${{ secrets.DOCKERHUB_PASSWORD }}
8373
run: |
84-
make -C operator apko apko-login build-and-push-operator-image \
74+
make -C operator build-and-push-operator-image \
8575
PACKAGE_VERSION=${{ needs.get-tag.outputs.tag-name }}
8676
echo "image=$(cat operator/build/image)" >> $GITHUB_OUTPUT
8777
@@ -114,16 +104,6 @@ jobs:
114104
- name: Checkout
115105
uses: actions/checkout@v4
116106

117-
- name: Cache Melange
118-
uses: actions/cache@v4
119-
with:
120-
path: |
121-
local-artifact-mirror/cache/.melange-cache
122-
key: melange-cache
123-
124-
- name: Setup melange
125-
uses: ./.github/actions/setup-melange
126-
127107
- name: Install dagger
128108
run: |
129109
curl -fsSL https://dl.dagger.io/dagger/install.sh | sh
@@ -132,11 +112,11 @@ jobs:
132112
- name: Build and push local-artifact-mirror image
133113
id: local-artifact-mirror
134114
env:
135-
REGISTRY: docker.io
136-
USERNAME: ${{ secrets.DOCKERHUB_USER }}
137-
PASSWORD: ${{ secrets.DOCKERHUB_PASSWORD }}
115+
REGISTRY_SERVER: docker.io
116+
REGISTRY_USERNAME: ${{ secrets.DOCKERHUB_USER }}
117+
REGISTRY_PASSWORD: ${{ secrets.DOCKERHUB_PASSWORD }}
138118
run: |
139-
make -C local-artifact-mirror apko apko-login build-and-push-local-artifact-mirror-image \
119+
make -C local-artifact-mirror build-and-push-local-artifact-mirror-image \
140120
PACKAGE_VERSION=${{ needs.get-tag.outputs.tag-name }}
141121
echo "image=$(cat local-artifact-mirror/build/image)" >> $GITHUB_OUTPUT
142122

dagger/chainguard.go

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ func (m *chainguard) apkoPublish(
9898
From(fmt.Sprintf("cgr.dev/chainguard/apko:%s", imageTag)).
9999
WithDirectory("/workspace", src).
100100
WithFile("/workspace/apko.yaml", apkoFile).
101+
WithEnvVariable("DOCKER_CONFIG", "/workspace/.docker").
101102
WithWorkdir("/workspace").
102103
WithExec(
103104
[]string{
@@ -109,3 +110,27 @@ func (m *chainguard) apkoPublish(
109110

110111
return c
111112
}
113+
114+
func (m *chainguard) apkoLogin(
115+
src *dagger.Directory,
116+
registryServer string,
117+
registryUsername string,
118+
registryPassword string,
119+
// +default="latest"
120+
imageTag string,
121+
) *dagger.Container {
122+
c := dag.Container().
123+
From(fmt.Sprintf("cgr.dev/chainguard/apko:%s", imageTag)).
124+
WithDirectory("/workspace", src).
125+
WithEnvVariable("DOCKER_CONFIG", "/workspace/.docker").
126+
WithWorkdir("/workspace").
127+
WithExec([]string{
128+
"apko", "login", registryServer,
129+
"--username", registryUsername,
130+
"--password-stdin",
131+
}, dagger.ContainerWithExecOpts{
132+
Stdin: registryPassword,
133+
})
134+
135+
return c
136+
}

dagger/localartifactmirror.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,10 @@ func (m *EmbeddedCluster) PublishLocalArtifactMirrorImage(
7272
WithFile("melange.rsa.pub", pkgBuild.File("melange.rsa.pub")).
7373
WithDirectory("packages", pkgBuild.Directory("packages"))
7474

75+
if m.RegistryAuth != nil {
76+
dir = dir.WithDirectory("/workspace/.docker", m.RegistryAuth)
77+
}
78+
7579
publish := m.apkoPublish(
7680
dir,
7781
apkoFile,

dagger/main.go

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,38 @@
11
package main
22

3-
import "dagger/embedded-cluster/internal/dagger"
3+
import (
4+
"context"
5+
"dagger/embedded-cluster/internal/dagger"
6+
"fmt"
7+
)
48

59
const (
610
APKOImageVersion = "latest"
711
MelangeImageVersion = "latest"
812
)
913

1014
type EmbeddedCluster struct {
15+
RegistryAuth *dagger.Directory
16+
1117
common
1218
chainguard
1319
}
1420

21+
func (m *EmbeddedCluster) WithRegistryLogin(
22+
ctx context.Context,
23+
server string,
24+
username string,
25+
password *dagger.Secret,
26+
) (*EmbeddedCluster, error) {
27+
plain, err := password.Plaintext(ctx)
28+
if err != nil {
29+
return nil, fmt.Errorf("get registry password from secret: %w", err)
30+
}
31+
c := m.apkoLogin(dag.Directory(), server, username, plain, APKOImageVersion)
32+
m.RegistryAuth = c.Directory("/workspace/.docker")
33+
return m, nil
34+
}
35+
1536
// directoryWithCommonGoFiles sets up the filesystem with only what we need to build for improved
1637
// caching.
1738
func directoryWithCommonGoFiles(dir *dagger.Directory, src *dagger.Directory) *dagger.Directory {

dagger/operator.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,15 +72,19 @@ func (m *EmbeddedCluster) PublishOperatorImage(
7272
WithFile("melange.rsa.pub", pkgBuild.File("melange.rsa.pub")).
7373
WithDirectory("packages", pkgBuild.Directory("packages"))
7474

75-
build := m.apkoPublish(
75+
if m.RegistryAuth != nil {
76+
dir = dir.WithDirectory("/workspace/.docker", m.RegistryAuth)
77+
}
78+
79+
publish := m.apkoPublish(
7680
dir,
7781
apkoFile,
7882
image,
7983
arch,
8084
APKOImageVersion,
8185
)
8286

83-
return build.Stdout(ctx)
87+
return publish.Stdout(ctx)
8488
}
8589

8690
// Builds the operator package with Melange.

local-artifact-mirror/Makefile

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,25 @@ build-and-push-local-artifact-mirror-image:
6262
.PHONY: build-and-push-local-artifact-mirror-image-chainguard
6363
build-and-push-local-artifact-mirror-image-chainguard:
6464
mkdir -p build
65-
dagger call publish-local-artifact-mirror-image \
66-
--ec-version $(PACKAGE_VERSION) \
67-
--repo $(IMAGE_NAME) \
68-
--arch $(ARCH) \
69-
> build/digest
65+
ifdef REGISTRY_SERVER
66+
dagger call \
67+
with-registry-login \
68+
--server $(REGISTRY_SERVER) \
69+
--username $(REGISTRY_USERNAME) \
70+
--password env:REGISTRY_PASSWORD \
71+
publish-local-artifact-mirror-image \
72+
--ec-version $(PACKAGE_VERSION) \
73+
--repo $(IMAGE_NAME) \
74+
--arch $(ARCH) \
75+
> build/digest
76+
else
77+
dagger call \
78+
publish-local-artifact-mirror-image \
79+
--ec-version $(PACKAGE_VERSION) \
80+
--repo $(IMAGE_NAME) \
81+
--arch $(ARCH) \
82+
> build/digest
83+
endif
7084
@$(MAKE) apko-output-image IMAGE="$(IMAGE_NAME):$(call image-tag,$(PACKAGE_VERSION))"
7185

7286
.PHONY: build-and-push-local-artifact-mirror-image-dockerfile

0 commit comments

Comments
 (0)