Skip to content

Commit

Permalink
Merge pull request #28 from satyazzz123/satyazzz123/ENV
Browse files Browse the repository at this point in the history
enable Read the environment variables through option(PATH)
  • Loading branch information
Peefy authored Jan 23, 2024
2 parents cf46a1d + f94762b commit daa152c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
4 changes: 4 additions & 0 deletions pkg/edit/bootstrap.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,8 @@ func constructOptions(resourceList *yaml.RNode) (*options.RunOptions, error) {
if err != nil {
return nil, errors.Wrap(err)
}
// 4. Read environment variables.
pathOptionKCLValue := os.Getenv("PATH")
opts := options.NewRunOptions()
opts.NoStyle = true
opts.Arguments = []string{
Expand All @@ -135,6 +137,8 @@ func constructOptions(resourceList *yaml.RNode) (*options.RunOptions, error) {
fmt.Sprintf("%s=%s", itemsOptionName, itemsOptionKCLValue),
// resource.functionConfig.spec.params
fmt.Sprintf("%s=%s", paramsOptionName, paramsOptionKCLValue),
// environment variable example (PATH)
fmt.Sprintf("PATH=%s", pathOptionKCLValue),
}
return opts, nil
}
6 changes: 5 additions & 1 deletion pkg/options/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,15 @@ type RunOptions struct {
InputPath string
// OutputPath is the -o flag
OutputPath string
// Environment variable example (PATH)
PathEnvVar string
}

// RunOptions creates a new options for the run command.
func NewRunOptions() *RunOptions {
return &RunOptions{}
return &RunOptions{
PathEnvVar: os.Getenv("PATH"),
}
}

// Run the with the run command options.
Expand Down

0 comments on commit daa152c

Please sign in to comment.