Skip to content

Commit

Permalink
Permit to have empty remote config.yml
Browse files Browse the repository at this point in the history
Closes: #1
  • Loading branch information
geaaru committed May 24, 2024
1 parent 8562c75 commit 06675f8
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions pkg/specs/remotes_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ See AUTHORS and LICENSE for the license details and contributors.
package specs

import (
"fmt"
"os"
"os/user"
"path/filepath"
Expand Down Expand Up @@ -48,9 +47,10 @@ func LoadRemotesConfig(remotesconfdir string) (*RemotesConfig, error) {
return ans, err
}
} else {
return ans, fmt.Errorf(
"the file %s doesn't exist.",
remotesconf)
// Just initialize an empty struct if the file doesn't
// exist. This could be happens in the initial setup.
ans = NewRemotesConfig()
ans.File = remotesconf
}
} else {
sshcDir, err := GetSshCRemotesDefaultConfDir()
Expand All @@ -69,5 +69,11 @@ func LoadRemotesConfig(remotesconfdir string) (*RemotesConfig, error) {
ans.File = remotesconf
}
}

// Correctly setup empty files.
if ans.Remotes == nil {
ans.Remotes = make(map[string]*Remote, 0)
ans.DefaultRemote = ""
}
return ans, nil
}

0 comments on commit 06675f8

Please sign in to comment.