Skip to content

Commit 0fc5100

Browse files
fix segfault when current context is invalid (#651)
1 parent ea5108b commit 0fc5100

File tree

3 files changed

+11
-5
lines changed

3 files changed

+11
-5
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
VERSION=v0.1.12
1+
VERSION=v0.1.13
22

33
OUT_DIR=dist
44
YEAR?=$(shell date +"%Y")

docs/releases/release_notes.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ cf version
2323

2424
```bash
2525
# download and extract the binary
26-
curl -L --output - https://github.com/codefresh-io/cli-v2/releases/download/v0.1.12/cf-linux-amd64.tar.gz | tar zx
26+
curl -L --output - https://github.com/codefresh-io/cli-v2/releases/download/v0.1.13/cf-linux-amd64.tar.gz | tar zx
2727

2828
# move the binary to your $PATH
2929
mv ./cf-linux-amd64 /usr/local/bin/cf
@@ -36,7 +36,7 @@ cf version
3636

3737
```bash
3838
# download and extract the binary
39-
curl -L --output - https://github.com/codefresh-io/cli-v2/releases/download/v0.1.12/cf-darwin-amd64.tar.gz | tar zx
39+
curl -L --output - https://github.com/codefresh-io/cli-v2/releases/download/v0.1.13/cf-darwin-amd64.tar.gz | tar zx
4040

4141
# move the binary to your $PATH
4242
mv ./cf-darwin-amd64 /usr/local/bin/cf

pkg/config/config.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,13 @@ func (c *Config) GetCurrentContext() *AuthContext {
155155
if c.contextOverride != "" {
156156
ctx = c.contextOverride
157157
}
158-
return c.Contexts[ctx]
158+
159+
authCtx, ok := c.Contexts[ctx]
160+
if !ok {
161+
log.G().Fatalf(util.Doc("Current Codefresh context \"%s\" does not exist. "+
162+
"You must select another context using '<BIN> config use-context <context>'"), ctx)
163+
}
164+
return authCtx
159165
}
160166

161167
// NewClient creates a new codefresh client for the current context or for
@@ -172,7 +178,7 @@ func (c *Config) DeleteContext(name string) error {
172178

173179
delete(c.Contexts, name)
174180
if c.CurrentContext == name {
175-
log.G().Warnf(util.Doc("delete context is set as current context, specify a new current context with '<BIN> config use-context'"))
181+
log.G().Warnf(util.Doc("Deleted context is set as current context, specify a new current context with '<BIN> config use-context'"))
176182
c.CurrentContext = ""
177183
}
178184

0 commit comments

Comments
 (0)