From 5a77d63681e9857ba4e5d6b68097d48ed8a6a49c Mon Sep 17 00:00:00 2001 From: James Tumber Date: Fri, 6 Oct 2023 15:51:35 +0100 Subject: [PATCH] caa: Move provider inclusion out of cloudmgr Move the init code to each provider's manager, and include the provider packages, at the cmd level instead. Signed-off-by: James Tumber --- cmd/cloud-api-adaptor/aws.go | 10 ++++++ cmd/cloud-api-adaptor/azure.go | 10 ++++++ cmd/cloud-api-adaptor/ibmcloud.go | 10 ++++++ cmd/cloud-api-adaptor/ibmcloud_powervs.go | 10 ++++++ cmd/cloud-api-adaptor/libvirt.go | 10 ++++++ cmd/cloud-api-adaptor/main.go | 6 ++-- cmd/cloud-api-adaptor/vsphere.go | 10 ++++++ pkg/adaptor/cloud/cloudmgr/aws.go | 14 -------- pkg/adaptor/cloud/cloudmgr/azure.go | 14 -------- pkg/adaptor/cloud/cloudmgr/ibmcloud.go | 14 -------- .../cloud/cloudmgr/ibmcloud_powervs.go | 14 -------- pkg/adaptor/cloud/cloudmgr/libvirt.go | 14 -------- pkg/adaptor/cloud/cloudmgr/manager.go | 33 ------------------- pkg/adaptor/cloud/cloudmgr/vsphere.go | 14 -------- 14 files changed, 63 insertions(+), 120 deletions(-) create mode 100644 cmd/cloud-api-adaptor/aws.go create mode 100644 cmd/cloud-api-adaptor/azure.go create mode 100644 cmd/cloud-api-adaptor/ibmcloud.go create mode 100644 cmd/cloud-api-adaptor/ibmcloud_powervs.go create mode 100644 cmd/cloud-api-adaptor/libvirt.go create mode 100644 cmd/cloud-api-adaptor/vsphere.go delete mode 100644 pkg/adaptor/cloud/cloudmgr/aws.go delete mode 100644 pkg/adaptor/cloud/cloudmgr/azure.go delete mode 100644 pkg/adaptor/cloud/cloudmgr/ibmcloud.go delete mode 100644 pkg/adaptor/cloud/cloudmgr/ibmcloud_powervs.go delete mode 100644 pkg/adaptor/cloud/cloudmgr/libvirt.go delete mode 100644 pkg/adaptor/cloud/cloudmgr/manager.go delete mode 100644 pkg/adaptor/cloud/cloudmgr/vsphere.go diff --git a/cmd/cloud-api-adaptor/aws.go b/cmd/cloud-api-adaptor/aws.go new file mode 100644 index 000000000..ed2248c59 --- /dev/null +++ b/cmd/cloud-api-adaptor/aws.go @@ -0,0 +1,10 @@ +//go:build aws + +// (C) Copyright Confidential Containers Contributors +// SPDX-License-Identifier: Apache-2.0 + +package main + +import ( + _ "github.com/confidential-containers/cloud-api-adaptor/pkg/adaptor/cloud/aws" +) diff --git a/cmd/cloud-api-adaptor/azure.go b/cmd/cloud-api-adaptor/azure.go new file mode 100644 index 000000000..8dfc77128 --- /dev/null +++ b/cmd/cloud-api-adaptor/azure.go @@ -0,0 +1,10 @@ +//go:build azure + +// (C) Copyright Confidential Containers Contributors +// SPDX-License-Identifier: Apache-2.0 + +package main + +import ( + _ "github.com/confidential-containers/cloud-api-adaptor/pkg/adaptor/cloud/azure" +) diff --git a/cmd/cloud-api-adaptor/ibmcloud.go b/cmd/cloud-api-adaptor/ibmcloud.go new file mode 100644 index 000000000..e22ca9a4e --- /dev/null +++ b/cmd/cloud-api-adaptor/ibmcloud.go @@ -0,0 +1,10 @@ +//go:build ibmcloud + +// (C) Copyright Confidential Containers Contributors +// SPDX-License-Identifier: Apache-2.0 + +package main + +import ( + _ "github.com/confidential-containers/cloud-api-adaptor/pkg/adaptor/cloud/ibmcloud" +) diff --git a/cmd/cloud-api-adaptor/ibmcloud_powervs.go b/cmd/cloud-api-adaptor/ibmcloud_powervs.go new file mode 100644 index 000000000..ebde60f5c --- /dev/null +++ b/cmd/cloud-api-adaptor/ibmcloud_powervs.go @@ -0,0 +1,10 @@ +//go:build ibmcloud_powervs + +// (C) Copyright Confidential Containers Contributors +// SPDX-License-Identifier: Apache-2.0 + +package main + +import ( + _ "github.com/confidential-containers/cloud-api-adaptor/pkg/adaptor/cloud/ibmcloud-powervs" +) diff --git a/cmd/cloud-api-adaptor/libvirt.go b/cmd/cloud-api-adaptor/libvirt.go new file mode 100644 index 000000000..05301a923 --- /dev/null +++ b/cmd/cloud-api-adaptor/libvirt.go @@ -0,0 +1,10 @@ +//go:build libvirt + +// (C) Copyright Confidential Containers Contributors +// SPDX-License-Identifier: Apache-2.0 + +package main + +import ( + _ "github.com/confidential-containers/cloud-api-adaptor/pkg/adaptor/cloud/libvirt" +) diff --git a/cmd/cloud-api-adaptor/main.go b/cmd/cloud-api-adaptor/main.go index d068b4a77..622c96216 100644 --- a/cmd/cloud-api-adaptor/main.go +++ b/cmd/cloud-api-adaptor/main.go @@ -12,7 +12,7 @@ import ( "github.com/confidential-containers/cloud-api-adaptor/cmd" "github.com/confidential-containers/cloud-api-adaptor/pkg/adaptor" - "github.com/confidential-containers/cloud-api-adaptor/pkg/adaptor/cloud/cloudmgr" + "github.com/confidential-containers/cloud-api-adaptor/pkg/adaptor/cloud" "github.com/confidential-containers/cloud-api-adaptor/pkg/adaptor/proxy" daemon "github.com/confidential-containers/cloud-api-adaptor/pkg/forwarder" "github.com/confidential-containers/cloud-api-adaptor/pkg/podnetwork/tunneler/vxlan" @@ -41,7 +41,7 @@ func printHelp(out io.Writer) { fmt.Fprintln(out) fmt.Fprintln(out, "Supported cloud providers are:") - for _, name := range cloudmgr.List() { + for _, name := range cloud.List() { fmt.Fprintf(out, "\t%s\n", name) } fmt.Fprintln(out) @@ -74,7 +74,7 @@ func (cfg *daemonConfig) Setup() (cmd.Starter, error) { cmd.Exit(1) } - cloud := cloudmgr.Get(cloudName) + cloud := cloud.Get(cloudName) if cloud == nil { fmt.Fprintf(os.Stderr, "%s: Unsupported cloud provider: %s\n\n", programName, cloudName) diff --git a/cmd/cloud-api-adaptor/vsphere.go b/cmd/cloud-api-adaptor/vsphere.go new file mode 100644 index 000000000..d7d63225c --- /dev/null +++ b/cmd/cloud-api-adaptor/vsphere.go @@ -0,0 +1,10 @@ +//go:build vsphere + +// (C) Copyright Confidential Containers Contributors +// SPDX-License-Identifier: Apache-2.0 + +package main + +import ( + _ "github.com/confidential-containers/cloud-api-adaptor/pkg/adaptor/cloud/vsphere" +) diff --git a/pkg/adaptor/cloud/cloudmgr/aws.go b/pkg/adaptor/cloud/cloudmgr/aws.go deleted file mode 100644 index 9e264ea51..000000000 --- a/pkg/adaptor/cloud/cloudmgr/aws.go +++ /dev/null @@ -1,14 +0,0 @@ -//go:build aws - -// (C) Copyright Confidential Containers Contributors -// SPDX-License-Identifier: Apache-2.0 - -package cloudmgr - -import ( - "github.com/confidential-containers/cloud-api-adaptor/pkg/adaptor/cloud/aws" -) - -func init() { - cloudTable["aws"] = &aws.Manager{} -} diff --git a/pkg/adaptor/cloud/cloudmgr/azure.go b/pkg/adaptor/cloud/cloudmgr/azure.go deleted file mode 100644 index 3610bca86..000000000 --- a/pkg/adaptor/cloud/cloudmgr/azure.go +++ /dev/null @@ -1,14 +0,0 @@ -//go:build azure - -// (C) Copyright Confidential Containers Contributors -// SPDX-License-Identifier: Apache-2.0 - -package cloudmgr - -import ( - "github.com/confidential-containers/cloud-api-adaptor/pkg/adaptor/cloud/azure" -) - -func init() { - cloudTable["azure"] = &azure.Manager{} -} diff --git a/pkg/adaptor/cloud/cloudmgr/ibmcloud.go b/pkg/adaptor/cloud/cloudmgr/ibmcloud.go deleted file mode 100644 index 0e37b9b4a..000000000 --- a/pkg/adaptor/cloud/cloudmgr/ibmcloud.go +++ /dev/null @@ -1,14 +0,0 @@ -//go:build ibmcloud - -// (C) Copyright Confidential Containers Contributors -// SPDX-License-Identifier: Apache-2.0 - -package cloudmgr - -import ( - "github.com/confidential-containers/cloud-api-adaptor/pkg/adaptor/cloud/ibmcloud" -) - -func init() { - cloudTable["ibmcloud"] = &ibmcloud.Manager{} -} diff --git a/pkg/adaptor/cloud/cloudmgr/ibmcloud_powervs.go b/pkg/adaptor/cloud/cloudmgr/ibmcloud_powervs.go deleted file mode 100644 index a7d678717..000000000 --- a/pkg/adaptor/cloud/cloudmgr/ibmcloud_powervs.go +++ /dev/null @@ -1,14 +0,0 @@ -//go:build ibmcloud_powervs - -// (C) Copyright Confidential Containers Contributors -// SPDX-License-Identifier: Apache-2.0 - -package cloudmgr - -import ( - powervs "github.com/confidential-containers/cloud-api-adaptor/pkg/adaptor/cloud/ibmcloud-powervs" -) - -func init() { - cloudTable["ibmcloud-powervs"] = &powervs.Manager{} -} diff --git a/pkg/adaptor/cloud/cloudmgr/libvirt.go b/pkg/adaptor/cloud/cloudmgr/libvirt.go deleted file mode 100644 index 4f1f8630d..000000000 --- a/pkg/adaptor/cloud/cloudmgr/libvirt.go +++ /dev/null @@ -1,14 +0,0 @@ -//go:build libvirt - -// (C) Copyright Confidential Containers Contributors -// SPDX-License-Identifier: Apache-2.0 - -package cloudmgr - -import ( - "github.com/confidential-containers/cloud-api-adaptor/pkg/adaptor/cloud/libvirt" -) - -func init() { - cloudTable["libvirt"] = &libvirt.Manager{} -} diff --git a/pkg/adaptor/cloud/cloudmgr/manager.go b/pkg/adaptor/cloud/cloudmgr/manager.go deleted file mode 100644 index b337124d5..000000000 --- a/pkg/adaptor/cloud/cloudmgr/manager.go +++ /dev/null @@ -1,33 +0,0 @@ -// (C) Copyright Confidential Containers Contributors -// SPDX-License-Identifier: Apache-2.0 - -package cloudmgr - -import ( - "flag" - - "github.com/confidential-containers/cloud-api-adaptor/pkg/adaptor/cloud" -) - -type Cloud interface { - ParseCmd(flags *flag.FlagSet) - LoadEnv() - NewProvider() (cloud.Provider, error) -} - -var cloudTable map[string]Cloud = make(map[string]Cloud) - -func Get(name string) Cloud { - return cloudTable[name] -} - -func List() []string { - - var list []string - - for name := range cloudTable { - list = append(list, name) - } - - return list -} diff --git a/pkg/adaptor/cloud/cloudmgr/vsphere.go b/pkg/adaptor/cloud/cloudmgr/vsphere.go deleted file mode 100644 index ba1ae981e..000000000 --- a/pkg/adaptor/cloud/cloudmgr/vsphere.go +++ /dev/null @@ -1,14 +0,0 @@ -//go:build vsphere - -// (C) Copyright Confidential Containers Contributors -// SPDX-License-Identifier: Apache-2.0 - -package cloudmgr - -import ( - "github.com/confidential-containers/cloud-api-adaptor/pkg/adaptor/cloud/vsphere" -) - -func init() { - cloudTable["vsphere"] = &vsphere.Manager{} -}