From f9e2ea9bd67288d0301edd547ffc7c36ce215ba2 Mon Sep 17 00:00:00 2001 From: Mariano Cano Date: Tue, 18 Jun 2019 14:44:19 -0700 Subject: [PATCH] Revert "Do not depend on config package." This reverts commit cc1c6f2cb458b29f151820fec82e76aa16082b26. --- ca/client.go | 23 ++--------------------- 1 file changed, 2 insertions(+), 21 deletions(-) diff --git a/ca/client.go b/ca/client.go index 14077d95..c9766293 100644 --- a/ca/client.go +++ b/ca/client.go @@ -17,8 +17,6 @@ import ( "net/http" "net/url" "os" - "os/user" - "path" "path/filepath" "strconv" "strings" @@ -26,6 +24,7 @@ import ( "github.com/pkg/errors" "github.com/smallstep/certificates/api" "github.com/smallstep/certificates/authority" + "github.com/smallstep/cli/config" "github.com/smallstep/cli/crypto/x509util" "gopkg.in/square/go-jose.v2/jwt" ) @@ -586,7 +585,7 @@ func getInsecureClient() *http.Client { // getRootCAPath returns the path where the root CA is stored based on the // STEPPATH environment variable. func getRootCAPath() string { - return filepath.Join(stepPath(), "certs", "root_ca.crt") + return filepath.Join(config.StepPath(), "certs", "root_ca.crt") } func readJSON(r io.ReadCloser, v interface{}) error { @@ -602,21 +601,3 @@ func readError(r io.ReadCloser) error { } return apiErr } - -// stepPath returns the step path. config.StepPath is not used because it will -// fail if it cannot create the folder. -func stepPath() string { - stepPath := os.Getenv("STEPPATH") - if stepPath == "" { - usr, err := user.Current() - if err == nil && usr.HomeDir != "" { - stepPath = path.Join(usr.HomeDir, ".step") - } else if home := os.Getenv("HOME"); home != "" { - stepPath = path.Join(home, ".step") - } else { - stepPath = "." - } - } - // cleanup - return path.Clean(stepPath) -}