From 14f5d490eff1b78becfedb359ba9bff3f0ebd156 Mon Sep 17 00:00:00 2001 From: Milas Bowman Date: Tue, 11 Apr 2023 12:19:11 -0400 Subject: [PATCH] builder: extra init error handling * Return errors from creating the `NodeGroup` * Ensure that `b.NodeGroup != nil` before reading from it during validation Signed-off-by: Milas Bowman --- builder/builder.go | 2 +- store/storeutil/storeutil.go | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/builder/builder.go b/builder/builder.go index 55476ea1..8353c84c 100644 --- a/builder/builder.go +++ b/builder/builder.go @@ -108,7 +108,7 @@ func New(dockerCli command.Cli, opts ...Option) (_ *Builder, err error) { // Validate validates builder context func (b *Builder) Validate() error { - if b.NodeGroup.DockerContext { + if b.NodeGroup != nil && b.NodeGroup.DockerContext { list, err := b.opts.dockerCli.ContextStore().List() if err != nil { return err diff --git a/store/storeutil/storeutil.go b/store/storeutil/storeutil.go index 4e6b0898..ce01d385 100644 --- a/store/storeutil/storeutil.go +++ b/store/storeutil/storeutil.go @@ -61,7 +61,10 @@ func GetCurrentInstance(txn *store.Txn, dockerCli command.Cli) (*store.NodeGroup return nil, err } if ng == nil { - ng, _ = GetNodeGroup(txn, dockerCli, dockerCli.CurrentContext()) + ng, err = GetNodeGroup(txn, dockerCli, dockerCli.CurrentContext()) + if err != nil { + return nil, err + } } return ng, nil