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

WIP: Moved oVirt installconfig to externalprovider #4517

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
10 changes: 8 additions & 2 deletions pkg/asset/installconfig/installconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ import (
icgcp "github.com/openshift/installer/pkg/asset/installconfig/gcp"
ickubevirt "github.com/openshift/installer/pkg/asset/installconfig/kubevirt"
icopenstack "github.com/openshift/installer/pkg/asset/installconfig/openstack"
icovirt "github.com/openshift/installer/pkg/asset/installconfig/ovirt"
icvsphere "github.com/openshift/installer/pkg/asset/installconfig/vsphere"
"github.com/openshift/installer/pkg/externalprovider"
"github.com/openshift/installer/pkg/types"
"github.com/openshift/installer/pkg/types/conversion"
"github.com/openshift/installer/pkg/types/defaults"
Expand Down Expand Up @@ -190,7 +190,13 @@ func (a *InstallConfig) platformValidation() error {
return icvsphere.Validate(a.Config)
}
if a.Config.Platform.Ovirt != nil {
return icovirt.Validate(a.Config)
return externalprovider.ValidateInstallConfig(
externalprovider.NameOvirt,
a.Config,
a.File,
a.AWS,
a.Azure,
)
}
if a.Config.Platform.OpenStack != nil {
return icopenstack.Validate(a.Config)
Expand Down
13 changes: 13 additions & 0 deletions pkg/externalprovider/provider/defaultprovider/default.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package defaultprovider

import (
"github.com/openshift/installer/pkg/asset"
"github.com/openshift/installer/pkg/asset/installconfig/aws"
"github.com/openshift/installer/pkg/asset/installconfig/azure"
"github.com/openshift/installer/pkg/types"
)

Expand All @@ -13,3 +16,13 @@ type DefaultProvider struct {
func (d *DefaultProvider) AddToInstallConfigPlatform(_ *types.Platform) error {
return nil
}

// ValidateInstallConfig validates the install config.
func (d *DefaultProvider) ValidateInstallConfig(
_ *types.InstallConfig,
_ *asset.File,
_ *aws.Metadata,
_ *azure.Metadata,
) error {
return nil
}
11 changes: 11 additions & 0 deletions pkg/externalprovider/provider/installconfig.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,22 @@
package provider

import (
"github.com/openshift/installer/pkg/asset"
"github.com/openshift/installer/pkg/asset/installconfig/aws"
icazure "github.com/openshift/installer/pkg/asset/installconfig/azure"
"github.com/openshift/installer/pkg/types"
)

// InstallConfigExternalProvider describes the methods required for the installconfig asset.
type InstallConfigExternalProvider interface {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The name is a bit confusing "InstallConfigExternalProvider", I understood that platforms are the "external providers", because of "ExternalProvider is a provider that is not maintained by the core installer team." [1] maybe you should use a different name? it seems like the InstallConfigExternalProvider is something that the installer team will want to maintain

[1]https://github.com/openshift/installer/pull/4517/files?file-filters%5B%5D=.go#diff-95c3eb6370ff093d7d65c61022511d7286d41e57f067925081077b6ded9fb55fR3

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm up for ideas instead of "External Provider", I'd like to wait for some feedback from the installer team on this.

// AddToInstallConfigPlatform adds the current platform to the installconfig.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe change to "adds the current provider to the installconfig Platform"

AddToInstallConfigPlatform(p *types.Platform) error

// ValidateInstallConfig validates the install config.
ValidateInstallConfig(
Config *types.InstallConfig,
File *asset.File,
AWS *aws.Metadata,
Azure *icazure.Metadata,
) error
}
12 changes: 12 additions & 0 deletions pkg/externalprovider/provider/ovirt/installconfig.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package ovirt

import (
"github.com/openshift/installer/pkg/asset"
"github.com/openshift/installer/pkg/asset/installconfig/aws"
icazure "github.com/openshift/installer/pkg/asset/installconfig/azure"
ovirt2 "github.com/openshift/installer/pkg/asset/installconfig/ovirt"
"github.com/openshift/installer/pkg/types"
)
Expand All @@ -15,3 +18,12 @@ func (ovirt *ovirtProvider) AddToInstallConfigPlatform(
p.Ovirt = platform
return nil
}

func (ovirt *ovirtProvider) ValidateInstallConfig(
Config *types.InstallConfig,
_ *asset.File,
_ *aws.Metadata,
_ *icazure.Metadata,
) error {
return ovirt2.Validate(Config)
}
20 changes: 20 additions & 0 deletions pkg/externalprovider/simpleapi.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package externalprovider

import (
"github.com/openshift/installer/pkg/asset"
"github.com/openshift/installer/pkg/asset/installconfig/aws"
icazure "github.com/openshift/installer/pkg/asset/installconfig/azure"
"github.com/openshift/installer/pkg/externalprovider/provider/ovirt"
"github.com/openshift/installer/pkg/types"
)
Expand All @@ -19,3 +22,20 @@ func AddToInstallConfigPlatform(
provider := providerRegistry.MustGet(string(ProviderName))
return provider.AddToInstallConfigPlatform(p)
}

// ValidateInstallConfig validates the install config.
func ValidateInstallConfig(
ProviderName Name,
Config *types.InstallConfig,
File *asset.File,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like most providers will not need File, AWS or Azure...
This is totally a design decision and I can go either way here, maybe a variadic function with the empty interface(a ...interface{}) can replace it?
I just hate to ignore them for all providers just because it is needed by some...

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The API is designed to 1:1 replace the current switch-cases with minimal changes to the code. Adding parameters to existing APIs is harder than adding new API calls.

AWS *aws.Metadata,
Azure *icazure.Metadata,
) error {
provider := providerRegistry.MustGet(string(ProviderName))
return provider.ValidateInstallConfig(
Config,
File,
AWS,
Azure,
)
}