Skip to content

Commit

Permalink
fix: some naming conflicts with ydb CLI
Browse files Browse the repository at this point in the history
  • Loading branch information
Jorres committed Jun 25, 2024
1 parent c619c02 commit a41cd39
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
8 changes: 4 additions & 4 deletions pkg/options/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,15 +79,15 @@ func (a *AuthStatic) DefineFlags(fs *pflag.FlagSet) {
User name search order:
1. This option
2. "%s" environment variable
3. active profile, see --config-file`, DefaultStaticUserEnvVar))
3. active profile, see --profile-file`, DefaultStaticUserEnvVar))

profile.PopulateFromProfileLater(
fs.StringVar, &a.PasswordFile, "password-file", "",
fmt.Sprintf(`File with password to authenticate with.
Password search order:
1. This option
2. "%s" environment variable (interpreted as password, not as a filepath)
3. active profile, see --config-file`, DefaultStaticPasswordEnvVar))
3. active profile, see --profile-file`, DefaultStaticPasswordEnvVar))

fs.BoolVar(&a.NoPassword, "no-password", false,
"TODO NOT IMPLEMENTED Do not ask for user password (if empty) (default: false)")
Expand Down Expand Up @@ -121,7 +121,7 @@ func (a *AuthIAMToken) DefineFlags(fs *pflag.FlagSet) {
Token search order:
1. This option
2. "YDB_TOKEN" environment variable (interpreted as token, not as a filepath)
3. active profile, see --config-file`)
3. active profile, see --profile-file`)
}

func (a *AuthIAMToken) Validate() error {
Expand Down Expand Up @@ -154,7 +154,7 @@ func (a *AuthIAMCreds) DefineFlags(fs *pflag.FlagSet) {
Definition priority:
1. This option
2. "%s" environment variable (interpreted as path to the file)
3. active profile, see --config-file`, DefaultServiceAccountKeyFile))
3. active profile, see --profile-file`, DefaultServiceAccountKeyFile))
fs.StringVarP(&a.Endpoint, "iam-endpoint", "", DefaultAuthIAMEndpoint,
"Authentication iam endpoint")
}
Expand Down
8 changes: 4 additions & 4 deletions pkg/options/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ package options

import (
"errors"
"fmt"
"os"
"path/filepath"

"github.com/spf13/pflag"
)
Expand Down Expand Up @@ -35,7 +35,7 @@ func (o *RootOptions) DefineFlags(fs *pflag.FlagSet) {

defaultProfileLocation := ""
if home, present := os.LookupEnv("HOME"); present {
defaultProfileLocation = fmt.Sprintf("%s/ydb/ydbops/config/config.yaml", home)
defaultProfileLocation = filepath.Join(home, "ydb", "ydbops", "config", "config.yaml")
}

_, err := os.Stat(defaultProfileLocation)
Expand All @@ -46,14 +46,14 @@ func (o *RootOptions) DefineFlags(fs *pflag.FlagSet) {
}

fs.StringVar(
&o.ProfileFile, "config-file",
&o.ProfileFile, "profile-file",
defaultProfileLocation,
"Path to config file with profile data in yaml format. Default: $HOME/ydb/ydbops/config/config.yaml")

fs.StringVar(
&o.ActiveProfile, "profile",
"",
"Override currently set profile name from --config-file")
"Override currently set profile name from --profile-file")

fs.BoolVar(&o.Verbose, "verbose", false, "Switches log level from INFO to DEBUG")
}
4 changes: 2 additions & 2 deletions tests/profile_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ var _ = Describe("Test Profile", func() {
steps: []StepData{
{
ydbopsInvocation: Command{
"--config-file",
"--profile-file",
filepath.Join(".", "test-data", "config_with_active_profile.yaml"),
"--availability-mode", "strong",
"--cms-query-interval", "1",
Expand Down Expand Up @@ -101,7 +101,7 @@ var _ = Describe("Test Profile", func() {
steps: []StepData{
{
ydbopsInvocation: Command{
"--config-file",
"--profile-file",
filepath.Join(".", "test-data", "config_without_active_profile.yaml"),
"--profile",
"my-profile",
Expand Down

0 comments on commit a41cd39

Please sign in to comment.