Skip to content

Commit

Permalink
Add feature of building images in ADO (#8806)
Browse files Browse the repository at this point in the history
* Add sign-only mode.

* POC of image building in ADO.

* go mod tidy

* Use default build config.

* Add sign-only mode.

* POC of image building in ADO.

* go mod tidy

* Use default build config.

* fix linter errors

* rendertemplates

* go get -t github.com/kyma-project/test-infra/pkg/prow/pjconfigtests

* Fixed test.

* Fix test

* Refactored code for building images in ADO.
Distributed code to multiple functions.

* Linter errors.

* Move ado code to separate pacakge and make it testable.

* Move build in ado code to separate package. This can be tested independent and reused in other tools.

* Tests.
TODOs for needed improvements.
Comments.
Small changes in code.

* go mod tidy

* Missing mocks.

* Key name aligned with ADO pipeline parameter name.

* Added building image-builder image to the prowjob.

* go mod tidy

* Aligned client with expected ado pipeline parameters names.

* Fixed validation.

* Use go buildpack. Chainguard offers free access to the latest tag only.

* Moved Dockerfile back to original location. images directory is not suitable for building image-builder.

* Build image-builder image in prowjob.
Fix flag.

* Apply suggestions from code review

Co-authored-by: Kamil Kasperski <kamil.kasperski@sap.com>

* Unexport options fields.

* Use sets.Strings.

* This tests will be added in separate pr.

* Not in use yet.

* Remove testing prowjob.

* Align build config with expected schema.

---------

Co-authored-by: Kamil Kasperski <kamil.kasperski@sap.com>
  • Loading branch information
dekiel and Ressetkk authored Dec 4, 2023
1 parent b21a8b6 commit 57f98c4
Show file tree
Hide file tree
Showing 17 changed files with 1,345 additions and 70 deletions.
7 changes: 7 additions & 0 deletions .mockery.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
with-expecter: true
packages:
github.com/kyma-project/test-infra/pkg/azuredevops/pipelines:
config:
include-regex: ".*Client"
dir: "{{.InterfaceDir}}/mocks"
outpkg: "{{.PackageName}}mocks"
2 changes: 2 additions & 0 deletions cmd/image-builder/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,14 @@ import (
"fmt"
"os"

adoPipelines "github.com/kyma-project/test-infra/pkg/azuredevops/pipelines"
"github.com/kyma-project/test-infra/pkg/sign"
"github.com/kyma-project/test-infra/pkg/tags"
"gopkg.in/yaml.v3"
)

type Config struct {
AdoConfig adoPipelines.Config `yaml:"ado-config,omitempty" json:"ado-config,omitempty"`
// Registry is URL where clean build should land.
Registry Registry `yaml:"registry" json:"registry"`
// DevRegistry is Registry URL where development/dirty images should land.
Expand Down
13 changes: 10 additions & 3 deletions cmd/image-builder/images/kaniko/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
FROM gcr.io/kaniko-project/executor:v1.9.0
FROM europe-docker.pkg.dev/kyma-project/prod/testimages/buildpack-go:v20231128-9bb59ac6 AS builder

COPY ./image-builder /image-builder
WORKDIR /
COPY . /app/
RUN cd /app/cmd/image-builder && CGO_ENABLED=0 go build -o /app/image-builder -a -ldflags '-extldflags "-static"' .

ENTRYPOINT ["/image-builder"]

FROM gcr.io/kaniko-project/executor:v1.14.0

COPY --from=builder /app/image-builder /image-builder

ENTRYPOINT ["/image-builder"]
Loading

0 comments on commit 57f98c4

Please sign in to comment.