99
1010type (
1111 IWorkflowV2API interface {
12- Get (ctx context.Context , name , namespace , runtime string ) (model.Workflow , error )
12+ Get (ctx context.Context , name , namespace , runtime string ) (* model.Workflow , error )
1313 List (ctx context.Context , filterArgs model.WorkflowsFilterArgs ) ([]model.Workflow , error )
1414 }
1515
@@ -36,58 +36,59 @@ func newWorkflowV2API(codefresh *codefresh) IWorkflowV2API {
3636 return & workflowV2 {codefresh : codefresh }
3737}
3838
39- func (w * workflowV2 ) Get (ctx context.Context , name , namespace , runtime string ) (model.Workflow , error ) {
39+ func (w * workflowV2 ) Get (ctx context.Context , name , namespace , runtime string ) (* model.Workflow , error ) {
4040 jsonData := map [string ]interface {}{
41- "query" : `{
42- workflow (
43- runtime: String!
44- name: String!
45- namespace: String
41+ "query" : `
42+ query Workflow (
43+ $ runtime: String!
44+ $ name: String!
45+ $ namespace: String
4646 ) {
47- metadata {
48- name
49- namespace
50- }
51- projects
52- spec {
53- entrypoint
54- templates {
55- name
56- }
57- workflowTemplateRef {
58- name
59- namespace
60- }
61- }
62- status {
63- createdAt
64- startedAt
65- finishedAt
66- phase
67- progress {
68- total
69- done
70- }
71- nodes {
72- type
73- name
74- }
75- message
76- statuses {
77- since
78- phase
79- message
80- }
81- }
82- pipeline {
47+ workflow(name: $name, namespace: $namespace, runtime: $runtime) {
8348 metadata {
84- name
85- namespace
49+ name
50+ namespace
8651 }
87- }
88- actualManifest
89- }
90- }` ,
52+ projects
53+ spec {
54+ entrypoint
55+ templates {
56+ name
57+ }
58+ workflowTemplateRef {
59+ name
60+ namespace
61+ }
62+ }
63+ status {
64+ createdAt
65+ startedAt
66+ finishedAt
67+ phase
68+ progress {
69+ total
70+ done
71+ }
72+ nodes {
73+ type
74+ name
75+ }
76+ message
77+ statuses {
78+ since
79+ phase
80+ message
81+ }
82+ }
83+ pipeline {
84+ metadata {
85+ name
86+ namespace
87+ }
88+ }
89+ actualManifest
90+ }
91+ }` ,
9192 "variables" : map [string ]interface {}{
9293 "runtime" : runtime ,
9394 "name" : name ,
@@ -98,68 +99,69 @@ func (w *workflowV2) Get(ctx context.Context, name, namespace, runtime string) (
9899 res := & graphqlGetWorkflowResponse {}
99100 err := w .codefresh .graphqlAPI (ctx , jsonData , res )
100101 if err != nil {
101- return model. Workflow {} , fmt .Errorf ("failed getting pipeline list : %w" , err )
102+ return nil , fmt .Errorf ("failed getting workflow : %w" , err )
102103 }
103104
104105 if len (res .Errors ) > 0 {
105- return model. Workflow {} , graphqlErrorResponse {errors : res .Errors }
106+ return nil , graphqlErrorResponse {errors : res .Errors }
106107 }
107108
108- return res .Data .Workflow , nil
109+ return & res .Data .Workflow , nil
109110}
110111
111112func (w * workflowV2 ) List (ctx context.Context , filterArgs model.WorkflowsFilterArgs ) ([]model.Workflow , error ) {
112113 jsonData := map [string ]interface {}{
113- "query" : `{
114- workflows(filters: WorkflowFilterArgs) {
115- edges {
116- node {
117- metadata {
118- name
119- namespace
120- }
121- projects
122- spec {
123- entrypoint
124- templates {
125- name
126- }
127- workflowTemplateRef {
128- name
129- namespace
130- }
131- }
132- status {
133- createdAt
134- startedAt
135- finishedAt
136- phase
137- progress {
138- total
139- done
140- }
141- nodes {
142- type
143- name
144- }
145- message
146- statuses {
147- since
148- phase
149- message
150- }
151- }
152- pipeline {
114+ "query" : `
115+ query Workflows($filters: WorkflowsFilterArgs) {
116+ workflows(filters: $filters) {
117+ edges {
118+ node {
153119 metadata {
154- name
155- namespace
120+ name
121+ namespace
156122 }
157- }
158- actualManifest
123+ projects
124+ spec {
125+ entrypoint
126+ templates {
127+ name
128+ }
129+ workflowTemplateRef {
130+ name
131+ namespace
132+ }
133+ }
134+ status {
135+ createdAt
136+ startedAt
137+ finishedAt
138+ phase
139+ progress {
140+ total
141+ done
142+ }
143+ nodes {
144+ type
145+ name
146+ }
147+ message
148+ statuses {
149+ since
150+ phase
151+ message
152+ }
153+ }
154+ pipeline {
155+ metadata {
156+ name
157+ namespace
158+ }
159+ }
160+ actualManifest
161+ }
159162 }
160163 }
161- }
162- }` ,
164+ }` ,
163165 "variables" : map [string ]interface {}{
164166 "filters" : filterArgs ,
165167 },
@@ -168,7 +170,7 @@ func (w *workflowV2) List(ctx context.Context, filterArgs model.WorkflowsFilterA
168170 res := & graphqlListWorkflowsResponse {}
169171 err := w .codefresh .graphqlAPI (ctx , jsonData , res )
170172 if err != nil {
171- return nil , fmt .Errorf ("failed getting pipeline list: %w" , err )
173+ return nil , fmt .Errorf ("failed getting workflow list: %w" , err )
172174 }
173175
174176 if len (res .Errors ) > 0 {
0 commit comments