소스 검색

Revert "Do not depend on config package."

This reverts commit cc1c6f2cb458b29f151820fec82e76aa16082b26.
Mariano Cano 7 년 전
부모
커밋
f9e2ea9bd6
1개의 변경된 파일과 2개의 추가작업 그리고 21개의 파일을 삭제
  1. 2 21
      ca/client.go

+ 2 - 21
ca/client.go

@@ -17,8 +17,6 @@ import (
 	"net/http"
 	"net/http"
 	"net/url"
 	"net/url"
 	"os"
 	"os"
-	"os/user"
-	"path"
 	"path/filepath"
 	"path/filepath"
 	"strconv"
 	"strconv"
 	"strings"
 	"strings"
@@ -26,6 +24,7 @@ import (
 	"github.com/pkg/errors"
 	"github.com/pkg/errors"
 	"github.com/smallstep/certificates/api"
 	"github.com/smallstep/certificates/api"
 	"github.com/smallstep/certificates/authority"
 	"github.com/smallstep/certificates/authority"
+	"github.com/smallstep/cli/config"
 	"github.com/smallstep/cli/crypto/x509util"
 	"github.com/smallstep/cli/crypto/x509util"
 	"gopkg.in/square/go-jose.v2/jwt"
 	"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
 // getRootCAPath returns the path where the root CA is stored based on the
 // STEPPATH environment variable.
 // STEPPATH environment variable.
 func getRootCAPath() string {
 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 {
 func readJSON(r io.ReadCloser, v interface{}) error {
@@ -602,21 +601,3 @@ func readError(r io.ReadCloser) error {
 	}
 	}
 	return apiErr
 	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)
-}