Skip to content

Commit

Permalink
Merge pull request #241 from shiftstack/minor
Browse files Browse the repository at this point in the history
Minor changes
  • Loading branch information
mandre authored Dec 20, 2024
2 parents d291cd6 + aecae7e commit 2e0af06
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
1 change: 0 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ go 1.22
require (
github.com/gofrs/uuid/v5 v5.3.0
github.com/gophercloud/gophercloud/v2 v2.4.0
github.com/mitchellh/go-homedir v1.1.0
golang.org/x/sys v0.28.0
golang.org/x/text v0.21.0
gopkg.in/yaml.v3 v3.0.1
Expand Down
2 changes: 0 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ github.com/gofrs/uuid/v5 v5.3.0 h1:m0mUMr+oVYUdxpMLgSYCZiXe7PuVPnI94+OMeVBNedk=
github.com/gofrs/uuid/v5 v5.3.0/go.mod h1:CDOjlDMVAtN56jqyRUZh58JT31Tiw7/oQyEXZV+9bD8=
github.com/gophercloud/gophercloud/v2 v2.4.0 h1:XhP5tVEH3ni66NSNK1+0iSO6kaGPH/6srtx6Cr+8eCg=
github.com/gophercloud/gophercloud/v2 v2.4.0/go.mod h1:uJWNpTgJPSl2gyzJqcU/pIAhFUWvIkp8eE8M15n9rs4=
github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y=
github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
golang.org/x/sys v0.28.0 h1:Fksou7UEQUWlKvIdsqzJmUmCX3cZuD2+P3XyyzwMhlA=
golang.org/x/sys v0.28.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/text v0.21.0 h1:zyQAAkrwaneQ066sspRyJaG9VNi/YJ1NfzcGB3hZ/qo=
Expand Down
16 changes: 10 additions & 6 deletions internal/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,11 @@ import (
"crypto/tls"
"crypto/x509"
"fmt"
"io/ioutil"
"os"
"os/user"
"path/filepath"
"reflect"
"strings"

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

// RemainingKeys will inspect a struct and compare it to a map. Any struct
Expand Down Expand Up @@ -92,15 +91,20 @@ func pathOrContents(poc string) ([]byte, bool, error) {

path := poc
if path[0] == '~' {
var err error
path, err = homedir.Expand(path)
usr, err := user.Current()
if err != nil {
return []byte(path), true, err
}

if len(path) == 1 {
path = usr.HomeDir
} else if strings.HasPrefix(path, "~/") {
path = filepath.Join(usr.HomeDir, path[2:])
}
}

if _, err := os.Stat(path); err == nil {
contents, err := ioutil.ReadFile(path)
contents, err := os.ReadFile(path)
if err != nil {
return contents, true, err
}
Expand Down

0 comments on commit 2e0af06

Please sign in to comment.