Add message asserting skip. Also return pointer to allow to edit Options

This commit is contained in:
Ettore Di Giacinto 2020-01-05 16:26:42 +01:00
parent d23e1dee78
commit d2abaa9cc1
No known key found for this signature in database
GPG Key ID: 1ADA699B145A2D1C
3 changed files with 6 additions and 3 deletions

View File

@ -35,6 +35,7 @@ var buildCmd = &cobra.Command{
Short: "build a package or a tree", Short: "build a package or a tree",
Long: `build packages or trees from luet tree definitions. Packages are in [category]/[name]-[version] form`, Long: `build packages or trees from luet tree definitions. Packages are in [category]/[name]-[version] form`,
PreRun: func(cmd *cobra.Command, args []string) { PreRun: func(cmd *cobra.Command, args []string) {
viper.BindPFlag("clean", cmd.Flags().Lookup("clean"))
viper.BindPFlag("tree", cmd.Flags().Lookup("tree")) viper.BindPFlag("tree", cmd.Flags().Lookup("tree"))
viper.BindPFlag("destination", cmd.Flags().Lookup("destination")) viper.BindPFlag("destination", cmd.Flags().Lookup("destination"))
viper.BindPFlag("backend", cmd.Flags().Lookup("backend")) viper.BindPFlag("backend", cmd.Flags().Lookup("backend"))

View File

@ -44,7 +44,7 @@ type LuetCompiler struct {
CompressionType CompressionImplementation CompressionType CompressionImplementation
} }
func NewLuetCompiler(backend CompilerBackend, db pkg.PackageDatabase, opt CompilerOptions) Compiler { func NewLuetCompiler(backend CompilerBackend, db pkg.PackageDatabase, opt *CompilerOptions) Compiler {
// The CompilerRecipe will gives us a tree with only build deps listed. // The CompilerRecipe will gives us a tree with only build deps listed.
return &LuetCompiler{ return &LuetCompiler{
Backend: backend, Backend: backend,
@ -229,6 +229,7 @@ func (cs *LuetCompiler) stripIncludesFromRootfs(includes []string, rootfs string
func (cs *LuetCompiler) compileWithImage(image, buildertaggedImage, packageImage string, concurrency int, keepPermissions, keepImg bool, p CompilationSpec) (Artifact, error) { func (cs *LuetCompiler) compileWithImage(image, buildertaggedImage, packageImage string, concurrency int, keepPermissions, keepImg bool, p CompilationSpec) (Artifact, error) {
if !cs.Clean { if !cs.Clean {
if art, err := LoadArtifactFromYaml(p); err == nil { if art, err := LoadArtifactFromYaml(p); err == nil {
Debug("Artifact reloaded. Skipping build")
return art, err return art, err
} }
} }
@ -389,6 +390,7 @@ func (cs *LuetCompiler) compileWithImage(image, buildertaggedImage, packageImage
func (cs *LuetCompiler) packageFromImage(p CompilationSpec, tag string, keepPermissions, keepImg bool, concurrency int) (Artifact, error) { func (cs *LuetCompiler) packageFromImage(p CompilationSpec, tag string, keepPermissions, keepImg bool, concurrency int) (Artifact, error) {
if !cs.Clean { if !cs.Clean {
if art, err := LoadArtifactFromYaml(p); err == nil { if art, err := LoadArtifactFromYaml(p); err == nil {
Debug("Artifact reloaded. Skipping build")
return art, err return art, err
} }
} }

View File

@ -50,8 +50,8 @@ type CompilerOptions struct {
Clean bool Clean bool
} }
func NewDefaultCompilerOptions() CompilerOptions { func NewDefaultCompilerOptions() *CompilerOptions {
return CompilerOptions{ return &CompilerOptions{
ImageRepository: "luet/cache", ImageRepository: "luet/cache",
PullFirst: true, PullFirst: true,
CompressionType: None, CompressionType: None,