Add cli option to skip packages if only metadata is present (without checking the image)

This commit is contained in:
Ettore Di Giacinto
2020-07-17 22:42:03 +02:00
parent 3af9109b99
commit 07a1058ac1
3 changed files with 8 additions and 4 deletions

View File

@@ -79,6 +79,7 @@ var buildCmd = &cobra.Command{
onlydeps := viper.GetBool("onlydeps") onlydeps := viper.GetBool("onlydeps")
keepExportedImages := viper.GetBool("keep-exported-images") keepExportedImages := viper.GetBool("keep-exported-images")
full, _ := cmd.Flags().GetBool("full") full, _ := cmd.Flags().GetBool("full")
skip, _ := cmd.Flags().GetBool("skip-if-metadata-exists")
compilerSpecs := compiler.NewLuetCompilationspecs() compilerSpecs := compiler.NewLuetCompilationspecs()
var compilerBackend compiler.CompilerBackend var compilerBackend compiler.CompilerBackend
@@ -143,6 +144,7 @@ var buildCmd = &cobra.Command{
opts.OnlyDeps = onlydeps opts.OnlyDeps = onlydeps
opts.NoDeps = nodeps opts.NoDeps = nodeps
opts.KeepImageExport = keepExportedImages opts.KeepImageExport = keepExportedImages
opts.SkipIfMetadataExists = skip
luetCompiler := compiler.NewLuetCompiler(compilerBackend, generalRecipe.GetDatabase(), opts) luetCompiler := compiler.NewLuetCompiler(compilerBackend, generalRecipe.GetDatabase(), opts)
luetCompiler.SetConcurrency(concurrency) luetCompiler.SetConcurrency(concurrency)
@@ -231,6 +233,7 @@ func init() {
buildCmd.Flags().Bool("nodeps", false, "Build only the target packages, skipping deps (it works only if you already built the deps locally, or by using --pull) ") buildCmd.Flags().Bool("nodeps", false, "Build only the target packages, skipping deps (it works only if you already built the deps locally, or by using --pull) ")
buildCmd.Flags().Bool("onlydeps", false, "Build only package dependencies") buildCmd.Flags().Bool("onlydeps", false, "Build only package dependencies")
buildCmd.Flags().Bool("keep-exported-images", false, "Keep exported images used during building") buildCmd.Flags().Bool("keep-exported-images", false, "Keep exported images used during building")
buildCmd.Flags().Bool("skip-if-metadata-exists", false, "Skip package if metadata exists")
buildCmd.Flags().String("solver-type", "", "Solver strategy") buildCmd.Flags().String("solver-type", "", "Solver strategy")
buildCmd.Flags().Float32("solver-rate", 0.7, "Solver learning rate") buildCmd.Flags().Float32("solver-rate", 0.7, "Solver learning rate")

View File

@@ -256,7 +256,7 @@ func (cs *LuetCompiler) compileWithImage(image, buildertaggedImage, packageImage
if !cs.Clean { if !cs.Clean {
exists := cs.Backend.ImageExists(buildertaggedImage) && cs.Backend.ImageExists(packageImage) exists := cs.Backend.ImageExists(buildertaggedImage) && cs.Backend.ImageExists(packageImage)
if art, err := LoadArtifactFromYaml(p); err == nil && exists { if art, err := LoadArtifactFromYaml(p); err == nil && (cs.Options.SkipIfMetadataExists || exists) {
Debug("Artifact reloaded. Skipping build") Debug("Artifact reloaded. Skipping build")
return art, err return art, err
} }

View File

@@ -52,9 +52,10 @@ type CompilerOptions struct {
Clean bool Clean bool
KeepImageExport bool KeepImageExport bool
OnlyDeps bool OnlyDeps bool
NoDeps bool NoDeps bool
SolverOptions config.LuetSolverOptions SolverOptions config.LuetSolverOptions
SkipIfMetadataExists bool
} }
func NewDefaultCompilerOptions() *CompilerOptions { func NewDefaultCompilerOptions() *CompilerOptions {