Skip to content

Commit

Permalink
chore: refactor vaulturl -> secreturl
Browse files Browse the repository at this point in the history
Signed-off-by: James Strachan <james.strachan@gmail.com>
  • Loading branch information
jstrachan committed Jun 19, 2019
1 parent 7c553ba commit 089882f
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 16 deletions.
4 changes: 2 additions & 2 deletions pkg/apps/values.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"path/filepath"
"strings"

"github.com/jenkins-x/jx/pkg/vaulturl"
"github.com/jenkins-x/jx/pkg/secreturl"
"gopkg.in/AlecAivazis/survey.v1/terminal"

"github.com/ghodss/yaml"
Expand Down Expand Up @@ -188,7 +188,7 @@ func GenerateQuestions(schema []byte, batchMode bool, askExisting bool, basePath
secrets = append(secrets, secret)
if passthrough {
if useVault {
return vaulturl.ToURI(secret.Path, secret.Key), nil
return secreturl.ToURI(secret.Path, secret.Key), nil
}
return value, nil
}
Expand Down
12 changes: 6 additions & 6 deletions pkg/helm/helm_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ import (

"github.com/jenkins-x/jx/pkg/kube"
"github.com/jenkins-x/jx/pkg/log"
"github.com/jenkins-x/jx/pkg/secreturl"
"github.com/jenkins-x/jx/pkg/table"
"github.com/jenkins-x/jx/pkg/util"
"github.com/jenkins-x/jx/pkg/vaulturl"
"github.com/jenkins-x/jx/pkg/version"

"k8s.io/client-go/kubernetes"
Expand Down Expand Up @@ -517,7 +517,7 @@ type InstallChartOptions struct {
// respecting the installTimeout, looking up or updating Vault with the username and password for the repo.
// If vaultClient is nil then username and passwords for repos will not be looked up in Vault.
func InstallFromChartOptions(options InstallChartOptions, helmer Helmer, kubeClient kubernetes.Interface,
installTimeout string, vaultClient vaulturl.Client) error {
installTimeout string, vaultClient secreturl.Client) error {
chart := options.Chart
if options.Version == "" {
versionsDir := options.VersionsDir
Expand Down Expand Up @@ -573,7 +573,7 @@ type HelmRepoCredential struct {

// DecorateWithSecrets will replace any vault: URIs with the secret from vault. Safe to call with a nil client (
// no replacement will take place).
func DecorateWithSecrets(options *InstallChartOptions, vaultClient vaulturl.Client) (func(), error) {
func DecorateWithSecrets(options *InstallChartOptions, vaultClient secreturl.Client) (func(), error) {
cleanup := func() {
}
if vaultClient != nil {
Expand All @@ -595,7 +595,7 @@ func DecorateWithSecrets(options *InstallChartOptions, vaultClient vaulturl.Clie
if err != nil {
return cleanup, errors.Wrapf(err, "reading file %s", valueFile)
}
newValues, err := vaulturl.ReplaceURIs(string(bytes), vaultClient)
newValues, err := secreturl.ReplaceURIs(string(bytes), vaultClient)
if err != nil {
return cleanup, errors.Wrapf(err, "replacing vault URIs")
}
Expand All @@ -615,7 +615,7 @@ func DecorateWithSecrets(options *InstallChartOptions, vaultClient vaulturl.Clie
// The repo name may have a suffix added in order to prevent name collisions, and is returned for this reason.
// The username and password will be stored in vault for the URL (if vault is enabled).
func AddHelmRepoIfMissing(helmURL, repoName, username, password string, helmer Helmer,
vaultClient vaulturl.Client, in terminal.FileReader,
vaultClient secreturl.Client, in terminal.FileReader,
out terminal.FileWriter, outErr io.Writer) (string, error) {
missing, existingName, err := helmer.IsRepoMissing(helmURL)
if err != nil {
Expand Down Expand Up @@ -662,7 +662,7 @@ func AddHelmRepoIfMissing(helmURL, repoName, username, password string, helmer H
}

// DecorateWithCredentials will, if vault is installed, store or replace the username or password
func DecorateWithCredentials(repo string, username string, password string, vaultClient vaulturl.Client, in terminal.FileReader,
func DecorateWithCredentials(repo string, username string, password string, vaultClient secreturl.Client, in terminal.FileReader,
out terminal.FileWriter, outErr io.Writer) (string,
string, error) {
if repo != "" && vaultClient != nil {
Expand Down
2 changes: 1 addition & 1 deletion pkg/helm/helm_helpers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"strings"
"testing"

"github.com/jenkins-x/jx/pkg/vaulturl/localvault"
"github.com/jenkins-x/jx/pkg/secreturl/localvault"
"github.com/pborman/uuid"
"github.com/petergtz/pegomock"
"github.com/stretchr/testify/require"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package vaulturl
package secreturl

// Client is a simple interface for Vault-like things such as `vault.Client` or a file system we can use to
// access secret files and values in helm.
Expand Down
2 changes: 1 addition & 1 deletion pkg/vaulturl/helpers.go → pkg/secreturl/helpers.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package vaulturl
package secreturl

import (
"fmt"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import (
"path/filepath"

"github.com/jenkins-x/jx/pkg/helm"
"github.com/jenkins-x/jx/pkg/secreturl"
"github.com/jenkins-x/jx/pkg/util"
"github.com/jenkins-x/jx/pkg/vaulturl"
"github.com/pkg/errors"
)

Expand All @@ -17,7 +17,7 @@ type FileSystemClient struct {
}

// NewFileSystemClient create a new local file system based client loading content from the given URL
func NewFileSystemClient(dir string) vaulturl.Client {
func NewFileSystemClient(dir string) secreturl.Client {
return &FileSystemClient{
Dir: dir,
}
Expand Down
6 changes: 3 additions & 3 deletions pkg/vault/helpers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"io/ioutil"
"testing"

"github.com/jenkins-x/jx/pkg/vaulturl"
"github.com/jenkins-x/jx/pkg/secreturl"
"github.com/pborman/uuid"

"github.com/stretchr/testify/assert"
Expand Down Expand Up @@ -35,7 +35,7 @@ func TestReplaceURIs(t *testing.T) {
pegomock.When(vaultClient.Read(pegomock.EqString(path))).ThenReturn(map[string]interface{}{
key: secret,
}, nil)
result, err := vaulturl.ReplaceURIs(valuesyaml, vaultClient)
result, err := secreturl.ReplaceURIs(valuesyaml, vaultClient)
assert.NoError(t, err)
assert.NoError(t, err)
assert.Equal(t, fmt.Sprintf(`foo:
Expand Down Expand Up @@ -63,7 +63,7 @@ func TestReplaceRealExampleURI(t *testing.T) {
pegomock.When(vaultClient.Read(pegomock.EqString(path))).ThenReturn(map[string]interface{}{
key: secret,
}, nil)
result, err := vaulturl.ReplaceURIs(valuesyaml, vaultClient)
result, err := secreturl.ReplaceURIs(valuesyaml, vaultClient)
assert.NoError(t, err)
assert.NoError(t, err)
assert.Equal(t, fmt.Sprintf(`foo:
Expand Down

0 comments on commit 089882f

Please sign in to comment.