Skip to content

Commit

Permalink
Load env variables later
Browse files Browse the repository at this point in the history
Don't try to load env vars for the version or build command
  • Loading branch information
carolynvs-msft committed Dec 10, 2018
1 parent 6f777f2 commit 237b4f5
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ $(BINDIR)/$(VERSION)/$(MIXIN)-$(CLIENT_PLATFORM)-$(CLIENT_ARCH)$(FILE_EXT):
GOOS=$(CLIENT_PLATFORM) GOARCH=$(CLIENT_ARCH) $(XBUILD) -o $@ ./cmd/$(MIXIN)

test: test-unit
$(BINDIR)/$(MIXIN)$(FILE_EXT) version

test-unit: build
go test ./...
Expand Down
3 changes: 3 additions & 0 deletions cmd/azure/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ func buildInstallCommand(m *azure.Mixin) *cobra.Command {
cmd := &cobra.Command{
Use: "install",
Short: "Execute the install functionality of this mixin",
PreRunE: func(cmd *cobra.Command, args []string) error {
return m.LoadConfigFromEnvironment()
},
RunE: func(cmd *cobra.Command, args []string) error {
return m.Install()
},
Expand Down
14 changes: 9 additions & 5 deletions pkg/azure/azure.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,21 @@ type AzureOutput struct {

// New azure mixin client, initialized with useful defaults.
func New() (*Mixin, error) {
cfg, err := GetConfigFromEnvironment()
if err != nil {
return nil, err
}
return &Mixin{
Context: context.New(),
cfg: cfg,
}, nil

}

func (m *Mixin)LoadConfigFromEnvironment() error {
cfg, err := GetConfigFromEnvironment()
if err != nil {
return err
}
m.cfg = cfg
return nil
}

func (m *Mixin) getPayloadData() ([]byte, error) {
reader := bufio.NewReader(m.In)
data, err := ioutil.ReadAll(reader)
Expand Down

0 comments on commit 237b4f5

Please sign in to comment.