-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #66 from equinix/config-file
load values from ~/.config/equinix/metal.yaml
- Loading branch information
Showing
7 changed files
with
108 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,19 @@ | ||
module github.com/equinix/docker-machine-driver-metal | ||
|
||
go 1.14 | ||
go 1.16 | ||
|
||
require ( | ||
github.com/Azure/go-ansiterm v0.0.0-20170929234023-d6e3b3328b78 // indirect | ||
github.com/carmo-evan/strtotime v0.0.0-20200108203155-3136cf889e3b | ||
github.com/docker/docker v0.0.0-20180805161158-f57f260b49b6 // indirect | ||
github.com/docker/machine v0.16.2 | ||
github.com/google/go-cmp v0.3.0 // indirect | ||
github.com/packethost/packngo v0.13.0 | ||
github.com/packethost/packngo v0.17.0 | ||
github.com/pkg/errors v0.8.1 // indirect | ||
github.com/sirupsen/logrus v1.6.0 // indirect | ||
github.com/stretchr/testify v1.5.1 | ||
golang.org/x/crypto v0.0.0-20200510223506-06a226fb4e37 // indirect | ||
golang.org/x/sys v0.0.0-20200515095857-1151b9dac4a9 // indirect | ||
gotest.tools v2.2.0+incompatible // indirect | ||
sigs.k8s.io/yaml v1.2.0 | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// SPDX-License-Identifier: BSD-3-Clause | ||
|
||
package metal | ||
|
||
import ( | ||
"os" | ||
"path" | ||
"runtime" | ||
) | ||
|
||
type metalSnakeConfig struct { | ||
Token string `json:"token,omitempty"` | ||
AuthToken string `json:"auth-token,omitempty"` | ||
Facility string `json:"facility,omitempty"` | ||
Metro string `json:"metro,omitempty"` | ||
OS string `json:"operating-system,omitempty"` | ||
Plan string `json:"plan,omitempty"` | ||
ProjectID string `json:"project-id,omitempty"` | ||
} | ||
|
||
func getConfigFile() string { | ||
configFile := os.Getenv("METAL_CONFIG") | ||
if configFile != "" { | ||
return configFile | ||
} | ||
|
||
return path.Join(userHomeDir(), "/.config/equinix/metal.yaml") | ||
} | ||
|
||
func userHomeDir() string { | ||
if runtime.GOOS == "windows" { | ||
home := os.Getenv("HOMEDRIVE") + os.Getenv("HOMEPATH") | ||
if home == "" { | ||
home = os.Getenv("USERPROFILE") | ||
} | ||
return home | ||
} | ||
return os.Getenv("HOME") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters