Skip to content

Commit

Permalink
Merge pull request #140 from ArangoGutierrez/cache_handling
Browse files Browse the repository at this point in the history
Only read sshkeys during provisioning
  • Loading branch information
ArangoGutierrez authored Aug 8, 2024
2 parents ebe4516 + 1de7ca9 commit fd7f312
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 22 deletions.
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

0 comments on commit fd7f312

Please sign in to comment.