Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Release-0.2] Fix removed ENV VAR Translation #130

Merged
merged 2 commits into from
Aug 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions cmd/action/ci/entrypoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,34 @@ func entrypoint(log *logger.FunLogger) error {
cfg.Spec.ContainerRuntime.Name = v1alpha1.ContainerRuntimeNone
}

// Read Inputs
// INPUT_* vars are optional since v0.2 of the action
// Users can set the variables on self hosted runners.
// Get INPUT_AWS_SSH_KEY to set AWS_SSH_KEY
sshKey := os.Getenv("INPUT_AWS_SSH_KEY")
if sshKey != "" {
err := os.Setenv("AWS_SSH_KEY", sshKey)
if err != nil {
return fmt.Errorf("failed to set AWS_SSH_KEY: %v", err)
}
}
// Map INPUT_AWS_ACCESS_KEY_ID and INPUT_AWS_SECRET_ACCESS_KEY
// to AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY
accessKeyID := os.Getenv("INPUT_AWS_ACCESS_KEY_ID")
if accessKeyID != "" {
err := os.Setenv("AWS_ACCESS_KEY_ID", accessKeyID)
if err != nil {
return fmt.Errorf("failed to set AWS_ACCESS_KEY_ID: %v", err)
}
}
secretAccessKey := os.Getenv("INPUT_AWS_SECRET_ACCESS_KEY")
if secretAccessKey != "" {
err := os.Setenv("AWS_SECRET_ACCESS_KEY", secretAccessKey)
if err != nil {
return fmt.Errorf("failed to set AWS_SECRET_ACCESS_KEY: %v", err)
}
}

provider, err := newProvider(log, cfg)
if err != nil {
return fmt.Errorf("failed to create provider: %v", err)
Expand Down
12 changes: 6 additions & 6 deletions cmd/action/ci/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,21 +55,21 @@ func newAwsProvider(log *logger.FunLogger, cfg v1alpha1.Environment) (*aws.Provi
err := os.Mkdir(cachedir, 0755)
if err != nil {
log.Error(fmt.Errorf("error creating cache directory: %s", err))
os.Exit(1)
return nil, err
}
}

// Get AWS_SSH_KEY and write it to a file
sshKey := os.Getenv("AWS_SSH_KEY")
if sshKey == "" {
log.Error(fmt.Errorf("ssh key not provided"))
os.Exit(1)
return nil, fmt.Errorf("ssh key not provided")
}

err := os.WriteFile(sshKeyFile, []byte(sshKey), 0600)
if err != nil {
log.Error(fmt.Errorf("error writing ssh key to file: %s", err))
os.Exit(1)
return nil, err
}

// Set auth.PrivateKey
Expand All @@ -93,21 +93,21 @@ func newVsphereProvider(log *logger.FunLogger, cfg v1alpha1.Environment) (*vsphe
err := os.Mkdir(cachedir, 0755)
if err != nil {
log.Error(fmt.Errorf("error creating cache directory: %s", err))
os.Exit(1)
return nil, err
}
}

// Get VSPHERE_SSH_KEY and write it to a file
sshKey := os.Getenv("VSPHERE_SSH_KEY")
if sshKey == "" {
log.Error(fmt.Errorf("ssh key not provided"))
os.Exit(1)
return nil, fmt.Errorf("ssh key not provided")
}

err := os.WriteFile(sshKeyFile, []byte(sshKey), 0600)
if err != nil {
log.Error(fmt.Errorf("error writing ssh key to file: %s", err))
os.Exit(1)
return nil, err
}

// Set auth.PrivateKey
Expand Down
Loading