Skip to content

Commit

Permalink
kola: Rework syncOptions
Browse files Browse the repository at this point in the history
Prep for adding more commands which need `syncOptions`; rather
than having `syncOptions` and `syncCosaOptions`, make the upgrade
test the exception that skips the latter.
  • Loading branch information
cgwalters committed Feb 24, 2020
1 parent f96d7e6 commit d4b252b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
5 changes: 1 addition & 4 deletions cmd/kola/kola.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,6 @@ func main() {

func preRun(cmd *cobra.Command, args []string) {
err := syncOptions()
if err == nil {
err = syncCosaOptions()
}

if err != nil {
fmt.Fprintf(os.Stderr, "Error: %v\n", err)
Expand Down Expand Up @@ -390,7 +387,7 @@ func preRunUpgrade(cmd *cobra.Command, args []string) error {
errors.New("Error: missing required argument --cosa-build")
}

err := syncOptions()
err := syncOptionsImpl(false)
if err != nil {
return err
}
Expand Down
19 changes: 12 additions & 7 deletions cmd/kola/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ func init() {
}

// Sync up the command line options if there is dependency
func syncOptions() error {
func syncOptionsImpl(useCosa bool) error {
kola.PacketOptions.Board = kola.QEMUOptions.Board
kola.PacketOptions.GSOptions = &kola.GCEOptions

Expand All @@ -169,10 +169,8 @@ func syncOptions() error {
return err
}

if kola.Options.CosaBuild != "" {
var err error
kola.CosaBuild, err = cosa.ParseBuild(kola.Options.CosaBuild)
if err != nil {
if useCosa && kola.Options.CosaBuild != "" {
if err := syncCosaOptions(); err != nil {
return err
}
}
Expand Down Expand Up @@ -201,11 +199,18 @@ func syncOptions() error {
return nil
}

// syncOptions updates default values of options based on provided ones
func syncOptions() error {
return syncOptionsImpl(true)
}

// syncCosaOptions parses the cosa build and sets unset platform-specific
// options that can be derived from the cosa build metadata
func syncCosaOptions() error {
if kola.CosaBuild == nil {
return nil
var err error
kola.CosaBuild, err = cosa.ParseBuild(kola.Options.CosaBuild)
if err != nil {
return err
}

switch kolaPlatform {
Expand Down

0 comments on commit d4b252b

Please sign in to comment.