Skip to content

Commit

Permalink
vendor k9s into "zarf tools k9s"
Browse files Browse the repository at this point in the history
  • Loading branch information
jeff-mccoy committed Feb 8, 2022
1 parent 1132f19 commit 9416163
Show file tree
Hide file tree
Showing 5 changed files with 202 additions and 132 deletions.
111 changes: 0 additions & 111 deletions assets/misc/k9s-theme.yaml

This file was deleted.

23 changes: 17 additions & 6 deletions cli/cmd/tools.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@ package cmd
import (
"encoding/json"
"fmt"
"os"

"github.com/alecthomas/jsonschema"
"github.com/defenseunicorns/zarf/cli/config"
"github.com/defenseunicorns/zarf/cli/internal/git"
"github.com/defenseunicorns/zarf/cli/internal/message"
k9s "github.com/derailed/k9s/cmd"
craneCmd "github.com/google/go-containerregistry/cmd/crane/cmd"
"github.com/google/go-containerregistry/pkg/crane"
v1 "github.com/google/go-containerregistry/pkg/v1"
"github.com/mholt/archiver/v3"
"github.com/spf13/cobra"
)
Expand Down Expand Up @@ -79,23 +80,33 @@ var configSchemaCmd = &cobra.Command{
},
}

var k9sCmd = &cobra.Command{
Use: "k9s",
Short: "Launch K9s tool for managing K8s clusters",
Run: func(cmd *cobra.Command, args []string) {
// Hack to make k9s think it's all alone
os.Args = []string{os.Args[0], "-n", "zarf"}
k9s.Execute()
},
}

func init() {
rootCmd.AddCommand(toolsCmd)

toolsCmd.AddCommand(archiverCmd)
toolsCmd.AddCommand(readCredsCmd)
toolsCmd.AddCommand(configSchemaCmd)
toolsCmd.AddCommand(k9sCmd)
toolsCmd.AddCommand(registryCmd)

archiverCmd.AddCommand(archiverCompressCmd)
archiverCmd.AddCommand(archiverDecompressCmd)

toolsCmd.AddCommand(registryCmd)
cranePlatformOptions := []crane.Option{
crane.WithPlatform(&v1.Platform{OS: "linux", Architecture: "amd64"}),
crane.WithPlatform(&v1.Platform{OS: "linux", Architecture: "arm64"}),
}
cranePlatformOptions := []crane.Option{config.ActiveCranePlatform}
registryCmd.AddCommand(craneCmd.NewCmdAuthLogin())
registryCmd.AddCommand(craneCmd.NewCmdPull(&cranePlatformOptions))
registryCmd.AddCommand(craneCmd.NewCmdPush(&cranePlatformOptions))
registryCmd.AddCommand(craneCmd.NewCmdCopy(&cranePlatformOptions))
registryCmd.AddCommand(craneCmd.NewCmdCatalog(&cranePlatformOptions))

}
3 changes: 2 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ go 1.16
require (
github.com/AlecAivazis/survey/v2 v2.3.2
github.com/alecthomas/jsonschema v0.0.0-20211228220459-151e3c21f49d
github.com/derailed/k9s v0.25.18
github.com/distribution/distribution/v3 v3.0.0-20210804104954-38ab4c606ee3
github.com/docker/cli v20.10.12+incompatible
github.com/fatih/color v1.13.0
Expand All @@ -25,7 +26,7 @@ require (
k8s.io/apimachinery v0.22.5
k8s.io/client-go v0.22.5
k8s.io/klog/v2 v2.40.1
sigs.k8s.io/yaml v1.2.0
sigs.k8s.io/yaml v1.3.0
)

replace (
Expand Down
Loading

0 comments on commit 9416163

Please sign in to comment.