Skip to content

Commit

Permalink
feat: add 'config-git-dir' global option (#435)
Browse files Browse the repository at this point in the history
* feat: add 'config-git-dir' global option

* fix: set '.' as default value for config-git-dir
  • Loading branch information
gacevicljubisa authored Dec 5, 2024
1 parent 53edf0f commit bf56c7d
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 12 deletions.
6 changes: 3 additions & 3 deletions cmd/beekeeper/cmd/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ func (c *command) deleteCluster(ctx context.Context, clusterName string, cfg *co
nName = v.Nodes[i].Name
}
if err := g.DeleteNode(ctx, nName); err != nil {
return fmt.Errorf("deleting node %s from the node group %s", nName, ngName)
return fmt.Errorf("deleting node %s from the node group %s: %w", nName, ngName, err)
}

if deleteStorage && *ngConfig.PersistenceEnabled {
Expand All @@ -77,7 +77,7 @@ func (c *command) deleteCluster(ctx context.Context, clusterName string, cfg *co
nName = v.Nodes[i].Name
}
if err := ng.DeleteNode(ctx, nName); err != nil {
return fmt.Errorf("deleting node %s from the node group %s", nName, ngName)
return fmt.Errorf("deleting node %s from the node group %s: %w", nName, ngName, err)
}

if deleteStorage && *ngConfig.PersistenceEnabled {
Expand All @@ -91,7 +91,7 @@ func (c *command) deleteCluster(ctx context.Context, clusterName string, cfg *co
for i := 0; i < v.Count; i++ {
nName := fmt.Sprintf("%s-%d", ngName, i)
if err := ng.DeleteNode(ctx, nName); err != nil {
return fmt.Errorf("deleting node %s from the node group %s", nName, ngName)
return fmt.Errorf("deleting node %s from the node group %s: %w", nName, ngName, err)
}

if deleteStorage && *ngConfig.PersistenceEnabled {
Expand Down
12 changes: 9 additions & 3 deletions cmd/beekeeper/cmd/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (
const (
optionNameConfigDir = "config-dir"
optionNameConfigGitRepo = "config-git-repo"
optionNameConfigGitDir = "config-git-dir"
optionNameConfigGitBranch = "config-git-branch"
optionNameConfigGitUsername = "config-git-username"
optionNameConfigGitPassword = "config-git-password"
Expand Down Expand Up @@ -146,6 +147,7 @@ func (c *command) initGlobalFlags() {
globalFlags.StringVar(&c.globalConfigFile, "config", "", "config file (default is $HOME/.beekeeper.yaml)")
globalFlags.String(optionNameConfigDir, filepath.Join(c.homeDir, "/.beekeeper/"), "config directory (default is $HOME/.beekeeper/)")
globalFlags.String(optionNameConfigGitRepo, "", "Git repository with configurations (uses config directory when Git repo is not specified) (default \"\")")
globalFlags.String(optionNameConfigGitDir, ".", "Git directory in the repository with configurations (default \".\")")
globalFlags.String(optionNameConfigGitBranch, "main", "Git branch")
globalFlags.String(optionNameConfigGitUsername, "", "Git username (needed for private repos)")
globalFlags.String(optionNameConfigGitPassword, "", "Git password or personal access tokens (needed for private repos)")
Expand Down Expand Up @@ -226,16 +228,20 @@ func (c *command) initConfig() (err error) {
return fmt.Errorf("cloning repo %s: %w ", c.globalConfig.GetString(optionNameConfigGitRepo), err)
}

files, err := fs.ReadDir(".")
dir := c.globalConfig.GetString(optionNameConfigGitDir)

files, err := fs.ReadDir(dir)
if err != nil {
return err
return fmt.Errorf("reading git config dir: %w", err)
}

yamlFiles := []config.YamlFile{}
for _, file := range files {
if file.IsDir() || (!strings.HasSuffix(file.Name(), ".yaml") && !strings.HasSuffix(file.Name(), ".yml")) {
continue
}
f, err := fs.Open(file.Name())
filePath := filepath.Join(dir, file.Name())
f, err := fs.Open(filePath)
if err != nil {
return fmt.Errorf("opening file %s: %w ", file.Name(), err)
}
Expand Down
11 changes: 6 additions & 5 deletions config/beekeeper-local.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
#config-dir: $HOME/.beekeeper
#config-git-repo: ""
#config-git-branch: main
#config-git-username: <GitHub username>
#config-git-password: <GitHub Personal Access Token>
# config-dir: $HOME/.beekeeper
# config-git-repo: "https://github.com/ethersphere/beekeeper"
# config-git-dir: ""
# config-git-branch: main
# config-git-username: <GitHub username>
# config-git-password: <GitHub Personal Access Token>
enable-k8s: true
in-cluster: false
kubeconfig: "~/.kube/config"
Expand Down
17 changes: 17 additions & 0 deletions config/public-testnet.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -126,3 +126,20 @@ checks:
postage-label: gsoc-label
timeout: 10m
type: gsoc
pt-testnet-load:
options:
content-size: 50000000
postage-amount: 1000000000 # 1024/15*60*60*24*7
postage-depth: 24
duration: 12h
uploader-count: 2
downloader-count: 0
max-use-batch: 1h
upload-groups:
- bee-1
- bee-2
download-groups:
- bee-3
- bee-4
timeout: 12h
type: load
21 changes: 20 additions & 1 deletion config/staging.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ clusters:
staging:
_inherit: ""
name: bee
namespace: beekeeper
namespace: staging
disable-namespace: false
api-domain: testnet.internal
api-insecure-tls: true
Expand Down Expand Up @@ -38,3 +38,22 @@ bee-configs:
swap-factory-address: ""
verbosity: 4
welcome-message: Welcome to the bee staging environment created by Beekeeper!

checks:
st-testnet-load:
options:
content-size: 50000000
postage-amount: 1000000000
postage-depth: 24
duration: 12h
uploader-count: 2
downloader-count: 0
max-use-batch: 1h
upload-groups:
- bee-1
- bee-2
download-groups:
- bee-3
- bee-4
timeout: 12h
type: load

0 comments on commit bf56c7d

Please sign in to comment.