Azure / draft-classic

A tool for developers to create cloud-native applications on Kubernetes.
https://draft.sh
MIT License
3.92k stars 397 forks source link

`draft config set` returns `panic: assignment to entry in nil map` on Windows #824

Closed PatrickLang closed 6 years ago

PatrickLang commented 6 years ago

draft config set seems to fail on Windows. I suspect that it's not handling the case where no config exists in ~/.draft

I was trying to follow the setup steps at https://docs.microsoft.com/en-us/azure/aks/kubernetes-draft#configure-draft-to-push-to-and-deploy-from-acr

and ran into this problem

PS> draft version
&version.Version{SemVer:"v0.15.0", GitCommit:"9d73889a1318a435d126bc5df846610d30cfbe7f", GitTreeState:"clean"}

PS> az acr list -o table
NAME     RESOURCE GROUP    LOCATION    SKU    LOGIN SERVER        CREATION DATE         ADMIN ENABLED
-------  ----------------  ----------  -----  ------------------  --------------------  ---------------
appreg  appregrg         westus2     Basic  appreg.azurecr.io  2018-06-17T03:51:41Z

PS> draft config set registry appreg.azurecr.io
panic: assignment to entry in nil map

goroutine 1 [running]:
main.(*configSetCmd).run(0xc042217090, 0x0, 0x0)
        /go/src/github.com/Azure/draft/cmd/draft/config_set.go:44 +0x5b
main.newConfigSetCmd.func2(0xc04293f440, 0xc042957b40, 0x2, 0x2, 0x0, 0x0)
        /go/src/github.com/Azure/draft/cmd/draft/config_set.go:28 +0x31
github.com/Azure/draft/vendor/github.com/spf13/cobra.(*Command).execute(0xc04293f440, 0xc042957aa0, 0x2, 0x2, 0xc04293f440, 0xc042957aa0)
        /go/src/github.com/Azure/draft/vendor/github.com/spf13/cobra/command.go:698 +0x481
github.com/Azure/draft/vendor/github.com/spf13/cobra.(*Command).ExecuteC(0xc04293e6c0, 0xc042004010, 0xc04293e6c0, 0xc0426f9f70)
        /go/src/github.com/Azure/draft/vendor/github.com/spf13/cobra/command.go:783 +0x315
github.com/Azure/draft/vendor/github.com/spf13/cobra.(*Command).Execute(0xc04293e6c0, 0x0, 0x0)
        /go/src/github.com/Azure/draft/vendor/github.com/spf13/cobra/command.go:736 +0x32
main.main()
        /go/src/github.com/Azure/draft/cmd/draft/draft.go:179 +0x34
PatrickLang commented 6 years ago

Actually - found the workaround - draft init hadn't been run on this machine yet. This should have a better error message