From feb636043bca4c7b56330fb845387c3cf50f811c Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 22 Jul 2024 11:37:22 -0600 Subject: [PATCH] deps(deps): update module github.com/validator-labs/validator-plugin-vsphere to v0.0.27 (#80) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit [![Mend Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com) This PR contains the following updates: | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | [github.com/validator-labs/validator-plugin-vsphere](https://togithub.com/validator-labs/validator-plugin-vsphere) | `v0.0.26` -> `v0.0.27` | [![age](https://developer.mend.io/api/mc/badges/age/go/github.com%2fvalidator-labs%2fvalidator-plugin-vsphere/v0.0.27?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://developer.mend.io/api/mc/badges/adoption/go/github.com%2fvalidator-labs%2fvalidator-plugin-vsphere/v0.0.27?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://developer.mend.io/api/mc/badges/compatibility/go/github.com%2fvalidator-labs%2fvalidator-plugin-vsphere/v0.0.26/v0.0.27?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://developer.mend.io/api/mc/badges/confidence/go/github.com%2fvalidator-labs%2fvalidator-plugin-vsphere/v0.0.26/v0.0.27?slim=true)](https://docs.renovatebot.com/merge-confidence/) | --- ### Release Notes
validator-labs/validator-plugin-vsphere (github.com/validator-labs/validator-plugin-vsphere) ### [`v0.0.27`](https://togithub.com/validator-labs/validator-plugin-vsphere/releases/tag/v0.0.27) [Compare Source](https://togithub.com/validator-labs/validator-plugin-vsphere/compare/v0.0.26...v0.0.27) ##### Bug Fixes - always return a ValidationResult from ReconcileComputeResourceValidationRule ([#​297](https://togithub.com/validator-labs/validator-plugin-vsphere/issues/297)) ([1a53fc6](https://togithub.com/validator-labs/validator-plugin-vsphere/commit/1a53fc6b733e82a28dce809122048e0f2adf50c9)) ##### Dependency Updates - **deps:** update golang.org/x/exp digest to [`7f521ea`](https://togithub.com/validator-labs/validator-plugin-vsphere/commit/7f521ea) ([#​285](https://togithub.com/validator-labs/validator-plugin-vsphere/issues/285)) ([598a86f](https://togithub.com/validator-labs/validator-plugin-vsphere/commit/598a86fc33e4784225661204a7df7ba3d39ddc9a)) - **deps:** update module github.com/validator-labs/validator to v0.0.43 ([#​287](https://togithub.com/validator-labs/validator-plugin-vsphere/issues/287)) ([49e45e9](https://togithub.com/validator-labs/validator-plugin-vsphere/commit/49e45e9a790b27d115ca11721897c1e7bb716d35)) - **deps:** update module github.com/vmware/govmomi to v0.38.0 ([#​288](https://togithub.com/validator-labs/validator-plugin-vsphere/issues/288)) ([8a98b24](https://togithub.com/validator-labs/validator-plugin-vsphere/commit/8a98b24c208576517a4c0cde129a1c3bc5a34686)) - **deps:** update dependency go to v1.22.5 ([#​291](https://togithub.com/validator-labs/validator-plugin-vsphere/issues/291)) ([e5d6717](https://togithub.com/validator-labs/validator-plugin-vsphere/commit/e5d671708c338b7c9e3c65391b60817e3c4751a5)) - **deps:** update golang.org/x/exp digest to [`46b0784`](https://togithub.com/validator-labs/validator-plugin-vsphere/commit/46b0784) ([#​292](https://togithub.com/validator-labs/validator-plugin-vsphere/issues/292)) ([fe35643](https://togithub.com/validator-labs/validator-plugin-vsphere/commit/fe35643ca8026cc8b9853f575dbe4c7c53ca5046)) - **deps:** update module github.com/validator-labs/validator to v0.0.44 ([#​295](https://togithub.com/validator-labs/validator-plugin-vsphere/issues/295)) ([c5ba9e0](https://togithub.com/validator-labs/validator-plugin-vsphere/commit/c5ba9e0dd75ad6076e4655e44832c76f9a4cb290)) - **deps:** update module github.com/validator-labs/validator to v0.0.46 ([#​296](https://togithub.com/validator-labs/validator-plugin-vsphere/issues/296)) ([704c063](https://togithub.com/validator-labs/validator-plugin-vsphere/commit/704c06367924f874a81aa805a8249bc436985262)) - **deps:** update module sigs.k8s.io/cluster-api to v1.7.4 ([#​294](https://togithub.com/validator-labs/validator-plugin-vsphere/issues/294)) ([2019561](https://togithub.com/validator-labs/validator-plugin-vsphere/commit/20195613d6189e60076d9d4b4060c8bd197dd0c2)) ##### Refactoring - enable revive and address all lints ([#​293](https://togithub.com/validator-labs/validator-plugin-vsphere/issues/293)) ([3d019e2](https://togithub.com/validator-labs/validator-plugin-vsphere/commit/3d019e27f865fc46d73326ad419a36c2613f176c))
--- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Enabled. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] If you want to rebase/retry this PR, check this box --- This PR was generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View the [repository job log](https://developer.mend.io/github/validator-labs/validatorctl). --------- Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Signed-off-by: Tyler Gillson Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: Tyler Gillson --- go.mod | 4 +- go.sum | 4 +- pkg/components/validator.go | 34 +++++++------- pkg/components/vsphere.go | 18 ++++---- pkg/services/clouds/vmware_service.go | 11 ++--- pkg/services/validator/vmware.go | 44 +++++++++---------- pkg/services/validator/vmware_test.go | 6 +-- .../_validator/testcases/test_validator.go | 14 +++--- 8 files changed, 68 insertions(+), 67 deletions(-) diff --git a/go.mod b/go.mod index e1a9184d..19105110 100644 --- a/go.mod +++ b/go.mod @@ -7,6 +7,7 @@ require ( github.com/L30Bola/aws-policy v0.0.0-20230126045340-5e6118545ac1 github.com/Masterminds/sprig/v3 v3.2.3 github.com/fsnotify/fsnotify v1.7.0 + github.com/go-logr/logr v1.4.2 github.com/google/uuid v1.6.0 github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826 github.com/pkg/errors v0.9.1 @@ -20,7 +21,7 @@ require ( github.com/validator-labs/validator-plugin-azure v0.0.13 github.com/validator-labs/validator-plugin-network v0.0.18 github.com/validator-labs/validator-plugin-oci v0.0.11 - github.com/validator-labs/validator-plugin-vsphere v0.0.26 + github.com/validator-labs/validator-plugin-vsphere v0.0.27 github.com/vmware/govmomi v0.38.0 golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56 gopkg.in/yaml.v2 v2.4.0 @@ -104,7 +105,6 @@ require ( github.com/ghodss/yaml v1.0.0 // indirect github.com/go-chi/chi v4.1.2+incompatible // indirect github.com/go-jose/go-jose/v4 v4.0.2 // indirect - github.com/go-logr/logr v1.4.2 // indirect github.com/go-logr/stdr v1.2.2 // indirect github.com/go-openapi/analysis v0.23.0 // indirect github.com/go-openapi/errors v0.22.0 // indirect diff --git a/go.sum b/go.sum index 7e820c16..87a1e2f6 100644 --- a/go.sum +++ b/go.sum @@ -698,8 +698,8 @@ github.com/validator-labs/validator-plugin-network v0.0.18 h1:UTcDM4afREb/phFxQl github.com/validator-labs/validator-plugin-network v0.0.18/go.mod h1:rLVE0TU8FnrHlLg+G0LQ4TQ2I2hyVxG/pwic4mqhRdY= github.com/validator-labs/validator-plugin-oci v0.0.11 h1:1eRpQNbmXntK//kYj+CsapseDqYX6tCn1csCdDKczKE= github.com/validator-labs/validator-plugin-oci v0.0.11/go.mod h1:nGwq7xPETEitU33oGyrGA6WgC5+fQeojPIo3ifG/RbA= -github.com/validator-labs/validator-plugin-vsphere v0.0.26 h1:Zoe75nhRo9duPAvptKotWnNDAukYHgPP+fMdVI8axz8= -github.com/validator-labs/validator-plugin-vsphere v0.0.26/go.mod h1:wZFC9Td8AinrqFZA4mVUwmnWhe1ZG++B5zJ4OYAB3xw= +github.com/validator-labs/validator-plugin-vsphere v0.0.27 h1:B1XAEzdxI9An3y//cF4zyS1fFjDorERuEASKXopUdEY= +github.com/validator-labs/validator-plugin-vsphere v0.0.27/go.mod h1:y2VFZJTnnR8dlAWra9kbIyFulcIq60AxSTfSbtWObuU= github.com/vbatts/tar-split v0.11.5 h1:3bHCTIheBm1qFTcgh9oPu+nNBtX+XJIupG/vacinCts= github.com/vbatts/tar-split v0.11.5/go.mod h1:yZbwRsSeGjusneWgA781EKej9HF8vme8okylkAeNKLk= github.com/vmware/govmomi v0.38.0 h1:UvQpLAOjDpO0JUxoPCXnEzOlEa/9kejO6K58qOFr6cM= diff --git a/pkg/components/validator.go b/pkg/components/validator.go index cfa9936a..c3288c54 100644 --- a/pkg/components/validator.go +++ b/pkg/components/validator.go @@ -12,8 +12,8 @@ import ( azure "github.com/validator-labs/validator-plugin-azure/api/v1alpha1" network "github.com/validator-labs/validator-plugin-network/api/v1alpha1" oci "github.com/validator-labs/validator-plugin-oci/api/v1alpha1" - vsphere "github.com/validator-labs/validator-plugin-vsphere/api/v1alpha1" - vsphere_cloud "github.com/validator-labs/validator-plugin-vsphere/pkg/vsphere" + vsphereapi "github.com/validator-labs/validator-plugin-vsphere/api/v1alpha1" + "github.com/validator-labs/validator-plugin-vsphere/pkg/vsphere" validator "github.com/validator-labs/validator/api/v1alpha1" cfg "github.com/validator-labs/validatorctl/pkg/config" @@ -108,8 +108,8 @@ func NewValidatorConfig() *ValidatorConfig { BasicAuth: &BasicAuth{}, Data: make(map[string]string), }, - Validator: &vsphere.VsphereValidatorSpec{}, - Account: &vsphere_cloud.VsphereCloudAccount{}, + Validator: &vsphereapi.VsphereValidatorSpec{}, + Account: &vsphere.CloudAccount{}, }, } } @@ -456,14 +456,14 @@ func (c *OCIPluginConfig) decrypt() error { // VspherePluginConfig represents the vSphere plugin configuration. type VspherePluginConfig struct { - Enabled bool `yaml:"enabled"` - Release *validator.HelmRelease `yaml:"helmRelease"` - ReleaseSecret *Secret `yaml:"helmReleaseSecret"` - Account *vsphere_cloud.VsphereCloudAccount `yaml:"account"` - Validator *vsphere.VsphereValidatorSpec `yaml:"validator"` - VsphereEntityPrivilegeRules []VsphereEntityPrivilegeRule `yaml:"vsphereEntityPrivilegeRules"` - VsphereRolePrivilegeRules []VsphereRolePrivilegeRule `yaml:"vsphereRolePrivilegeRules"` - VsphereTagRules []VsphereTagRule `yaml:"vsphereTagRules"` + Enabled bool `yaml:"enabled"` + Release *validator.HelmRelease `yaml:"helmRelease"` + ReleaseSecret *Secret `yaml:"helmReleaseSecret"` + Account *vsphere.CloudAccount `yaml:"account"` + Validator *vsphereapi.VsphereValidatorSpec `yaml:"validator"` + VsphereEntityPrivilegeRules []VsphereEntityPrivilegeRule `yaml:"vsphereEntityPrivilegeRules"` + VsphereRolePrivilegeRules []VsphereRolePrivilegeRule `yaml:"vsphereRolePrivilegeRules"` + VsphereTagRules []VsphereTagRule `yaml:"vsphereTagRules"` } func (c *VspherePluginConfig) encrypt() error { @@ -500,19 +500,19 @@ func (c *VspherePluginConfig) decrypt() error { // VsphereEntityPrivilegeRule represents a vSphere entity privilege rule. type VsphereEntityPrivilegeRule struct { - vsphere.EntityPrivilegeValidationRule `yaml:",inline"` - ClusterScoped bool `yaml:"clusterScoped"` + vsphereapi.EntityPrivilegeValidationRule `yaml:",inline"` + ClusterScoped bool `yaml:"clusterScoped"` } // VsphereRolePrivilegeRule represents a vSphere role privilege rule. type VsphereRolePrivilegeRule struct { - vsphere.GenericRolePrivilegeValidationRule `yaml:",inline"` - Name string `yaml:"name"` + vsphereapi.GenericRolePrivilegeValidationRule `yaml:",inline"` + Name string `yaml:"name"` } // VsphereTagRule represents a vSphere tag rule. type VsphereTagRule struct { - vsphere.TagValidationRule `yaml:",inline"` + vsphereapi.TagValidationRule `yaml:",inline"` } // PublicKeySecret represents a public key secret. diff --git a/pkg/components/vsphere.go b/pkg/components/vsphere.go index da91e920..21a251a6 100644 --- a/pkg/components/vsphere.go +++ b/pkg/components/vsphere.go @@ -3,7 +3,7 @@ package components import ( "fmt" - vsphere_api "github.com/validator-labs/validator-plugin-vsphere/api/v1alpha1" + vsphereapi "github.com/validator-labs/validator-plugin-vsphere/api/v1alpha1" "github.com/validator-labs/validator-plugin-vsphere/pkg/vsphere" vapi "github.com/validator-labs/validator/api/v1alpha1" @@ -18,8 +18,8 @@ type VsphereConfig struct { Datacenter string ClusterName string ImageTemplateFolder string - NodePoolResourceRequirements []vsphere_api.NodepoolResourceRequirement - TagValidationRules []vsphere_api.TagValidationRule + NodePoolResourceRequirements []vsphereapi.NodepoolResourceRequirement + TagValidationRules []vsphereapi.TagValidationRule Privileges []string } @@ -39,18 +39,18 @@ func ConfigureVspherePlugin(vc *ValidatorConfig, config VsphereConfig) { ReleaseSecret: &Secret{ Name: fmt.Sprintf("validator-helm-release-%s", cfg.ValidatorPluginVsphere), }, - Account: &vsphere.VsphereCloudAccount{ + Account: &vsphere.CloudAccount{ Insecure: true, Username: config.Username, Password: config.Password, VcenterServer: config.VcenterServer, }, - Validator: &vsphere_api.VsphereValidatorSpec{ - Auth: vsphere_api.VsphereAuth{ + Validator: &vsphereapi.VsphereValidatorSpec{ + Auth: vsphereapi.VsphereAuth{ SecretName: "vsphere-creds", }, Datacenter: config.Datacenter, - ComputeResourceRules: []vsphere_api.ComputeResourceRule{ + ComputeResourceRules: []vsphereapi.ComputeResourceRule{ { Name: "Cluster Compute Resource Availability", ClusterName: config.ClusterName, @@ -59,7 +59,7 @@ func ConfigureVspherePlugin(vc *ValidatorConfig, config VsphereConfig) { NodepoolResourceRequirements: config.NodePoolResourceRequirements, }, }, - EntityPrivilegeValidationRules: []vsphere_api.EntityPrivilegeValidationRule{ + EntityPrivilegeValidationRules: []vsphereapi.EntityPrivilegeValidationRule{ { Name: "Create folder: image template folder", Username: config.Username, @@ -68,7 +68,7 @@ func ConfigureVspherePlugin(vc *ValidatorConfig, config VsphereConfig) { Privileges: []string{"Folder.Create"}, }, }, - RolePrivilegeValidationRules: []vsphere_api.GenericRolePrivilegeValidationRule{ + RolePrivilegeValidationRules: []vsphereapi.GenericRolePrivilegeValidationRule{ { Username: config.Username, Privileges: config.Privileges, diff --git a/pkg/services/clouds/vmware_service.go b/pkg/services/clouds/vmware_service.go index d9578655..49205856 100644 --- a/pkg/services/clouds/vmware_service.go +++ b/pkg/services/clouds/vmware_service.go @@ -6,6 +6,7 @@ import ( "fmt" "os" + "github.com/go-logr/logr" "github.com/pkg/errors" "github.com/spectrocloud-labs/prompts-tui/prompts" @@ -18,7 +19,7 @@ import ( var GetVSphereDriver = getVSphereDriver // ReadVsphereAccountProps prompts the user to configure vSphere account properties -func ReadVsphereAccountProps(account *vsphere.VsphereCloudAccount) error { +func ReadVsphereAccountProps(account *vsphere.CloudAccount) error { vcenterServer := account.VcenterServer username := account.Username password := account.Password @@ -72,12 +73,12 @@ func ReadVsphereAccountProps(account *vsphere.VsphereCloudAccount) error { return nil } -func getVSphereDriver(account *vsphere.VsphereCloudAccount) (vsphere.VsphereDriver, error) { - return vsphere.NewVSphereDriver(account.VcenterServer, account.Username, account.Password, "") +func getVSphereDriver(account *vsphere.CloudAccount) (vsphere.Driver, error) { + return vsphere.NewVSphereDriver(account.VcenterServer, account.Username, account.Password, "", logr.Logger{}) } // ValidateCloudAccountVsphere validates that the provided vSphere cloud account is valid -func ValidateCloudAccountVsphere(account *vsphere.VsphereCloudAccount) error { +func ValidateCloudAccountVsphere(account *vsphere.CloudAccount) error { driver, err := GetVSphereDriver(account) if err != nil { return err @@ -86,7 +87,7 @@ func ValidateCloudAccountVsphere(account *vsphere.VsphereCloudAccount) error { ctx, cancel := context.WithCancel(context.Background()) defer cancel() - isValid, err := driver.IsValidVSphereCredentials(ctx) + isValid, err := driver.IsValidVSphereCredentials() if err != nil { return err } diff --git a/pkg/services/validator/vmware.go b/pkg/services/validator/vmware.go index 58bf282d..cf5fa47d 100644 --- a/pkg/services/validator/vmware.go +++ b/pkg/services/validator/vmware.go @@ -167,7 +167,7 @@ func initVsphereRule[R vSphereRule](r R, ruleType, message string, ruleNames *[] } // nolint:dupl -func configureNtpRules(ctx context.Context, c *components.VspherePluginConfig, driver vsphere.VsphereDriver, ruleNames *[]string) error { +func configureNtpRules(ctx context.Context, c *components.VspherePluginConfig, driver vsphere.Driver, ruleNames *[]string) error { log.InfoCLI(` NTP validation ensures that ntpd is enabled and running on a set of ESXi hosts. If enabled, you will be prompted to select one or more of ESXi hosts. @@ -214,7 +214,7 @@ func configureNtpRules(ctx context.Context, c *components.VspherePluginConfig, d return nil } -func readNtpRule(ctx context.Context, c *components.VspherePluginConfig, r *v1alpha1.NTPValidationRule, driver vsphere.VsphereDriver, idx int, ruleNames *[]string) error { +func readNtpRule(ctx context.Context, c *components.VspherePluginConfig, r *v1alpha1.NTPValidationRule, driver vsphere.Driver, idx int, ruleNames *[]string) error { err := initVsphereRule(r, "NTP", "The rule's ESXi host selection will be replaced.", ruleNames) if err != nil { return err @@ -237,7 +237,7 @@ func readNtpRule(ctx context.Context, c *components.VspherePluginConfig, r *v1al return nil } -func selectEsxiHosts(ctx context.Context, datacenter string, clusterName string, driver vsphere.VsphereDriver) ([]string, error) { +func selectEsxiHosts(ctx context.Context, datacenter string, clusterName string, driver vsphere.Driver) ([]string, error) { hosts, err := driver.GetVSphereHostSystems(ctx, datacenter, clusterName) if err != nil { return nil, errors.Wrap(err, "failed to list vSphere ESXi hosts") @@ -270,7 +270,7 @@ func selectEsxiHosts(ctx context.Context, datacenter string, clusterName string, return selectedHosts, nil } -func configureRolePrivilegeRules(c *components.VspherePluginConfig, ruleNames *[]string, vSphereCloudDriver vsphere.VsphereDriver) error { +func configureRolePrivilegeRules(c *components.VspherePluginConfig, ruleNames *[]string, vSphereCloudDriver vsphere.Driver) error { log.InfoCLI(` Role privilege validation ensures that a vSphere user has a specific set of root-level vSphere privileges. @@ -413,7 +413,7 @@ func selectPrivileges(allPrivileges []string) ([]string, error) { return selectedPrivileges, nil } -func configureEntityPrivilegeRules(ctx context.Context, c *components.VspherePluginConfig, driver vsphere.VsphereDriver, ruleNames *[]string, vSphereCloudDriver vsphere.VsphereDriver) error { +func configureEntityPrivilegeRules(ctx context.Context, c *components.VspherePluginConfig, driver vsphere.Driver, ruleNames *[]string, vSphereCloudDriver vsphere.Driver) error { log.InfoCLI(` Entity privilege validation ensures that a vSphere user has certain privileges with respect to a specific vSphere resource. @@ -468,7 +468,7 @@ func configureEntityPrivilegeRules(ctx context.Context, c *components.VspherePlu return nil } -func readEntityPrivilegeRule(ctx context.Context, c *components.VspherePluginConfig, r *components.VsphereEntityPrivilegeRule, driver vsphere.VsphereDriver, idx int, ruleNames *[]string, isAdmin bool) error { +func readEntityPrivilegeRule(ctx context.Context, c *components.VspherePluginConfig, r *components.VsphereEntityPrivilegeRule, driver vsphere.Driver, idx int, ruleNames *[]string, isAdmin bool) error { var err error var initMsg string reconfigureEntity := true @@ -501,7 +501,7 @@ func readEntityPrivilegeRule(ctx context.Context, c *components.VspherePluginCon return nil } -func readEntityPrivileges(ctx context.Context, c *components.VspherePluginConfig, r *components.VsphereEntityPrivilegeRule, driver vsphere.VsphereDriver, isAdmin, reconfigureEntity bool) error { +func readEntityPrivileges(ctx context.Context, c *components.VspherePluginConfig, r *components.VsphereEntityPrivilegeRule, driver vsphere.Driver, isAdmin, reconfigureEntity bool) error { var err error if isAdmin { @@ -533,7 +533,7 @@ func readEntityPrivileges(ctx context.Context, c *components.VspherePluginConfig } // nolint:dupl -func configureResourceRequirementRules(ctx context.Context, c *components.VspherePluginConfig, driver vsphere.VsphereDriver, ruleNames *[]string) error { +func configureResourceRequirementRules(ctx context.Context, c *components.VspherePluginConfig, driver vsphere.Driver, ruleNames *[]string) error { log.InfoCLI(` Resource requirement validation ensures that sufficient capacity is available within a vSphere Datacenter or Cluster for a configurable number of VMs with specific CPU, RAM, and Storage minimums. @@ -580,7 +580,7 @@ func configureResourceRequirementRules(ctx context.Context, c *components.Vspher return nil } -func readResourceRequirementRule(ctx context.Context, c *components.VspherePluginConfig, r *v1alpha1.ComputeResourceRule, driver vsphere.VsphereDriver, idx int, ruleNames *[]string) error { +func readResourceRequirementRule(ctx context.Context, c *components.VspherePluginConfig, r *v1alpha1.ComputeResourceRule, driver vsphere.Driver, idx int, ruleNames *[]string) error { err := initVsphereRule(r, "resource requirement", "", ruleNames) if err != nil { return err @@ -671,7 +671,7 @@ func readResourceRequirements(r *v1alpha1.ComputeResourceRule, n *v1alpha1.Nodep return nil } -func configureVsphereTagRules(ctx context.Context, c *components.VspherePluginConfig, driver vsphere.VsphereDriver, ruleNames *[]string) error { +func configureVsphereTagRules(ctx context.Context, c *components.VspherePluginConfig, driver vsphere.Driver, ruleNames *[]string) error { log.InfoCLI(` Tag validation ensures that a specific tag is present on a particular vSphere resource. `) @@ -720,7 +720,7 @@ func configureVsphereTagRules(ctx context.Context, c *components.VspherePluginCo return nil } -func readVsphereTagRule(ctx context.Context, c *components.VspherePluginConfig, r *components.VsphereTagRule, driver vsphere.VsphereDriver, idx int, ruleNames *[]string) error { +func readVsphereTagRule(ctx context.Context, c *components.VspherePluginConfig, r *components.VsphereTagRule, driver vsphere.Driver, idx int, ruleNames *[]string) error { err := initVsphereRule(r, "tag", "", ruleNames) if err != nil { return err @@ -741,7 +741,7 @@ func readVsphereTagRule(ctx context.Context, c *components.VspherePluginConfig, return nil } -func readCustomVsphereTagRule(ctx context.Context, c *components.VspherePluginConfig, r *components.VsphereTagRule, driver vsphere.VsphereDriver) error { +func readCustomVsphereTagRule(ctx context.Context, c *components.VspherePluginConfig, r *components.VsphereTagRule, driver vsphere.Driver) error { var err error r.EntityType, r.EntityName, r.ClusterName, err = getEntityInfo(ctx, r.EntityType, "Entity Type", c.Validator.Datacenter, cfg.ValidatorPluginVsphereEntities, driver) if err != nil { @@ -754,7 +754,7 @@ func readCustomVsphereTagRule(ctx context.Context, c *components.VspherePluginCo return nil } -func getClusterScopedInfo(ctx context.Context, datacenter, entityType string, driver vsphere.VsphereDriver) (bool, string, error) { +func getClusterScopedInfo(ctx context.Context, datacenter, entityType string, driver vsphere.Driver) (bool, string, error) { var clusterName string clusterScopedPrompt := fmt.Sprintf("Is %s cluster scoped", entityType) @@ -772,7 +772,7 @@ func getClusterScopedInfo(ctx context.Context, datacenter, entityType string, dr return clusterScoped, clusterName, nil } -func getClusterName(ctx context.Context, datacenter string, driver vsphere.VsphereDriver) (string, error) { +func getClusterName(ctx context.Context, datacenter string, driver vsphere.Driver) (string, error) { clusterList, err := driver.GetVSphereClusters(ctx, datacenter) if err != nil { return "", errors.Wrap(err, "failed to list vSphere clusters") @@ -784,7 +784,7 @@ func getClusterName(ctx context.Context, datacenter string, driver vsphere.Vsphe return clusterName, nil } -func getEntityInfo(ctx context.Context, entityType, entityTypePrompt, datacenter string, entityTypesList []string, driver vsphere.VsphereDriver) (string, string, string, error) { +func getEntityInfo(ctx context.Context, entityType, entityTypePrompt, datacenter string, entityTypesList []string, driver vsphere.Driver) (string, string, string, error) { var err error if entityType == "" { entityType, err = prompts.Select(entityTypePrompt, entityTypesList) @@ -809,7 +809,7 @@ func getEntityInfo(ctx context.Context, entityType, entityTypePrompt, datacenter return validatorEntityType, entityName, clusterName, err } -func getEntityAndClusterInfo(ctx context.Context, entityType string, driver vsphere.VsphereDriver, datacenter string) (entityName, clusterName string, err error) { +func getEntityAndClusterInfo(ctx context.Context, entityType string, driver vsphere.Driver, datacenter string) (entityName, clusterName string, err error) { switch entityType { case cfg.ValidatorVsphereEntityCluster, "cluster": entityName, err = getClusterName(ctx, datacenter, driver) @@ -846,7 +846,7 @@ func getEntityAndClusterInfo(ctx context.Context, entityType string, driver vsph } } -func handleDatacenterEntity(ctx context.Context, driver vsphere.VsphereDriver) (string, error) { +func handleDatacenterEntity(ctx context.Context, driver vsphere.Driver) (string, error) { dcList, err := driver.GetVSphereDatacenters(ctx) if err != nil { return "", err @@ -858,7 +858,7 @@ func handleDatacenterEntity(ctx context.Context, driver vsphere.VsphereDriver) ( return dcName, nil } -func handleFolderEntity(ctx context.Context, driver vsphere.VsphereDriver, datacenter string) (string, error) { +func handleFolderEntity(ctx context.Context, driver vsphere.Driver, datacenter string) (string, error) { folderList, err := driver.GetVSphereVMFolders(ctx, datacenter) if err != nil { return "", err @@ -870,7 +870,7 @@ func handleFolderEntity(ctx context.Context, driver vsphere.VsphereDriver, datac return folderName, nil } -func handleHostEntity(ctx context.Context, driver vsphere.VsphereDriver, datacenter, entityType string) (string, string, error) { +func handleHostEntity(ctx context.Context, driver vsphere.Driver, datacenter, entityType string) (string, string, error) { _, clusterName, err := getClusterScopedInfo(ctx, datacenter, entityType, driver) if err != nil { return "", "", err @@ -890,7 +890,7 @@ func handleHostEntity(ctx context.Context, driver vsphere.VsphereDriver, datacen return hostName, clusterName, nil } -func handleResourcePoolEntity(ctx context.Context, driver vsphere.VsphereDriver, datacenter string, entityType string) (string, string, error) { +func handleResourcePoolEntity(ctx context.Context, driver vsphere.Driver, datacenter string, entityType string) (string, string, error) { allResourcePools := make([]*object.ResourcePool, 0) clusterScoped, clusterName, err := getClusterScopedInfo(ctx, datacenter, entityType, driver) @@ -940,7 +940,7 @@ func handleResourcePoolEntity(ctx context.Context, driver vsphere.VsphereDriver, return choice.ID, rpClusterMapping[choice.Name], nil } -func handleVAppEntity(ctx context.Context, driver vsphere.VsphereDriver) (string, error) { +func handleVAppEntity(ctx context.Context, driver vsphere.Driver) (string, error) { vApps, err := driver.GetVapps(ctx) if err != nil { return "", err @@ -956,7 +956,7 @@ func handleVAppEntity(ctx context.Context, driver vsphere.VsphereDriver) (string return vAppName, nil } -func handleVMEntity(ctx context.Context, driver vsphere.VsphereDriver, datacenter string, entityType string) (string, string, error) { +func handleVMEntity(ctx context.Context, driver vsphere.Driver, datacenter string, entityType string) (string, string, error) { clusterScoped, clusterName, err := getClusterScopedInfo(ctx, datacenter, entityType, driver) if err != nil { return "", "", err diff --git a/pkg/services/validator/vmware_test.go b/pkg/services/validator/vmware_test.go index df560394..4bc164e1 100644 --- a/pkg/services/validator/vmware_test.go +++ b/pkg/services/validator/vmware_test.go @@ -26,7 +26,7 @@ var vSphereDummyConfig = &components.ValidatorConfig{ Chart: v1alpha1.HelmChart{}, }, ReleaseSecret: &components.Secret{}, - Account: &vsphere.VsphereCloudAccount{}, + Account: &vsphere.CloudAccount{}, Validator: &vsphereapi.VsphereValidatorSpec{}, }, Release: &v1alpha1.HelmRelease{ @@ -37,7 +37,7 @@ var vSphereDummyConfig = &components.ValidatorConfig{ var ( tui prompts.TUI - vSphereDriverFunc func(account *vsphere.VsphereCloudAccount) (vsphere.VsphereDriver, error) + vSphereDriverFunc func(account *vsphere.CloudAccount) (vsphere.Driver, error) ) func setup(returnVals []string) { @@ -45,7 +45,7 @@ func setup(returnVals []string) { prompts.Tui = &tuimocks.MockTUI{ReturnVals: returnVals} vSphereDriverFunc = clouds.GetVSphereDriver - clouds.GetVSphereDriver = func(account *vsphere.VsphereCloudAccount) (vsphere.VsphereDriver, error) { + clouds.GetVSphereDriver = func(account *vsphere.CloudAccount) (vsphere.Driver, error) { return vsphere.MockVsphereDriver{}, nil } } diff --git a/tests/integration/_validator/testcases/test_validator.go b/tests/integration/_validator/testcases/test_validator.go index 030864d5..843d9369 100644 --- a/tests/integration/_validator/testcases/test_validator.go +++ b/tests/integration/_validator/testcases/test_validator.go @@ -9,7 +9,7 @@ import ( log "github.com/sirupsen/logrus" "github.com/spectrocloud-labs/prompts-tui/prompts" tuimocks "github.com/spectrocloud-labs/prompts-tui/prompts/mocks" - vsphere_cloud "github.com/validator-labs/validator-plugin-vsphere/pkg/vsphere" + "github.com/validator-labs/validator-plugin-vsphere/pkg/vsphere" cfg "github.com/validator-labs/validatorctl/pkg/config" "github.com/validator-labs/validatorctl/pkg/services/clouds" @@ -67,11 +67,11 @@ func (t *ValidatorTest) testDeployInteractive(ctx *test.TestContext) (tr *test.T interactiveCmd, buffer := common.InitCmd([]string{"install", "-o", "-l", "debug"}) - vsphereDriverMock := vsphere_cloud.MockVsphereDriver{ + vsphereDriverMock := vsphere.MockVsphereDriver{ Datacenters: []string{"DC0"}, Clusters: []string{"C0", "C1", "C2", "C3", "C4"}, VMFolders: []string{"spectro-templates", "test"}, - HostSystems: map[string][]vsphere_cloud.VSphereHostSystem{ + HostSystems: map[string][]vsphere.HostSystem{ "DC0_C0": { { Name: "DC0_C0_H0", @@ -91,7 +91,7 @@ func (t *ValidatorTest) testDeployInteractive(ctx *test.TestContext) (tr *test.T vsphereDriverFunc := clouds.GetVSphereDriver ctx.Put("vsphereDriverFunc", vsphereDriverFunc) - clouds.GetVSphereDriver = func(account *vsphere_cloud.VsphereCloudAccount) (vsphere_cloud.VsphereDriver, error) { + clouds.GetVSphereDriver = func(account *vsphere.CloudAccount) (vsphere.Driver, error) { return vsphereDriverMock, nil } @@ -462,8 +462,8 @@ func (t *ValidatorTest) testUpdatePasswords() (tr *test.TestResult) { "install", "-f", t.filePath(cfg.ValidatorConfigFile), "-p", }) - clouds.GetVSphereDriver = func(account *vsphere_cloud.VsphereCloudAccount) (vsphere_cloud.VsphereDriver, error) { - return vsphere_cloud.MockVsphereDriver{}, nil + clouds.GetVSphereDriver = func(account *vsphere.CloudAccount) (vsphere.Driver, error) { + return vsphere.MockVsphereDriver{}, nil } prompts.Tui = &tuimocks.MockTUI{ @@ -539,7 +539,7 @@ func (t *ValidatorTest) TearDown(ctx *test.TestContext) { // restore clouds.GetVSphereDriver vsphereDriverFunc := ctx.Get("vsphereDriverFunc") - clouds.GetVSphereDriver = vsphereDriverFunc.(func(account *vsphere_cloud.VsphereCloudAccount) (vsphere_cloud.VsphereDriver, error)) + clouds.GetVSphereDriver = vsphereDriverFunc.(func(account *vsphere.CloudAccount) (vsphere.Driver, error)) } // updateTestData updates the hard-coded validator config used in silent installation tests