diff --git a/CHANGELOG.md b/CHANGELOG.md index 427379bc..4a70d70c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # Release Notes for Craft Nitro +## 2.0.2 - 2021-03-02 + +### Fixed +- Fixed a bug that could occur when running `nitro add` before `nitro init`. + ## 2.0.1 - 2021-03-02 ### Fixed diff --git a/command/initialize/initialize.go b/command/initialize/initialize.go index 32d7ba7c..dca85217 100644 --- a/command/initialize/initialize.go +++ b/command/initialize/initialize.go @@ -1,6 +1,7 @@ package initialize import ( + "context" "errors" "fmt" "strings" @@ -39,6 +40,10 @@ func NewCommand(home string, docker client.CommonAPIClient, output terminal.Outp }, RunE: func(cmd *cobra.Command, args []string) error { ctx := cmd.Context() + if ctx == nil { + ctx = context.Background() + } + // check if there is a config file _, err := config.Load(home) if errors.Is(err, config.ErrNoConfigFile) { diff --git a/pkg/config/config.go b/pkg/config/config.go index f2205ceb..fe319c1b 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -624,7 +624,11 @@ func (c *Config) createFile(dir string) error { defer f.Close() // try to chown otherwise be quiet - return f.Chown(os.Geteuid(), os.Getuid()) + if err := f.Chown(os.Geteuid(), os.Getuid()); err != nil { + return nil + } + + return nil } // GetFile returns the file location for the config diff --git a/pkg/proxycontainer/proxycontainer.go b/pkg/proxycontainer/proxycontainer.go index 7f028aef..37d7cfe0 100644 --- a/pkg/proxycontainer/proxycontainer.go +++ b/pkg/proxycontainer/proxycontainer.go @@ -33,6 +33,9 @@ var ( // Create is used to create a new proxy container for the nitro development environment. func Create(ctx context.Context, docker client.CommonAPIClient, output terminal.Outputer, networkID string) error { + if ctx == nil { + ctx = context.Background() + } filter := filters.NewArgs() filter.Add("label", labels.Nitro+"=true") filter.Add("reference", ProxyImage)