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

chore(platform): thin out platform client #1825

Merged
merged 1 commit into from
May 31, 2024
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
2 changes: 1 addition & 1 deletion cmd/vclusterctl/cmd/platform/access_key.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ func printToken(token string) error {
}

func getCertificate(cmd *AccessKeyCmd, platformClient platform.Client) error {
certificateData, keyData, err := platformClient.VirtualClusterAccessPointCertificate(cmd.Project, cmd.VirtualCluster, false)
certificateData, keyData, err := platform.VirtualClusterAccessPointCertificate(platformClient, cmd.Project, cmd.VirtualCluster, false)
if err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/vclusterctl/cmd/platform/connect/space.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ func (cmd *SpaceCmd) connectSpace(ctx context.Context, platformClient platform.C
}

// create kube context options
contextOptions, err := platformClient.CreateSpaceInstanceOptions(ctx, cmd.Config, cmd.Project, spaceInstance, true)
contextOptions, err := platform.CreateSpaceInstanceOptions(ctx, platformClient, cmd.Config, cmd.Project, spaceInstance, true)
if err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/vclusterctl/cmd/platform/create/space.go
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ func (cmd *SpaceCmd) createSpace(ctx context.Context, platformClient platform.Cl
// should we create a kube context for the space
if cmd.CreateContext {
// create kube context options
contextOptions, err := platformClient.CreateSpaceInstanceOptions(ctx, cmd.Config, cmd.Project, spaceInstance, cmd.SwitchContext)
contextOptions, err := platform.CreateSpaceInstanceOptions(ctx, platformClient, cmd.Config, cmd.Project, spaceInstance, cmd.SwitchContext)
if err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/cli/connect_platform.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ func (cmd *connectPlatform) validateProFlags() error {
}

func (cmd *connectPlatform) getVClusterKubeConfig(ctx context.Context, platformClient platform.Client, vCluster *platform.VirtualClusterInstanceProject) (*clientcmdapi.Config, error) {
contextOptions, err := platformClient.CreateVirtualClusterInstanceOptions(ctx, "", vCluster.Project.Name, vCluster.VirtualCluster, false)
contextOptions, err := platform.CreateVirtualClusterInstanceOptions(ctx, platformClient, "", vCluster.Project.Name, vCluster.VirtualCluster, false)
if err != nil {
return nil, fmt.Errorf("prepare vCluster kube config: %w", err)
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/cli/create_helm.go
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ func (cmd *createHelm) activateVCluster(ctx context.Context, vClusterConfig *con
return nil
}

err = platformClient.ApplyPlatformSecret(ctx, cmd.kubeClient, "", cmd.Namespace, cmd.Project)
err = platform.ApplyPlatformSecret(ctx, platformClient, cmd.kubeClient, "", cmd.Namespace, cmd.Project)
if err != nil {
return fmt.Errorf("apply platform secret: %w", err)
}
Expand Down
8 changes: 5 additions & 3 deletions pkg/cli/create_platform.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ func CreatePlatform(ctx context.Context, options *CreateOptions, globalFlags *fl

if options.CreateContext {
// create kube context options
contextOptions, err := platformClient.CreateVirtualClusterInstanceOptions(ctx, "", options.Project, virtualClusterInstance, options.SwitchContext)
contextOptions, err := platform.CreateVirtualClusterInstanceOptions(ctx, platformClient, "", options.Project, virtualClusterInstance, options.SwitchContext)
if err != nil {
return err
}
Expand Down Expand Up @@ -397,8 +397,9 @@ func createWithTemplate(ctx context.Context, platformClient platform.Client, opt
}

// resolve template
virtualClusterTemplate, resolvedParameters, err := platformClient.ResolveTemplate(
virtualClusterTemplate, resolvedParameters, err := platform.ResolveVirtualClusterTemplate(
ctx,
platformClient,
options.Project,
options.Template,
options.TemplateVersion,
Expand Down Expand Up @@ -480,8 +481,9 @@ func upgradeWithTemplate(ctx context.Context, platformClient platform.Client, op
}

// resolve template
virtualClusterTemplate, resolvedParameters, err := platformClient.ResolveTemplate(
virtualClusterTemplate, resolvedParameters, err := platform.ResolveVirtualClusterTemplate(
ctx,
platformClient,
options.Project,
options.Template,
options.TemplateVersion,
Expand Down
2 changes: 1 addition & 1 deletion pkg/cli/find/find.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ func CurrentContext() (string, *clientcmdapi.Config, error) {
}

func GetPlatformVCluster(ctx context.Context, platformClient platform.Client, name, project string, log log.Logger) (*platform.VirtualClusterInstanceProject, error) {
platformVClusters, err := platformClient.ListVClusters(ctx, name, project)
platformVClusters, err := platform.ListVClusters(ctx, platformClient, name, project)
if err != nil {
log.Warnf("Error retrieving platform vclusters: %v", err)
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/cli/import_helm.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func ImportHelm(ctx context.Context, options *ImportOptions, globalFlags *flags.
}

// apply platform secret
err = platformClient.ApplyPlatformSecret(ctx, kubeClient, options.ImportName, vCluster.Namespace, options.Project)
err = platform.ApplyPlatformSecret(ctx, platformClient, kubeClient, options.ImportName, vCluster.Namespace, options.Project)
if err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/cli/list_helm.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ func printVClusters(ctx context.Context, options *ListOptions, output []ListVClu
ctx, cancel := context.WithTimeout(ctx, 2*time.Second)
defer cancel()

proVClusters, _ := platformClient.ListVClusters(ctx, "", "")
proVClusters, _ := platform.ListVClusters(ctx, platformClient, "", "")
if len(proVClusters) > 0 {
logger.Infof("You also have %d virtual clusters in your platform manager context.", len(proVClusters))
logger.Info("If you want to see them, run: 'vcluster list --manager platform' or 'vcluster use manager platform' to change the default")
Expand Down
2 changes: 1 addition & 1 deletion pkg/cli/list_platform.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ func ListPlatform(ctx context.Context, options *ListOptions, globalFlags *flags.
return err
}

proVClusters, err := platformClient.ListVClusters(ctx, "", "")
proVClusters, err := platform.ListVClusters(ctx, platformClient, "", "")
if err != nil {
return err
}
Expand Down
Loading
Loading