Skip to content

Commit

Permalink
kubectl-kcp: remove unused code
Browse files Browse the repository at this point in the history
  • Loading branch information
sttts committed Mar 20, 2022
1 parent 2cf1475 commit ea3dfd2
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 100 deletions.
64 changes: 0 additions & 64 deletions pkg/cliplugins/workspace/plugin/kubeconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import (
"context"
"errors"
"fmt"
"net/http"
"net/url"
"path"
"strings"
Expand All @@ -29,8 +28,6 @@ import (
"github.com/kcp-dev/apimachinery/pkg/logicalcluster"

metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
metav1beta1 "k8s.io/apimachinery/pkg/apis/meta/v1beta1"
"k8s.io/cli-runtime/pkg/printers"
"k8s.io/client-go/rest"
"k8s.io/client-go/tools/clientcmd"
"k8s.io/client-go/tools/clientcmd/api"
Expand Down Expand Up @@ -254,49 +251,6 @@ func (kc *KubeConfig) currentWorkspace(ctx context.Context, host, workspaceType
return outputCurrentWorkspaceMessage(parentClusterName, workspacePrettyName, workspaceName, workspaceType, opts)
}

// ListWorkspaces outputs the list of workspaces of the current user
// (kubeconfig user possibly overridden by CLI options).
func (kc *KubeConfig) ListWorkspaces(ctx context.Context, opts *Options) error {
config, err := clientcmd.NewDefaultClientConfig(*kc.startingConfig, opts.KubectlOverrides).ClientConfig()
if err != nil {
return err
}
tenancyClient, err := tenancyclient.NewForConfig(config)
if err != nil {
return err
}

result := tenancyClient.TenancyV1beta1().RESTClient().Get().Resource("workspaces").SetHeader("Accept", strings.Join([]string{
fmt.Sprintf("application/json;as=Table;v=%s;g=%s", metav1.SchemeGroupVersion.Version, metav1.GroupName),
fmt.Sprintf("application/json;as=Table;v=%s;g=%s", metav1beta1.SchemeGroupVersion.Version, metav1beta1.GroupName),
"application/json",
}, ",")).Do(ctx)

var statusCode int
if result.StatusCode(&statusCode).Error() != nil {
return result.Error()
}

if statusCode != http.StatusOK {
rawResult, err := result.Raw()
if err != nil {
return err
}
return errors.New(string(rawResult))
}

table, err := result.Get()
if err != nil {
return err
}

printer := printers.NewTablePrinter(printers.PrintOptions{
Wide: true,
})

return printer.PrintObj(table, opts.Out)
}

// CreateWorkspace creates a workspace owned by the the current user
// (kubeconfig user possibly overridden by CLI options).
func (kc *KubeConfig) CreateWorkspace(ctx context.Context, opts *Options, workspaceName string, workspaceType string, useAfterCreation bool) error {
Expand Down Expand Up @@ -333,24 +287,6 @@ func (kc *KubeConfig) CreateWorkspace(ctx context.Context, opts *Options, worksp
return nil
}

// DeleteWorkspace deletes a workspace owned by the the current user
// (kubeconfig user possibly overridden by CLI options).
func (kc *KubeConfig) DeleteWorkspace(ctx context.Context, opts *Options, workspaceName string) error {
config, err := clientcmd.NewDefaultClientConfig(*kc.startingConfig, opts.KubectlOverrides).ClientConfig()
if err != nil {
return err
}
tenancyClient, err := tenancyclient.NewForConfig(config)
if err != nil {
return err
}
if err := tenancyClient.TenancyV1beta1().Workspaces().Delete(ctx, workspaceName, metav1.DeleteOptions{}); err != nil {
return err
}

return write(opts, fmt.Sprintf("Workspace \"%s\" deleted.\n", workspaceName))
}

func (kc *KubeConfig) logicalClusterClientConfig(clusterName logicalcluster.LogicalCluster, opts *Options) (*rest.Config, error) {
baseConfig, err := clientcmd.NewDefaultClientConfig(*kc.startingConfig, opts.KubectlOverrides).ClientConfig()
if err != nil {
Expand Down
36 changes: 0 additions & 36 deletions pkg/cliplugins/workspace/plugin/scheme.go

This file was deleted.

0 comments on commit ea3dfd2

Please sign in to comment.