Skip to content

Commit 400d9e1

Browse files
.
1 parent 514dcd5 commit 400d9e1

File tree

1 file changed

+27
-12
lines changed

1 file changed

+27
-12
lines changed

pkg/codefresh/git-source.go

Lines changed: 27 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,7 @@ type (
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

4139
func (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

Comments
 (0)