Skip to content

Commit 6edf97d

Browse files
Added all git contexs types support
1 parent 3b8925f commit 6edf97d

File tree

3 files changed

+21
-4
lines changed

3 files changed

+21
-4
lines changed

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.25.1
1+
0.25.2

pkg/codefresh/contexts.go

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package codefresh
22

3+
import "github.com/codefresh-io/go-sdk/pkg/utils"
4+
35
type (
46
IContextAPI interface {
57
GetGitContexts() (error, *[]ContextPayload)
@@ -32,6 +34,11 @@ type (
3234
} `json:"data"`
3335
} `json:"spec"`
3436
}
37+
38+
GitContextsQs struct {
39+
Type []string `json:"type"`
40+
Decrypt string `json:"decrypt"`
41+
}
3542
)
3643

3744
func newContextAPI(codefresh *codefresh) IContextAPI {
@@ -40,11 +47,15 @@ func newContextAPI(codefresh *codefresh) IContextAPI {
4047

4148
func (c context) GetGitContexts() (error, *[]ContextPayload) {
4249
var result []ContextPayload
43-
var qs = map[string]string{
44-
"type": "git.github",
45-
"decrypt": "true",
50+
var qs map[string]string
51+
52+
gitContextsQs := GitContextsQs{
53+
Type: []string{"git.github", "git.gitlab", "git.github-app"},
54+
Decrypt: "true",
4655
}
4756

57+
utils.Convert(gitContextsQs, &qs)
58+
4859
resp, err := c.codefresh.requestAPI(&requestOptions{
4960
method: "GET",
5061
path: "/api/contexts",

pkg/utils/utils.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package utils
22

33
import (
4+
"encoding/json"
45
"fmt"
56

67
"github.com/codefresh-io/go-sdk/internal"
@@ -14,3 +15,8 @@ func CastToCodefreshOrDie(candidate interface{}) codefresh.Codefresh {
1415
}
1516
return client
1617
}
18+
19+
func Convert(from interface{}, to interface{}) {
20+
rs, _ := json.Marshal(from)
21+
_ = json.Unmarshal(rs, to)
22+
}

0 commit comments

Comments
 (0)