Skip to content

Commit

Permalink
Merge pull request #124 from ArangoGutierrez/action02
Browse files Browse the repository at this point in the history
Fix SSH handling
  • Loading branch information
ArangoGutierrez authored Jul 31, 2024
2 parents 43bde4c + 1e42aa3 commit 6ea0b50
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 2 deletions.
4 changes: 2 additions & 2 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ runs:
inputs:
aws_access_key_id:
description: 'AWS Access Key ID'
required: true
required: false
aws_secret_access_key:
description: 'AWS Secret Access Key'
required: true
required: false
aws_ssh_key:
description: 'AWS SSH Key'
required: false
Expand Down
29 changes: 29 additions & 0 deletions cmd/action/ci/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,19 @@ func newAwsProvider(log *logger.FunLogger, cfg v1alpha1.Environment) (*aws.Provi
}
}

// 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)
}

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)
}

// Set auth.PrivateKey
cfg.Spec.Auth.PrivateKey = sshKeyFile
cfg.Spec.Auth.Username = username
Expand All @@ -84,6 +97,22 @@ func newVsphereProvider(log *logger.FunLogger, cfg v1alpha1.Environment) (*vsphe
}
}

// 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)
}

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)
}

// Set auth.PrivateKey
cfg.Spec.Auth.PrivateKey = sshKeyFile

// Set env name
setCfgName(&cfg)

Expand Down

0 comments on commit 6ea0b50

Please sign in to comment.