Skip to content

Commit

Permalink
Drop unused image targets
Browse files Browse the repository at this point in the history
Signed-off-by: Thomas Hipp <thomas.hipp@canonical.com>
  • Loading branch information
monstermunchkin committed Jul 12, 2023
1 parent 2050149 commit a064022
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 46 deletions.
30 changes: 0 additions & 30 deletions distrobuilder/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -376,36 +376,6 @@ func (c *cmdGlobal) preRunBuild(cmd *cobra.Command, args []string) error {
_ = exitChroot()
}()

// Always include sections which have no type filter. If running build-dir,
// only these sections will be processed.
imageTargets := shared.ImageTargetUndefined

// If we're running either build-lxc or build-lxd, include types which are
// meant for all.
if !isRunningBuildDir {
imageTargets |= shared.ImageTargetAll
}

switch cmd.CalledAs() {
case "build-lxc":
// If we're running build-lxc, also process container-only sections.
imageTargets |= shared.ImageTargetContainer
case "build-lxd":
// Include either container-specific or vm-specific sections when
// running build-lxd.
ok, err := cmd.Flags().GetBool("vm")
if err != nil {
return fmt.Errorf(`Failed to get bool value of "vm": %w`, err)
}

if ok {
imageTargets |= shared.ImageTargetVM
c.definition.Targets.Type = shared.DefinitionFilterTypeVM
} else {
imageTargets |= shared.ImageTargetContainer
}
}

manager, err := managers.Load(c.ctx, c.definition.Packages.Manager, c.logger, *c.definition)
if err != nil {
return fmt.Errorf("Failed to load manager %q: %w", c.definition.Packages.Manager, err)
Expand Down
16 changes: 0 additions & 16 deletions distrobuilder/main_lxd.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,14 +184,6 @@ func (c *cmdLXD) runPack(cmd *cobra.Command, args []string, overlayDir string) e
_ = exitChroot()
}()

imageTargets := shared.ImageTargetAll

if c.flagVM {
imageTargets |= shared.ImageTargetVM
} else {
imageTargets |= shared.ImageTargetContainer
}

manager, err := managers.Load(c.global.ctx, c.global.definition.Packages.Manager, c.global.logger, *c.global.definition)
if err != nil {
return fmt.Errorf("Failed to load manager %q: %w", c.global.definition.Packages.Manager, err)
Expand Down Expand Up @@ -253,14 +245,6 @@ func (c *cmdLXD) run(cmd *cobra.Command, args []string, overlayDir string) error
img := image.NewLXDImage(c.global.ctx, overlayDir, c.global.targetDir,
c.global.flagCacheDir, *c.global.definition)

imageTargets := shared.ImageTargetUndefined | shared.ImageTargetAll

if c.flagVM {
imageTargets |= shared.ImageTargetVM
} else {
imageTargets |= shared.ImageTargetContainer
}

for _, file := range c.global.definition.Files {
generator, err := generators.Load(file.Generator, c.global.logger, c.global.flagCacheDir, overlayDir, file, *c.global.definition)
if err != nil {
Expand Down

0 comments on commit a064022

Please sign in to comment.