Skip to content

Commit

Permalink
Move vsphere user config to config pkg
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathanmeier5 committed Aug 11, 2022
1 parent 0512381 commit 698ea1d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 13 deletions.
7 changes: 4 additions & 3 deletions pkg/providers/vsphere/validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"net"

anywherev1 "github.com/aws/eks-anywhere/pkg/api/v1alpha1"
"github.com/aws/eks-anywhere/pkg/config"
"github.com/aws/eks-anywhere/pkg/logger"
"github.com/aws/eks-anywhere/pkg/networkutils"
"github.com/aws/eks-anywhere/pkg/types"
Expand Down Expand Up @@ -424,7 +425,7 @@ func (v *Validator) validateControlPlaneIpUniqueness(spec *Spec) error {
return nil
}

func (v *Validator) validateUserPrivs(ctx context.Context, spec *Spec, vuc *VSphereUserConfig) error {
func (v *Validator) validateUserPrivs(ctx context.Context, spec *Spec, vuc *config.VSphereUserConfig) error {
controlPlaneMachineConfig := spec.controlPlaneMachineConfig()

privObjs := []map[string]string{
Expand Down Expand Up @@ -485,7 +486,7 @@ func (v *Validator) validateUserPrivs(ctx context.Context, spec *Spec, vuc *VSph
return v.validatePrivs(ctx, privObjs, vsc)
}

func (v *Validator) validateCSIUserPrivs(ctx context.Context, spec *Spec, vuc *VSphereUserConfig) error {
func (v *Validator) validateCSIUserPrivs(ctx context.Context, spec *Spec, vuc *config.VSphereUserConfig) error {
controlPlaneMachineConfig := spec.controlPlaneMachineConfig()

privObjs := []map[string]string{
Expand Down Expand Up @@ -525,7 +526,7 @@ func (v *Validator) validateCSIUserPrivs(ctx context.Context, spec *Spec, vuc *V
return v.validatePrivs(ctx, privObjs, vsc)
}

func (v *Validator) validateCPUserPrivs(ctx context.Context, spec *Spec, vuc *VSphereUserConfig) error {
func (v *Validator) validateCPUserPrivs(ctx context.Context, spec *Spec, vuc *config.VSphereUserConfig) error {
// CP role just needs read only
privObjs := []map[string]string{
{
Expand Down
13 changes: 3 additions & 10 deletions pkg/providers/vsphere/vsphere.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"github.com/aws/eks-anywhere/pkg/cluster"
"github.com/aws/eks-anywhere/pkg/clusterapi"
"github.com/aws/eks-anywhere/pkg/constants"
"github.com/aws/eks-anywhere/pkg/config"
"github.com/aws/eks-anywhere/pkg/crypto"
"github.com/aws/eks-anywhere/pkg/executables"
"github.com/aws/eks-anywhere/pkg/filewriter"
Expand Down Expand Up @@ -710,16 +711,8 @@ func (vs *VsphereTemplateBuilder) GenerateCAPISpecWorkers(clusterSpec *cluster.S
return templater.AppendYamlResources(workerSpecs...), nil
}

type VSphereUserConfig struct {
EksaVsphereUsername string
EksaVspherePassword string
EksaVsphereCPUsername string
EksaVsphereCPPassword string
EksaVsphereCSIUsername string
EksaVsphereCSIPassword string
}

func NewVsphereUserConfig() *VSphereUserConfig {
func NewVsphereUserConfig() *config.VSphereUserConfig {
eksaVsphereUsername := os.Getenv(EksavSphereUsernameKey)
eksaVspherePassword := os.Getenv(EksavSpherePasswordKey)

Expand All @@ -739,7 +732,7 @@ func NewVsphereUserConfig() *VSphereUserConfig {
eksaCSIPassword = eksaVspherePassword
}

vuc := VSphereUserConfig{
vuc := config.VSphereUserConfig{
eksaVsphereUsername,
eksaVspherePassword,
eksaCPUsername,
Expand Down

0 comments on commit 698ea1d

Please sign in to comment.