Skip to content

Commit a45f37a

Browse files
author
Oleg Sucharevich
committed
add func to get cf config
1 parent 7f50c8d commit a45f37a

File tree

2 files changed

+16
-8
lines changed

2 files changed

+16
-8
lines changed

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.10.0
1+
0.11.0

pkg/utils/context_reader.go

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,20 @@ type (
3030
)
3131

3232
func ReadAuthContext(path string, name string) (*CFContext, error) {
33+
config, err := GetCFConfig(path)
34+
if err != nil {
35+
return nil, err
36+
}
37+
var context *CFContext
38+
if name != "" {
39+
context = config.Contexts[name]
40+
} else {
41+
context = config.Contexts[config.CurrentContext]
42+
}
43+
return context, nil
44+
}
45+
46+
func GetCFConfig(path string) (*CFConfig, error) {
3347
content, err := ioutil.ReadFile(path)
3448
if err != nil {
3549
fmt.Printf("Error reading file\n")
@@ -42,11 +56,5 @@ func ReadAuthContext(path string, name string) (*CFContext, error) {
4256
fmt.Println(err.Error())
4357
return nil, err
4458
}
45-
var context *CFContext
46-
if name != "" {
47-
context = config.Contexts[name]
48-
} else {
49-
context = config.Contexts[config.CurrentContext]
50-
}
51-
return context, nil
59+
return &config, nil
5260
}

0 commit comments

Comments
 (0)