1919
2020 graphQlGitSourcesListResponse struct {
2121 Data struct {
22- name string
23- repoUrl string
24- path string
22+ GitSources model.GitSourcePage
2523 }
2624 Errors []graphqlError
2725 }
@@ -40,7 +38,7 @@ func newGitSourceAPI(codefresh *codefresh) IGitSourceAPI {
4038
4139func (g * gitSource ) List (runtimeName string ) ([]model.GitSource , error ) {
4240 // jsonData := map[string]interface{}{
43- // "query": `GetGitSourcesList(pagination: SlicePaginationArgs!, project: String!, $runtime: String!) {
41+ // "query": `query GetGitSourcesList(pagination: SlicePaginationArgs!, project: String!, $runtime: String!) {
4442 // gitSources(pagination: {}, project: "", runtime: $runtime) {
4543 // edges {
4644 // node {
@@ -59,7 +57,24 @@ func (g *gitSource) List(runtimeName string) ([]model.GitSource, error) {
5957 // }
6058
6159 jsonData := map [string ]interface {}{
62- "query" : `{\n gitSources(pagination: {}, project: \"\", runtime: \"gs-list-runtime-5\") {\n edges {\n node {\n metadata {\n name\n }\n path\n repoURL\n }\n }\n }\n}` ,
60+ "query" : `query ListGitSources($runtime: String, $pagination: SlicePaginationArgs) {
61+ gitSources(runtime: $runtime, pagination: $pagination) {
62+ edges {
63+ node {
64+ metadata {
65+ name
66+ }
67+ app {
68+ repoURL
69+ path
70+ }
71+ }
72+ }
73+ }
74+ }` ,
75+ "variables" : map [string ]interface {}{
76+ "runtime" : runtimeName ,
77+ },
6378 }
6479
6580 response , err := g .codefresh .requestAPI (& requestOptions {
@@ -86,14 +101,14 @@ func (g *gitSource) List(runtimeName string) ([]model.GitSource, error) {
86101 return nil , err
87102 }
88103
89- gitSources := make ([]model.GitSource , 3 )
90- // for i := range res.Data.GitSourceEdge {
91- // gitSources[i] = *res.Data.GitSourceEdges.
92- // }
104+ gitSources := make ([]model.GitSource , len ( res . Data . GitSources . Edges ) )
105+ for i := range res .Data .GitSources . Edges {
106+ gitSources [i ] = * res .Data .GitSources . Edges [ i ]. Node
107+ }
93108
94- // if len(res.Errors) > 0 {
95- // return nil, graphqlErrorResponse{errors: res.Errors}
96- // }
109+ if len (res .Errors ) > 0 {
110+ return nil , graphqlErrorResponse {errors : res .Errors }
111+ }
97112
98113 return gitSources , nil
99114}
0 commit comments