Skip to content

Commit

Permalink
add an example environment config
Browse files Browse the repository at this point in the history
  • Loading branch information
djelusic committed Oct 15, 2021
1 parent a49d0b6 commit ca4a6df
Showing 1 changed file with 26 additions and 6 deletions.
32 changes: 26 additions & 6 deletions workspace/project.go
Original file line number Diff line number Diff line change
Expand Up @@ -209,17 +209,37 @@ type FunctionEnvironmentConfig struct {

func CreateEnvironmentConfig(basePath string) error {
path := environmentConfigPath(basePath)
ec := &EnvironmentConfig{}
buf, err := yaml.Marshal(ec)
if err != nil {
return log.Wrap(err)
}
if err := ioutil.WriteFile(path, buf, 0644); err != nil {
if err := ioutil.WriteFile(path, []byte(environmentConfigExample), 0644); err != nil {
return log.Wrap(err)
}
return nil
}

const environmentConfigExample = `# Here you can define environment variables for functions
# on a project, stage or function level. If the same variable is
# defined on multiple levels the lowest level will take precedence.
# For example, uncommenting the config below will result in
# the function ping having the following environment:
# KEY: project
# KEY2: stage
# KEY3: function
# project:
# env:
# KEY: project
# KEY2: project
# KEY3: project
# stages:
# - name: dev
# env:
# KEY2: stage
# KEY3: stage
# functions:
# - name: ping
# env:
# KEY3: function
`

func environmentConfigPath(basePath string) string {
return filepath.Join(basePath, configDir, environmentConfigName)
}

0 comments on commit ca4a6df

Please sign in to comment.