Skip to content

Commit 10a36cc

Browse files
refactor: yamllint
1 parent 311f161 commit 10a36cc

1 file changed

Lines changed: 11 additions & 6 deletions

File tree

‎yamllint/main.go‎

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@ import (
99
)
1010

1111
const (
12-
defaultImageRepository = "pipelinecomponents/yamllint:latest"
13-
defaultConfigData = "{extends: default, rules: {line-length: {level: warning}}}"
12+
defaultConfigData = "{extends: default, rules: {line-length: {level: warning}}}"
1413
)
1514

1615
// Yamllint provides functions for checking YAML files.
@@ -24,6 +23,7 @@ type Yamllint struct {
2423
// New creates a new instance of the Yamllint struct.
2524
func New(
2625
// Custom image reference in "repository:tag" format to use as a base container.
26+
// If not provided, a clean container built from official Alpine Linux with yamllint will be used.
2727
// +optional
2828
image string,
2929
) *Yamllint {
@@ -38,12 +38,17 @@ func (m *Yamllint) container() *dagger.Container {
3838
return m.Ctr
3939
}
4040

41-
image := m.Image
42-
if image == "" {
43-
image = defaultImageRepository
41+
// If the user provided a custom image, use it directly
42+
if m.Image != "" {
43+
m.Ctr = dag.Container().From(m.Image)
44+
return m.Ctr
4445
}
4546

46-
m.Ctr = dag.Container().From(image)
47+
// Build a minimal, secure container on-the-fly from official Alpine Linux
48+
m.Ctr = dag.Container().
49+
From("alpine:latest").
50+
WithExec([]string{"apk", "add", "--no-cache", "yamllint"})
51+
4752
return m.Ctr
4853
}
4954

0 commit comments

Comments
 (0)