@@ -90,14 +90,14 @@ func InitConfig(cfgFile string, userSpecifiedConfig bool) {
90
90
}
91
91
92
92
// Read and unmarshal the config file
93
- v , err : = ReadConfig (harborConfigPath )
93
+ err = ReadConfig (harborConfigPath )
94
94
if err != nil {
95
95
configInitError = err
96
96
log .Fatalf ("%v" , err )
97
97
}
98
98
99
99
var harborConfig HarborConfig
100
- if err := v .Unmarshal (& harborConfig ); err != nil {
100
+ if err := viper .Unmarshal (& harborConfig ); err != nil {
101
101
configInitError = fmt .Errorf ("failed to unmarshal config file: %w" , err )
102
102
log .Fatalf ("%v" , configInitError )
103
103
}
@@ -181,14 +181,13 @@ func EnsureConfigFileExists(harborConfigPath string) error {
181
181
}
182
182
183
183
// 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 )
190
189
}
191
- return v , nil
190
+ return nil
192
191
}
193
192
194
193
func GetCurrentHarborConfig () (* HarborConfig , error ) {
0 commit comments