Skip to content

Commit 3cff25f

Browse files
authored
project create cmd fix (goharbor#307)
Signed-off-by: Rizul Gupta <[email protected]>
1 parent 524adda commit 3cff25f

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

pkg/utils/config.go

+8-9
Original file line numberDiff line numberDiff line change
@@ -90,14 +90,14 @@ func InitConfig(cfgFile string, userSpecifiedConfig bool) {
9090
}
9191

9292
// Read and unmarshal the config file
93-
v, err := ReadConfig(harborConfigPath)
93+
err = ReadConfig(harborConfigPath)
9494
if err != nil {
9595
configInitError = err
9696
log.Fatalf("%v", err)
9797
}
9898

9999
var harborConfig HarborConfig
100-
if err := v.Unmarshal(&harborConfig); err != nil {
100+
if err := viper.Unmarshal(&harborConfig); err != nil {
101101
configInitError = fmt.Errorf("failed to unmarshal config file: %w", err)
102102
log.Fatalf("%v", configInitError)
103103
}
@@ -181,14 +181,13 @@ func EnsureConfigFileExists(harborConfigPath string) error {
181181
}
182182

183183
// Helper function to read the config file using Viper
184-
func ReadConfig(harborConfigPath string) (*viper.Viper, error) {
185-
v := viper.New()
186-
v.SetConfigFile(harborConfigPath)
187-
v.SetConfigType("yaml")
188-
if err := v.ReadInConfig(); err != nil {
189-
return nil, fmt.Errorf("error reading config file: %w. Please ensure the config file exists.", err)
184+
func ReadConfig(harborConfigPath string) error {
185+
viper.SetConfigFile(harborConfigPath)
186+
viper.SetConfigType("yaml")
187+
if err := viper.ReadInConfig(); err != nil {
188+
return fmt.Errorf("error reading config file: %w. Please ensure the config file exists.", err)
190189
}
191-
return v, nil
190+
return nil
192191
}
193192

194193
func GetCurrentHarborConfig() (*HarborConfig, error) {

0 commit comments

Comments
 (0)