Skip to content

Commit

Permalink
Move required const out of restic package (#375)
Browse files Browse the repository at this point in the history
  • Loading branch information
pavannd1 authored and mergify[bot] committed Oct 29, 2019
1 parent 673f595 commit f15eb57
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 10 deletions.
9 changes: 5 additions & 4 deletions pkg/consts/consts.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package consts

const (
ActionsetNameKey = "ActionSet"
PodNameKey = "Pod"
ContainerNameKey = "Container"
PhaseNameKey = "Phase"
ActionsetNameKey = "ActionSet"
PodNameKey = "Pod"
ContainerNameKey = "Container"
PhaseNameKey = "Phase"
GoogleCloudCredsFilePath = "/tmp/creds.txt"
)
4 changes: 2 additions & 2 deletions pkg/function/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ import (
"k8s.io/client-go/kubernetes"

crv1alpha1 "github.com/kanisterio/kanister/pkg/apis/cr/v1alpha1"
"github.com/kanisterio/kanister/pkg/consts"
"github.com/kanisterio/kanister/pkg/kube"
"github.com/kanisterio/kanister/pkg/log"
"github.com/kanisterio/kanister/pkg/param"
"github.com/kanisterio/kanister/pkg/restic"
"github.com/kanisterio/kanister/pkg/secrets"
)

Expand Down Expand Up @@ -60,7 +60,7 @@ func ValidateProfile(profile *param.Profile) error {
// GetPodWriter creates a file with Google credentials if the given profile points to a GCS location
func GetPodWriter(cli kubernetes.Interface, ctx context.Context, namespace, podName, containerName string, profile *param.Profile) (*kube.PodWriter, error) {
if profile.Location.Type == crv1alpha1.LocationTypeGCS {
pw := kube.NewPodWriter(cli, restic.GoogleCloudCredsFilePath, bytes.NewBufferString(profile.Credential.KeyPair.Secret))
pw := kube.NewPodWriter(cli, consts.GoogleCloudCredsFilePath, bytes.NewBufferString(profile.Credential.KeyPair.Secret))
if err := pw.Write(ctx, namespace, podName, containerName); err != nil {
return nil, err
}
Expand Down
8 changes: 4 additions & 4 deletions pkg/restic/restic.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (
"k8s.io/client-go/kubernetes"

crv1alpha1 "github.com/kanisterio/kanister/pkg/apis/cr/v1alpha1"
"github.com/kanisterio/kanister/pkg/consts"
"github.com/kanisterio/kanister/pkg/format"
"github.com/kanisterio/kanister/pkg/kube"
"github.com/kanisterio/kanister/pkg/location"
Expand All @@ -35,9 +36,8 @@ import (
)

const (
GoogleCloudCredsFilePath = "/tmp/creds.txt"
PasswordIncorrect = "Password is incorrect"
RepoDoesNotExist = "Repo does not exist"
PasswordIncorrect = "Password is incorrect"
RepoDoesNotExist = "Repo does not exist"
)

func shCommand(command string) []string {
Expand Down Expand Up @@ -240,7 +240,7 @@ func resticS3CredentialSecretArgs(secret *v1.Secret) ([]string, error) {
func resticGCSArgs(profile *param.Profile, repository string) []string {
return []string{
fmt.Sprintf("export %s=%s\n", location.GoogleProjectId, profile.Credential.KeyPair.ID),
fmt.Sprintf("export %s=%s\n", location.GoogleCloudCreds, GoogleCloudCredsFilePath),
fmt.Sprintf("export %s=%s\n", location.GoogleCloudCreds, consts.GoogleCloudCredsFilePath),
fmt.Sprintf("export %s=gs:%s/\n", ResticRepository, strings.Replace(repository, "/", ":/", 1)),
}
}
Expand Down

0 comments on commit f15eb57

Please sign in to comment.