Skip to content

Commit

Permalink
Merge pull request #389 from tnthornton/move-mcp-connect
Browse files Browse the repository at this point in the history
Move `ctp connect` to `ctp connector install`
  • Loading branch information
tnthornton committed Oct 8, 2023
2 parents 97f19fb + 5df06c5 commit 353ea63
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 7 deletions.
31 changes: 31 additions & 0 deletions cmd/up/controlplane/connector/connector.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// 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.
// 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."`
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

package controlplane
package connector

import (
"context"
Expand Down Expand Up @@ -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
}
Expand Down Expand Up @@ -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
Expand All @@ -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)
}
Expand Down Expand Up @@ -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
}
Expand Down
3 changes: 2 additions & 1 deletion cmd/up/controlplane/controlplane.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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."`
Expand Down

0 comments on commit 353ea63

Please sign in to comment.