Skip to content
This repository has been archived by the owner on Sep 17, 2024. It is now read-only.

Commit

Permalink
chore: add back traces when extracting the files from the box (#946)
Browse files Browse the repository at this point in the history
* fix: use a more comprehensive initialisation method for configs

As go init() method is not deterministic, I found that the logger init was
not called at the right time. With change we ensure that the Init is:
1) called first
2) existing it the config was already populated

* chore: add back traces when extracting the files from the box
  • Loading branch information
mdelapenya authored Mar 26, 2021
1 parent 54fa95e commit b96d41a
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 4 deletions.
2 changes: 1 addition & 1 deletion cli/cmd/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import (
var deployToProfile string

func init() {
config.InitConfig()
config.Init()

for k := range config.AvailableServices() {
// deploy command
Expand Down
2 changes: 1 addition & 1 deletion cli/cmd/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ var servicesToRun string
var versionToRun string

func init() {
config.InitConfig()
config.Init()

rootCmd.AddCommand(runCmd)

Expand Down
2 changes: 1 addition & 1 deletion cli/cmd/stop.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import (
var versionToStop string

func init() {
config.InitConfig()
config.Init()

rootCmd.AddCommand(stopCmd)

Expand Down
2 changes: 1 addition & 1 deletion cli/cmd/sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ var excludedBlocks = []string{"build"}
var remote = "elastic:master"

func init() {
config.InitConfig()
config.Init()

syncIntegrationsCmd.Flags().BoolVarP(&deleteRepository, "delete", "d", false, "Will delete the existing Beats repository before cloning it again (default false)")
syncIntegrationsCmd.Flags().StringVarP(&remote, "remote", "r", "elastic:master", "Sets the remote for Beats, using 'user:branch' as format (i.e. elastic:master)")
Expand Down
10 changes: 10 additions & 0 deletions cli/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,10 @@ func GetServiceConfig(service string) (Service, bool) {

// Init creates this tool workspace under user's home, in a hidden directory named ".op"
func Init() {
if Op != nil {
return
}

configureLogger()

binaries := []string{
Expand Down Expand Up @@ -310,6 +314,12 @@ func extractProfileServiceConfig(op *OpConfig, box *packr.Box) error {
return err
}
}

log.WithFields(log.Fields{
"file": p,
"dir": dir,
}).Trace("Extracting boxed file")

return ioutil.WriteFile(p, []byte(file.String()), 0644)
}

Expand Down

0 comments on commit b96d41a

Please sign in to comment.