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

Move ctp connect to ctp connector install #389

Merged
merged 2 commits into from
Oct 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
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
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
Loading