Skip to content

Commit

Permalink
replace password cmd with go-bits implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
VoigtS committed Dec 20, 2023
1 parent 9a31e20 commit b3e4076
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 10 deletions.
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ require (
github.com/gophercloud/utils v0.0.0-20231010081019-80377eca5d56
github.com/olekukonko/tablewriter v0.0.5
github.com/sapcc/go-api-declarations v1.10.5
github.com/sapcc/go-bits v0.0.0-20231213211425-ddd5e41f8535
github.com/sapcc/gophercloud-sapcc v0.0.0-20231214091214-e4517ca1b6a4
github.com/spf13/cobra v1.8.0
)
Expand Down
4 changes: 4 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,12 @@ github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/sapcc/go-api-declarations v1.10.5 h1:1jGXudH2kcS0JCfGqooHszhSIe7BCvqu7QYJdqfas0A=
github.com/sapcc/go-api-declarations v1.10.5/go.mod h1:83R3hTANhuRXt/pXDby37IJetw8l7DG41s33Tp9NXxI=
github.com/sapcc/go-bits v0.0.0-20231213211425-ddd5e41f8535 h1:spliyqfKEO+098p/TBNjNIhXoyCqj1Zf+pROsaoN9SQ=
github.com/sapcc/go-bits v0.0.0-20231213211425-ddd5e41f8535/go.mod h1:jsn7K60WbjIzXz5V38eeHP2SNsBsCpFOtbXOSsBZXoQ=
github.com/sapcc/gophercloud-sapcc v0.0.0-20231214091214-e4517ca1b6a4 h1:bPzqErdlvFN8KkZorXj0Js2bIMrSAt5oGdo65ncjnSM=
github.com/sapcc/gophercloud-sapcc v0.0.0-20231214091214-e4517ca1b6a4/go.mod h1:W7BMHKOIhBMtBOqCDBT4APx7A48q7wt9i0jPB0PDXLs=
github.com/sergi/go-diff v1.3.1 h1:xkr+Oxo4BOQKmkn/B9eMK0g5Kg/983T9DqqPHwYqD+8=
github.com/sergi/go-diff v1.3.1/go.mod h1:aMJSSKb2lpPvRNec0+w3fl7LP9IOFzdc9Pa4NFbPK1I=
github.com/spf13/cobra v1.8.0 h1:7aJaZx1B85qltLMc546zn58BxxfZdR/W22ej9CFoEf0=
github.com/spf13/cobra v1.8.0/go.mod h1:WXLWApfZ71AjXPya3WOlMsY9yMs7YeiHhFVlvLyhcho=
github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
Expand Down
13 changes: 3 additions & 10 deletions internal/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,12 @@ import (
"fmt"
"net/http"
"os"
"os/exec"
"strings"

"github.com/gophercloud/gophercloud"
"github.com/gophercloud/gophercloud/openstack"
"github.com/gophercloud/utils/client"
"github.com/gophercloud/utils/openstack/clientconfig"
"github.com/sapcc/go-bits/secrets"

Check failure on line 27 in internal/cmd/root.go

View workflow job for this annotation

GitHub Actions / Analyze

cannot find module providing package github.com/sapcc/go-bits/secrets: import lookup disabled by -mod=vendor

Check failure on line 27 in internal/cmd/root.go

View workflow job for this annotation

GitHub Actions / Analyze

cannot find module providing package github.com/sapcc/go-bits/secrets: import lookup disabled by -mod=vendor

Check failure on line 27 in internal/cmd/root.go

View workflow job for this annotation

GitHub Actions / Analyze

cannot find module providing package github.com/sapcc/go-bits/secrets: import lookup disabled by -mod=vendor

Check failure on line 27 in internal/cmd/root.go

View workflow job for this annotation

GitHub Actions / Build & Lint

cannot find module providing package github.com/sapcc/go-bits/secrets: import lookup disabled by -mod=vendor

Check failure on line 27 in internal/cmd/root.go

View workflow job for this annotation

GitHub Actions / Build & Lint

cannot find module providing package github.com/sapcc/go-bits/secrets: import lookup disabled by -mod=vendor

Check failure on line 27 in internal/cmd/root.go

View workflow job for this annotation

GitHub Actions / Build & Lint

cannot find module providing package github.com/sapcc/go-bits/secrets: import lookup disabled by -mod=vendor

Check failure on line 27 in internal/cmd/root.go

View workflow job for this annotation

GitHub Actions / Checks

cannot find module providing package github.com/sapcc/go-bits/secrets: import lookup disabled by -mod=vendor

Check failure on line 27 in internal/cmd/root.go

View workflow job for this annotation

GitHub Actions / Checks

could not import github.com/sapcc/go-bits/secrets (invalid package name: "")
"github.com/sapcc/gophercloud-sapcc/clients"
"github.com/spf13/cobra"

Expand Down Expand Up @@ -109,14 +108,8 @@ func authenticate() (*gophercloud.ProviderClient, error) {
// Update OpenStack environment variables, if value(s) provided as flag.
updateOpenStackEnvVars()

pwCmd := os.Getenv("OS_PW_CMD")
if pwCmd != "" && os.Getenv("OS_PASSWORD") == "" {
// Retrieve user's password from external command.
out, err := exec.Command("sh", "-c", pwCmd).Output()
if err != nil {
return nil, util.WrapError(err, fmt.Sprintf("could not retrieve user password using: %s", pwCmd))
}
setenvIfVal("OS_PASSWORD", strings.TrimSuffix(string(out), "\n"))
if err := secrets.GetPasswordFromCommandIfRequested(); err != nil {
return nil, err
}
ao, err := clientconfig.AuthOptions(nil)
if err != nil {
Expand Down
5 changes: 5 additions & 0 deletions vendor/modules.txt
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ github.com/sapcc/go-api-declarations/internal/marshal
github.com/sapcc/go-api-declarations/limes
github.com/sapcc/go-api-declarations/limes/rates
github.com/sapcc/go-api-declarations/limes/resources
# github.com/sapcc/go-bits v0.0.0-20231213211425-ddd5e41f8535
## explicit; go 1.21
github.com/sapcc/go-bits/logg
github.com/sapcc/go-bits/osext
github.com/sapcc/go-bits/secrets
# github.com/sapcc/gophercloud-sapcc v0.0.0-20231214091214-e4517ca1b6a4
## explicit; go 1.21
github.com/sapcc/gophercloud-sapcc/clients
Expand Down

0 comments on commit b3e4076

Please sign in to comment.