Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(images-dependencies): introduce basic image dependencies configu…
…ration structs
- Loading branch information
1 parent
525db42
commit da36104
Showing
6 changed files
with
57 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package config | ||
|
||
type Dependency struct { | ||
ImageName string | ||
Imports []*DependencyImport | ||
|
||
// TODO: raw *rawDependencies | ||
} |
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,31 @@ | ||
package config | ||
|
||
import ( | ||
"fmt" | ||
"strings" | ||
) | ||
|
||
type DependencyImport struct { | ||
Type DependencyImportType | ||
TargetBuildArg string | ||
TargetEnv string | ||
|
||
// TODO: raw *rawDependencyImport | ||
} | ||
|
||
func (i *DependencyImport) validate(img ImageInterface) error { | ||
switch { | ||
case img.IsStapel() && i.TargetBuildArg != "": | ||
return newDetailedConfigError("`targetBuildArg cannot be used in the stapel image", nil, nil) // TODO: raw | ||
case !img.IsStapel() && i.TargetEnv != "": | ||
return newDetailedConfigError("`targetEnv cannot be used in the dockerfile image", nil, nil) // TODO: raw | ||
} | ||
|
||
switch i.Type { | ||
case ImageNameImport, ImageTagImport, ImageRepoImport: | ||
default: | ||
return newDetailedConfigError(fmt.Sprintf("invalid `type: %s` for dependency import, expected one of: %s", i.Type, strings.Join([]string{string(ImageNameImport), string(ImageTagImport), string(ImageRepoImport)}, ", ")), nil, nil) // TODO: raw | ||
} | ||
|
||
return nil | ||
} |
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,9 @@ | ||
package config | ||
|
||
type DependencyImportType string | ||
|
||
const ( | ||
ImageNameImport DependencyImportType = "ImageName" | ||
ImageTagImport DependencyImportType = "ImageTag" | ||
ImageRepoImport DependencyImportType = "ImageRepo" | ||
) |
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 |
---|---|---|
|
@@ -2,4 +2,5 @@ package config | |
|
||
type ImageInterface interface { | ||
GetName() string | ||
IsStapel() bool | ||
} |
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