Skip to content

Commit

Permalink
enable Read the environment variables through option(PATH)
Browse files Browse the repository at this point in the history
Signed-off-by: satyazzz123 <[email protected]>
  • Loading branch information
satyazzz123 committed Jan 23, 2024
1 parent cf46a1d commit f94762b
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 f94762b

Please sign in to comment.