From 682e557677c34e671e5b0a5d472016cf905259a1 Mon Sep 17 00:00:00 2001 From: Jason McCallister Date: Tue, 2 Mar 2021 14:44:02 -0500 Subject: [PATCH 1/3] fixed error when running nitro add before init --- command/initialize/initialize.go | 5 +++++ pkg/config/config.go | 6 +++++- pkg/proxycontainer/proxycontainer.go | 3 +++ 3 files changed, 13 insertions(+), 1 deletion(-) 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) From 0d6267d55fd63d50b1b4025b04a851a4c7c03b0a Mon Sep 17 00:00:00 2001 From: Jason McCallister Date: Tue, 2 Mar 2021 14:46:10 -0500 Subject: [PATCH 2/3] changelog --- CHANGELOG.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 427379bc..d4aa3d0f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,11 @@ ## 2.0.1 - 2021-03-02 +### Fixed +- Fixed a bug that could occur when running `nitro add` before `nitro init`. + +## 2.0.1 - 2021-03-02 + ### Fixed - Fixed a bug where `self-update` was not updating. From a162ea42a959a7df2df7c74a5072a3f4295c0513 Mon Sep 17 00:00:00 2001 From: Jason McCallister Date: Tue, 2 Mar 2021 14:47:04 -0500 Subject: [PATCH 3/3] 2.0.2 Signed-off-by: Jason McCallister --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d4aa3d0f..4a70d70c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,6 @@ # Release Notes for Craft Nitro -## 2.0.1 - 2021-03-02 +## 2.0.2 - 2021-03-02 ### Fixed - Fixed a bug that could occur when running `nitro add` before `nitro init`.