Skip to content

Commit

Permalink
Merge pull request #1838 from johannesfrey/drop-lofctl-deps
Browse files Browse the repository at this point in the history
Drop loftctl deps
  • Loading branch information
FabianKramm authored Jun 4, 2024
2 parents 3deed2f + 2c498b1 commit 4511908
Show file tree
Hide file tree
Showing 85 changed files with 743 additions and 8,191 deletions.
4 changes: 2 additions & 2 deletions cmd/vclusterctl/cmd/connect.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ import (
"context"
"fmt"

loftctlUtil "github.com/loft-sh/loftctl/v4/pkg/util"
"github.com/loft-sh/log"
"github.com/loft-sh/vcluster/pkg/cli"
"github.com/loft-sh/vcluster/pkg/cli/config"
"github.com/loft-sh/vcluster/pkg/cli/flags"
"github.com/loft-sh/vcluster/pkg/cli/util"
"github.com/loft-sh/vcluster/pkg/upgrade"
"github.com/spf13/cobra"
)
Expand All @@ -27,7 +27,7 @@ func NewConnectCmd(globalFlags *flags.GlobalFlags) *cobra.Command {
Log: log.GetInstance(),
}

useLine, nameValidator := loftctlUtil.NamedPositionalArgsValidator(true, false, "VCLUSTER_NAME")
useLine, nameValidator := util.NamedPositionalArgsValidator(true, false, "VCLUSTER_NAME")

cobraCmd := &cobra.Command{
Use: "connect" + useLine,
Expand Down
6 changes: 3 additions & 3 deletions cmd/vclusterctl/cmd/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ import (
"fmt"
"strings"

loftctlUtil "github.com/loft-sh/loftctl/v4/pkg/util"
"github.com/loft-sh/log"
"github.com/loft-sh/vcluster/pkg/cli"
"github.com/loft-sh/vcluster/pkg/cli/config"
"github.com/loft-sh/vcluster/pkg/cli/flags"
"github.com/loft-sh/vcluster/pkg/cli/util"
"github.com/loft-sh/vcluster/pkg/constants"
"github.com/loft-sh/vcluster/pkg/platform"
"github.com/loft-sh/vcluster/pkg/upgrade"
Expand All @@ -32,7 +32,7 @@ func NewCreateCmd(globalFlags *flags.GlobalFlags) *cobra.Command {
}

cobraCmd := &cobra.Command{
Use: "create" + loftctlUtil.VClusterNameOnlyUseLine,
Use: "create" + util.VClusterNameOnlyUseLine,
Short: "Create a new virtual cluster",
Long: `#######################################################
################### vcluster create ###################
Expand All @@ -43,7 +43,7 @@ Example:
vcluster create test --namespace test
#######################################################
`,
Args: loftctlUtil.VClusterNameOnlyValidator,
Args: util.VClusterNameOnlyValidator,
RunE: func(cobraCmd *cobra.Command, args []string) error {
// Check for newer version
upgrade.PrintNewerVersionWarning()
Expand Down
6 changes: 3 additions & 3 deletions cmd/vclusterctl/cmd/delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ package cmd
import (
"context"

loftctlUtil "github.com/loft-sh/loftctl/v4/pkg/util"
"github.com/loft-sh/log"
"github.com/loft-sh/vcluster/pkg/cli"
"github.com/loft-sh/vcluster/pkg/cli/config"
"github.com/loft-sh/vcluster/pkg/cli/flags"
"github.com/loft-sh/vcluster/pkg/cli/util"
"github.com/loft-sh/vcluster/pkg/platform"
"github.com/spf13/cobra"
)
Expand All @@ -28,7 +28,7 @@ func NewDeleteCmd(globalFlags *flags.GlobalFlags) *cobra.Command {
}

cobraCmd := &cobra.Command{
Use: "delete" + loftctlUtil.VClusterNameOnlyUseLine,
Use: "delete" + util.VClusterNameOnlyUseLine,
Short: "Deletes a virtual cluster",
Long: `#######################################################
################### vcluster delete ###################
Expand All @@ -39,7 +39,7 @@ Example:
vcluster delete test --namespace test
#######################################################
`,
Args: loftctlUtil.VClusterNameOnlyValidator,
Args: util.VClusterNameOnlyValidator,
Aliases: []string{"rm"},
ValidArgsFunction: newValidVClusterNameFunc(globalFlags),
RunE: func(cobraCmd *cobra.Command, args []string) error {
Expand Down
7 changes: 3 additions & 4 deletions cmd/vclusterctl/cmd/import.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ import (
"github.com/loft-sh/vcluster/pkg/cli"
"github.com/loft-sh/vcluster/pkg/cli/config"
"github.com/loft-sh/vcluster/pkg/cli/flags"

loftctlUtil "github.com/loft-sh/vcluster/pkg/platform/loftutils"
"github.com/loft-sh/vcluster/pkg/cli/util"
"github.com/spf13/cobra"
)

Expand Down Expand Up @@ -37,10 +36,10 @@ vcluster import my-vcluster --cluster connected-cluster \
`

importCmd := &cobra.Command{
Use: "import" + loftctlUtil.VClusterNameOnlyUseLine,
Use: "import" + util.VClusterNameOnlyUseLine,
Short: "Imports a vCluster into a vCluster platform project",
Long: description,
Args: loftctlUtil.VClusterNameOnlyValidator,
Args: util.VClusterNameOnlyValidator,
RunE: func(cobraCmd *cobra.Command, args []string) error {
return cmd.Run(cobraCmd.Context(), args)
},
Expand Down
6 changes: 3 additions & 3 deletions cmd/vclusterctl/cmd/login.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ import (
managementv1 "github.com/loft-sh/api/v4/pkg/apis/management/v1"
storagev1 "github.com/loft-sh/api/v4/pkg/apis/storage/v1"
"github.com/loft-sh/api/v4/pkg/product"
"github.com/loft-sh/loftctl/v4/pkg/clihelper"
"github.com/loft-sh/loftctl/v4/pkg/docker"
"github.com/loft-sh/loftctl/v4/pkg/kube"
"github.com/loft-sh/log"
"github.com/loft-sh/vcluster/cmd/vclusterctl/cmd/use"
"github.com/loft-sh/vcluster/pkg/cli/config"
"github.com/loft-sh/vcluster/pkg/cli/flags"
"github.com/loft-sh/vcluster/pkg/docker"
"github.com/loft-sh/vcluster/pkg/platform"
"github.com/loft-sh/vcluster/pkg/platform/clihelper"
"github.com/loft-sh/vcluster/pkg/platform/kube"
"github.com/loft-sh/vcluster/pkg/upgrade"
"github.com/mgutz/ansi"
"github.com/pkg/errors"
Expand Down
6 changes: 3 additions & 3 deletions cmd/vclusterctl/cmd/pause.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ import (
"context"

"github.com/loft-sh/api/v4/pkg/product"
loftctlUtil "github.com/loft-sh/loftctl/v4/pkg/util"
"github.com/loft-sh/log"
"github.com/loft-sh/vcluster/pkg/cli"
"github.com/loft-sh/vcluster/pkg/cli/config"
"github.com/loft-sh/vcluster/pkg/cli/flags"
"github.com/loft-sh/vcluster/pkg/cli/util"
"github.com/spf13/cobra"
)

Expand All @@ -28,7 +28,7 @@ func NewPauseCmd(globalFlags *flags.GlobalFlags) *cobra.Command {
}

cobraCmd := &cobra.Command{
Use: "pause" + loftctlUtil.VClusterNameOnlyUseLine,
Use: "pause" + util.VClusterNameOnlyUseLine,
Aliases: []string{"sleep"},
Short: "Pauses a virtual cluster",
Long: `#######################################################
Expand All @@ -46,7 +46,7 @@ Example:
vcluster pause test --namespace test
#######################################################
`,
Args: loftctlUtil.VClusterNameOnlyValidator,
Args: util.VClusterNameOnlyValidator,
ValidArgsFunction: newValidVClusterNameFunc(globalFlags),
RunE: func(cobraCmd *cobra.Command, args []string) error {
return cmd.Run(cobraCmd.Context(), args)
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 @@ -5,10 +5,10 @@ import (
"os"

"github.com/loft-sh/api/v4/pkg/product"
"github.com/loft-sh/loftctl/v4/pkg/util"
"github.com/loft-sh/log"
"github.com/loft-sh/vcluster/pkg/cli/config"
"github.com/loft-sh/vcluster/pkg/cli/flags"
"github.com/loft-sh/vcluster/pkg/cli/util"
"github.com/loft-sh/vcluster/pkg/platform"
pdefaults "github.com/loft-sh/vcluster/pkg/platform/defaults"
"github.com/loft-sh/vcluster/pkg/platform/kubeconfig"
Expand Down
30 changes: 14 additions & 16 deletions cmd/vclusterctl/cmd/platform/create/space.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,17 @@ import (
managementv1 "github.com/loft-sh/api/v4/pkg/apis/management/v1"
storagev1 "github.com/loft-sh/api/v4/pkg/apis/storage/v1"
"github.com/loft-sh/api/v4/pkg/product"
"github.com/loft-sh/loftctl/v4/cmd/loftctl/cmd/create"
"github.com/loft-sh/loftctl/v4/pkg/config"
"github.com/loft-sh/loftctl/v4/pkg/parameters"
"github.com/loft-sh/loftctl/v4/pkg/upgrade"
"github.com/loft-sh/loftctl/v4/pkg/util"
"github.com/loft-sh/loftctl/v4/pkg/version"
"github.com/loft-sh/log"
cliconfig "github.com/loft-sh/vcluster/pkg/cli/config"
"github.com/loft-sh/vcluster/pkg/cli/flags"
"github.com/loft-sh/vcluster/pkg/cli/util"
"github.com/loft-sh/vcluster/pkg/kube"
"github.com/loft-sh/vcluster/pkg/platform"
"github.com/loft-sh/vcluster/pkg/platform/clihelper"
pdefaults "github.com/loft-sh/vcluster/pkg/platform/defaults"
"github.com/loft-sh/vcluster/pkg/platform/kubeconfig"
"github.com/loft-sh/vcluster/pkg/projectutil"
"github.com/loft-sh/vcluster/pkg/upgrade"
"github.com/mgutz/ansi"
"github.com/pkg/errors"
"github.com/spf13/cobra"
Expand Down Expand Up @@ -188,7 +186,7 @@ func (cmd *SpaceCmd) createSpace(ctx context.Context, platformClient platform.Cl
cmd.Log.Infof("Waiting until space is deleted...")

// wait until the space instance is deleted
waitErr := wait.PollUntilContextTimeout(ctx, time.Second, config.Timeout(), false, func(ctx context.Context) (done bool, err error) {
waitErr := wait.PollUntilContextTimeout(ctx, time.Second, clihelper.Timeout(), false, func(ctx context.Context) (done bool, err error) {
spaceInstance, err = managementClient.Loft().ManagementV1().SpaceInstances(spaceNamespace).Get(ctx, spaceName, metav1.GetOptions{})
if err != nil && !kerrors.IsNotFound(err) {
return false, err
Expand Down Expand Up @@ -249,12 +247,12 @@ func (cmd *SpaceCmd) createSpace(ctx context.Context, platformClient platform.Cl
},
},
}
create.SetCustomLinksAnnotation(spaceInstance, cmd.Links)
_, err = create.UpdateLabels(spaceInstance, cmd.Labels)
kube.SetCustomLinksAnnotation(spaceInstance, cmd.Links)
_, err = kube.UpdateLabels(spaceInstance, cmd.Labels)
if err != nil {
return err
}
_, err = create.UpdateAnnotations(spaceInstance, cmd.Annotations)
_, err = kube.UpdateAnnotations(spaceInstance, cmd.Annotations)
if err != nil {
return err
}
Expand All @@ -281,12 +279,12 @@ func (cmd *SpaceCmd) createSpace(ctx context.Context, platformClient platform.Cl
templateRefChanged := spaceInstance.Spec.TemplateRef.Name != spaceTemplate.Name
paramsChanged := spaceInstance.Spec.Parameters != resolvedParameters
versionChanged := (cmd.Version != "" && spaceInstance.Spec.TemplateRef.Version != cmd.Version)
linksChanged := create.SetCustomLinksAnnotation(spaceInstance, cmd.Links)
labelsChanged, err := create.UpdateLabels(spaceInstance, cmd.Labels)
linksChanged := kube.SetCustomLinksAnnotation(spaceInstance, cmd.Links)
labelsChanged, err := kube.UpdateLabels(spaceInstance, cmd.Labels)
if err != nil {
return err
}
annotationsChanged, err := create.UpdateAnnotations(spaceInstance, cmd.Annotations)
annotationsChanged, err := kube.UpdateAnnotations(spaceInstance, cmd.Annotations)
if err != nil {
return err
}
Expand Down Expand Up @@ -351,14 +349,14 @@ func (cmd *SpaceCmd) resolveTemplate(ctx context.Context, platformClient platfor
var templateParameters []storagev1.AppParameter
if len(spaceTemplate.Spec.Versions) > 0 {
if cmd.Version == "" {
latestVersion := version.GetLatestVersion(spaceTemplate)
latestVersion := platform.GetLatestVersion(spaceTemplate)
if latestVersion == nil {
return nil, "", fmt.Errorf("couldn't find any version in template")
}

templateParameters = latestVersion.(*storagev1.SpaceTemplateVersion).Parameters
} else {
_, latestMatched, err := version.GetLatestMatchedVersion(spaceTemplate, cmd.Version)
_, latestMatched, err := platform.GetLatestMatchedVersion(spaceTemplate, cmd.Version)
if err != nil {
return nil, "", err
} else if latestMatched == nil {
Expand All @@ -372,7 +370,7 @@ func (cmd *SpaceCmd) resolveTemplate(ctx context.Context, platformClient platfor
}

// resolve space template parameters
resolvedParameters, err := parameters.ResolveTemplateParameters(cmd.Set, templateParameters, cmd.ParametersFile)
resolvedParameters, err := platform.ResolveTemplateParameters(cmd.Set, templateParameters, cmd.ParametersFile)
if err != nil {
return nil, "", err
}
Expand Down
6 changes: 3 additions & 3 deletions cmd/vclusterctl/cmd/platform/delete/space.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ import (
"time"

"github.com/loft-sh/api/v4/pkg/product"
"github.com/loft-sh/loftctl/v4/pkg/kube"
"github.com/loft-sh/loftctl/v4/pkg/upgrade"
"github.com/loft-sh/loftctl/v4/pkg/util"
"github.com/loft-sh/log"
"github.com/loft-sh/vcluster/pkg/cli/flags"
"github.com/loft-sh/vcluster/pkg/cli/util"
"github.com/loft-sh/vcluster/pkg/platform"
pdefaults "github.com/loft-sh/vcluster/pkg/platform/defaults"
"github.com/loft-sh/vcluster/pkg/platform/kube"
"github.com/loft-sh/vcluster/pkg/platform/kubeconfig"
"github.com/loft-sh/vcluster/pkg/projectutil"
"github.com/loft-sh/vcluster/pkg/upgrade"
"github.com/mgutz/ansi"
"github.com/pkg/errors"
"github.com/spf13/cobra"
Expand Down
6 changes: 3 additions & 3 deletions cmd/vclusterctl/cmd/platform/get/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ import (
"time"

managementv1 "github.com/loft-sh/api/v4/pkg/apis/management/v1"
"github.com/loft-sh/loftctl/v4/pkg/config"
"github.com/loft-sh/log"
"github.com/loft-sh/vcluster/pkg/cli/flags"
"github.com/loft-sh/vcluster/pkg/platform"
"github.com/loft-sh/vcluster/pkg/platform/clihelper"
"github.com/loft-sh/vcluster/pkg/projectutil"
"github.com/spf13/cobra"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand Down Expand Up @@ -72,7 +72,7 @@ func (c *clusterCmd) Run(ctx context.Context, _ []string) error {

if isSpace, spaceName := isSpaceContext(cluster); isSpace {
var spaceInstance *managementv1.SpaceInstance
err := wait.PollUntilContextTimeout(ctx, time.Second, config.Timeout(), true, func(ctx context.Context) (bool, error) {
err := wait.PollUntilContextTimeout(ctx, time.Second, clihelper.Timeout(), true, func(ctx context.Context) (bool, error) {
var err error

spaceInstance, err = managementClient.Loft().ManagementV1().SpaceInstances(projectutil.ProjectNamespace(projectName)).Get(ctx, spaceName, metav1.GetOptions{})
Expand All @@ -97,7 +97,7 @@ func (c *clusterCmd) Run(ctx context.Context, _ []string) error {

if isVirtualCluster, virtualClusterName := isVirtualClusterContext(cluster); isVirtualCluster {
var virtualClusterInstance *managementv1.VirtualClusterInstance
err := wait.PollUntilContextTimeout(ctx, time.Second, config.Timeout(), true, func(ctx context.Context) (bool, error) {
err := wait.PollUntilContextTimeout(ctx, time.Second, clihelper.Timeout(), true, func(ctx context.Context) (bool, error) {
var err error

virtualClusterInstance, err = managementClient.Loft().ManagementV1().VirtualClusterInstances(projectutil.ProjectNamespace(projectName)).Get(ctx, virtualClusterName, metav1.GetOptions{})
Expand Down
2 changes: 1 addition & 1 deletion cmd/vclusterctl/cmd/platform/get/cluster_access_key.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import (
"github.com/loft-sh/api/v4/pkg/product"
"github.com/loft-sh/log"
"github.com/loft-sh/vcluster/pkg/cli/flags"
"github.com/loft-sh/vcluster/pkg/cli/util"
"github.com/loft-sh/vcluster/pkg/platform"
util "github.com/loft-sh/vcluster/pkg/platform/loftutils"
"github.com/sirupsen/logrus"
"github.com/spf13/cobra"
"gopkg.in/yaml.v2"
Expand Down
2 changes: 1 addition & 1 deletion cmd/vclusterctl/cmd/platform/get/secret.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ import (
"github.com/loft-sh/log/survey"
"github.com/loft-sh/vcluster/cmd/vclusterctl/cmd/platform/set"
"github.com/loft-sh/vcluster/pkg/cli/flags"
"github.com/loft-sh/vcluster/pkg/cli/util"
"github.com/loft-sh/vcluster/pkg/platform"
pdefaults "github.com/loft-sh/vcluster/pkg/platform/defaults"
util "github.com/loft-sh/vcluster/pkg/platform/loftutils"
"github.com/loft-sh/vcluster/pkg/projectutil"
"github.com/pkg/errors"
"github.com/spf13/cobra"
Expand Down
4 changes: 2 additions & 2 deletions cmd/vclusterctl/cmd/platform/import/import.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package importcmd

import (
loftctlUtil "github.com/loft-sh/loftctl/v4/pkg/util"
"github.com/loft-sh/vcluster/pkg/cli/flags"
"github.com/loft-sh/vcluster/pkg/cli/util"
"github.com/spf13/cobra"
)

Expand All @@ -17,7 +17,7 @@ func NewImportCmd(globalFlags *flags.GlobalFlags) *cobra.Command {
Use: "import",
Short: "Imports a virtual cluster / space into a vCluster platform project",
Long: description,
Args: loftctlUtil.VClusterNameOnlyValidator,
Args: util.VClusterNameOnlyValidator,
}

importCmd.AddCommand(NewVClusterCmd(globalFlags))
Expand Down
10 changes: 4 additions & 6 deletions cmd/vclusterctl/cmd/platform/import/space.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,14 @@ package importcmd
import (
"context"

"github.com/loft-sh/loftctl/v4/pkg/util"
managementv1 "github.com/loft-sh/api/v4/pkg/apis/management/v1"
"github.com/loft-sh/api/v4/pkg/product"
"github.com/loft-sh/log"
"github.com/loft-sh/vcluster/pkg/cli/flags"
"github.com/loft-sh/vcluster/pkg/cli/util"
"github.com/loft-sh/vcluster/pkg/platform"
"github.com/loft-sh/vcluster/pkg/upgrade"
"github.com/mgutz/ansi"

managementv1 "github.com/loft-sh/api/v4/pkg/apis/management/v1"
"github.com/loft-sh/api/v4/pkg/product"

"github.com/loft-sh/loftctl/v4/pkg/upgrade"
"github.com/spf13/cobra"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
Expand Down
6 changes: 3 additions & 3 deletions cmd/vclusterctl/cmd/platform/import/vcluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ package importcmd
import (
"context"

loftctlUtil "github.com/loft-sh/loftctl/v4/pkg/util"
"github.com/loft-sh/log"
"github.com/loft-sh/vcluster/pkg/cli"
"github.com/loft-sh/vcluster/pkg/cli/flags"
"github.com/loft-sh/vcluster/pkg/cli/util"
"github.com/spf13/cobra"
)

Expand Down Expand Up @@ -35,10 +35,10 @@ vcluster platform import vcluster my-vcluster --cluster connected-cluster \
`

importCmd := &cobra.Command{
Use: "vcluster" + loftctlUtil.VClusterNameOnlyUseLine,
Use: "vcluster" + util.VClusterNameOnlyUseLine,
Short: "Imports a vCluster into a vCluster platform project",
Long: description,
Args: loftctlUtil.VClusterNameOnlyValidator,
Args: util.VClusterNameOnlyValidator,
RunE: func(cobraCmd *cobra.Command, args []string) error {
return cmd.Run(cobraCmd.Context(), args)
},
Expand Down
Loading

0 comments on commit 4511908

Please sign in to comment.