Skip to content

Commit

Permalink
Merge pull request #129 from ArangoGutierrez/action0211
Browse files Browse the repository at this point in the history
Fix removed ENV VAR Translation
  • Loading branch information
ArangoGutierrez authored Aug 1, 2024
2 parents fc10d42 + a350153 commit 14b1c43
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 6 deletions.
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

0 comments on commit 14b1c43

Please sign in to comment.