File tree Expand file tree Collapse file tree 1 file changed +69
-0
lines changed Expand file tree Collapse file tree 1 file changed +69
-0
lines changed Original file line number Diff line number Diff line change
1
+ package codefresh
2
+
3
+ type (
4
+ IContextAPI interface {
5
+ GetGitContexts () (error , * []ContextPayload )
6
+ GetGitContextByName (name string ) (error , * ContextPayload )
7
+ }
8
+
9
+ context struct {
10
+ codefresh Codefresh
11
+ }
12
+
13
+ ContextPayload struct {
14
+ Metadata struct {
15
+ Name string `json:"name"`
16
+ }
17
+ Spec struct {
18
+ Type string `json:"type"`
19
+ Data struct {
20
+ Auth struct {
21
+ Password string `json:"password"`
22
+ ApiHost string `json:"apiHost"`
23
+ ApiPathPrefix string `json:"apiPathPrefix"`
24
+ } `json:"auth"`
25
+ } `json:"data"`
26
+ } `json:"spec"`
27
+ }
28
+ )
29
+
30
+ func (c context ) GetGitContexts () (error , * []ContextPayload ) {
31
+ var result []ContextPayload
32
+ var qs = map [string ]string {
33
+ "type" : "git.github" ,
34
+ "decrypt" : "true" ,
35
+ }
36
+
37
+ resp , err := c .codefresh .requestAPI (& requestOptions {
38
+ method : "GET" ,
39
+ path : "/contexts" ,
40
+ qs : qs ,
41
+ })
42
+ if err != nil {
43
+ return err , nil
44
+ }
45
+
46
+ err = c .codefresh .decodeResponseInto (resp , & result )
47
+
48
+ return nil , & result
49
+ }
50
+
51
+ func (c context ) GetGitContextByName (name string ) (error , * ContextPayload ) {
52
+ var result ContextPayload
53
+ var qs = map [string ]string {
54
+ "decrypt" : "true" ,
55
+ }
56
+
57
+ resp , err := c .codefresh .requestAPI (& requestOptions {
58
+ method : "GET" ,
59
+ path : "/contexts/" + name ,
60
+ qs : qs ,
61
+ })
62
+ if err != nil {
63
+ return err , nil
64
+ }
65
+
66
+ err = c .codefresh .decodeResponseInto (resp , & result )
67
+
68
+ return nil , & result
69
+ }
You can’t perform that action at this time.
0 commit comments