From 7e36bdca4521f9f0001701e4d57a2eccdfedec41 Mon Sep 17 00:00:00 2001 From: Taylor Thornton Date: Sun, 8 Oct 2023 14:01:39 -0700 Subject: [PATCH 1/2] Move `ctp connect` to `ctp connector install` Signed-off-by: Taylor Thornton --- cmd/up/controlplane/connector/connector.go | 31 +++++++++++++++++++ .../{connect.go => connector/install.go} | 12 +++---- cmd/up/controlplane/controlplane.go | 3 +- 3 files changed, 39 insertions(+), 7 deletions(-) create mode 100644 cmd/up/controlplane/connector/connector.go rename cmd/up/controlplane/{connect.go => connector/install.go} (95%) diff --git a/cmd/up/controlplane/connector/connector.go b/cmd/up/controlplane/connector/connector.go new file mode 100644 index 00000000..9e2dd33b --- /dev/null +++ b/cmd/up/controlplane/connector/connector.go @@ -0,0 +1,31 @@ +// Copyright 2021 Upbound Inc +// +// 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 connector + +import ( + "github.com/alecthomas/kong" + + "github.com/upbound/up/internal/feature" +) + +// BeforeReset is the first hook to run. +func (c *Cmd) BeforeReset(p *kong.Path, maturity feature.Maturity) error { + return feature.HideMaturity(p, maturity) +} + +// Cmd contains commands for installing mcp-connector into an App Cluster. +type Cmd struct { + Install installCmd `cmd:"" help:"Install mcp-connector into an App Cluster."` +} diff --git a/cmd/up/controlplane/connect.go b/cmd/up/controlplane/connector/install.go similarity index 95% rename from cmd/up/controlplane/connect.go rename to cmd/up/controlplane/connector/install.go index dc768295..4a242eaa 100644 --- a/cmd/up/controlplane/connect.go +++ b/cmd/up/controlplane/connector/install.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package controlplane +package connector import ( "context" @@ -48,7 +48,7 @@ const ( ) // AfterApply sets default values in command after assignment and validation. -func (c *connectCmd) AfterApply(kongCtx *kong.Context, upCtx *upbound.Context) error { +func (c *installCmd) AfterApply(kongCtx *kong.Context, upCtx *upbound.Context) error { if c.ClusterName == "" { c.ClusterName = c.Namespace } @@ -94,9 +94,9 @@ func (c *connectCmd) AfterApply(kongCtx *kong.Context, upCtx *upbound.Context) e return nil } -// connectCmd connects the current cluster to a control plane in an account on +// installCmd connects the current cluster to a control plane in an account on // Upbound. -type connectCmd struct { +type installCmd struct { mgr install.Manager parser install.ParameterParser kClient kubernetes.Interface @@ -113,7 +113,7 @@ type connectCmd struct { } // Run executes the connect command. -func (c *connectCmd) Run(p pterm.TextPrinter, upCtx *upbound.Context) error { +func (c *installCmd) Run(p pterm.TextPrinter, upCtx *upbound.Context) error { if upCtx.Profile.IsSpace() { return fmt.Errorf("connect is not supported for space profile %q", upCtx.ProfileName) } @@ -147,7 +147,7 @@ func (c *connectCmd) Run(p pterm.TextPrinter, upCtx *upbound.Context) error { return nil } -func (c *connectCmd) getToken(p pterm.TextPrinter, upCtx *upbound.Context) (string, error) { +func (c *installCmd) getToken(p pterm.TextPrinter, upCtx *upbound.Context) (string, error) { if c.Token != "" { return c.Token, nil } diff --git a/cmd/up/controlplane/controlplane.go b/cmd/up/controlplane/controlplane.go index 8d98e1be..ef3a1fc1 100644 --- a/cmd/up/controlplane/controlplane.go +++ b/cmd/up/controlplane/controlplane.go @@ -21,6 +21,7 @@ import ( "github.com/posener/complete" cp "github.com/upbound/up-sdk-go/service/controlplanes" + "github.com/upbound/up/cmd/up/controlplane/connector" "github.com/upbound/up/cmd/up/controlplane/kubeconfig" "github.com/upbound/up/cmd/up/controlplane/pkg" "github.com/upbound/up/cmd/up/controlplane/pullsecret" @@ -92,7 +93,7 @@ type Cmd struct { List listCmd `cmd:"" help:"List control planes for the account."` Get getCmd `cmd:"" help:"Get a single control plane."` - Connect connectCmd `cmd:"" help:"Connect an App Cluster to a managed control plane."` + Connector connector.Cmd `cmd:"" help:"Connect an App Cluster to a managed control plane."` Configuration pkg.Cmd `cmd:"" set:"package_type=Configuration" help:"Manage Configurations."` Provider pkg.Cmd `cmd:"" set:"package_type=Provider" help:"Manage Providers."` From 5df06c573fddc54d8ff945bc3c20b435787063ef Mon Sep 17 00:00:00 2001 From: Taylor Thornton Date: Sun, 8 Oct 2023 16:00:49 -0700 Subject: [PATCH 2/2] update license header for connector Signed-off-by: Taylor Thornton --- cmd/up/controlplane/connector/connector.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/up/controlplane/connector/connector.go b/cmd/up/controlplane/connector/connector.go index 9e2dd33b..cfd8273b 100644 --- a/cmd/up/controlplane/connector/connector.go +++ b/cmd/up/controlplane/connector/connector.go @@ -1,4 +1,4 @@ -// Copyright 2021 Upbound Inc +// Copyright 2023 Upbound Inc // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License.