-
Notifications
You must be signed in to change notification settings - Fork 432
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: clean up & add synccontext to HostName
- Loading branch information
1 parent
3922aee
commit 82ac24b
Showing
114 changed files
with
613 additions
and
11,136 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package etcd | ||
|
||
import ( | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
func NewEtcdCmd() *cobra.Command { | ||
debugCmd := &cobra.Command{ | ||
Use: "etcd", | ||
Short: "vCluster etcd subcommand", | ||
Long: `####################################################### | ||
############### vcluster debug etcd ############### | ||
####################################################### | ||
`, | ||
Args: cobra.NoArgs, | ||
} | ||
|
||
debugCmd.AddCommand(NewKeysCommand()) | ||
return debugCmd | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
package etcd | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
"os" | ||
|
||
"github.com/loft-sh/vcluster/pkg/config" | ||
"github.com/loft-sh/vcluster/pkg/constants" | ||
"github.com/loft-sh/vcluster/pkg/etcd" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
type KeysOptions struct { | ||
Config string | ||
|
||
Prefix string | ||
} | ||
|
||
func NewKeysCommand() *cobra.Command { | ||
options := &KeysOptions{} | ||
cmd := &cobra.Command{ | ||
Use: "keys", | ||
Short: "Dump the vCluster etcd stored keys", | ||
Args: cobra.NoArgs, | ||
RunE: func(cobraCommand *cobra.Command, _ []string) (err error) { | ||
return ExecuteKeys(cobraCommand.Context(), options) | ||
}, | ||
} | ||
|
||
cmd.Flags().StringVar(&options.Config, "config", constants.DefaultVClusterConfigLocation, "The path where to find the vCluster config to load") | ||
cmd.Flags().StringVar(&options.Prefix, "prefix", "/", "The prefix to use for listing the keys") | ||
return cmd | ||
} | ||
|
||
func ExecuteKeys(ctx context.Context, options *KeysOptions) error { | ||
// parse vCluster config | ||
vConfig, err := config.ParseConfig(options.Config, os.Getenv("VCLUSTER_NAME"), nil) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
// create new etcd client | ||
etcdClient, err := etcd.NewFromConfig(ctx, vConfig) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
// create new etcd backend & list mappings | ||
keyValues, err := etcdClient.List(ctx, options.Prefix, 0) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
// print mappings | ||
for _, keyValue := range keyValues { | ||
fmt.Println(string(keyValue.Key)) | ||
} | ||
|
||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.