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

Only read sshkeys during provisioning #140

Merged
merged 1 commit into from
Aug 8, 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
2 changes: 0 additions & 2 deletions cmd/action/ci/ci.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@ const (
)

func Run(log *logger.FunLogger) error {
log.Info("Holodeck Settting up test environment")

// Get GitHub Actions INPUT_* vars
err := readInputs()
if err != nil {
Expand Down
15 changes: 11 additions & 4 deletions cmd/action/ci/entrypoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,17 +70,24 @@ func entrypoint(log *logger.FunLogger) error {

// Get the host url
var hostUrl string
var username string
if cfg.Spec.Provider == v1alpha1.ProviderAWS {
username = "ubuntu"
if err := getSSHKeyFile(log, "AWS_SSH_KEY"); err != nil {
return err
}
cfg.Spec.Auth.PrivateKey = sshKeyFile
cfg.Spec.Auth.Username = "ubuntu"
for _, p := range cache.Status.Properties {
if p.Name == aws.PublicDnsName {
hostUrl = p.Value
break
}
}
} else if cfg.Spec.Provider == v1alpha1.ProviderVSphere {
username = "nvidia"
if err := getSSHKeyFile(log, "VSPHERE_SSH_KEY"); err != nil {
return err
}
cfg.Spec.Auth.PrivateKey = sshKeyFile
cfg.Spec.Auth.Username = "nvidia"
for _, p := range cache.Status.Properties {
if p.Name == vsphere.IpAddress {
hostUrl = p.Value
Expand All @@ -90,7 +97,7 @@ func entrypoint(log *logger.FunLogger) error {
}

// Run the provisioner
p, err := provisioner.New(log, sshKeyFile, username, hostUrl)
p, err := provisioner.New(log, sshKeyFile, cfg.Spec.Auth.Username, hostUrl)
if err != nil {
return err
}
Expand Down
16 changes: 0 additions & 16 deletions cmd/action/ci/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,6 @@ func newAwsProvider(log *logger.FunLogger, cfg *v1alpha1.Environment) (*aws.Prov
}
}

if err := getSSHKeyFile(log, "AWS_SSH_KEY"); err != nil {
return nil, err
}

// Set auth.PrivateKey
cfg.Spec.Auth.PrivateKey = sshKeyFile
cfg.Spec.Auth.Username = "ubuntu"

// Set env name
setCfgName(cfg)

Expand All @@ -88,14 +80,6 @@ func newVsphereProvider(log *logger.FunLogger, cfg *v1alpha1.Environment) (*vsph
}
}

if err := getSSHKeyFile(log, "VSPHERE_SSH_KEY"); err != nil {
return nil, err
}

// Set auth.PrivateKey
cfg.Spec.Auth.PrivateKey = sshKeyFile
cfg.Spec.Auth.Username = "nvidia"

// Set env name
setCfgName(cfg)

Expand Down
Loading