diff --git a/cmd/subctl/generic_cloud.go b/cmd/subctl/generic_cloud.go deleted file mode 100644 index 850cafba4..000000000 --- a/cmd/subctl/generic_cloud.go +++ /dev/null @@ -1,70 +0,0 @@ -//go:build !non_deploy - -/* -SPDX-License-Identifier: Apache-2.0 - -Copyright Contributors to the Submariner project. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package subctl - -import ( - "github.com/spf13/cobra" - "github.com/submariner-io/admiral/pkg/reporter" - "github.com/submariner-io/subctl/internal/cli" - "github.com/submariner-io/subctl/internal/exit" - "github.com/submariner-io/subctl/pkg/cloud/cleanup" - "github.com/submariner-io/subctl/pkg/cloud/prepare" - "github.com/submariner-io/subctl/pkg/cluster" -) - -var ( - genericCloudConfig struct { - gateways int - } - - genericPrepareCmd = &cobra.Command{ - Use: "generic", - Deprecated: "Deprecated in 0.15, to be removed in 0.16. Use `subctl join` instead.", - Short: "Prepares a generic cluster for Submariner", - Long: "This command labels the required number of gateway nodes for Submariner installation.", - Run: func(cmd *cobra.Command, args []string) { - exit.OnError(cloudRestConfigProducer.RunOnSelectedContext( - func(clusterInfo *cluster.Info, namespace string, status reporter.Interface) error { - return prepare.GenericCluster( //nolint:wrapcheck // No need to wrap errors here. - clusterInfo, genericCloudConfig.gateways, status) - }, cli.NewReporter())) - }, - } - - genericCleanupCmd = &cobra.Command{ - Use: "generic", - Short: "Cleans up a cluster after Submariner uninstallation", - Long: "This command removes the labels from gateway nodes after Submariner uninstallation.", - Run: func(cmd *cobra.Command, args []string) { - exit.OnError(cloudRestConfigProducer.RunOnSelectedContext( - func(clusterInfo *cluster.Info, namespace string, status reporter.Interface) error { - return cleanup.GenericCluster(clusterInfo, status) //nolint:wrapcheck // No need to wrap errors here. - }, cli.NewReporter())) - }, - } -) - -func init() { - genericPrepareCmd.Flags().IntVar(&genericCloudConfig.gateways, "gateways", defaultNumGateways, "Number of gateways to deploy") - cloudPrepareCmd.AddCommand(genericPrepareCmd) - - cloudCleanupCmd.AddCommand(genericCleanupCmd) -} diff --git a/pkg/cloud/cleanup/generic.go b/pkg/cloud/cleanup/generic.go deleted file mode 100644 index af308ff17..000000000 --- a/pkg/cloud/cleanup/generic.go +++ /dev/null @@ -1,36 +0,0 @@ -/* -SPDX-License-Identifier: Apache-2.0 - -Copyright Contributors to the Submariner project. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package cleanup - -import ( - "github.com/submariner-io/admiral/pkg/reporter" - "github.com/submariner-io/cloud-prepare/pkg/api" - "github.com/submariner-io/subctl/pkg/cloud/generic" - "github.com/submariner-io/subctl/pkg/cluster" -) - -func GenericCluster(clusterInfo *cluster.Info, status reporter.Interface) error { - defer status.End() - err := generic.RunOnCluster(clusterInfo, status, - func(gwDeployer api.GatewayDeployer, status reporter.Interface) error { - return gwDeployer.Cleanup(status) //nolint:wrapcheck // No need to wrap here - }) - - return status.Error(err, "Failed to cleanup generic K8s cluster") -} diff --git a/pkg/cloud/generic/generic.go b/pkg/cloud/generic/generic.go deleted file mode 100644 index 81eaae3d9..000000000 --- a/pkg/cloud/generic/generic.go +++ /dev/null @@ -1,37 +0,0 @@ -/* -SPDX-License-Identifier: Apache-2.0 - -Copyright Contributors to the Submariner project. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package generic - -import ( - "github.com/submariner-io/admiral/pkg/reporter" - "github.com/submariner-io/cloud-prepare/pkg/api" - "github.com/submariner-io/cloud-prepare/pkg/generic" - "github.com/submariner-io/cloud-prepare/pkg/k8s" - "github.com/submariner-io/subctl/pkg/cluster" -) - -func RunOnCluster(clusterInfo *cluster.Info, status reporter.Interface, - function func(api.GatewayDeployer, reporter.Interface) error, -) error { - clientSet := clusterInfo.ClientProducer.ForKubernetes() - k8sClientSet := k8s.NewInterface(clientSet) - gwDeployer := generic.NewGatewayDeployer(k8sClientSet) - - return function(gwDeployer, status) -} diff --git a/pkg/cloud/prepare/generic.go b/pkg/cloud/prepare/generic.go deleted file mode 100644 index 88fed96ac..000000000 --- a/pkg/cloud/prepare/generic.go +++ /dev/null @@ -1,48 +0,0 @@ -/* -SPDX-License-Identifier: Apache-2.0 - -Copyright Contributors to the Submariner project. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package prepare - -import ( - "github.com/submariner-io/admiral/pkg/reporter" - "github.com/submariner-io/cloud-prepare/pkg/api" - "github.com/submariner-io/subctl/pkg/cloud/generic" - "github.com/submariner-io/subctl/pkg/cluster" -) - -func GenericCluster(clusterInfo *cluster.Info, gateways int, status reporter.Interface) error { - defer status.End() - - //nolint:wrapcheck // No need to wrap errors here. - err := generic.RunOnCluster(clusterInfo, status, - func(gwDeployer api.GatewayDeployer, status reporter.Interface) error { - if gateways > 0 { - gwInput := api.GatewayDeployInput{ - Gateways: gateways, - } - err := gwDeployer.Deploy(gwInput, status) - if err != nil { - return err - } - } - - return nil - }) - - return status.Error(err, "Failed to prepare generic K8s cluster") -}