chore: update
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
This commit is contained in:
Родитель
f518c1b9a7
Коммит
f05453caff
|
@ -29,10 +29,6 @@ func BuildArgs(o options.Build, github options.GitHub, tags []string) []string {
|
|||
args = append(args, "--file", o.Dockerfile)
|
||||
}
|
||||
|
||||
if o.CacheFrom != "" {
|
||||
args = append(args, "--cache-from", o.CacheFrom)
|
||||
}
|
||||
|
||||
if o.Target != "" {
|
||||
args = append(args, "--target", o.Target)
|
||||
}
|
||||
|
@ -41,6 +37,10 @@ func BuildArgs(o options.Build, github options.GitHub, tags []string) []string {
|
|||
args = append(args, "--pull")
|
||||
}
|
||||
|
||||
for _, cacheFrom := range o.CacheFroms {
|
||||
args = append(args, "--cache-from", cacheFrom)
|
||||
}
|
||||
|
||||
for _, buildArg := range o.BuildArgs {
|
||||
args = append(args, "--build-arg", buildArg)
|
||||
}
|
||||
|
|
|
@ -80,10 +80,10 @@ func TestBuildArgs(t *testing.T) {
|
|||
{
|
||||
name: "with-cache-from",
|
||||
build: options.Build{
|
||||
Path: ".",
|
||||
CacheFrom: "foo/bar",
|
||||
Path: ".",
|
||||
CacheFroms: []string{"foo/bar-1", "foo/bar-2"},
|
||||
},
|
||||
expected: []string{"build", "--progress", "plain", "--cache-from", "foo/bar", "."},
|
||||
expected: []string{"build", "--progress", "plain", "--cache-from", "foo/bar-1", "--cache-from", "foo/bar-2", "."},
|
||||
},
|
||||
}
|
||||
for _, tc := range testCases {
|
||||
|
|
|
@ -17,7 +17,7 @@ type Build struct {
|
|||
AddGitLabels bool `env:"INPUT_ADD_GIT_LABELS"`
|
||||
Target string `env:"INPUT_TARGET"`
|
||||
AlwaysPull bool `env:"INPUT_ALWAYS_PULL"`
|
||||
CacheFrom string `env:"INPUT_CACHE_FROM"`
|
||||
CacheFroms []string
|
||||
BuildArgs []string
|
||||
Labels []string
|
||||
}
|
||||
|
@ -29,6 +29,10 @@ func GetBuildOptions() (Build, error) {
|
|||
return build, err
|
||||
}
|
||||
|
||||
if cacheFroms := os.Getenv("INPUT_CACHE_FROMS"); cacheFroms != "" {
|
||||
build.CacheFroms = strings.Split(cacheFroms, ",")
|
||||
}
|
||||
|
||||
if buildArgs := os.Getenv("INPUT_BUILD_ARGS"); buildArgs != "" {
|
||||
build.BuildArgs = strings.Split(buildArgs, ",")
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@ import (
|
|||
func TestGetBuildOptions(t *testing.T) {
|
||||
_ = os.Setenv("INPUT_PATH", "path")
|
||||
_ = os.Setenv("INPUT_DOCKERFILE", "dockerfile")
|
||||
_ = os.Setenv("INPUT_CACHE_FROM", "foo/bar")
|
||||
_ = os.Setenv("INPUT_CACHE_FROMS", "foo/bar-1,foo/bar-2")
|
||||
_ = os.Setenv("INPUT_REPOSITORY", "repository")
|
||||
_ = os.Setenv("INPUT_BUILD_ARGS", "buildarg1=b1,buildarg2=b2")
|
||||
_ = os.Setenv("INPUT_LABELS", "label1=l1,label2=l2")
|
||||
|
@ -30,7 +30,7 @@ func TestGetBuildOptions(t *testing.T) {
|
|||
AlwaysPull: true,
|
||||
BuildArgs: []string{"buildarg1=b1", "buildarg2=b2"},
|
||||
Labels: []string{"label1=l1", "label2=l2"},
|
||||
CacheFrom: "foo/bar",
|
||||
CacheFroms: []string{"foo/bar-1", "foo/bar-2"},
|
||||
}, o)
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче