From 458b7b39e4a5b879bb6112ff4ab23b58159be91b Mon Sep 17 00:00:00 2001 From: Trung Do Date: Fri, 21 Aug 2020 14:47:01 +0700 Subject: [PATCH] actions/apt_action: Add property 'update' This property is a boolean value indicating if `apt update` will be run before install package. Default value is 'true'. Signed-off-by: Trung Do Signed-off-by: Daniel Sangorrin --- actions/apt_action.go | 20 ++++++++++++++++---- actions/recipe.go | 2 +- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/actions/apt_action.go b/actions/apt_action.go index 9136687f..ccc2aa43 100644 --- a/actions/apt_action.go +++ b/actions/apt_action.go @@ -7,6 +7,7 @@ Yaml syntax: - action: apt recommends: bool unauthenticated: bool + update: bool packages: - package1 - package2 @@ -20,6 +21,8 @@ Optional properties: - recommends -- boolean indicating if suggested packages will be installed - unauthenticated -- boolean indicating if unauthenticated packages can be installed + +- update -- boolean indicating if `apt update` will be run. Default 'true'. */ package actions @@ -31,9 +34,15 @@ type AptAction struct { debos.BaseAction `yaml:",inline"` Recommends bool Unauthenticated bool + Update bool Packages []string } +func NewAptAction() *AptAction { + a := &AptAction{Update: true} + return a +} + func (apt *AptAction) Run(context *debos.DebosContext) error { apt.LogStart() aptOptions := []string{"apt-get", "-y"} @@ -52,11 +61,14 @@ func (apt *AptAction) Run(context *debos.DebosContext) error { c := debos.NewChrootCommandForContext(*context) c.AddEnv("DEBIAN_FRONTEND=noninteractive") - err := c.Run("apt", "apt-get", "update") - if err != nil { - return err + if apt.Update { + err := c.Run("apt", "apt-get", "update") + if err != nil { + return err + } } - err = c.Run("apt", aptOptions...) + + err := c.Run("apt", aptOptions...) if err != nil { return err } diff --git a/actions/recipe.go b/actions/recipe.go index 1da6a6bf..d4a0d211 100644 --- a/actions/recipe.go +++ b/actions/recipe.go @@ -107,7 +107,7 @@ func (y *YamlAction) UnmarshalYAML(unmarshal func(interface{}) error) error { case "run": y.Action = &RunAction{} case "apt": - y.Action = &AptAction{} + y.Action = NewAptAction() case "ostree-commit": y.Action = &OstreeCommitAction{} case "ostree-deploy":