Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
feat(staged-dockerfile): support werf images dependencies build-args
Implemented 2-stage build-args expansion: 1. Expand all build-args except dependencies-args on early dockerfile parsing stage. 2. Expand dependencies-args when dependencies images names are available during image conveyor processing. refs #2215 Signed-off-by: Timofey Kirillov <timofey.kirillov@flant.com>
- Loading branch information
1 parent
334644d
commit 8faf229
Showing
19 changed files
with
282 additions
and
103 deletions.
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
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
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
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
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,40 @@ | ||
package stage | ||
|
||
import ( | ||
"github.com/werf/werf/pkg/config" | ||
"github.com/werf/werf/pkg/image" | ||
) | ||
|
||
func GetDependenciesArgsKeys(dependencies []*config.Dependency) (res []string) { | ||
for _, dep := range dependencies { | ||
for _, imp := range dep.Imports { | ||
res = append(res, imp.TargetBuildArg) | ||
} | ||
} | ||
return | ||
} | ||
|
||
func ResolveDependenciesArgs(dependencies []*config.Dependency, c Conveyor) map[string]string { | ||
resolved := make(map[string]string) | ||
|
||
for _, dep := range dependencies { | ||
depImageName := c.GetImageNameForLastImageStage(dep.ImageName) | ||
depImageID := c.GetImageIDForLastImageStage(dep.ImageName) | ||
depImageRepo, depImageTag := image.ParseRepositoryAndTag(depImageName) | ||
|
||
for _, imp := range dep.Imports { | ||
switch imp.Type { | ||
case config.ImageRepoImport: | ||
resolved[imp.TargetBuildArg] = depImageRepo | ||
case config.ImageTagImport: | ||
resolved[imp.TargetBuildArg] = depImageTag | ||
case config.ImageNameImport: | ||
resolved[imp.TargetBuildArg] = depImageName | ||
case config.ImageIDImport: | ||
resolved[imp.TargetBuildArg] = depImageID | ||
} | ||
} | ||
} | ||
|
||
return resolved | ||
} |
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
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
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
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
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
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
Oops, something went wrong.