Skip to content
This repository has been archived by the owner on Oct 23, 2023. It is now read-only.

Commit

Permalink
Move env file to parent directory to avoid conflict with config provider
Browse files Browse the repository at this point in the history
  • Loading branch information
farshidtz committed Mar 13, 2023
1 parent 434c8fb commit 121d301
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
9 changes: 7 additions & 2 deletions options/env.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,9 @@ func (cp *configProcessor) filename(service string) string {
// include the service name in it's configuration path.
var path string
if env.SnapName == "edgex-app-service-configurable" {
path = fmt.Sprintf("%s/config/res/%s.env", env.SnapData, service)
path = fmt.Sprintf("%s/config/overrides.env", env.SnapData)
} else {
path = fmt.Sprintf("%s/config/%s/res/%s.env", env.SnapData, service, service)
path = fmt.Sprintf("%s/config/%s/overrides.env", env.SnapData, service)
}
return path
}
Expand All @@ -99,6 +99,11 @@ func (cp *configProcessor) writeEnvFiles() error {
continue
}

// Add comment on top of the file
if _, err := fmt.Fprintln(&buffer, "# System-generated list of environment variables from snap options"); err != nil {
return err
}

// add env vars to buffer
for k, v := range envVars {
if _, err := fmt.Fprintf(&buffer, "%s=\"%s\"\n", k, v); err != nil {
Expand Down
8 changes: 4 additions & 4 deletions options/options_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,12 @@ func TestProcessConfig(t *testing.T) {
// uncomment to cleanup previous mess
// assert.NoError(t, snapctl.Unset("app-options", "config-enabled", "apps", "config").Run())

configDir := fmt.Sprintf("%s/config/%s/res/", env.SnapData, testService)
envFile := path.Join(configDir, testService+".env")
configDir := fmt.Sprintf("%s/config/%s/", env.SnapData, testService)
envFile := path.Join(configDir, "overrides.env")
os.MkdirAll(configDir, os.ModePerm)

configDir2 := fmt.Sprintf("%s/config/%s/res/", env.SnapData, testService2)
envFile2 := path.Join(configDir2, testService2+".env")
configDir2 := fmt.Sprintf("%s/config/%s/", env.SnapData, testService2)
envFile2 := path.Join(configDir2, "overrides.env")
os.MkdirAll(configDir2, os.ModePerm)

require.NoError(t, snapctl.Set("debug", "true").Run())
Expand Down

0 comments on commit 121d301

Please sign in to comment.