-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
74151f5
commit 81cee84
Showing
3 changed files
with
62 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,7 @@ | ||
--- | ||
trustedRegistries: | ||
- docker.io | ||
|
||
ignored: | ||
- DL3008 | ||
- DL3018 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
//revive:disable:package-comments,exported | ||
package linting | ||
|
||
import ( | ||
"cc/util" | ||
"context" | ||
"path/filepath" | ||
|
||
"dagger.io/dagger" | ||
) | ||
|
||
func Hadolint(dir string, c *dagger.Client, id dagger.ContainerID, mountedDir string) error { | ||
ctx := context.Background() | ||
|
||
p := filepath.Join(dir, "..") | ||
file := c.Host(). | ||
Directory(p). | ||
File(".hadolint.yaml") | ||
|
||
id, err := util.MountedHostDirectory(c, id, p, mountedDir). | ||
ID(ctx) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
_, err = H(c, id). | ||
WithWorkdir(mountedDir). | ||
WithMountedFile("/.config/.hadolint.yaml", file). | ||
WithExec([]string{"sh", "-c", "/hadolint --config /.config/.hadolint.yaml $(find . -type f \\( -name Dockerfile -o -name Dockerfile.* \\))"}). | ||
Stdout(ctx) | ||
if err != nil { | ||
return err | ||
} | ||
return nil | ||
} | ||
|
||
func H(c *dagger.Client, id dagger.ContainerID) *dagger.Container { | ||
return h(c, id) | ||
} | ||
|
||
func h(c *dagger.Client, id dagger.ContainerID) *dagger.Container { | ||
hadolint := c. | ||
Container(). | ||
From("hadolint/hadolint:latest-alpine") | ||
|
||
return c.Container(dagger.ContainerOpts{ID: id}). | ||
WithFile("/", hadolint.File("/bin/hadolint")) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters