Skip to content
This repository has been archived by the owner on Jan 9, 2023. It is now read-only.

Commit

Permalink
Merge pull request #774 from simonswine/automated-cherry-pick-of-#773…
Browse files Browse the repository at this point in the history
…-release-0.6

Automated cherry pick of #773
  • Loading branch information
jetstack-bot committed Mar 14, 2019
2 parents 7c8b918 + 35a16ea commit 9886443
Show file tree
Hide file tree
Showing 9 changed files with 8 additions and 24 deletions.
2 changes: 1 addition & 1 deletion pkg/puppet/puppet.go
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,7 @@ func (p *Puppet) writeLines(filePath string, lines []string) error {
// TODO: delete a potentially existing file
return nil
}
err := utils.EnsureDirectory(filepath.Dir(filePath), 0750)
err := os.MkdirAll(filepath.Dir(filePath), 0750)
if err != nil {
return err
}
Expand Down
3 changes: 1 addition & 2 deletions pkg/tarmak/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import (
clusterv1alpha1 "github.com/jetstack/tarmak/pkg/apis/cluster/v1alpha1"
tarmakv1alpha1 "github.com/jetstack/tarmak/pkg/apis/tarmak/v1alpha1"
"github.com/jetstack/tarmak/pkg/tarmak/interfaces"
"github.com/jetstack/tarmak/pkg/tarmak/utils"
)

type Config struct {
Expand Down Expand Up @@ -103,7 +102,7 @@ func (c *Config) writeYAML(config *tarmakv1alpha1.Config) error {
encoder = json.NewYAMLSerializer(json.DefaultMetaFactory, c.scheme, c.scheme)
encoder = c.codecs.EncoderForVersion(encoder, tarmakv1alpha1.SchemeGroupVersion)

err := utils.EnsureDirectory(filepath.Dir(c.configPath()), 0750)
err := os.MkdirAll(filepath.Dir(c.configPath()), 0750)
if err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/tarmak/environment/environment.go
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ func (e *Environment) getSSHPrivateKey() (interface{}, error) {
path := e.SSHPrivateKeyPath()

if _, err := os.Stat(path); os.IsNotExist(err) {
if err := utils.EnsureDirectory(filepath.Dir(path), 0700); err != nil {
if err := os.MkdirAll(filepath.Dir(path), 0700); err != nil {
return nil, fmt.Errorf("error creating directory: %s", err)
}

Expand Down
3 changes: 1 addition & 2 deletions pkg/tarmak/kubectl/kubectl.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import (

clusterv1alpha1 "github.com/jetstack/tarmak/pkg/apis/cluster/v1alpha1"
"github.com/jetstack/tarmak/pkg/tarmak/interfaces"
"github.com/jetstack/tarmak/pkg/tarmak/utils"
)

var _ interfaces.Kubectl = &Kubectl{}
Expand Down Expand Up @@ -209,7 +208,7 @@ func (k *Kubectl) ensureWorkingKubeconfig(configPath string, publicAPIEndpoint b
return err
}

if err := utils.EnsureDirectory(filepath.Dir(configPath), 0700); err != nil {
if err := os.MkdirAll(filepath.Dir(configPath), 0700); err != nil {
k.stopTunnel()
return err
}
Expand Down
3 changes: 1 addition & 2 deletions pkg/tarmak/ssh/ssh.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import (

clusterv1alpha1 "github.com/jetstack/tarmak/pkg/apis/cluster/v1alpha1"
"github.com/jetstack/tarmak/pkg/tarmak/interfaces"
"github.com/jetstack/tarmak/pkg/tarmak/utils"
)

var _ interfaces.SSH = &SSH{}
Expand Down Expand Up @@ -61,7 +60,7 @@ func New(tarmak interfaces.Tarmak) *SSH {
}

func (s *SSH) WriteConfig(c interfaces.Cluster) error {
err := utils.EnsureDirectory(filepath.Dir(c.SSHConfigPath()), 0700)
err := os.MkdirAll(filepath.Dir(c.SSHConfigPath()), 0700)
if err != nil {
return err
}
Expand Down
13 changes: 0 additions & 13 deletions pkg/tarmak/utils/files.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,11 @@
package utils

import (
"os"
"path/filepath"

"github.com/mitchellh/go-homedir"
)

func EnsureDirectory(path string, mode os.FileMode) error {
if _, err := os.Stat(path); os.IsNotExist(err) {
if err := EnsureDirectory(filepath.Dir(path), mode); err != nil {
return err
}
os.Mkdir(path, mode)
} else {
return err
}
return nil
}

func Expand(path string) (string, error) {
p, err := homedir.Expand(path)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion pkg/tarmak/vault/vault.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ func (v *Vault) RootToken() (string, error) {
path := v.rootTokenPath()

if _, err := os.Stat(path); os.IsNotExist(err) {
if err := utils.EnsureDirectory(filepath.Dir(path), 0700); err != nil {
if err := os.MkdirAll(filepath.Dir(path), 0700); err != nil {
return "", fmt.Errorf("error creating directory: %s", err)
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/terraform/templating.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func (t *Terraform) GenerateCode(c interfaces.Cluster) (err error) {
t.log.Info("generating terraform code")

terraformCodePath := t.codePath(c)
if err := utils.EnsureDirectory(
if err := os.MkdirAll(
terraformCodePath,
0700,
); err != nil {
Expand Down
2 changes: 1 addition & 1 deletion pkg/terraform/terraform.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ func (t *Terraform) preparePlugins(c interfaces.Cluster) error {
}

pluginPath := t.pluginPath(c)
if err := utils.EnsureDirectory(pluginPath, 0755); err != nil {
if err := os.MkdirAll(pluginPath, 0755); err != nil {
return err
}

Expand Down

0 comments on commit 9886443

Please sign in to comment.