Skip to content

Commit

Permalink
fix: nil issue when repo doesn't exist (#8)
Browse files Browse the repository at this point in the history
  • Loading branch information
m-adawi committed Jul 17, 2024
1 parent c3e5496 commit e735dec
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions swarmcd/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@ func Init() (err error ) {
if err != nil {
return err
}
initStacks()
err = initStacks()
if err != nil {
return err
}
err = initDockerCli()
if err != nil {
return err
Expand Down Expand Up @@ -59,11 +62,16 @@ func initRepos() (err error) {
return nil
}

func initStacks() {
func initStacks() error {
for stack, stackConfig := range config.StackConfigs{
stackStatus[stack] = &StackStatus{}
stackStatus[stack].RepoURL = config.RepoConfigs[stackConfig.Repo].Url
repoConfig, ok := config.RepoConfigs[stackConfig.Repo]
if !ok {
return fmt.Errorf("error initializing %s stack, no such repo: %s", stack, stackConfig.Repo)
}
stackStatus[stack].RepoURL = repoConfig.Url
}
return nil
}


Expand Down

0 comments on commit e735dec

Please sign in to comment.