@@ -108,7 +108,7 @@ func GetDefaultHomeDir() *paths.Path {
108108 return paths .New (homeDir )
109109}
110110
111- //go:embed config-default .ini
111+ //go:embed config.ini
112112var configContent []byte
113113
114114// GenerateConfig function will take a directory path as an input
@@ -142,46 +142,3 @@ func SetInstallCertsIni(filename string, value string) error {
142142 }
143143 return nil
144144}
145-
146- // GetConfigPath returns the full path to the Arduino Create Agent configuration file.
147- // It will check if the config file exists in the default location
148- // and if not, it will generate a new one.
149- // It will also check if the ARDUINO_CREATE_AGENT_CONFIG environment variable is set,
150- // and if so, it will use that path instead of the default one.
151- func GetConfigPath () * paths.Path {
152- // Let's handle the config
153- configDir := GetDefaultConfigDir ()
154- var configPath * paths.Path
155-
156- // see if the env var is defined, if it is take the config from there, this will override the default path
157- if envConfig := os .Getenv ("ARDUINO_CREATE_AGENT_CONFIG" ); envConfig != "" {
158- configPath = paths .New (envConfig )
159- if configPath .NotExist () {
160- log .Panicf ("config from env var %s does not exists" , envConfig )
161- }
162- log .Infof ("using config from env variable: %s" , configPath )
163- } else if defaultConfigPath := configDir .Join ("config.ini" ); defaultConfigPath .Exist () {
164- // by default take the config from the ~/.arduino-create/config.ini file
165- configPath = defaultConfigPath
166- log .Infof ("using config from default: %s" , configPath )
167- } else {
168- // Fall back to the old config.ini location
169- src , _ := os .Executable ()
170- oldConfigPath := paths .New (src ).Parent ().Join ("config.ini" )
171- if oldConfigPath .Exist () {
172- err := oldConfigPath .CopyTo (defaultConfigPath )
173- if err != nil {
174- log .Errorf ("cannot copy old %s, to %s, generating new config" , oldConfigPath , configPath )
175- } else {
176- configPath = defaultConfigPath
177- log .Infof ("copied old %s, to %s" , oldConfigPath , configPath )
178- }
179- }
180- }
181- if configPath == nil {
182- configPath = GenerateConfig (configDir )
183- }
184-
185- return configPath
186-
187- }
0 commit comments