From addbf4874b6acdadd36e3e61c6c7f0ac0b95956f Mon Sep 17 00:00:00 2001 From: pashavictorovich Date: Tue, 27 Apr 2021 22:30:56 +0300 Subject: [PATCH 01/81] private functions shouldnt be part of interface --- VERSION | 2 +- pkg/codefresh/codefresh.go | 4 ---- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/VERSION b/VERSION index 8b95abd..6308234 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.24.2 +0.24.3 diff --git a/pkg/codefresh/codefresh.go b/pkg/codefresh/codefresh.go index f114153..e5e4d07 100644 --- a/pkg/codefresh/codefresh.go +++ b/pkg/codefresh/codefresh.go @@ -11,10 +11,6 @@ import ( type ( Codefresh interface { - requestAPI(*requestOptions) (*http.Response, error) - decodeResponseInto(*http.Response, interface{}) error - getBodyAsString(*http.Response) (string, error) - getBodyAsBytes(*http.Response) ([]byte, error) Pipelines() IPipelineAPI Tokens() ITokenAPI RuntimeEnvironments() IRuntimeEnvironmentAPI From cf4e65c51582fbec99f3f8dd1303f5feafed5c3a Mon Sep 17 00:00:00 2001 From: pashavictorovich Date: Tue, 27 Apr 2021 22:36:59 +0300 Subject: [PATCH 02/81] private functions shouldnt be part of interface --- pkg/codefresh/argo.go | 4 ++-- pkg/codefresh/cluster.go | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/pkg/codefresh/argo.go b/pkg/codefresh/argo.go index b21649a..700347d 100644 --- a/pkg/codefresh/argo.go +++ b/pkg/codefresh/argo.go @@ -14,7 +14,7 @@ type ( } argo struct { - codefresh Codefresh + codefresh codefresh } IntegrationItem struct { @@ -50,7 +50,7 @@ type ( } ) -func newArgoAPI(codefresh Codefresh) ArgoAPI { +func newArgoAPI(codefresh codefresh) ArgoAPI { return &argo{codefresh} } diff --git a/pkg/codefresh/cluster.go b/pkg/codefresh/cluster.go index 4254cdc..2915e80 100644 --- a/pkg/codefresh/cluster.go +++ b/pkg/codefresh/cluster.go @@ -9,7 +9,7 @@ type ( } cluster struct { - codefresh Codefresh + codefresh codefresh } Cluster struct { @@ -31,7 +31,7 @@ type ( } ) -func newClusterAPI(codefresh Codefresh) IClusterAPI { +func newClusterAPI(codefresh codefresh) IClusterAPI { return &cluster{codefresh} } From 7fb9ffac2cd0563692d8b3b78e0e924a6393a4d2 Mon Sep 17 00:00:00 2001 From: pashavictorovich Date: Tue, 27 Apr 2021 22:39:58 +0300 Subject: [PATCH 03/81] private functions shouldnt be part of interface --- pkg/codefresh/argo.go | 4 ++-- pkg/codefresh/cluster.go | 4 ++-- pkg/codefresh/contexts.go | 4 ++-- pkg/codefresh/gitops.go | 4 ++-- pkg/codefresh/pipeline.go | 4 ++-- pkg/codefresh/progress.go | 4 ++-- pkg/codefresh/runtime_enrionment.go | 4 ++-- pkg/codefresh/tokens.go | 4 ++-- pkg/codefresh/workflow.go | 4 ++-- 9 files changed, 18 insertions(+), 18 deletions(-) diff --git a/pkg/codefresh/argo.go b/pkg/codefresh/argo.go index 700347d..02d5044 100644 --- a/pkg/codefresh/argo.go +++ b/pkg/codefresh/argo.go @@ -14,7 +14,7 @@ type ( } argo struct { - codefresh codefresh + codefresh *codefresh } IntegrationItem struct { @@ -50,7 +50,7 @@ type ( } ) -func newArgoAPI(codefresh codefresh) ArgoAPI { +func newArgoAPI(codefresh *codefresh) ArgoAPI { return &argo{codefresh} } diff --git a/pkg/codefresh/cluster.go b/pkg/codefresh/cluster.go index 2915e80..6e6ec62 100644 --- a/pkg/codefresh/cluster.go +++ b/pkg/codefresh/cluster.go @@ -9,7 +9,7 @@ type ( } cluster struct { - codefresh codefresh + codefresh *codefresh } Cluster struct { @@ -31,7 +31,7 @@ type ( } ) -func newClusterAPI(codefresh codefresh) IClusterAPI { +func newClusterAPI(codefresh *codefresh) IClusterAPI { return &cluster{codefresh} } diff --git a/pkg/codefresh/contexts.go b/pkg/codefresh/contexts.go index 7799956..1da8c31 100644 --- a/pkg/codefresh/contexts.go +++ b/pkg/codefresh/contexts.go @@ -8,7 +8,7 @@ type ( } context struct { - codefresh Codefresh + codefresh *codefresh } ContextPayload struct { @@ -31,7 +31,7 @@ type ( } ) -func newContextAPI(codefresh Codefresh) IContextAPI { +func newContextAPI(codefresh *codefresh) IContextAPI { return &context{codefresh} } diff --git a/pkg/codefresh/gitops.go b/pkg/codefresh/gitops.go index 1eeed79..7bf3741 100644 --- a/pkg/codefresh/gitops.go +++ b/pkg/codefresh/gitops.go @@ -13,7 +13,7 @@ type ( } gitops struct { - codefresh Codefresh + codefresh *codefresh } CodefreshEvent struct { Event string `json:"event"` @@ -117,7 +117,7 @@ type ( } ) -func newGitopsAPI(codefresh Codefresh) GitopsAPI { +func newGitopsAPI(codefresh *codefresh) GitopsAPI { return &gitops{codefresh} } diff --git a/pkg/codefresh/pipeline.go b/pkg/codefresh/pipeline.go index 067cfb9..e26d4c7 100644 --- a/pkg/codefresh/pipeline.go +++ b/pkg/codefresh/pipeline.go @@ -61,7 +61,7 @@ type ( } pipeline struct { - codefresh Codefresh + codefresh *codefresh } RunOptions struct { @@ -70,7 +70,7 @@ type ( } ) -func newPipelineAPI(codefresh Codefresh) IPipelineAPI { +func newPipelineAPI(codefresh *codefresh) IPipelineAPI { return &pipeline{codefresh} } diff --git a/pkg/codefresh/progress.go b/pkg/codefresh/progress.go index ae03e92..ac58e71 100644 --- a/pkg/codefresh/progress.go +++ b/pkg/codefresh/progress.go @@ -10,7 +10,7 @@ type ( } progress struct { - codefresh Codefresh + codefresh *codefresh } Progress struct { @@ -25,7 +25,7 @@ type ( } ) -func newProgressAPI(codefresh Codefresh) IProgressAPI { +func newProgressAPI(codefresh *codefresh) IProgressAPI { return &progress{codefresh} } diff --git a/pkg/codefresh/runtime_enrionment.go b/pkg/codefresh/runtime_enrionment.go index 349397a..6e6e924 100644 --- a/pkg/codefresh/runtime_enrionment.go +++ b/pkg/codefresh/runtime_enrionment.go @@ -98,11 +98,11 @@ type ( } runtimeEnvironment struct { - codefresh Codefresh + codefresh *codefresh } ) -func newRuntimeEnvironmentAPI(codefresh Codefresh) IRuntimeEnvironmentAPI { +func newRuntimeEnvironmentAPI(codefresh *codefresh) IRuntimeEnvironmentAPI { return &runtimeEnvironment{codefresh} } diff --git a/pkg/codefresh/tokens.go b/pkg/codefresh/tokens.go index 0f3d601..3112a44 100644 --- a/pkg/codefresh/tokens.go +++ b/pkg/codefresh/tokens.go @@ -30,7 +30,7 @@ type ( } token struct { - codefresh Codefresh + codefresh *codefresh } ) @@ -38,7 +38,7 @@ const ( runtimeEnvironmentSubject tokenSubjectType = 0 ) -func newTokenAPI(codefresh Codefresh) ITokenAPI { +func newTokenAPI(codefresh *codefresh) ITokenAPI { return &token{codefresh} } diff --git a/pkg/codefresh/workflow.go b/pkg/codefresh/workflow.go index 7c26c4d..56ea61a 100644 --- a/pkg/codefresh/workflow.go +++ b/pkg/codefresh/workflow.go @@ -13,7 +13,7 @@ type ( } workflow struct { - codefresh Codefresh + codefresh *codefresh } Workflow struct { @@ -27,7 +27,7 @@ type ( } ) -func newWorkflowAPI(codefresh Codefresh) IWorkflowAPI { +func newWorkflowAPI(codefresh *codefresh) IWorkflowAPI { return &workflow{codefresh} } From 1a6be60060fafdf221d0e7a3576d378e39b126dd Mon Sep 17 00:00:00 2001 From: pashavictorovich Date: Wed, 28 Apr 2021 11:58:53 +0300 Subject: [PATCH 04/81] fix send env endpoint --- VERSION | 2 +- pkg/codefresh/gitops.go | 12 ++++++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/VERSION b/VERSION index 6308234..d21d277 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.24.3 +0.25.0 diff --git a/pkg/codefresh/gitops.go b/pkg/codefresh/gitops.go index 7bf3741..99a5e7a 100644 --- a/pkg/codefresh/gitops.go +++ b/pkg/codefresh/gitops.go @@ -146,11 +146,19 @@ func (a *gitops) CreateEnvironment(name string, project string, application stri } func (a *gitops) SendEnvironment(environment Environment) (map[string]interface{}, error) { - _, err := a.codefresh.requestAPI(&requestOptions{method: "POST", path: "/api/gitops/rollout", body: environment}) + var result map[string]interface{} + resp, err := a.codefresh.requestAPI(&requestOptions{method: "POST", path: "/api/environments-v2/argo/events", body: environment}) if err != nil { return nil, err } - return nil, nil + + err = a.codefresh.decodeResponseInto(resp, &result) + + if err != nil { + return nil, err + } + + return result, nil } func (a *gitops) DeleteEnvironment(name string) error { From 3173607986500ae116f5e1ae0e8939c6823c74cc Mon Sep 17 00:00:00 2001 From: pashavictorovich Date: Sat, 1 May 2021 20:20:02 +0300 Subject: [PATCH 05/81] extends context struct --- VERSION | 2 +- pkg/codefresh/contexts.go | 15 +++++++++------ 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/VERSION b/VERSION index d21d277..af2dabf 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.25.0 +0.25.1 diff --git a/pkg/codefresh/contexts.go b/pkg/codefresh/contexts.go index 1da8c31..b076ea3 100644 --- a/pkg/codefresh/contexts.go +++ b/pkg/codefresh/contexts.go @@ -19,12 +19,15 @@ type ( Type string `json:"type"` Data struct { Auth struct { - Type string `json:"type"` - Username string `json:"username"` - Password string `json:"password"` - ApiHost string `json:"apiHost"` - ApiPathPrefix string `json:"apiPathPrefix"` - SshPrivateKey string `json:"sshPrivateKey"` + Type string `json:"type"` + Username string `json:"username"` + Password string `json:"password"` + ApiHost string `json:"apiHost"` + ApiPathPrefix string `json:"apiPathPrefix"` + SshPrivateKey string `json:"sshPrivateKey"` + AppId string `json:"sshPrivateKey"` + InstallationId string `json:"installationId"` + PrivateKey string `json:"privateKey"` } `json:"auth"` } `json:"data"` } `json:"spec"` From 3b8925fb08ec6928ad4717c0d797f794962f58c2 Mon Sep 17 00:00:00 2001 From: pashavictorovich Date: Sat, 1 May 2021 21:18:17 +0300 Subject: [PATCH 06/81] fix typo --- pkg/codefresh/contexts.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/codefresh/contexts.go b/pkg/codefresh/contexts.go index b076ea3..84eb979 100644 --- a/pkg/codefresh/contexts.go +++ b/pkg/codefresh/contexts.go @@ -25,7 +25,7 @@ type ( ApiHost string `json:"apiHost"` ApiPathPrefix string `json:"apiPathPrefix"` SshPrivateKey string `json:"sshPrivateKey"` - AppId string `json:"sshPrivateKey"` + AppId string `json:"appId"` InstallationId string `json:"installationId"` PrivateKey string `json:"privateKey"` } `json:"auth"` From 110d0e22772f7284aaad7d851eba35ddd8237dc4 Mon Sep 17 00:00:00 2001 From: andrii-codefresh Date: Fri, 21 May 2021 12:07:36 +0300 Subject: [PATCH 07/81] remove resources from environment --- VERSION | 2 +- pkg/codefresh/gitops.go | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/VERSION b/VERSION index af2dabf..166c9e2 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.25.1 +0.25.2 diff --git a/pkg/codefresh/gitops.go b/pkg/codefresh/gitops.go index 99a5e7a..ff2ac8e 100644 --- a/pkg/codefresh/gitops.go +++ b/pkg/codefresh/gitops.go @@ -93,7 +93,6 @@ type ( SyncRevision string `json:"revision"` Name string `json:"name"` Activities []EnvironmentActivity `json:"activities"` - Resources interface{} `json:"resources"` RepoUrl string `json:"repoUrl"` Commit Commit `json:"commit"` SyncPolicy SyncPolicy `json:"syncPolicy"` From c6d3907cb08149f8c1eee44dd4ff033215bec5d1 Mon Sep 17 00:00:00 2001 From: andrii-codefresh Date: Fri, 21 May 2021 12:09:21 +0300 Subject: [PATCH 08/81] update version --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index 166c9e2..3d9dcb1 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.25.2 +0.25.3 From 6edf97d33efa65ec4260c009218ffdbdf9f47280 Mon Sep 17 00:00:00 2001 From: olegz-codefresh Date: Tue, 25 May 2021 13:12:59 +0300 Subject: [PATCH 09/81] Added all git contexs types support --- VERSION | 2 +- pkg/codefresh/contexts.go | 17 ++++++++++++++--- pkg/utils/utils.go | 6 ++++++ 3 files changed, 21 insertions(+), 4 deletions(-) diff --git a/VERSION b/VERSION index af2dabf..166c9e2 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.25.1 +0.25.2 diff --git a/pkg/codefresh/contexts.go b/pkg/codefresh/contexts.go index 84eb979..1d181c6 100644 --- a/pkg/codefresh/contexts.go +++ b/pkg/codefresh/contexts.go @@ -1,5 +1,7 @@ package codefresh +import "github.com/codefresh-io/go-sdk/pkg/utils" + type ( IContextAPI interface { GetGitContexts() (error, *[]ContextPayload) @@ -32,6 +34,11 @@ type ( } `json:"data"` } `json:"spec"` } + + GitContextsQs struct { + Type []string `json:"type"` + Decrypt string `json:"decrypt"` + } ) func newContextAPI(codefresh *codefresh) IContextAPI { @@ -40,11 +47,15 @@ func newContextAPI(codefresh *codefresh) IContextAPI { func (c context) GetGitContexts() (error, *[]ContextPayload) { var result []ContextPayload - var qs = map[string]string{ - "type": "git.github", - "decrypt": "true", + var qs map[string]string + + gitContextsQs := GitContextsQs{ + Type: []string{"git.github", "git.gitlab", "git.github-app"}, + Decrypt: "true", } + utils.Convert(gitContextsQs, &qs) + resp, err := c.codefresh.requestAPI(&requestOptions{ method: "GET", path: "/api/contexts", diff --git a/pkg/utils/utils.go b/pkg/utils/utils.go index 3499856..671d50b 100644 --- a/pkg/utils/utils.go +++ b/pkg/utils/utils.go @@ -1,6 +1,7 @@ package utils import ( + "encoding/json" "fmt" "github.com/codefresh-io/go-sdk/internal" @@ -14,3 +15,8 @@ func CastToCodefreshOrDie(candidate interface{}) codefresh.Codefresh { } return client } + +func Convert(from interface{}, to interface{}) { + rs, _ := json.Marshal(from) + _ = json.Unmarshal(rs, to) +} From 5ecbab42c34707e52176a3642166fd0114406c57 Mon Sep 17 00:00:00 2001 From: olegz-codefresh Date: Tue, 25 May 2021 13:13:55 +0300 Subject: [PATCH 10/81] Added all git contexs types support --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index 166c9e2..3d9dcb1 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.25.2 +0.25.3 From a46218c5b6748489240c341d942121ada3dbc88a Mon Sep 17 00:00:00 2001 From: olegz-codefresh Date: Tue, 25 May 2021 13:19:29 +0300 Subject: [PATCH 11/81] Added all git contexs types support --- pkg/codefresh/contexts.go | 7 +++++-- pkg/utils/utils.go | 6 ------ 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/pkg/codefresh/contexts.go b/pkg/codefresh/contexts.go index 1d181c6..93ac12c 100644 --- a/pkg/codefresh/contexts.go +++ b/pkg/codefresh/contexts.go @@ -1,6 +1,8 @@ package codefresh -import "github.com/codefresh-io/go-sdk/pkg/utils" +import ( + "encoding/json" +) type ( IContextAPI interface { @@ -54,7 +56,8 @@ func (c context) GetGitContexts() (error, *[]ContextPayload) { Decrypt: "true", } - utils.Convert(gitContextsQs, &qs) + rs, _ := json.Marshal(gitContextsQs) + _ = json.Unmarshal(rs, &qs) resp, err := c.codefresh.requestAPI(&requestOptions{ method: "GET", diff --git a/pkg/utils/utils.go b/pkg/utils/utils.go index 671d50b..3499856 100644 --- a/pkg/utils/utils.go +++ b/pkg/utils/utils.go @@ -1,7 +1,6 @@ package utils import ( - "encoding/json" "fmt" "github.com/codefresh-io/go-sdk/internal" @@ -15,8 +14,3 @@ func CastToCodefreshOrDie(candidate interface{}) codefresh.Codefresh { } return client } - -func Convert(from interface{}, to interface{}) { - rs, _ := json.Marshal(from) - _ = json.Unmarshal(rs, to) -} From 123c4fec2be0e64b599c078d3b7a90873a47f49e Mon Sep 17 00:00:00 2001 From: olegz-codefresh Date: Tue, 25 May 2021 13:22:10 +0300 Subject: [PATCH 12/81] Added all git contexs types support --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index 3d9dcb1..35aa2f3 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.25.3 +0.25.4 From feed0541a834a8290b49a66b7a7b813edfdcf3fd Mon Sep 17 00:00:00 2001 From: olegz-codefresh Date: Tue, 25 May 2021 13:48:11 +0300 Subject: [PATCH 13/81] Added all git contexs types support --- VERSION | 2 +- go.mod | 1 + go.sum | 6 ++++++ pkg/codefresh/codefresh.go | 11 ++++------- pkg/codefresh/contexts.go | 10 +--------- pkg/codefresh/types.go | 2 +- 6 files changed, 14 insertions(+), 18 deletions(-) diff --git a/VERSION b/VERSION index 35aa2f3..4e8f395 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.25.4 +0.26.0 diff --git a/go.mod b/go.mod index bea98d2..da1e054 100644 --- a/go.mod +++ b/go.mod @@ -3,6 +3,7 @@ module github.com/codefresh-io/go-sdk require ( github.com/BurntSushi/toml v0.3.1 // indirect github.com/dustin/go-humanize v1.0.0 + github.com/google/go-querystring v1.1.0 github.com/inconshreveable/mousetrap v1.0.0 // indirect github.com/mattn/go-runewidth v0.0.4 // indirect github.com/mitchellh/go-homedir v1.0.0 diff --git a/go.sum b/go.sum index 896b2e4..87362f0 100644 --- a/go.sum +++ b/go.sum @@ -10,6 +10,10 @@ github.com/dustin/go-humanize v1.0.0 h1:VSnTsYCnlFHaM2/igO1h6X3HA71jcobQuxemgkq4 github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= github.com/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV9I= github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= +github.com/google/go-cmp v0.5.2 h1:X2ev0eStA3AbceY54o37/0PQ/UWqKEiiO2dKL5OPaFM= +github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-querystring v1.1.0 h1:AnCroh3fv4ZBgVIf1Iwtovgjaw/GiKJo8M8yD/fhyJ8= +github.com/google/go-querystring v1.1.0/go.mod h1:Kcdr2DB4koayq7X8pmAG4sNG59So17icRSOU623lUBU= github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4= github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ= github.com/inconshreveable/mousetrap v1.0.0 h1:Z8tu5sraLXCXIcARxBp/8cbvlwVa7Z1NHg9XEKhtSvM= @@ -51,6 +55,8 @@ golang.org/x/sys v0.0.0-20181228144115-9a3f9b0469bb h1:pf3XwC90UUdNPYWZdFjhGBE7D golang.org/x/sys v0.0.0-20181228144115-9a3f9b0469bb/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4= +golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw= diff --git a/pkg/codefresh/codefresh.go b/pkg/codefresh/codefresh.go index e5e4d07..4d8ec0b 100644 --- a/pkg/codefresh/codefresh.go +++ b/pkg/codefresh/codefresh.go @@ -4,9 +4,9 @@ import ( "bytes" "encoding/json" "fmt" + "github.com/google/go-querystring/query" "io/ioutil" "net/http" - "strings" ) type ( @@ -92,12 +92,9 @@ func (c *codefresh) requestAPI(opt *requestOptions) (*http.Response, error) { return response, nil } -func toQS(qs map[string]string) string { - var arr = []string{} - for k, v := range qs { - arr = append(arr, fmt.Sprintf("%s=%s", k, v)) - } - return "?" + strings.Join(arr, "&") +func toQS(qs interface{}) string { + v, _ := query.Values(qs) + return "?" + v.Encode() } func (c *codefresh) decodeResponseInto(resp *http.Response, target interface{}) error { diff --git a/pkg/codefresh/contexts.go b/pkg/codefresh/contexts.go index 93ac12c..d908a2e 100644 --- a/pkg/codefresh/contexts.go +++ b/pkg/codefresh/contexts.go @@ -1,9 +1,5 @@ package codefresh -import ( - "encoding/json" -) - type ( IContextAPI interface { GetGitContexts() (error, *[]ContextPayload) @@ -49,16 +45,12 @@ func newContextAPI(codefresh *codefresh) IContextAPI { func (c context) GetGitContexts() (error, *[]ContextPayload) { var result []ContextPayload - var qs map[string]string - gitContextsQs := GitContextsQs{ + qs := GitContextsQs{ Type: []string{"git.github", "git.gitlab", "git.github-app"}, Decrypt: "true", } - rs, _ := json.Marshal(gitContextsQs) - _ = json.Unmarshal(rs, &qs) - resp, err := c.codefresh.requestAPI(&requestOptions{ method: "GET", path: "/api/contexts", diff --git a/pkg/codefresh/types.go b/pkg/codefresh/types.go index f9d89d8..157ad48 100644 --- a/pkg/codefresh/types.go +++ b/pkg/codefresh/types.go @@ -28,6 +28,6 @@ type ( path string method string body interface{} - qs map[string]string + qs interface{} } ) From 16cf8af9a969cf095ec8f4123ea2ce3414ef906e Mon Sep 17 00:00:00 2001 From: olegz-codefresh Date: Tue, 25 May 2021 13:51:25 +0300 Subject: [PATCH 14/81] Added all git contexs types support --- pkg/codefresh/contexts.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/codefresh/contexts.go b/pkg/codefresh/contexts.go index d908a2e..a49a297 100644 --- a/pkg/codefresh/contexts.go +++ b/pkg/codefresh/contexts.go @@ -34,8 +34,8 @@ type ( } GitContextsQs struct { - Type []string `json:"type"` - Decrypt string `json:"decrypt"` + Type []string `url:"type"` + Decrypt string `url:"decrypt"` } ) From 7117c21e328dbee95054fb3e3ab0a6b66497ddc4 Mon Sep 17 00:00:00 2001 From: andrii-codefresh Date: Tue, 25 May 2021 14:00:23 +0300 Subject: [PATCH 15/81] update branch --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index 4e8f395..30f6cf8 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.26.0 +0.26.1 From b1073dde7ad21cfc64adc01b05b8e290fe785502 Mon Sep 17 00:00:00 2001 From: olegz-codefresh Date: Tue, 25 May 2021 15:29:14 +0300 Subject: [PATCH 16/81] Added all git contexs types support --- pkg/codefresh/codefresh.go | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/pkg/codefresh/codefresh.go b/pkg/codefresh/codefresh.go index 4d8ec0b..fce546e 100644 --- a/pkg/codefresh/codefresh.go +++ b/pkg/codefresh/codefresh.go @@ -7,6 +7,7 @@ import ( "github.com/google/go-querystring/query" "io/ioutil" "net/http" + "strings" ) type ( @@ -92,9 +93,27 @@ func (c *codefresh) requestAPI(opt *requestOptions) (*http.Response, error) { return response, nil } +func buildQSFromMap(qs map[string]string) string { + var arr = []string{} + for k, v := range qs { + arr = append(arr, fmt.Sprintf("%s=%s", k, v)) + } + return "?" + strings.Join(arr, "&") +} + func toQS(qs interface{}) string { v, _ := query.Values(qs) - return "?" + v.Encode() + qsStr := v.Encode() + if qsStr != "" { + return "?" + qsStr + } + var qsMap map[string]string + rs, _ := json.Marshal(qs) + err := json.Unmarshal(rs, &qsMap) + if err != nil { + return "" + } + return buildQSFromMap(qsMap) } func (c *codefresh) decodeResponseInto(resp *http.Response, target interface{}) error { From 0b79ede6cbd2ab147885e7928c51a36717830e47 Mon Sep 17 00:00:00 2001 From: pashavictorovich Date: Wed, 26 May 2021 18:21:22 +0300 Subject: [PATCH 17/81] add api url for gitlab --- pkg/codefresh/contexts.go | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/pkg/codefresh/contexts.go b/pkg/codefresh/contexts.go index a49a297..c4982c2 100644 --- a/pkg/codefresh/contexts.go +++ b/pkg/codefresh/contexts.go @@ -19,10 +19,12 @@ type ( Type string `json:"type"` Data struct { Auth struct { - Type string `json:"type"` - Username string `json:"username"` - Password string `json:"password"` - ApiHost string `json:"apiHost"` + Type string `json:"type"` + Username string `json:"username"` + Password string `json:"password"` + ApiHost string `json:"apiHost"` + // for gitlab + ApiURL string `json:"apiURL"` ApiPathPrefix string `json:"apiPathPrefix"` SshPrivateKey string `json:"sshPrivateKey"` AppId string `json:"appId"` From d48761fb10ca62a809a154df2aa82eab17bed8c7 Mon Sep 17 00:00:00 2001 From: olegz-codefresh Date: Wed, 26 May 2021 18:55:07 +0300 Subject: [PATCH 18/81] Revert "remove resources from environment" This reverts commit 110d0e22 --- pkg/codefresh/gitops.go | 1 + 1 file changed, 1 insertion(+) diff --git a/pkg/codefresh/gitops.go b/pkg/codefresh/gitops.go index ff2ac8e..99a5e7a 100644 --- a/pkg/codefresh/gitops.go +++ b/pkg/codefresh/gitops.go @@ -93,6 +93,7 @@ type ( SyncRevision string `json:"revision"` Name string `json:"name"` Activities []EnvironmentActivity `json:"activities"` + Resources interface{} `json:"resources"` RepoUrl string `json:"repoUrl"` Commit Commit `json:"commit"` SyncPolicy SyncPolicy `json:"syncPolicy"` From 4df2b2616e303e36f4a9816b0b563425227f9bf7 Mon Sep 17 00:00:00 2001 From: roi-codefresh <60569147+roi-codefresh@users.noreply.github.com> Date: Mon, 31 May 2021 15:23:46 +0300 Subject: [PATCH 19/81] cli-v2 support (#18) * cli-v2 support * wip * fix avatar field * undelete gitops use * wip --- VERSION | 2 +- go.mod | 2 + go.sum | 7 +- pkg/codefresh/codefresh.go | 22 +++- pkg/codefresh/contexts.go | 10 +- pkg/codefresh/gitops.go | 12 ++- pkg/codefresh/mocks/codefresh.go | 173 +++++++++++++++++++++++++++++++ pkg/codefresh/mocks/users.go | 39 +++++++ pkg/codefresh/users.go | 65 ++++++++++++ 9 files changed, 318 insertions(+), 14 deletions(-) create mode 100644 pkg/codefresh/mocks/codefresh.go create mode 100644 pkg/codefresh/mocks/users.go create mode 100644 pkg/codefresh/users.go diff --git a/VERSION b/VERSION index 30f6cf8..894542a 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.26.1 +0.26.2 diff --git a/go.mod b/go.mod index da1e054..d7fd2cd 100644 --- a/go.mod +++ b/go.mod @@ -11,6 +11,8 @@ require ( github.com/spf13/afero v1.2.0 // indirect github.com/spf13/cobra v0.0.3 github.com/spf13/viper v1.3.1 + github.com/stretchr/objx v0.3.0 // indirect + github.com/stretchr/testify v1.3.0 golang.org/x/sys v0.0.0-20181228144115-9a3f9b0469bb // indirect gopkg.in/yaml.v2 v2.2.2 ) diff --git a/go.sum b/go.sum index 87362f0..ea03c6c 100644 --- a/go.sum +++ b/go.sum @@ -4,6 +4,7 @@ github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5 github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE= github.com/coreos/go-etcd v2.0.0+incompatible/go.mod h1:Jez6KQU2B/sWsbdaef3ED8NzMklzPG4d5KIOhIy30Tk= github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/dustin/go-humanize v1.0.0 h1:VSnTsYCnlFHaM2/igO1h6X3HA71jcobQuxemgkq4zYo= @@ -45,8 +46,12 @@ github.com/spf13/pflag v1.0.3 h1:zPAT6CGy6wXeQ7NtTnaTerfKOsV6V6F8agHXFiazDkg= github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= github.com/spf13/viper v1.3.1 h1:5+8j8FTpnFV4nEImW/ofkzEt8VoOiLXxdYIDsB73T38= github.com/spf13/viper v1.3.1/go.mod h1:ZiWeW+zYFKm7srdB9IoDzzZXaJaI5eL9QjNiN/DMA2s= -github.com/stretchr/testify v1.2.2 h1:bSDNvY7ZPG5RlJ8otE/7V6gMiyenm9RtJ7IUVIAoJ1w= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/objx v0.3.0 h1:NGXK3lHquSN08v5vWalVI/L8XU9hdzE/G6xsrze47As= +github.com/stretchr/objx v0.3.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= +github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0Q= +github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/ugorji/go/codec v0.0.0-20181204163529-d75b2dcb6bc8/go.mod h1:VFNgLljTbGfSG7qAOspJ7OScBnGdDN/yBr0sguwnwf0= github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q= golang.org/x/crypto v0.0.0-20181203042331-505ab145d0a9/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= diff --git a/pkg/codefresh/codefresh.go b/pkg/codefresh/codefresh.go index fce546e..fe23f83 100644 --- a/pkg/codefresh/codefresh.go +++ b/pkg/codefresh/codefresh.go @@ -2,14 +2,20 @@ package codefresh import ( "bytes" + "context" "encoding/json" "fmt" - "github.com/google/go-querystring/query" "io/ioutil" "net/http" "strings" + + "github.com/google/go-querystring/query" ) +//go:generate mockery -name Codefresh -filename codefresh.go + +//go:generate mockery -name UsersAPI -filename users.go + type ( Codefresh interface { Pipelines() IPipelineAPI @@ -19,6 +25,7 @@ type ( Progresses() IProgressAPI Clusters() IClusterAPI Contexts() IContextAPI + Users() UsersAPI Argo() ArgoAPI Gitops() GitopsAPI } @@ -41,6 +48,10 @@ func (c *codefresh) Pipelines() IPipelineAPI { return newPipelineAPI(c) } +func (c *codefresh) Users() UsersAPI { + return newUsersAPI(c) +} + func (c *codefresh) Tokens() ITokenAPI { return newTokenAPI(c) } @@ -74,6 +85,10 @@ func (c *codefresh) Gitops() GitopsAPI { } func (c *codefresh) requestAPI(opt *requestOptions) (*http.Response, error) { + return c.requestAPIWithContext(context.Background(), opt) +} + +func (c *codefresh) requestAPIWithContext(ctx context.Context, opt *requestOptions) (*http.Response, error) { var body []byte finalURL := fmt.Sprintf("%s%s", c.host, opt.path) if opt.qs != nil { @@ -82,7 +97,10 @@ func (c *codefresh) requestAPI(opt *requestOptions) (*http.Response, error) { if opt.body != nil { body, _ = json.Marshal(opt.body) } - request, err := http.NewRequest(opt.method, finalURL, bytes.NewBuffer(body)) + request, err := http.NewRequestWithContext(ctx, opt.method, finalURL, bytes.NewBuffer(body)) + if err != nil { + return nil, err + } request.Header.Set("Authorization", c.token) request.Header.Set("Content-Type", "application/json") diff --git a/pkg/codefresh/contexts.go b/pkg/codefresh/contexts.go index c4982c2..210efc7 100644 --- a/pkg/codefresh/contexts.go +++ b/pkg/codefresh/contexts.go @@ -7,7 +7,7 @@ type ( GetDefaultGitContext() (error, *ContextPayload) } - context struct { + contexts struct { codefresh *codefresh } @@ -42,10 +42,10 @@ type ( ) func newContextAPI(codefresh *codefresh) IContextAPI { - return &context{codefresh} + return &contexts{codefresh} } -func (c context) GetGitContexts() (error, *[]ContextPayload) { +func (c contexts) GetGitContexts() (error, *[]ContextPayload) { var result []ContextPayload qs := GitContextsQs{ @@ -67,7 +67,7 @@ func (c context) GetGitContexts() (error, *[]ContextPayload) { return err, &result } -func (c context) GetGitContextByName(name string) (error, *ContextPayload) { +func (c contexts) GetGitContextByName(name string) (error, *ContextPayload) { var result ContextPayload var qs = map[string]string{ "decrypt": "true", @@ -87,7 +87,7 @@ func (c context) GetGitContextByName(name string) (error, *ContextPayload) { return nil, &result } -func (c context) GetDefaultGitContext() (error, *ContextPayload) { +func (c contexts) GetDefaultGitContext() (error, *ContextPayload) { var result ContextPayload resp, err := c.codefresh.requestAPI(&requestOptions{ diff --git a/pkg/codefresh/gitops.go b/pkg/codefresh/gitops.go index 99a5e7a..61c476d 100644 --- a/pkg/codefresh/gitops.go +++ b/pkg/codefresh/gitops.go @@ -69,17 +69,19 @@ type ( Current int64 `json:"current"` Desired int64 `json:"desired"` } - User struct { - Name string `json:"name"` - Avatar string `json:"avatar"` - } + Annotation struct { Key string `json:"key"` Value string `json:"value"` } + GitopsUser struct { + Name string `json:"name"` + Avatar string `json:"avatar"` + } + Gitops struct { - Comitters []User `json:"comitters"` + Comitters []GitopsUser `json:"comitters"` Prs []Annotation `json:"prs"` Issues []Annotation `json:"issues"` } diff --git a/pkg/codefresh/mocks/codefresh.go b/pkg/codefresh/mocks/codefresh.go new file mode 100644 index 0000000..d924579 --- /dev/null +++ b/pkg/codefresh/mocks/codefresh.go @@ -0,0 +1,173 @@ +// Code generated by mockery v1.1.1. DO NOT EDIT. + +package mocks + +import ( + codefresh "github.com/codefresh-io/go-sdk/pkg/codefresh" + mock "github.com/stretchr/testify/mock" +) + +// Codefresh is an autogenerated mock type for the Codefresh type +type Codefresh struct { + mock.Mock +} + +// Argo provides a mock function with given fields: +func (_m *Codefresh) Argo() codefresh.ArgoAPI { + ret := _m.Called() + + var r0 codefresh.ArgoAPI + if rf, ok := ret.Get(0).(func() codefresh.ArgoAPI); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(codefresh.ArgoAPI) + } + } + + return r0 +} + +// Clusters provides a mock function with given fields: +func (_m *Codefresh) Clusters() codefresh.IClusterAPI { + ret := _m.Called() + + var r0 codefresh.IClusterAPI + if rf, ok := ret.Get(0).(func() codefresh.IClusterAPI); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(codefresh.IClusterAPI) + } + } + + return r0 +} + +// Contexts provides a mock function with given fields: +func (_m *Codefresh) Contexts() codefresh.IContextAPI { + ret := _m.Called() + + var r0 codefresh.IContextAPI + if rf, ok := ret.Get(0).(func() codefresh.IContextAPI); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(codefresh.IContextAPI) + } + } + + return r0 +} + +// Gitops provides a mock function with given fields: +func (_m *Codefresh) Gitops() codefresh.GitopsAPI { + ret := _m.Called() + + var r0 codefresh.GitopsAPI + if rf, ok := ret.Get(0).(func() codefresh.GitopsAPI); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(codefresh.GitopsAPI) + } + } + + return r0 +} + +// Pipelines provides a mock function with given fields: +func (_m *Codefresh) Pipelines() codefresh.IPipelineAPI { + ret := _m.Called() + + var r0 codefresh.IPipelineAPI + if rf, ok := ret.Get(0).(func() codefresh.IPipelineAPI); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(codefresh.IPipelineAPI) + } + } + + return r0 +} + +// Progresses provides a mock function with given fields: +func (_m *Codefresh) Progresses() codefresh.IProgressAPI { + ret := _m.Called() + + var r0 codefresh.IProgressAPI + if rf, ok := ret.Get(0).(func() codefresh.IProgressAPI); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(codefresh.IProgressAPI) + } + } + + return r0 +} + +// RuntimeEnvironments provides a mock function with given fields: +func (_m *Codefresh) RuntimeEnvironments() codefresh.IRuntimeEnvironmentAPI { + ret := _m.Called() + + var r0 codefresh.IRuntimeEnvironmentAPI + if rf, ok := ret.Get(0).(func() codefresh.IRuntimeEnvironmentAPI); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(codefresh.IRuntimeEnvironmentAPI) + } + } + + return r0 +} + +// Tokens provides a mock function with given fields: +func (_m *Codefresh) Tokens() codefresh.ITokenAPI { + ret := _m.Called() + + var r0 codefresh.ITokenAPI + if rf, ok := ret.Get(0).(func() codefresh.ITokenAPI); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(codefresh.ITokenAPI) + } + } + + return r0 +} + +// Users provides a mock function with given fields: +func (_m *Codefresh) Users() codefresh.UsersAPI { + ret := _m.Called() + + var r0 codefresh.UsersAPI + if rf, ok := ret.Get(0).(func() codefresh.UsersAPI); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(codefresh.UsersAPI) + } + } + + return r0 +} + +// Workflows provides a mock function with given fields: +func (_m *Codefresh) Workflows() codefresh.IWorkflowAPI { + ret := _m.Called() + + var r0 codefresh.IWorkflowAPI + if rf, ok := ret.Get(0).(func() codefresh.IWorkflowAPI); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(codefresh.IWorkflowAPI) + } + } + + return r0 +} diff --git a/pkg/codefresh/mocks/users.go b/pkg/codefresh/mocks/users.go new file mode 100644 index 0000000..700d911 --- /dev/null +++ b/pkg/codefresh/mocks/users.go @@ -0,0 +1,39 @@ +// Code generated by mockery v1.1.1. DO NOT EDIT. + +package mocks + +import ( + context "context" + + codefresh "github.com/codefresh-io/go-sdk/pkg/codefresh" + + mock "github.com/stretchr/testify/mock" +) + +// UsersAPI is an autogenerated mock type for the UsersAPI type +type UsersAPI struct { + mock.Mock +} + +// GetCurrent provides a mock function with given fields: ctx +func (_m *UsersAPI) GetCurrent(ctx context.Context) (*codefresh.User, error) { + ret := _m.Called(ctx) + + var r0 *codefresh.User + if rf, ok := ret.Get(0).(func(context.Context) *codefresh.User); ok { + r0 = rf(ctx) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*codefresh.User) + } + } + + var r1 error + if rf, ok := ret.Get(1).(func(context.Context) error); ok { + r1 = rf(ctx) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} diff --git a/pkg/codefresh/users.go b/pkg/codefresh/users.go new file mode 100644 index 0000000..ca73af9 --- /dev/null +++ b/pkg/codefresh/users.go @@ -0,0 +1,65 @@ +package codefresh + +import ( + "context" + "fmt" +) + +type ( + UsersAPI interface { + GetCurrent(ctx context.Context) (*User, error) + } + + User struct { + ID string `json:"_id"` + Name string `json:"userName"` + Email string `json:"email"` + Accounts []Account `json:"account"` + ActiveAccountName string `json:"activeAccountName"` + Roles []string `json:"roles"` + UserData struct { + Avatar string `json:"image"` + } `json:"user_data"` + } + + Account struct { + Name string `json:"name"` + } + + users struct { + *codefresh + } +) + +func newUsersAPI(codefresh *codefresh) UsersAPI { + return &users{codefresh} +} + +func (u *users) GetCurrent(ctx context.Context) (*User, error) { + result := &User{} + resp, err := u.codefresh.requestAPIWithContext(ctx, &requestOptions{ + method: "GET", + path: "/api/user", + }) + if err != nil { + return nil, err + } + if resp.StatusCode >= 400 { + return nil, fmt.Errorf(resp.Status) + } + + if err := u.codefresh.decodeResponseInto(resp, &result); err != nil { + return nil, err + } + + return result, nil +} + +func (u *User) GetActiveAccount() *Account { + for i := 0; i < len(u.Accounts); i++ { + if u.Accounts[i].Name == u.ActiveAccountName { + return &u.Accounts[i] + } + } + return nil +} From 8a9aa2bd353687497b70fe7b9c0399b442e4d7e4 Mon Sep 17 00:00:00 2001 From: roi-codefresh <60569147+roi-codefresh@users.noreply.github.com> Date: Mon, 31 May 2021 15:39:49 +0300 Subject: [PATCH 20/81] Update codefresh.yaml (#19) * Update codefresh.yaml * Delete .goreleaser.yml --- .goreleaser.yml | 27 --------------------------- codefresh.yaml | 35 +++++++++++------------------------ 2 files changed, 11 insertions(+), 51 deletions(-) delete mode 100644 .goreleaser.yml diff --git a/.goreleaser.yml b/.goreleaser.yml deleted file mode 100644 index 94ab732..0000000 --- a/.goreleaser.yml +++ /dev/null @@ -1,27 +0,0 @@ -builds: -- env: - - CGO_ENABLED=0 - goos: - - darwin - - linux - - windows -archive: - replacements: - darwin: Darwin - linux: Linux - windows: Windows - 386: i386 - amd64: x86_64 - format_overrides: - - goos: windows - format: zip -checksum: - name_template: 'checksums.txt' -snapshot: - name_template: "{{ .Tag }}-next" -changelog: - sort: asc - filters: - exclude: - - '^docs:' - - '^test:' diff --git a/codefresh.yaml b/codefresh.yaml index 593c51c..6a1e520 100644 --- a/codefresh.yaml +++ b/codefresh.yaml @@ -1,41 +1,28 @@ version: '1.0' stages: +- Prepare - Release mode: parallel steps: - CreatingGitTag: - title: Push tag to git - image: codefresh/cli - stage: Release - commands: - - export VERSION=$(cat VERSION) - - export OLD_ORIGIN=$(git remote get-url origin) - - git remote rm origin - - git remote add origin https://${{GITHUB_TOKEN}}@github.com/codefresh-io/go-sdk.git - - git tag v$VERSION - - git push --tags - - git remote rm origin - - git remote add origin $OLD_ORIGIN - fail_fast: false - when: - steps: - - name: main_clone - branch: - only: - - master + main_clone: + stage: Prepare + title: clone repository + type: git-clone + git: cf_github + repo: ${{CF_REPO_OWNER}}/${{CF_REPO_NAME}} + revision: ${{CF_BRANCH}} ReleasingBinaries: title: Create release in Github - image: goreleaser/goreleaser + image: quay.io/codefresh/golang-ci-helper:latest stage: Release - fail_fast: false commands: - go mod download - - goreleaser release -f .goreleaser.yml --rm-dist --skip-validate + - gh release create --repo ${{CF_REPO_OWNER}}/${{CF_REPO_NAME}} -t $VERSION -n $VERSION $VERSION when: steps: - name: CreatingGitTag @@ -43,4 +30,4 @@ steps: - finished branch: only: - - master \ No newline at end of file + - master From c904a23a204a9616a7f338396fa6609e2a269c49 Mon Sep 17 00:00:00 2001 From: roi-codefresh <60569147+roi-codefresh@users.noreply.github.com> Date: Mon, 31 May 2021 15:43:06 +0300 Subject: [PATCH 21/81] Update codefresh.yaml --- codefresh.yaml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/codefresh.yaml b/codefresh.yaml index 6a1e520..4c2889b 100644 --- a/codefresh.yaml +++ b/codefresh.yaml @@ -24,10 +24,6 @@ steps: - go mod download - gh release create --repo ${{CF_REPO_OWNER}}/${{CF_REPO_NAME}} -t $VERSION -n $VERSION $VERSION when: - steps: - - name: CreatingGitTag - on: - - finished branch: only: - master From 8a185de49d14e6f9a150b0577af2882e9836d5bf Mon Sep 17 00:00:00 2001 From: roi-codefresh <60569147+roi-codefresh@users.noreply.github.com> Date: Mon, 31 May 2021 15:44:22 +0300 Subject: [PATCH 22/81] Update codefresh.yaml --- codefresh.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/codefresh.yaml b/codefresh.yaml index 4c2889b..9cc26cc 100644 --- a/codefresh.yaml +++ b/codefresh.yaml @@ -21,7 +21,6 @@ steps: image: quay.io/codefresh/golang-ci-helper:latest stage: Release commands: - - go mod download - gh release create --repo ${{CF_REPO_OWNER}}/${{CF_REPO_NAME}} -t $VERSION -n $VERSION $VERSION when: branch: From 39385ee73fe9f0deae903b11f33f38b16ddd2b3b Mon Sep 17 00:00:00 2001 From: roi-codefresh <60569147+roi-codefresh@users.noreply.github.com> Date: Mon, 31 May 2021 15:45:43 +0300 Subject: [PATCH 23/81] Update codefresh.yaml --- codefresh.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/codefresh.yaml b/codefresh.yaml index 9cc26cc..67f97f7 100644 --- a/codefresh.yaml +++ b/codefresh.yaml @@ -21,6 +21,7 @@ steps: image: quay.io/codefresh/golang-ci-helper:latest stage: Release commands: + - export VERSION=$(cat VERSION) - gh release create --repo ${{CF_REPO_OWNER}}/${{CF_REPO_NAME}} -t $VERSION -n $VERSION $VERSION when: branch: From 38b1d0cea5f83b6d3df940f5910e206ca002e4f2 Mon Sep 17 00:00:00 2001 From: roi-codefresh <60569147+roi-codefresh@users.noreply.github.com> Date: Mon, 31 May 2021 15:46:30 +0300 Subject: [PATCH 24/81] Update codefresh.yaml --- codefresh.yaml | 2 -- 1 file changed, 2 deletions(-) diff --git a/codefresh.yaml b/codefresh.yaml index 67f97f7..bde7389 100644 --- a/codefresh.yaml +++ b/codefresh.yaml @@ -4,8 +4,6 @@ stages: - Prepare - Release -mode: parallel - steps: main_clone: From 99a13d0444372b42f1beda9a19e5bd42030d7eef Mon Sep 17 00:00:00 2001 From: Oren Gurfinkel Date: Sun, 4 Jul 2021 18:25:12 +0300 Subject: [PATCH 25/81] support runtime list --- go.mod | 1 + go.sum | 2 + pkg/codefresh/argo_runtime.go | 82 +++++++++++++++++++++++++++++++++++ pkg/codefresh/codefresh.go | 5 +++ 4 files changed, 90 insertions(+) create mode 100644 pkg/codefresh/argo_runtime.go diff --git a/go.mod b/go.mod index d7fd2cd..e0c9317 100644 --- a/go.mod +++ b/go.mod @@ -2,6 +2,7 @@ module github.com/codefresh-io/go-sdk require ( github.com/BurntSushi/toml v0.3.1 // indirect + github.com/codefresh-io/argo-platform v1.12.4-0.20210630081821-dfc9fd4ddae9 github.com/dustin/go-humanize v1.0.0 github.com/google/go-querystring v1.1.0 github.com/inconshreveable/mousetrap v1.0.0 // indirect diff --git a/go.sum b/go.sum index ea03c6c..7ed1e4a 100644 --- a/go.sum +++ b/go.sum @@ -1,6 +1,8 @@ github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8= +github.com/codefresh-io/argo-platform v1.12.4-0.20210630081821-dfc9fd4ddae9 h1:lUrKubj1uhE2q60hSJ8uPqVPax9jk6Wzu8UEhK5A5rM= +github.com/codefresh-io/argo-platform v1.12.4-0.20210630081821-dfc9fd4ddae9/go.mod h1:u/eLWAySJ1nRzNWnB5baeyIc5vqINghwYJvydU+EC3c= github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE= github.com/coreos/go-etcd v2.0.0+incompatible/go.mod h1:Jez6KQU2B/sWsbdaef3ED8NzMklzPG4d5KIOhIy30Tk= github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= diff --git a/pkg/codefresh/argo_runtime.go b/pkg/codefresh/argo_runtime.go new file mode 100644 index 0000000..15e568d --- /dev/null +++ b/pkg/codefresh/argo_runtime.go @@ -0,0 +1,82 @@ +package codefresh + +import ( + "bytes" + "encoding/json" + "fmt" + "io/ioutil" + + "github.com/codefresh-io/argo-platform/libs/ql/graph/model" +) + + +type ( + IArgoRuntimeAPI interface { + List() ([]model.Runtime, error) + } + argoRuntime struct { + codefresh *codefresh + } + graphqlRuntimesResponse struct { + Data graphqlRuntimesInnerResponse`json:"data"` + // Errors []byte + } + graphqlRuntimesInnerResponse struct { + Runtimes model.RuntimePage `json:"runtimes"` + } +) + +func newArgoRuntimeAPI(codefresh *codefresh) IArgoRuntimeAPI { + return &argoRuntime{codefresh: codefresh} +} +func (r *argoRuntime) List() ([]model.Runtime, error) { + + jsonData := map[string]interface{}{ + "query":` + { + runtimes{ + edges{ + node { + id + namespace + objectMeta { + name + description + } + } + } + } + } + `, + } + + + response, err := r.codefresh.requestAPI(&requestOptions{ + method: "POST", + path: "/argo/api/graphql", + body: jsonData, + }) + defer response.Body.Close() + if err != nil { + fmt.Printf("The HTTP request failed with error %s\n", err) + return nil, err + } + data, err := ioutil.ReadAll(response.Body) + if err != nil { + fmt.Printf("failed to read from response body") + return nil, err + } + res := graphqlRuntimesResponse{} + err = json.Unmarshal(data, &res) + if err != nil { + return nil, err + } + runtimes := []model.Runtime{} + for _, v := range res.Data.Runtimes.Edges { + runtimes = append(runtimes, *v.Node) + } + + return runtimes, nil + + +} \ No newline at end of file diff --git a/pkg/codefresh/codefresh.go b/pkg/codefresh/codefresh.go index fe23f83..f1e4309 100644 --- a/pkg/codefresh/codefresh.go +++ b/pkg/codefresh/codefresh.go @@ -28,6 +28,7 @@ type ( Users() UsersAPI Argo() ArgoAPI Gitops() GitopsAPI + ArgoRuntime() IArgoRuntimeAPI } ) @@ -84,6 +85,10 @@ func (c *codefresh) Gitops() GitopsAPI { return newGitopsAPI(c) } +func (c *codefresh) ArgoRuntime() IArgoRuntimeAPI { + return newArgoRuntimeAPI(c) +} + func (c *codefresh) requestAPI(opt *requestOptions) (*http.Response, error) { return c.requestAPIWithContext(context.Background(), opt) } From 89b3f7b6708f2b5d39c27c59f1a3734b11314724 Mon Sep 17 00:00:00 2001 From: Oren Gurfinkel Date: Sun, 4 Jul 2021 21:56:14 +0300 Subject: [PATCH 26/81] bump --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index 894542a..3f45a64 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.26.2 +0.26.3 From 62235d2a4288e81dec5c1823315340177a0e4e01 Mon Sep 17 00:00:00 2001 From: Oren Gurfinkel Date: Mon, 5 Jul 2021 09:59:36 +0300 Subject: [PATCH 27/81] wip --- go.mod | 2 +- go.sum | 4 ++-- pkg/codefresh/argo_runtime.go | 10 ++++------ 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/go.mod b/go.mod index e0c9317..fcceda6 100644 --- a/go.mod +++ b/go.mod @@ -2,7 +2,7 @@ module github.com/codefresh-io/go-sdk require ( github.com/BurntSushi/toml v0.3.1 // indirect - github.com/codefresh-io/argo-platform v1.12.4-0.20210630081821-dfc9fd4ddae9 + github.com/codefresh-io/argo-platform v1.13.0 github.com/dustin/go-humanize v1.0.0 github.com/google/go-querystring v1.1.0 github.com/inconshreveable/mousetrap v1.0.0 // indirect diff --git a/go.sum b/go.sum index 7ed1e4a..23e05ed 100644 --- a/go.sum +++ b/go.sum @@ -1,8 +1,8 @@ github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8= -github.com/codefresh-io/argo-platform v1.12.4-0.20210630081821-dfc9fd4ddae9 h1:lUrKubj1uhE2q60hSJ8uPqVPax9jk6Wzu8UEhK5A5rM= -github.com/codefresh-io/argo-platform v1.12.4-0.20210630081821-dfc9fd4ddae9/go.mod h1:u/eLWAySJ1nRzNWnB5baeyIc5vqINghwYJvydU+EC3c= +github.com/codefresh-io/argo-platform v1.13.0 h1:eWAWkxtO0nGZuekrQJsfFT5KfBMdWby0cOucy4yTExs= +github.com/codefresh-io/argo-platform v1.13.0/go.mod h1:u/eLWAySJ1nRzNWnB5baeyIc5vqINghwYJvydU+EC3c= github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE= github.com/coreos/go-etcd v2.0.0+incompatible/go.mod h1:Jez6KQU2B/sWsbdaef3ED8NzMklzPG4d5KIOhIy30Tk= github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= diff --git a/pkg/codefresh/argo_runtime.go b/pkg/codefresh/argo_runtime.go index 15e568d..56772ad 100644 --- a/pkg/codefresh/argo_runtime.go +++ b/pkg/codefresh/argo_runtime.go @@ -1,7 +1,6 @@ package codefresh import ( - "bytes" "encoding/json" "fmt" "io/ioutil" @@ -18,11 +17,10 @@ type ( codefresh *codefresh } graphqlRuntimesResponse struct { - Data graphqlRuntimesInnerResponse`json:"data"` - // Errors []byte - } - graphqlRuntimesInnerResponse struct { - Runtimes model.RuntimePage `json:"runtimes"` + Data struct { + Runtimes model.RuntimePage `json:"runtimes"` + } `json:"data"` + Errors []byte } ) From bf4bfc6297acb953dafaf581a14a3b1d9b2109f6 Mon Sep 17 00:00:00 2001 From: Oren Gurfinkel Date: Mon, 5 Jul 2021 15:33:07 +0300 Subject: [PATCH 28/81] wip --- pkg/codefresh/argo_runtime.go | 45 ++++++++++++++++++----------------- pkg/codefresh/common.go | 40 +++++++++++++++++++++++++++++++ 2 files changed, 63 insertions(+), 22 deletions(-) create mode 100644 pkg/codefresh/common.go diff --git a/pkg/codefresh/argo_runtime.go b/pkg/codefresh/argo_runtime.go index 56772ad..4ac0e96 100644 --- a/pkg/codefresh/argo_runtime.go +++ b/pkg/codefresh/argo_runtime.go @@ -8,7 +8,6 @@ import ( "github.com/codefresh-io/argo-platform/libs/ql/graph/model" ) - type ( IArgoRuntimeAPI interface { List() ([]model.Runtime, error) @@ -17,20 +16,20 @@ type ( codefresh *codefresh } graphqlRuntimesResponse struct { - Data struct { - Runtimes model.RuntimePage `json:"runtimes"` - } `json:"data"` - Errors []byte + Data struct { + Runtimes model.RuntimePage + } + Errors []graphqlError } ) func newArgoRuntimeAPI(codefresh *codefresh) IArgoRuntimeAPI { return &argoRuntime{codefresh: codefresh} } -func (r *argoRuntime) List() ([]model.Runtime, error) { +func (r *argoRuntime) List() ([]model.Runtime, error) { jsonData := map[string]interface{}{ - "query":` + "query": ` { runtimes{ edges{ @@ -46,24 +45,23 @@ func (r *argoRuntime) List() ([]model.Runtime, error) { } } `, - } - + } response, err := r.codefresh.requestAPI(&requestOptions{ method: "POST", - path: "/argo/api/graphql", - body: jsonData, + path: "/argo/api/graphql", + body: jsonData, }) - defer response.Body.Close() - if err != nil { - fmt.Printf("The HTTP request failed with error %s\n", err) + defer response.Body.Close() + if err != nil { + fmt.Printf("The HTTP request failed with error %s\n", err) return nil, err - } - data, err := ioutil.ReadAll(response.Body) + } + data, err := ioutil.ReadAll(response.Body) if err != nil { - fmt.Printf("failed to read from response body") + fmt.Printf("failed to read from response body") return nil, err - } + } res := graphqlRuntimesResponse{} err = json.Unmarshal(data, &res) if err != nil { @@ -73,8 +71,11 @@ func (r *argoRuntime) List() ([]model.Runtime, error) { for _, v := range res.Data.Runtimes.Edges { runtimes = append(runtimes, *v.Node) } - + + if len(res.Errors) > 0 { + return nil, graphqlErrorResponse{errors: res.Errors} + } + return runtimes, nil - - -} \ No newline at end of file + +} diff --git a/pkg/codefresh/common.go b/pkg/codefresh/common.go new file mode 100644 index 0000000..b26ce59 --- /dev/null +++ b/pkg/codefresh/common.go @@ -0,0 +1,40 @@ +package codefresh + +import ( + "fmt" + "strings" + +) + +type graphqlError struct { + Message string + Locations [] struct { + Line int + Column int + } + Extensions struct { + Code string + Exception struct { + Stacktrace []string + } + } +} + +type graphqlErrorResponse struct { + errors []graphqlError + concatenatedErrors string +} + + +func (e graphqlErrorResponse) Error() string { + + if e.concatenatedErrors != "" { + return e.concatenatedErrors + } + var sb strings.Builder + for _, err := range e.errors { + sb.WriteString(fmt.Sprintln(err.Message)) + } + e.concatenatedErrors = sb.String() + return e.concatenatedErrors +} \ No newline at end of file From 5a77eaea4074b0e7679c2e0b074098d0bb76f461 Mon Sep 17 00:00:00 2001 From: Oren Gurfinkel Date: Mon, 5 Jul 2021 15:49:23 +0300 Subject: [PATCH 29/81] wip --- pkg/codefresh/argo_runtime.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pkg/codefresh/argo_runtime.go b/pkg/codefresh/argo_runtime.go index 4ac0e96..0d6571c 100644 --- a/pkg/codefresh/argo_runtime.go +++ b/pkg/codefresh/argo_runtime.go @@ -67,9 +67,9 @@ func (r *argoRuntime) List() ([]model.Runtime, error) { if err != nil { return nil, err } - runtimes := []model.Runtime{} - for _, v := range res.Data.Runtimes.Edges { - runtimes = append(runtimes, *v.Node) + runtimes := make([]model.Runtime, len(res.Data.Runtimes.Edges)) + for i := range res.Data.Runtimes.Edges { + runtimes[i] = *res.Data.Runtimes.Edges[i].Node } if len(res.Errors) > 0 { From 62da06172d24a0c8454831dfa7bb44bd6a6fbd44 Mon Sep 17 00:00:00 2001 From: Oren Gurfinkel Date: Tue, 6 Jul 2021 18:29:21 +0300 Subject: [PATCH 30/81] update mocks --- VERSION | 2 +- mocks/ArgoAPI.go | 129 ++++++++++++++++++++++ mocks/Codefresh.go | 189 ++++++++++++++++++++++++++++++++ mocks/GitopsAPI.go | 115 +++++++++++++++++++ mocks/IArgoRuntimeAPI.go | 36 ++++++ mocks/IClusterAPI.go | 59 ++++++++++ mocks/IContextAPI.go | 82 ++++++++++++++ mocks/IPipelineAPI.go | 57 ++++++++++ mocks/IProgressAPI.go | 36 ++++++ mocks/IRuntimeEnvironmentAPI.go | 161 +++++++++++++++++++++++++++ mocks/ITokenAPI.go | 59 ++++++++++ mocks/IWorkflowAPI.go | 52 +++++++++ mocks/UsersAPI.go | 39 +++++++ 13 files changed, 1015 insertions(+), 1 deletion(-) create mode 100644 mocks/ArgoAPI.go create mode 100644 mocks/Codefresh.go create mode 100644 mocks/GitopsAPI.go create mode 100644 mocks/IArgoRuntimeAPI.go create mode 100644 mocks/IClusterAPI.go create mode 100644 mocks/IContextAPI.go create mode 100644 mocks/IPipelineAPI.go create mode 100644 mocks/IProgressAPI.go create mode 100644 mocks/IRuntimeEnvironmentAPI.go create mode 100644 mocks/ITokenAPI.go create mode 100644 mocks/IWorkflowAPI.go create mode 100644 mocks/UsersAPI.go diff --git a/VERSION b/VERSION index 3f45a64..12a91df 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.26.3 +0.26.4 diff --git a/mocks/ArgoAPI.go b/mocks/ArgoAPI.go new file mode 100644 index 0000000..356d2cc --- /dev/null +++ b/mocks/ArgoAPI.go @@ -0,0 +1,129 @@ +// Code generated by mockery v1.1.1. DO NOT EDIT. + +package mocks + +import ( + codefresh "github.com/codefresh-io/go-sdk/pkg/codefresh" + mock "github.com/stretchr/testify/mock" +) + +// ArgoAPI is an autogenerated mock type for the ArgoAPI type +type ArgoAPI struct { + mock.Mock +} + +// CreateIntegration provides a mock function with given fields: integration +func (_m *ArgoAPI) CreateIntegration(integration codefresh.IntegrationPayloadData) error { + ret := _m.Called(integration) + + var r0 error + if rf, ok := ret.Get(0).(func(codefresh.IntegrationPayloadData) error); ok { + r0 = rf(integration) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// DeleteIntegrationByName provides a mock function with given fields: name +func (_m *ArgoAPI) DeleteIntegrationByName(name string) error { + ret := _m.Called(name) + + var r0 error + if rf, ok := ret.Get(0).(func(string) error); ok { + r0 = rf(name) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// GetIntegrationByName provides a mock function with given fields: name +func (_m *ArgoAPI) GetIntegrationByName(name string) (*codefresh.IntegrationPayload, error) { + ret := _m.Called(name) + + var r0 *codefresh.IntegrationPayload + if rf, ok := ret.Get(0).(func(string) *codefresh.IntegrationPayload); ok { + r0 = rf(name) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*codefresh.IntegrationPayload) + } + } + + var r1 error + if rf, ok := ret.Get(1).(func(string) error); ok { + r1 = rf(name) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// GetIntegrations provides a mock function with given fields: +func (_m *ArgoAPI) GetIntegrations() ([]*codefresh.IntegrationPayload, error) { + ret := _m.Called() + + var r0 []*codefresh.IntegrationPayload + if rf, ok := ret.Get(0).(func() []*codefresh.IntegrationPayload); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]*codefresh.IntegrationPayload) + } + } + + var r1 error + if rf, ok := ret.Get(1).(func() error); ok { + r1 = rf() + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// HeartBeat provides a mock function with given fields: error, version, integration +func (_m *ArgoAPI) HeartBeat(error string, version string, integration string) error { + ret := _m.Called(error, version, integration) + + var r0 error + if rf, ok := ret.Get(0).(func(string, string, string) error); ok { + r0 = rf(error, version, integration) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// SendResources provides a mock function with given fields: kind, items, amount, integration +func (_m *ArgoAPI) SendResources(kind string, items interface{}, amount int, integration string) error { + ret := _m.Called(kind, items, amount, integration) + + var r0 error + if rf, ok := ret.Get(0).(func(string, interface{}, int, string) error); ok { + r0 = rf(kind, items, amount, integration) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// UpdateIntegration provides a mock function with given fields: name, integration +func (_m *ArgoAPI) UpdateIntegration(name string, integration codefresh.IntegrationPayloadData) error { + ret := _m.Called(name, integration) + + var r0 error + if rf, ok := ret.Get(0).(func(string, codefresh.IntegrationPayloadData) error); ok { + r0 = rf(name, integration) + } else { + r0 = ret.Error(0) + } + + return r0 +} diff --git a/mocks/Codefresh.go b/mocks/Codefresh.go new file mode 100644 index 0000000..67721eb --- /dev/null +++ b/mocks/Codefresh.go @@ -0,0 +1,189 @@ +// Code generated by mockery v1.1.1. DO NOT EDIT. + +package mocks + +import ( + codefresh "github.com/codefresh-io/go-sdk/pkg/codefresh" + mock "github.com/stretchr/testify/mock" +) + +// Codefresh is an autogenerated mock type for the Codefresh type +type Codefresh struct { + mock.Mock +} + +// Argo provides a mock function with given fields: +func (_m *Codefresh) Argo() codefresh.ArgoAPI { + ret := _m.Called() + + var r0 codefresh.ArgoAPI + if rf, ok := ret.Get(0).(func() codefresh.ArgoAPI); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(codefresh.ArgoAPI) + } + } + + return r0 +} + +// ArgoRuntime provides a mock function with given fields: +func (_m *Codefresh) ArgoRuntime() codefresh.IArgoRuntimeAPI { + ret := _m.Called() + + var r0 codefresh.IArgoRuntimeAPI + if rf, ok := ret.Get(0).(func() codefresh.IArgoRuntimeAPI); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(codefresh.IArgoRuntimeAPI) + } + } + + return r0 +} + +// Clusters provides a mock function with given fields: +func (_m *Codefresh) Clusters() codefresh.IClusterAPI { + ret := _m.Called() + + var r0 codefresh.IClusterAPI + if rf, ok := ret.Get(0).(func() codefresh.IClusterAPI); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(codefresh.IClusterAPI) + } + } + + return r0 +} + +// Contexts provides a mock function with given fields: +func (_m *Codefresh) Contexts() codefresh.IContextAPI { + ret := _m.Called() + + var r0 codefresh.IContextAPI + if rf, ok := ret.Get(0).(func() codefresh.IContextAPI); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(codefresh.IContextAPI) + } + } + + return r0 +} + +// Gitops provides a mock function with given fields: +func (_m *Codefresh) Gitops() codefresh.GitopsAPI { + ret := _m.Called() + + var r0 codefresh.GitopsAPI + if rf, ok := ret.Get(0).(func() codefresh.GitopsAPI); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(codefresh.GitopsAPI) + } + } + + return r0 +} + +// Pipelines provides a mock function with given fields: +func (_m *Codefresh) Pipelines() codefresh.IPipelineAPI { + ret := _m.Called() + + var r0 codefresh.IPipelineAPI + if rf, ok := ret.Get(0).(func() codefresh.IPipelineAPI); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(codefresh.IPipelineAPI) + } + } + + return r0 +} + +// Progresses provides a mock function with given fields: +func (_m *Codefresh) Progresses() codefresh.IProgressAPI { + ret := _m.Called() + + var r0 codefresh.IProgressAPI + if rf, ok := ret.Get(0).(func() codefresh.IProgressAPI); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(codefresh.IProgressAPI) + } + } + + return r0 +} + +// RuntimeEnvironments provides a mock function with given fields: +func (_m *Codefresh) RuntimeEnvironments() codefresh.IRuntimeEnvironmentAPI { + ret := _m.Called() + + var r0 codefresh.IRuntimeEnvironmentAPI + if rf, ok := ret.Get(0).(func() codefresh.IRuntimeEnvironmentAPI); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(codefresh.IRuntimeEnvironmentAPI) + } + } + + return r0 +} + +// Tokens provides a mock function with given fields: +func (_m *Codefresh) Tokens() codefresh.ITokenAPI { + ret := _m.Called() + + var r0 codefresh.ITokenAPI + if rf, ok := ret.Get(0).(func() codefresh.ITokenAPI); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(codefresh.ITokenAPI) + } + } + + return r0 +} + +// Users provides a mock function with given fields: +func (_m *Codefresh) Users() codefresh.UsersAPI { + ret := _m.Called() + + var r0 codefresh.UsersAPI + if rf, ok := ret.Get(0).(func() codefresh.UsersAPI); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(codefresh.UsersAPI) + } + } + + return r0 +} + +// Workflows provides a mock function with given fields: +func (_m *Codefresh) Workflows() codefresh.IWorkflowAPI { + ret := _m.Called() + + var r0 codefresh.IWorkflowAPI + if rf, ok := ret.Get(0).(func() codefresh.IWorkflowAPI); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(codefresh.IWorkflowAPI) + } + } + + return r0 +} diff --git a/mocks/GitopsAPI.go b/mocks/GitopsAPI.go new file mode 100644 index 0000000..8fe7be2 --- /dev/null +++ b/mocks/GitopsAPI.go @@ -0,0 +1,115 @@ +// Code generated by mockery v1.1.1. DO NOT EDIT. + +package mocks + +import ( + codefresh "github.com/codefresh-io/go-sdk/pkg/codefresh" + mock "github.com/stretchr/testify/mock" +) + +// GitopsAPI is an autogenerated mock type for the GitopsAPI type +type GitopsAPI struct { + mock.Mock +} + +// CreateEnvironment provides a mock function with given fields: name, project, application, integration +func (_m *GitopsAPI) CreateEnvironment(name string, project string, application string, integration string) error { + ret := _m.Called(name, project, application, integration) + + var r0 error + if rf, ok := ret.Get(0).(func(string, string, string, string) error); ok { + r0 = rf(name, project, application, integration) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// DeleteEnvironment provides a mock function with given fields: name +func (_m *GitopsAPI) DeleteEnvironment(name string) error { + ret := _m.Called(name) + + var r0 error + if rf, ok := ret.Get(0).(func(string) error); ok { + r0 = rf(name) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// GetEnvironments provides a mock function with given fields: +func (_m *GitopsAPI) GetEnvironments() ([]codefresh.CFEnvironment, error) { + ret := _m.Called() + + var r0 []codefresh.CFEnvironment + if rf, ok := ret.Get(0).(func() []codefresh.CFEnvironment); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]codefresh.CFEnvironment) + } + } + + var r1 error + if rf, ok := ret.Get(1).(func() error); ok { + r1 = rf() + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// SendApplicationResources provides a mock function with given fields: resources +func (_m *GitopsAPI) SendApplicationResources(resources *codefresh.ApplicationResources) error { + ret := _m.Called(resources) + + var r0 error + if rf, ok := ret.Get(0).(func(*codefresh.ApplicationResources) error); ok { + r0 = rf(resources) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// SendEnvironment provides a mock function with given fields: environment +func (_m *GitopsAPI) SendEnvironment(environment codefresh.Environment) (map[string]interface{}, error) { + ret := _m.Called(environment) + + var r0 map[string]interface{} + if rf, ok := ret.Get(0).(func(codefresh.Environment) map[string]interface{}); ok { + r0 = rf(environment) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(map[string]interface{}) + } + } + + var r1 error + if rf, ok := ret.Get(1).(func(codefresh.Environment) error); ok { + r1 = rf(environment) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// SendEvent provides a mock function with given fields: name, props +func (_m *GitopsAPI) SendEvent(name string, props map[string]string) error { + ret := _m.Called(name, props) + + var r0 error + if rf, ok := ret.Get(0).(func(string, map[string]string) error); ok { + r0 = rf(name, props) + } else { + r0 = ret.Error(0) + } + + return r0 +} diff --git a/mocks/IArgoRuntimeAPI.go b/mocks/IArgoRuntimeAPI.go new file mode 100644 index 0000000..f66f112 --- /dev/null +++ b/mocks/IArgoRuntimeAPI.go @@ -0,0 +1,36 @@ +// Code generated by mockery v1.1.1. DO NOT EDIT. + +package mocks + +import ( + model "github.com/codefresh-io/argo-platform/libs/ql/graph/model" + mock "github.com/stretchr/testify/mock" +) + +// IArgoRuntimeAPI is an autogenerated mock type for the IArgoRuntimeAPI type +type IArgoRuntimeAPI struct { + mock.Mock +} + +// List provides a mock function with given fields: +func (_m *IArgoRuntimeAPI) List() ([]model.Runtime, error) { + ret := _m.Called() + + var r0 []model.Runtime + if rf, ok := ret.Get(0).(func() []model.Runtime); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]model.Runtime) + } + } + + var r1 error + if rf, ok := ret.Get(1).(func() error); ok { + r1 = rf() + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} diff --git a/mocks/IClusterAPI.go b/mocks/IClusterAPI.go new file mode 100644 index 0000000..c4d93ae --- /dev/null +++ b/mocks/IClusterAPI.go @@ -0,0 +1,59 @@ +// Code generated by mockery v1.1.1. DO NOT EDIT. + +package mocks + +import ( + codefresh "github.com/codefresh-io/go-sdk/pkg/codefresh" + mock "github.com/stretchr/testify/mock" +) + +// IClusterAPI is an autogenerated mock type for the IClusterAPI type +type IClusterAPI struct { + mock.Mock +} + +// GetAccountClusters provides a mock function with given fields: +func (_m *IClusterAPI) GetAccountClusters() ([]*codefresh.ClusterMinified, error) { + ret := _m.Called() + + var r0 []*codefresh.ClusterMinified + if rf, ok := ret.Get(0).(func() []*codefresh.ClusterMinified); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]*codefresh.ClusterMinified) + } + } + + var r1 error + if rf, ok := ret.Get(1).(func() error); ok { + r1 = rf() + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// GetClusterCredentialsByAccountId provides a mock function with given fields: selector +func (_m *IClusterAPI) GetClusterCredentialsByAccountId(selector string) (*codefresh.Cluster, error) { + ret := _m.Called(selector) + + var r0 *codefresh.Cluster + if rf, ok := ret.Get(0).(func(string) *codefresh.Cluster); ok { + r0 = rf(selector) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*codefresh.Cluster) + } + } + + var r1 error + if rf, ok := ret.Get(1).(func(string) error); ok { + r1 = rf(selector) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} diff --git a/mocks/IContextAPI.go b/mocks/IContextAPI.go new file mode 100644 index 0000000..7aa15c1 --- /dev/null +++ b/mocks/IContextAPI.go @@ -0,0 +1,82 @@ +// Code generated by mockery v1.1.1. DO NOT EDIT. + +package mocks + +import ( + codefresh "github.com/codefresh-io/go-sdk/pkg/codefresh" + mock "github.com/stretchr/testify/mock" +) + +// IContextAPI is an autogenerated mock type for the IContextAPI type +type IContextAPI struct { + mock.Mock +} + +// GetDefaultGitContext provides a mock function with given fields: +func (_m *IContextAPI) GetDefaultGitContext() (error, *codefresh.ContextPayload) { + ret := _m.Called() + + var r0 error + if rf, ok := ret.Get(0).(func() error); ok { + r0 = rf() + } else { + r0 = ret.Error(0) + } + + var r1 *codefresh.ContextPayload + if rf, ok := ret.Get(1).(func() *codefresh.ContextPayload); ok { + r1 = rf() + } else { + if ret.Get(1) != nil { + r1 = ret.Get(1).(*codefresh.ContextPayload) + } + } + + return r0, r1 +} + +// GetGitContextByName provides a mock function with given fields: name +func (_m *IContextAPI) GetGitContextByName(name string) (error, *codefresh.ContextPayload) { + ret := _m.Called(name) + + var r0 error + if rf, ok := ret.Get(0).(func(string) error); ok { + r0 = rf(name) + } else { + r0 = ret.Error(0) + } + + var r1 *codefresh.ContextPayload + if rf, ok := ret.Get(1).(func(string) *codefresh.ContextPayload); ok { + r1 = rf(name) + } else { + if ret.Get(1) != nil { + r1 = ret.Get(1).(*codefresh.ContextPayload) + } + } + + return r0, r1 +} + +// GetGitContexts provides a mock function with given fields: +func (_m *IContextAPI) GetGitContexts() (error, *[]codefresh.ContextPayload) { + ret := _m.Called() + + var r0 error + if rf, ok := ret.Get(0).(func() error); ok { + r0 = rf() + } else { + r0 = ret.Error(0) + } + + var r1 *[]codefresh.ContextPayload + if rf, ok := ret.Get(1).(func() *[]codefresh.ContextPayload); ok { + r1 = rf() + } else { + if ret.Get(1) != nil { + r1 = ret.Get(1).(*[]codefresh.ContextPayload) + } + } + + return r0, r1 +} diff --git a/mocks/IPipelineAPI.go b/mocks/IPipelineAPI.go new file mode 100644 index 0000000..05ae012 --- /dev/null +++ b/mocks/IPipelineAPI.go @@ -0,0 +1,57 @@ +// Code generated by mockery v1.1.1. DO NOT EDIT. + +package mocks + +import ( + codefresh "github.com/codefresh-io/go-sdk/pkg/codefresh" + mock "github.com/stretchr/testify/mock" +) + +// IPipelineAPI is an autogenerated mock type for the IPipelineAPI type +type IPipelineAPI struct { + mock.Mock +} + +// List provides a mock function with given fields: qs +func (_m *IPipelineAPI) List(qs map[string]string) ([]*codefresh.Pipeline, error) { + ret := _m.Called(qs) + + var r0 []*codefresh.Pipeline + if rf, ok := ret.Get(0).(func(map[string]string) []*codefresh.Pipeline); ok { + r0 = rf(qs) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]*codefresh.Pipeline) + } + } + + var r1 error + if rf, ok := ret.Get(1).(func(map[string]string) error); ok { + r1 = rf(qs) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// Run provides a mock function with given fields: _a0, _a1 +func (_m *IPipelineAPI) Run(_a0 string, _a1 *codefresh.RunOptions) (string, error) { + ret := _m.Called(_a0, _a1) + + var r0 string + if rf, ok := ret.Get(0).(func(string, *codefresh.RunOptions) string); ok { + r0 = rf(_a0, _a1) + } else { + r0 = ret.Get(0).(string) + } + + var r1 error + if rf, ok := ret.Get(1).(func(string, *codefresh.RunOptions) error); ok { + r1 = rf(_a0, _a1) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} diff --git a/mocks/IProgressAPI.go b/mocks/IProgressAPI.go new file mode 100644 index 0000000..1672ff4 --- /dev/null +++ b/mocks/IProgressAPI.go @@ -0,0 +1,36 @@ +// Code generated by mockery v1.1.1. DO NOT EDIT. + +package mocks + +import ( + codefresh "github.com/codefresh-io/go-sdk/pkg/codefresh" + mock "github.com/stretchr/testify/mock" +) + +// IProgressAPI is an autogenerated mock type for the IProgressAPI type +type IProgressAPI struct { + mock.Mock +} + +// Get provides a mock function with given fields: _a0 +func (_m *IProgressAPI) Get(_a0 string) (*codefresh.Progress, error) { + ret := _m.Called(_a0) + + var r0 *codefresh.Progress + if rf, ok := ret.Get(0).(func(string) *codefresh.Progress); ok { + r0 = rf(_a0) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*codefresh.Progress) + } + } + + var r1 error + if rf, ok := ret.Get(1).(func(string) error); ok { + r1 = rf(_a0) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} diff --git a/mocks/IRuntimeEnvironmentAPI.go b/mocks/IRuntimeEnvironmentAPI.go new file mode 100644 index 0000000..d962d77 --- /dev/null +++ b/mocks/IRuntimeEnvironmentAPI.go @@ -0,0 +1,161 @@ +// Code generated by mockery v1.1.1. DO NOT EDIT. + +package mocks + +import ( + codefresh "github.com/codefresh-io/go-sdk/pkg/codefresh" + mock "github.com/stretchr/testify/mock" +) + +// IRuntimeEnvironmentAPI is an autogenerated mock type for the IRuntimeEnvironmentAPI type +type IRuntimeEnvironmentAPI struct { + mock.Mock +} + +// Create provides a mock function with given fields: _a0 +func (_m *IRuntimeEnvironmentAPI) Create(_a0 *codefresh.CreateRuntimeOptions) (*codefresh.RuntimeEnvironment, error) { + ret := _m.Called(_a0) + + var r0 *codefresh.RuntimeEnvironment + if rf, ok := ret.Get(0).(func(*codefresh.CreateRuntimeOptions) *codefresh.RuntimeEnvironment); ok { + r0 = rf(_a0) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*codefresh.RuntimeEnvironment) + } + } + + var r1 error + if rf, ok := ret.Get(1).(func(*codefresh.CreateRuntimeOptions) error); ok { + r1 = rf(_a0) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// Default provides a mock function with given fields: _a0 +func (_m *IRuntimeEnvironmentAPI) Default(_a0 string) (bool, error) { + ret := _m.Called(_a0) + + var r0 bool + if rf, ok := ret.Get(0).(func(string) bool); ok { + r0 = rf(_a0) + } else { + r0 = ret.Get(0).(bool) + } + + var r1 error + if rf, ok := ret.Get(1).(func(string) error); ok { + r1 = rf(_a0) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// Delete provides a mock function with given fields: _a0 +func (_m *IRuntimeEnvironmentAPI) Delete(_a0 string) (bool, error) { + ret := _m.Called(_a0) + + var r0 bool + if rf, ok := ret.Get(0).(func(string) bool); ok { + r0 = rf(_a0) + } else { + r0 = ret.Get(0).(bool) + } + + var r1 error + if rf, ok := ret.Get(1).(func(string) error); ok { + r1 = rf(_a0) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// Get provides a mock function with given fields: _a0 +func (_m *IRuntimeEnvironmentAPI) Get(_a0 string) (*codefresh.RuntimeEnvironment, error) { + ret := _m.Called(_a0) + + var r0 *codefresh.RuntimeEnvironment + if rf, ok := ret.Get(0).(func(string) *codefresh.RuntimeEnvironment); ok { + r0 = rf(_a0) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*codefresh.RuntimeEnvironment) + } + } + + var r1 error + if rf, ok := ret.Get(1).(func(string) error); ok { + r1 = rf(_a0) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// List provides a mock function with given fields: +func (_m *IRuntimeEnvironmentAPI) List() ([]*codefresh.RuntimeEnvironment, error) { + ret := _m.Called() + + var r0 []*codefresh.RuntimeEnvironment + if rf, ok := ret.Get(0).(func() []*codefresh.RuntimeEnvironment); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]*codefresh.RuntimeEnvironment) + } + } + + var r1 error + if rf, ok := ret.Get(1).(func() error); ok { + r1 = rf() + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// SignCertificate provides a mock function with given fields: _a0 +func (_m *IRuntimeEnvironmentAPI) SignCertificate(_a0 *codefresh.SignCertificatesOptions) ([]byte, error) { + ret := _m.Called(_a0) + + var r0 []byte + if rf, ok := ret.Get(0).(func(*codefresh.SignCertificatesOptions) []byte); ok { + r0 = rf(_a0) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]byte) + } + } + + var r1 error + if rf, ok := ret.Get(1).(func(*codefresh.SignCertificatesOptions) error); ok { + r1 = rf(_a0) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// Validate provides a mock function with given fields: _a0 +func (_m *IRuntimeEnvironmentAPI) Validate(_a0 *codefresh.ValidateRuntimeOptions) error { + ret := _m.Called(_a0) + + var r0 error + if rf, ok := ret.Get(0).(func(*codefresh.ValidateRuntimeOptions) error); ok { + r0 = rf(_a0) + } else { + r0 = ret.Error(0) + } + + return r0 +} diff --git a/mocks/ITokenAPI.go b/mocks/ITokenAPI.go new file mode 100644 index 0000000..475a3f0 --- /dev/null +++ b/mocks/ITokenAPI.go @@ -0,0 +1,59 @@ +// Code generated by mockery v1.1.1. DO NOT EDIT. + +package mocks + +import ( + codefresh "github.com/codefresh-io/go-sdk/pkg/codefresh" + mock "github.com/stretchr/testify/mock" +) + +// ITokenAPI is an autogenerated mock type for the ITokenAPI type +type ITokenAPI struct { + mock.Mock +} + +// Create provides a mock function with given fields: name, subject +func (_m *ITokenAPI) Create(name string, subject string) (*codefresh.Token, error) { + ret := _m.Called(name, subject) + + var r0 *codefresh.Token + if rf, ok := ret.Get(0).(func(string, string) *codefresh.Token); ok { + r0 = rf(name, subject) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*codefresh.Token) + } + } + + var r1 error + if rf, ok := ret.Get(1).(func(string, string) error); ok { + r1 = rf(name, subject) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// List provides a mock function with given fields: +func (_m *ITokenAPI) List() ([]*codefresh.Token, error) { + ret := _m.Called() + + var r0 []*codefresh.Token + if rf, ok := ret.Get(0).(func() []*codefresh.Token); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]*codefresh.Token) + } + } + + var r1 error + if rf, ok := ret.Get(1).(func() error); ok { + r1 = rf() + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} diff --git a/mocks/IWorkflowAPI.go b/mocks/IWorkflowAPI.go new file mode 100644 index 0000000..c06f9c2 --- /dev/null +++ b/mocks/IWorkflowAPI.go @@ -0,0 +1,52 @@ +// Code generated by mockery v1.1.1. DO NOT EDIT. + +package mocks + +import ( + codefresh "github.com/codefresh-io/go-sdk/pkg/codefresh" + mock "github.com/stretchr/testify/mock" + + time "time" +) + +// IWorkflowAPI is an autogenerated mock type for the IWorkflowAPI type +type IWorkflowAPI struct { + mock.Mock +} + +// Get provides a mock function with given fields: _a0 +func (_m *IWorkflowAPI) Get(_a0 string) (*codefresh.Workflow, error) { + ret := _m.Called(_a0) + + var r0 *codefresh.Workflow + if rf, ok := ret.Get(0).(func(string) *codefresh.Workflow); ok { + r0 = rf(_a0) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*codefresh.Workflow) + } + } + + var r1 error + if rf, ok := ret.Get(1).(func(string) error); ok { + r1 = rf(_a0) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// WaitForStatus provides a mock function with given fields: _a0, _a1, _a2, _a3 +func (_m *IWorkflowAPI) WaitForStatus(_a0 string, _a1 string, _a2 time.Duration, _a3 time.Duration) error { + ret := _m.Called(_a0, _a1, _a2, _a3) + + var r0 error + if rf, ok := ret.Get(0).(func(string, string, time.Duration, time.Duration) error); ok { + r0 = rf(_a0, _a1, _a2, _a3) + } else { + r0 = ret.Error(0) + } + + return r0 +} diff --git a/mocks/UsersAPI.go b/mocks/UsersAPI.go new file mode 100644 index 0000000..700d911 --- /dev/null +++ b/mocks/UsersAPI.go @@ -0,0 +1,39 @@ +// Code generated by mockery v1.1.1. DO NOT EDIT. + +package mocks + +import ( + context "context" + + codefresh "github.com/codefresh-io/go-sdk/pkg/codefresh" + + mock "github.com/stretchr/testify/mock" +) + +// UsersAPI is an autogenerated mock type for the UsersAPI type +type UsersAPI struct { + mock.Mock +} + +// GetCurrent provides a mock function with given fields: ctx +func (_m *UsersAPI) GetCurrent(ctx context.Context) (*codefresh.User, error) { + ret := _m.Called(ctx) + + var r0 *codefresh.User + if rf, ok := ret.Get(0).(func(context.Context) *codefresh.User); ok { + r0 = rf(ctx) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*codefresh.User) + } + } + + var r1 error + if rf, ok := ret.Get(1).(func(context.Context) error); ok { + r1 = rf(ctx) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} From 20e128f7847d4737d310380ba90d7a9c5cc6ea97 Mon Sep 17 00:00:00 2001 From: Oren Gurfinkel Date: Wed, 7 Jul 2021 15:58:04 +0300 Subject: [PATCH 31/81] update mocks --- VERSION | 2 +- mocks/ArgoAPI.go | 129 --------------------- mocks/Codefresh.go | 189 ------------------------------- mocks/GitopsAPI.go | 115 ------------------- mocks/IArgoRuntimeAPI.go | 36 ------ mocks/IClusterAPI.go | 59 ---------- mocks/IContextAPI.go | 82 -------------- mocks/IPipelineAPI.go | 57 ---------- mocks/IProgressAPI.go | 36 ------ mocks/IRuntimeEnvironmentAPI.go | 161 -------------------------- mocks/ITokenAPI.go | 59 ---------- mocks/IWorkflowAPI.go | 52 --------- mocks/UsersAPI.go | 39 ------- pkg/codefresh/mocks/codefresh.go | 16 +++ 14 files changed, 17 insertions(+), 1015 deletions(-) delete mode 100644 mocks/ArgoAPI.go delete mode 100644 mocks/Codefresh.go delete mode 100644 mocks/GitopsAPI.go delete mode 100644 mocks/IArgoRuntimeAPI.go delete mode 100644 mocks/IClusterAPI.go delete mode 100644 mocks/IContextAPI.go delete mode 100644 mocks/IPipelineAPI.go delete mode 100644 mocks/IProgressAPI.go delete mode 100644 mocks/IRuntimeEnvironmentAPI.go delete mode 100644 mocks/ITokenAPI.go delete mode 100644 mocks/IWorkflowAPI.go delete mode 100644 mocks/UsersAPI.go diff --git a/VERSION b/VERSION index 12a91df..5564d9a 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.26.4 +0.26.5 diff --git a/mocks/ArgoAPI.go b/mocks/ArgoAPI.go deleted file mode 100644 index 356d2cc..0000000 --- a/mocks/ArgoAPI.go +++ /dev/null @@ -1,129 +0,0 @@ -// Code generated by mockery v1.1.1. DO NOT EDIT. - -package mocks - -import ( - codefresh "github.com/codefresh-io/go-sdk/pkg/codefresh" - mock "github.com/stretchr/testify/mock" -) - -// ArgoAPI is an autogenerated mock type for the ArgoAPI type -type ArgoAPI struct { - mock.Mock -} - -// CreateIntegration provides a mock function with given fields: integration -func (_m *ArgoAPI) CreateIntegration(integration codefresh.IntegrationPayloadData) error { - ret := _m.Called(integration) - - var r0 error - if rf, ok := ret.Get(0).(func(codefresh.IntegrationPayloadData) error); ok { - r0 = rf(integration) - } else { - r0 = ret.Error(0) - } - - return r0 -} - -// DeleteIntegrationByName provides a mock function with given fields: name -func (_m *ArgoAPI) DeleteIntegrationByName(name string) error { - ret := _m.Called(name) - - var r0 error - if rf, ok := ret.Get(0).(func(string) error); ok { - r0 = rf(name) - } else { - r0 = ret.Error(0) - } - - return r0 -} - -// GetIntegrationByName provides a mock function with given fields: name -func (_m *ArgoAPI) GetIntegrationByName(name string) (*codefresh.IntegrationPayload, error) { - ret := _m.Called(name) - - var r0 *codefresh.IntegrationPayload - if rf, ok := ret.Get(0).(func(string) *codefresh.IntegrationPayload); ok { - r0 = rf(name) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*codefresh.IntegrationPayload) - } - } - - var r1 error - if rf, ok := ret.Get(1).(func(string) error); ok { - r1 = rf(name) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// GetIntegrations provides a mock function with given fields: -func (_m *ArgoAPI) GetIntegrations() ([]*codefresh.IntegrationPayload, error) { - ret := _m.Called() - - var r0 []*codefresh.IntegrationPayload - if rf, ok := ret.Get(0).(func() []*codefresh.IntegrationPayload); ok { - r0 = rf() - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).([]*codefresh.IntegrationPayload) - } - } - - var r1 error - if rf, ok := ret.Get(1).(func() error); ok { - r1 = rf() - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// HeartBeat provides a mock function with given fields: error, version, integration -func (_m *ArgoAPI) HeartBeat(error string, version string, integration string) error { - ret := _m.Called(error, version, integration) - - var r0 error - if rf, ok := ret.Get(0).(func(string, string, string) error); ok { - r0 = rf(error, version, integration) - } else { - r0 = ret.Error(0) - } - - return r0 -} - -// SendResources provides a mock function with given fields: kind, items, amount, integration -func (_m *ArgoAPI) SendResources(kind string, items interface{}, amount int, integration string) error { - ret := _m.Called(kind, items, amount, integration) - - var r0 error - if rf, ok := ret.Get(0).(func(string, interface{}, int, string) error); ok { - r0 = rf(kind, items, amount, integration) - } else { - r0 = ret.Error(0) - } - - return r0 -} - -// UpdateIntegration provides a mock function with given fields: name, integration -func (_m *ArgoAPI) UpdateIntegration(name string, integration codefresh.IntegrationPayloadData) error { - ret := _m.Called(name, integration) - - var r0 error - if rf, ok := ret.Get(0).(func(string, codefresh.IntegrationPayloadData) error); ok { - r0 = rf(name, integration) - } else { - r0 = ret.Error(0) - } - - return r0 -} diff --git a/mocks/Codefresh.go b/mocks/Codefresh.go deleted file mode 100644 index 67721eb..0000000 --- a/mocks/Codefresh.go +++ /dev/null @@ -1,189 +0,0 @@ -// Code generated by mockery v1.1.1. DO NOT EDIT. - -package mocks - -import ( - codefresh "github.com/codefresh-io/go-sdk/pkg/codefresh" - mock "github.com/stretchr/testify/mock" -) - -// Codefresh is an autogenerated mock type for the Codefresh type -type Codefresh struct { - mock.Mock -} - -// Argo provides a mock function with given fields: -func (_m *Codefresh) Argo() codefresh.ArgoAPI { - ret := _m.Called() - - var r0 codefresh.ArgoAPI - if rf, ok := ret.Get(0).(func() codefresh.ArgoAPI); ok { - r0 = rf() - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(codefresh.ArgoAPI) - } - } - - return r0 -} - -// ArgoRuntime provides a mock function with given fields: -func (_m *Codefresh) ArgoRuntime() codefresh.IArgoRuntimeAPI { - ret := _m.Called() - - var r0 codefresh.IArgoRuntimeAPI - if rf, ok := ret.Get(0).(func() codefresh.IArgoRuntimeAPI); ok { - r0 = rf() - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(codefresh.IArgoRuntimeAPI) - } - } - - return r0 -} - -// Clusters provides a mock function with given fields: -func (_m *Codefresh) Clusters() codefresh.IClusterAPI { - ret := _m.Called() - - var r0 codefresh.IClusterAPI - if rf, ok := ret.Get(0).(func() codefresh.IClusterAPI); ok { - r0 = rf() - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(codefresh.IClusterAPI) - } - } - - return r0 -} - -// Contexts provides a mock function with given fields: -func (_m *Codefresh) Contexts() codefresh.IContextAPI { - ret := _m.Called() - - var r0 codefresh.IContextAPI - if rf, ok := ret.Get(0).(func() codefresh.IContextAPI); ok { - r0 = rf() - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(codefresh.IContextAPI) - } - } - - return r0 -} - -// Gitops provides a mock function with given fields: -func (_m *Codefresh) Gitops() codefresh.GitopsAPI { - ret := _m.Called() - - var r0 codefresh.GitopsAPI - if rf, ok := ret.Get(0).(func() codefresh.GitopsAPI); ok { - r0 = rf() - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(codefresh.GitopsAPI) - } - } - - return r0 -} - -// Pipelines provides a mock function with given fields: -func (_m *Codefresh) Pipelines() codefresh.IPipelineAPI { - ret := _m.Called() - - var r0 codefresh.IPipelineAPI - if rf, ok := ret.Get(0).(func() codefresh.IPipelineAPI); ok { - r0 = rf() - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(codefresh.IPipelineAPI) - } - } - - return r0 -} - -// Progresses provides a mock function with given fields: -func (_m *Codefresh) Progresses() codefresh.IProgressAPI { - ret := _m.Called() - - var r0 codefresh.IProgressAPI - if rf, ok := ret.Get(0).(func() codefresh.IProgressAPI); ok { - r0 = rf() - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(codefresh.IProgressAPI) - } - } - - return r0 -} - -// RuntimeEnvironments provides a mock function with given fields: -func (_m *Codefresh) RuntimeEnvironments() codefresh.IRuntimeEnvironmentAPI { - ret := _m.Called() - - var r0 codefresh.IRuntimeEnvironmentAPI - if rf, ok := ret.Get(0).(func() codefresh.IRuntimeEnvironmentAPI); ok { - r0 = rf() - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(codefresh.IRuntimeEnvironmentAPI) - } - } - - return r0 -} - -// Tokens provides a mock function with given fields: -func (_m *Codefresh) Tokens() codefresh.ITokenAPI { - ret := _m.Called() - - var r0 codefresh.ITokenAPI - if rf, ok := ret.Get(0).(func() codefresh.ITokenAPI); ok { - r0 = rf() - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(codefresh.ITokenAPI) - } - } - - return r0 -} - -// Users provides a mock function with given fields: -func (_m *Codefresh) Users() codefresh.UsersAPI { - ret := _m.Called() - - var r0 codefresh.UsersAPI - if rf, ok := ret.Get(0).(func() codefresh.UsersAPI); ok { - r0 = rf() - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(codefresh.UsersAPI) - } - } - - return r0 -} - -// Workflows provides a mock function with given fields: -func (_m *Codefresh) Workflows() codefresh.IWorkflowAPI { - ret := _m.Called() - - var r0 codefresh.IWorkflowAPI - if rf, ok := ret.Get(0).(func() codefresh.IWorkflowAPI); ok { - r0 = rf() - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(codefresh.IWorkflowAPI) - } - } - - return r0 -} diff --git a/mocks/GitopsAPI.go b/mocks/GitopsAPI.go deleted file mode 100644 index 8fe7be2..0000000 --- a/mocks/GitopsAPI.go +++ /dev/null @@ -1,115 +0,0 @@ -// Code generated by mockery v1.1.1. DO NOT EDIT. - -package mocks - -import ( - codefresh "github.com/codefresh-io/go-sdk/pkg/codefresh" - mock "github.com/stretchr/testify/mock" -) - -// GitopsAPI is an autogenerated mock type for the GitopsAPI type -type GitopsAPI struct { - mock.Mock -} - -// CreateEnvironment provides a mock function with given fields: name, project, application, integration -func (_m *GitopsAPI) CreateEnvironment(name string, project string, application string, integration string) error { - ret := _m.Called(name, project, application, integration) - - var r0 error - if rf, ok := ret.Get(0).(func(string, string, string, string) error); ok { - r0 = rf(name, project, application, integration) - } else { - r0 = ret.Error(0) - } - - return r0 -} - -// DeleteEnvironment provides a mock function with given fields: name -func (_m *GitopsAPI) DeleteEnvironment(name string) error { - ret := _m.Called(name) - - var r0 error - if rf, ok := ret.Get(0).(func(string) error); ok { - r0 = rf(name) - } else { - r0 = ret.Error(0) - } - - return r0 -} - -// GetEnvironments provides a mock function with given fields: -func (_m *GitopsAPI) GetEnvironments() ([]codefresh.CFEnvironment, error) { - ret := _m.Called() - - var r0 []codefresh.CFEnvironment - if rf, ok := ret.Get(0).(func() []codefresh.CFEnvironment); ok { - r0 = rf() - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).([]codefresh.CFEnvironment) - } - } - - var r1 error - if rf, ok := ret.Get(1).(func() error); ok { - r1 = rf() - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// SendApplicationResources provides a mock function with given fields: resources -func (_m *GitopsAPI) SendApplicationResources(resources *codefresh.ApplicationResources) error { - ret := _m.Called(resources) - - var r0 error - if rf, ok := ret.Get(0).(func(*codefresh.ApplicationResources) error); ok { - r0 = rf(resources) - } else { - r0 = ret.Error(0) - } - - return r0 -} - -// SendEnvironment provides a mock function with given fields: environment -func (_m *GitopsAPI) SendEnvironment(environment codefresh.Environment) (map[string]interface{}, error) { - ret := _m.Called(environment) - - var r0 map[string]interface{} - if rf, ok := ret.Get(0).(func(codefresh.Environment) map[string]interface{}); ok { - r0 = rf(environment) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(map[string]interface{}) - } - } - - var r1 error - if rf, ok := ret.Get(1).(func(codefresh.Environment) error); ok { - r1 = rf(environment) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// SendEvent provides a mock function with given fields: name, props -func (_m *GitopsAPI) SendEvent(name string, props map[string]string) error { - ret := _m.Called(name, props) - - var r0 error - if rf, ok := ret.Get(0).(func(string, map[string]string) error); ok { - r0 = rf(name, props) - } else { - r0 = ret.Error(0) - } - - return r0 -} diff --git a/mocks/IArgoRuntimeAPI.go b/mocks/IArgoRuntimeAPI.go deleted file mode 100644 index f66f112..0000000 --- a/mocks/IArgoRuntimeAPI.go +++ /dev/null @@ -1,36 +0,0 @@ -// Code generated by mockery v1.1.1. DO NOT EDIT. - -package mocks - -import ( - model "github.com/codefresh-io/argo-platform/libs/ql/graph/model" - mock "github.com/stretchr/testify/mock" -) - -// IArgoRuntimeAPI is an autogenerated mock type for the IArgoRuntimeAPI type -type IArgoRuntimeAPI struct { - mock.Mock -} - -// List provides a mock function with given fields: -func (_m *IArgoRuntimeAPI) List() ([]model.Runtime, error) { - ret := _m.Called() - - var r0 []model.Runtime - if rf, ok := ret.Get(0).(func() []model.Runtime); ok { - r0 = rf() - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).([]model.Runtime) - } - } - - var r1 error - if rf, ok := ret.Get(1).(func() error); ok { - r1 = rf() - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} diff --git a/mocks/IClusterAPI.go b/mocks/IClusterAPI.go deleted file mode 100644 index c4d93ae..0000000 --- a/mocks/IClusterAPI.go +++ /dev/null @@ -1,59 +0,0 @@ -// Code generated by mockery v1.1.1. DO NOT EDIT. - -package mocks - -import ( - codefresh "github.com/codefresh-io/go-sdk/pkg/codefresh" - mock "github.com/stretchr/testify/mock" -) - -// IClusterAPI is an autogenerated mock type for the IClusterAPI type -type IClusterAPI struct { - mock.Mock -} - -// GetAccountClusters provides a mock function with given fields: -func (_m *IClusterAPI) GetAccountClusters() ([]*codefresh.ClusterMinified, error) { - ret := _m.Called() - - var r0 []*codefresh.ClusterMinified - if rf, ok := ret.Get(0).(func() []*codefresh.ClusterMinified); ok { - r0 = rf() - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).([]*codefresh.ClusterMinified) - } - } - - var r1 error - if rf, ok := ret.Get(1).(func() error); ok { - r1 = rf() - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// GetClusterCredentialsByAccountId provides a mock function with given fields: selector -func (_m *IClusterAPI) GetClusterCredentialsByAccountId(selector string) (*codefresh.Cluster, error) { - ret := _m.Called(selector) - - var r0 *codefresh.Cluster - if rf, ok := ret.Get(0).(func(string) *codefresh.Cluster); ok { - r0 = rf(selector) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*codefresh.Cluster) - } - } - - var r1 error - if rf, ok := ret.Get(1).(func(string) error); ok { - r1 = rf(selector) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} diff --git a/mocks/IContextAPI.go b/mocks/IContextAPI.go deleted file mode 100644 index 7aa15c1..0000000 --- a/mocks/IContextAPI.go +++ /dev/null @@ -1,82 +0,0 @@ -// Code generated by mockery v1.1.1. DO NOT EDIT. - -package mocks - -import ( - codefresh "github.com/codefresh-io/go-sdk/pkg/codefresh" - mock "github.com/stretchr/testify/mock" -) - -// IContextAPI is an autogenerated mock type for the IContextAPI type -type IContextAPI struct { - mock.Mock -} - -// GetDefaultGitContext provides a mock function with given fields: -func (_m *IContextAPI) GetDefaultGitContext() (error, *codefresh.ContextPayload) { - ret := _m.Called() - - var r0 error - if rf, ok := ret.Get(0).(func() error); ok { - r0 = rf() - } else { - r0 = ret.Error(0) - } - - var r1 *codefresh.ContextPayload - if rf, ok := ret.Get(1).(func() *codefresh.ContextPayload); ok { - r1 = rf() - } else { - if ret.Get(1) != nil { - r1 = ret.Get(1).(*codefresh.ContextPayload) - } - } - - return r0, r1 -} - -// GetGitContextByName provides a mock function with given fields: name -func (_m *IContextAPI) GetGitContextByName(name string) (error, *codefresh.ContextPayload) { - ret := _m.Called(name) - - var r0 error - if rf, ok := ret.Get(0).(func(string) error); ok { - r0 = rf(name) - } else { - r0 = ret.Error(0) - } - - var r1 *codefresh.ContextPayload - if rf, ok := ret.Get(1).(func(string) *codefresh.ContextPayload); ok { - r1 = rf(name) - } else { - if ret.Get(1) != nil { - r1 = ret.Get(1).(*codefresh.ContextPayload) - } - } - - return r0, r1 -} - -// GetGitContexts provides a mock function with given fields: -func (_m *IContextAPI) GetGitContexts() (error, *[]codefresh.ContextPayload) { - ret := _m.Called() - - var r0 error - if rf, ok := ret.Get(0).(func() error); ok { - r0 = rf() - } else { - r0 = ret.Error(0) - } - - var r1 *[]codefresh.ContextPayload - if rf, ok := ret.Get(1).(func() *[]codefresh.ContextPayload); ok { - r1 = rf() - } else { - if ret.Get(1) != nil { - r1 = ret.Get(1).(*[]codefresh.ContextPayload) - } - } - - return r0, r1 -} diff --git a/mocks/IPipelineAPI.go b/mocks/IPipelineAPI.go deleted file mode 100644 index 05ae012..0000000 --- a/mocks/IPipelineAPI.go +++ /dev/null @@ -1,57 +0,0 @@ -// Code generated by mockery v1.1.1. DO NOT EDIT. - -package mocks - -import ( - codefresh "github.com/codefresh-io/go-sdk/pkg/codefresh" - mock "github.com/stretchr/testify/mock" -) - -// IPipelineAPI is an autogenerated mock type for the IPipelineAPI type -type IPipelineAPI struct { - mock.Mock -} - -// List provides a mock function with given fields: qs -func (_m *IPipelineAPI) List(qs map[string]string) ([]*codefresh.Pipeline, error) { - ret := _m.Called(qs) - - var r0 []*codefresh.Pipeline - if rf, ok := ret.Get(0).(func(map[string]string) []*codefresh.Pipeline); ok { - r0 = rf(qs) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).([]*codefresh.Pipeline) - } - } - - var r1 error - if rf, ok := ret.Get(1).(func(map[string]string) error); ok { - r1 = rf(qs) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// Run provides a mock function with given fields: _a0, _a1 -func (_m *IPipelineAPI) Run(_a0 string, _a1 *codefresh.RunOptions) (string, error) { - ret := _m.Called(_a0, _a1) - - var r0 string - if rf, ok := ret.Get(0).(func(string, *codefresh.RunOptions) string); ok { - r0 = rf(_a0, _a1) - } else { - r0 = ret.Get(0).(string) - } - - var r1 error - if rf, ok := ret.Get(1).(func(string, *codefresh.RunOptions) error); ok { - r1 = rf(_a0, _a1) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} diff --git a/mocks/IProgressAPI.go b/mocks/IProgressAPI.go deleted file mode 100644 index 1672ff4..0000000 --- a/mocks/IProgressAPI.go +++ /dev/null @@ -1,36 +0,0 @@ -// Code generated by mockery v1.1.1. DO NOT EDIT. - -package mocks - -import ( - codefresh "github.com/codefresh-io/go-sdk/pkg/codefresh" - mock "github.com/stretchr/testify/mock" -) - -// IProgressAPI is an autogenerated mock type for the IProgressAPI type -type IProgressAPI struct { - mock.Mock -} - -// Get provides a mock function with given fields: _a0 -func (_m *IProgressAPI) Get(_a0 string) (*codefresh.Progress, error) { - ret := _m.Called(_a0) - - var r0 *codefresh.Progress - if rf, ok := ret.Get(0).(func(string) *codefresh.Progress); ok { - r0 = rf(_a0) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*codefresh.Progress) - } - } - - var r1 error - if rf, ok := ret.Get(1).(func(string) error); ok { - r1 = rf(_a0) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} diff --git a/mocks/IRuntimeEnvironmentAPI.go b/mocks/IRuntimeEnvironmentAPI.go deleted file mode 100644 index d962d77..0000000 --- a/mocks/IRuntimeEnvironmentAPI.go +++ /dev/null @@ -1,161 +0,0 @@ -// Code generated by mockery v1.1.1. DO NOT EDIT. - -package mocks - -import ( - codefresh "github.com/codefresh-io/go-sdk/pkg/codefresh" - mock "github.com/stretchr/testify/mock" -) - -// IRuntimeEnvironmentAPI is an autogenerated mock type for the IRuntimeEnvironmentAPI type -type IRuntimeEnvironmentAPI struct { - mock.Mock -} - -// Create provides a mock function with given fields: _a0 -func (_m *IRuntimeEnvironmentAPI) Create(_a0 *codefresh.CreateRuntimeOptions) (*codefresh.RuntimeEnvironment, error) { - ret := _m.Called(_a0) - - var r0 *codefresh.RuntimeEnvironment - if rf, ok := ret.Get(0).(func(*codefresh.CreateRuntimeOptions) *codefresh.RuntimeEnvironment); ok { - r0 = rf(_a0) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*codefresh.RuntimeEnvironment) - } - } - - var r1 error - if rf, ok := ret.Get(1).(func(*codefresh.CreateRuntimeOptions) error); ok { - r1 = rf(_a0) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// Default provides a mock function with given fields: _a0 -func (_m *IRuntimeEnvironmentAPI) Default(_a0 string) (bool, error) { - ret := _m.Called(_a0) - - var r0 bool - if rf, ok := ret.Get(0).(func(string) bool); ok { - r0 = rf(_a0) - } else { - r0 = ret.Get(0).(bool) - } - - var r1 error - if rf, ok := ret.Get(1).(func(string) error); ok { - r1 = rf(_a0) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// Delete provides a mock function with given fields: _a0 -func (_m *IRuntimeEnvironmentAPI) Delete(_a0 string) (bool, error) { - ret := _m.Called(_a0) - - var r0 bool - if rf, ok := ret.Get(0).(func(string) bool); ok { - r0 = rf(_a0) - } else { - r0 = ret.Get(0).(bool) - } - - var r1 error - if rf, ok := ret.Get(1).(func(string) error); ok { - r1 = rf(_a0) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// Get provides a mock function with given fields: _a0 -func (_m *IRuntimeEnvironmentAPI) Get(_a0 string) (*codefresh.RuntimeEnvironment, error) { - ret := _m.Called(_a0) - - var r0 *codefresh.RuntimeEnvironment - if rf, ok := ret.Get(0).(func(string) *codefresh.RuntimeEnvironment); ok { - r0 = rf(_a0) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*codefresh.RuntimeEnvironment) - } - } - - var r1 error - if rf, ok := ret.Get(1).(func(string) error); ok { - r1 = rf(_a0) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// List provides a mock function with given fields: -func (_m *IRuntimeEnvironmentAPI) List() ([]*codefresh.RuntimeEnvironment, error) { - ret := _m.Called() - - var r0 []*codefresh.RuntimeEnvironment - if rf, ok := ret.Get(0).(func() []*codefresh.RuntimeEnvironment); ok { - r0 = rf() - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).([]*codefresh.RuntimeEnvironment) - } - } - - var r1 error - if rf, ok := ret.Get(1).(func() error); ok { - r1 = rf() - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// SignCertificate provides a mock function with given fields: _a0 -func (_m *IRuntimeEnvironmentAPI) SignCertificate(_a0 *codefresh.SignCertificatesOptions) ([]byte, error) { - ret := _m.Called(_a0) - - var r0 []byte - if rf, ok := ret.Get(0).(func(*codefresh.SignCertificatesOptions) []byte); ok { - r0 = rf(_a0) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).([]byte) - } - } - - var r1 error - if rf, ok := ret.Get(1).(func(*codefresh.SignCertificatesOptions) error); ok { - r1 = rf(_a0) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// Validate provides a mock function with given fields: _a0 -func (_m *IRuntimeEnvironmentAPI) Validate(_a0 *codefresh.ValidateRuntimeOptions) error { - ret := _m.Called(_a0) - - var r0 error - if rf, ok := ret.Get(0).(func(*codefresh.ValidateRuntimeOptions) error); ok { - r0 = rf(_a0) - } else { - r0 = ret.Error(0) - } - - return r0 -} diff --git a/mocks/ITokenAPI.go b/mocks/ITokenAPI.go deleted file mode 100644 index 475a3f0..0000000 --- a/mocks/ITokenAPI.go +++ /dev/null @@ -1,59 +0,0 @@ -// Code generated by mockery v1.1.1. DO NOT EDIT. - -package mocks - -import ( - codefresh "github.com/codefresh-io/go-sdk/pkg/codefresh" - mock "github.com/stretchr/testify/mock" -) - -// ITokenAPI is an autogenerated mock type for the ITokenAPI type -type ITokenAPI struct { - mock.Mock -} - -// Create provides a mock function with given fields: name, subject -func (_m *ITokenAPI) Create(name string, subject string) (*codefresh.Token, error) { - ret := _m.Called(name, subject) - - var r0 *codefresh.Token - if rf, ok := ret.Get(0).(func(string, string) *codefresh.Token); ok { - r0 = rf(name, subject) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*codefresh.Token) - } - } - - var r1 error - if rf, ok := ret.Get(1).(func(string, string) error); ok { - r1 = rf(name, subject) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// List provides a mock function with given fields: -func (_m *ITokenAPI) List() ([]*codefresh.Token, error) { - ret := _m.Called() - - var r0 []*codefresh.Token - if rf, ok := ret.Get(0).(func() []*codefresh.Token); ok { - r0 = rf() - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).([]*codefresh.Token) - } - } - - var r1 error - if rf, ok := ret.Get(1).(func() error); ok { - r1 = rf() - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} diff --git a/mocks/IWorkflowAPI.go b/mocks/IWorkflowAPI.go deleted file mode 100644 index c06f9c2..0000000 --- a/mocks/IWorkflowAPI.go +++ /dev/null @@ -1,52 +0,0 @@ -// Code generated by mockery v1.1.1. DO NOT EDIT. - -package mocks - -import ( - codefresh "github.com/codefresh-io/go-sdk/pkg/codefresh" - mock "github.com/stretchr/testify/mock" - - time "time" -) - -// IWorkflowAPI is an autogenerated mock type for the IWorkflowAPI type -type IWorkflowAPI struct { - mock.Mock -} - -// Get provides a mock function with given fields: _a0 -func (_m *IWorkflowAPI) Get(_a0 string) (*codefresh.Workflow, error) { - ret := _m.Called(_a0) - - var r0 *codefresh.Workflow - if rf, ok := ret.Get(0).(func(string) *codefresh.Workflow); ok { - r0 = rf(_a0) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*codefresh.Workflow) - } - } - - var r1 error - if rf, ok := ret.Get(1).(func(string) error); ok { - r1 = rf(_a0) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// WaitForStatus provides a mock function with given fields: _a0, _a1, _a2, _a3 -func (_m *IWorkflowAPI) WaitForStatus(_a0 string, _a1 string, _a2 time.Duration, _a3 time.Duration) error { - ret := _m.Called(_a0, _a1, _a2, _a3) - - var r0 error - if rf, ok := ret.Get(0).(func(string, string, time.Duration, time.Duration) error); ok { - r0 = rf(_a0, _a1, _a2, _a3) - } else { - r0 = ret.Error(0) - } - - return r0 -} diff --git a/mocks/UsersAPI.go b/mocks/UsersAPI.go deleted file mode 100644 index 700d911..0000000 --- a/mocks/UsersAPI.go +++ /dev/null @@ -1,39 +0,0 @@ -// Code generated by mockery v1.1.1. DO NOT EDIT. - -package mocks - -import ( - context "context" - - codefresh "github.com/codefresh-io/go-sdk/pkg/codefresh" - - mock "github.com/stretchr/testify/mock" -) - -// UsersAPI is an autogenerated mock type for the UsersAPI type -type UsersAPI struct { - mock.Mock -} - -// GetCurrent provides a mock function with given fields: ctx -func (_m *UsersAPI) GetCurrent(ctx context.Context) (*codefresh.User, error) { - ret := _m.Called(ctx) - - var r0 *codefresh.User - if rf, ok := ret.Get(0).(func(context.Context) *codefresh.User); ok { - r0 = rf(ctx) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*codefresh.User) - } - } - - var r1 error - if rf, ok := ret.Get(1).(func(context.Context) error); ok { - r1 = rf(ctx) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} diff --git a/pkg/codefresh/mocks/codefresh.go b/pkg/codefresh/mocks/codefresh.go index d924579..67721eb 100644 --- a/pkg/codefresh/mocks/codefresh.go +++ b/pkg/codefresh/mocks/codefresh.go @@ -28,6 +28,22 @@ func (_m *Codefresh) Argo() codefresh.ArgoAPI { return r0 } +// ArgoRuntime provides a mock function with given fields: +func (_m *Codefresh) ArgoRuntime() codefresh.IArgoRuntimeAPI { + ret := _m.Called() + + var r0 codefresh.IArgoRuntimeAPI + if rf, ok := ret.Get(0).(func() codefresh.IArgoRuntimeAPI); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(codefresh.IArgoRuntimeAPI) + } + } + + return r0 +} + // Clusters provides a mock function with given fields: func (_m *Codefresh) Clusters() codefresh.IClusterAPI { ret := _m.Called() From 78b29628b8e1149a265a1c6be03c2d54bc29a90c Mon Sep 17 00:00:00 2001 From: olegz-codefresh Date: Tue, 13 Jul 2021 17:41:08 +0300 Subject: [PATCH 32/81] Add server and ns for env struct --- VERSION | 2 +- pkg/codefresh/gitops.go | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/VERSION b/VERSION index 5564d9a..5d700c0 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.26.5 +0.26.6 diff --git a/pkg/codefresh/gitops.go b/pkg/codefresh/gitops.go index 61c476d..2024b17 100644 --- a/pkg/codefresh/gitops.go +++ b/pkg/codefresh/gitops.go @@ -101,6 +101,8 @@ type ( SyncPolicy SyncPolicy `json:"syncPolicy"` Date string `json:"date"` ParentApp string `json:"parentApp"` + Namespace string `json:"namespace"` + Server string `json:"server"` } EnvironmentActivity struct { From 4f23d7803bd8bbf9f9cb10fcc5bdc13a7e1bd689 Mon Sep 17 00:00:00 2001 From: pashavictorovich Date: Wed, 14 Jul 2021 14:21:07 +0300 Subject: [PATCH 33/81] bump --- VERSION | 2 +- pkg/codefresh/gitops.go | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/VERSION b/VERSION index 30f6cf8..1b58cc1 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.26.1 +0.27.0 diff --git a/pkg/codefresh/gitops.go b/pkg/codefresh/gitops.go index ff2ac8e..864c95b 100644 --- a/pkg/codefresh/gitops.go +++ b/pkg/codefresh/gitops.go @@ -98,6 +98,7 @@ type ( SyncPolicy SyncPolicy `json:"syncPolicy"` Date string `json:"date"` ParentApp string `json:"parentApp"` + Context *string `json:"context"` } EnvironmentActivity struct { @@ -113,6 +114,7 @@ type ( HistoryId int64 `json:"historyId"` Revision string `json:"revision, omitempty"` Resources interface{} `json:"resources"` + Context *string `json:"context"` } ) From 3dac085948fa17dbf0df884e4a863b7f0db8acae Mon Sep 17 00:00:00 2001 From: pashavictorovich Date: Wed, 14 Jul 2021 14:26:19 +0300 Subject: [PATCH 34/81] add params --- VERSION | 2 +- pkg/codefresh/gitops.go | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/VERSION b/VERSION index 5d700c0..1b58cc1 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.26.6 +0.27.0 diff --git a/pkg/codefresh/gitops.go b/pkg/codefresh/gitops.go index 2024b17..f343d3e 100644 --- a/pkg/codefresh/gitops.go +++ b/pkg/codefresh/gitops.go @@ -103,6 +103,7 @@ type ( ParentApp string `json:"parentApp"` Namespace string `json:"namespace"` Server string `json:"server"` + Context *string `json:"context"` } EnvironmentActivity struct { @@ -118,6 +119,7 @@ type ( HistoryId int64 `json:"historyId"` Revision string `json:"revision, omitempty"` Resources interface{} `json:"resources"` + Context *string `json:"context"` } ) From 00a04a9135e13275a0e7896d30ec2d8aa3072b4e Mon Sep 17 00:00:00 2001 From: elad-codefresh Date: Tue, 27 Jul 2021 11:48:05 +0300 Subject: [PATCH 35/81] new runtimes query --- go.mod | 10 ++--- go.sum | 70 +++++++++++++++++++++++++++++++---- pkg/codefresh/argo_runtime.go | 16 +++++--- pkg/codefresh/codefresh.go | 3 +- 4 files changed, 79 insertions(+), 20 deletions(-) diff --git a/go.mod b/go.mod index fcceda6..fbe83d8 100644 --- a/go.mod +++ b/go.mod @@ -1,8 +1,7 @@ module github.com/codefresh-io/go-sdk require ( - github.com/BurntSushi/toml v0.3.1 // indirect - github.com/codefresh-io/argo-platform v1.13.0 + github.com/codefresh-io/argo-platform v1.35.0 github.com/dustin/go-humanize v1.0.0 github.com/google/go-querystring v1.1.0 github.com/inconshreveable/mousetrap v1.0.0 // indirect @@ -13,9 +12,8 @@ require ( github.com/spf13/cobra v0.0.3 github.com/spf13/viper v1.3.1 github.com/stretchr/objx v0.3.0 // indirect - github.com/stretchr/testify v1.3.0 - golang.org/x/sys v0.0.0-20181228144115-9a3f9b0469bb // indirect - gopkg.in/yaml.v2 v2.2.2 + github.com/stretchr/testify v1.4.0 + gopkg.in/yaml.v2 v2.2.4 ) -go 1.13 +go 1.14 diff --git a/go.sum b/go.sum index 23e05ed..9551493 100644 --- a/go.sum +++ b/go.sum @@ -1,40 +1,73 @@ +github.com/99designs/gqlgen v0.13.0/go.mod h1:NV130r6f4tpRWuAI+zsrSdooO/eWUv+Gyyoi3rEfXIk= github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= +github.com/agnivade/levenshtein v1.0.1/go.mod h1:CURSv5d9Uaml+FovSIICkLbAUZ9S4RqaHDIsdSBg7lM= +github.com/agnivade/levenshtein v1.0.3/go.mod h1:4SFRZbbXWLF4MU1T9Qg0pGgH3Pjs+t6ie5efyrwRJXs= +github.com/andreyvit/diff v0.0.0-20170406064948-c7f18ee00883/go.mod h1:rCTlJbsFo29Kk6CurOXKm700vrz8f0KW0JNfpkRJY/8= +github.com/arbovm/levenshtein v0.0.0-20160628152529-48b4e1c0c4d0/go.mod h1:t2tdKJDJF9BV14lnkjHmOQgcvEKgtqs5a1N3LNdJhGE= github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8= -github.com/codefresh-io/argo-platform v1.13.0 h1:eWAWkxtO0nGZuekrQJsfFT5KfBMdWby0cOucy4yTExs= -github.com/codefresh-io/argo-platform v1.13.0/go.mod h1:u/eLWAySJ1nRzNWnB5baeyIc5vqINghwYJvydU+EC3c= +github.com/codefresh-io/argo-platform v1.35.0 h1:9rboz3DYnfdH9UdQhDQ6dkVLJWhnR5eHqH7mM+kyQcc= +github.com/codefresh-io/argo-platform v1.35.0/go.mod h1:rNms+r6lqY5QPEkHROmh5jXKA8VrasuN6CfleuX2xFY= github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE= github.com/coreos/go-etcd v2.0.0+incompatible/go.mod h1:Jez6KQU2B/sWsbdaef3ED8NzMklzPG4d5KIOhIy30Tk= github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= +github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/dgryski/trifles v0.0.0-20190318185328-a8d75aae118c/go.mod h1:if7Fbed8SFyPtHLHbg49SI7NAdJiC5WIA09pe59rfAA= github.com/dustin/go-humanize v1.0.0 h1:VSnTsYCnlFHaM2/igO1h6X3HA71jcobQuxemgkq4zYo= github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= github.com/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV9I= github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= +github.com/go-chi/chi v3.3.2+incompatible/go.mod h1:eB3wogJHnLi3x/kFX2A+IbTBlXxmMeXJVKy9tTv1XzQ= +github.com/gogo/protobuf v1.0.0/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= github.com/google/go-cmp v0.5.2 h1:X2ev0eStA3AbceY54o37/0PQ/UWqKEiiO2dKL5OPaFM= github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-querystring v1.1.0 h1:AnCroh3fv4ZBgVIf1Iwtovgjaw/GiKJo8M8yD/fhyJ8= github.com/google/go-querystring v1.1.0/go.mod h1:Kcdr2DB4koayq7X8pmAG4sNG59So17icRSOU623lUBU= +github.com/gorilla/context v0.0.0-20160226214623-1ea25387ff6f/go.mod h1:kBGZzfjB9CEq2AlWe17Uuf7NDRt0dE0s8S51q0aT7Yg= +github.com/gorilla/mux v1.6.1/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs= +github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= +github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4= github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ= github.com/inconshreveable/mousetrap v1.0.0 h1:Z8tu5sraLXCXIcARxBp/8cbvlwVa7Z1NHg9XEKhtSvM= github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= +github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI= +github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= +github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= +github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= +github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= +github.com/logrusorgru/aurora v0.0.0-20200102142835-e9ef32dff381/go.mod h1:7rIyQOR62GCctdiQpZ/zOJlFyk6y+94wXzv6RNZgaR4= github.com/magiconair/properties v1.8.0 h1:LLgXmsheXeRoUOBOjtwPQCWIYqM/LU1ayDtDePerRcY= github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ= +github.com/matryer/moq v0.0.0-20200106131100-75d0ddfc0007/go.mod h1:9ELz6aaclSIGnZBoaSLZ3NAl1VTufbOrXBPvtcy6WiQ= +github.com/mattn/go-colorable v0.1.4/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE= +github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= +github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= github.com/mattn/go-runewidth v0.0.4 h1:2BvfKmzob6Bmd4YsL0zygOqfdFnK7GR4QL06Do4/p7Y= github.com/mattn/go-runewidth v0.0.4/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU= github.com/mitchellh/go-homedir v1.0.0 h1:vKb8ShqSby24Yrqr/yDYkuFz8d0WUjys40rvnGC8aR0= github.com/mitchellh/go-homedir v1.0.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= +github.com/mitchellh/mapstructure v0.0.0-20180203102830-a4e142e9c047/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= github.com/mitchellh/mapstructure v1.1.2 h1:fmNYVwqnSfB9mZU6OS2O6GsXM+wcskZDuKQzvN1EDeE= github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= github.com/olekukonko/tablewriter v0.0.1 h1:b3iUnf1v+ppJiOfNX4yxxqfWKMQPZR5yoh8urCTFX88= github.com/olekukonko/tablewriter v0.0.1/go.mod h1:vsDQFd/mU46D+Z4whnwzcISnGGzXWMclvtLoiIKAKIo= +github.com/opentracing/basictracer-go v1.0.0/go.mod h1:QfBfYuafItcjQuMwinw9GhYKwFXS9KnPs5lxoYwgW74= +github.com/opentracing/opentracing-go v1.0.2/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o= github.com/pelletier/go-toml v1.2.0 h1:T5zMGML61Wp+FlcbWjRDT7yAxhJNAiPPLOFECq181zc= github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic= +github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/rs/cors v1.6.0/go.mod h1:gFx+x8UowdsKA9AchylcLynDq+nNFfI8FkUZdN/jGCU= +github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= +github.com/sergi/go-diff v1.1.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM= +github.com/shurcooL/httpfs v0.0.0-20171119174359-809beceb2371/go.mod h1:ZY1cvUeJuFPAdZ/B6v7RHavJWZn2YPVFQ1OSXhCGOkg= +github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc= +github.com/shurcooL/vfsgen v0.0.0-20180121065927-ffb13db8def0/go.mod h1:TrYk7fJVaAttu97ZZKrO9UbRa8izdowaMIZcxYMbVaw= github.com/spf13/afero v1.1.2/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ= github.com/spf13/afero v1.2.0 h1:O9FblXGxoTc51M+cqr74Bm2Tmt4PvkA5iu/j8HrkNuY= github.com/spf13/afero v1.2.0/go.mod h1:9ZxEEn6pIJ8Rxe320qSDBk6AsU0r9pR7Q4OcevTdifk= @@ -51,20 +84,43 @@ github.com/spf13/viper v1.3.1/go.mod h1:ZiWeW+zYFKm7srdB9IoDzzZXaJaI5eL9QjNiN/DM github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.3.0 h1:NGXK3lHquSN08v5vWalVI/L8XU9hdzE/G6xsrze47As= github.com/stretchr/objx v0.3.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE= +github.com/stretchr/testify v1.2.1/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= -github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0Q= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= +github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk= +github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= github.com/ugorji/go/codec v0.0.0-20181204163529-d75b2dcb6bc8/go.mod h1:VFNgLljTbGfSG7qAOspJ7OScBnGdDN/yBr0sguwnwf0= +github.com/urfave/cli/v2 v2.1.1/go.mod h1:SE9GqnLQmjVa0iPEY0f1w3ygNIYcIJ0OKPMoW2caLfQ= +github.com/vektah/dataloaden v0.2.1-0.20190515034641-a19b9a6e7c9e/go.mod h1:/HUdMve7rvxZma+2ZELQeNh88+003LL7Pf/CZ089j8U= +github.com/vektah/gqlparser/v2 v2.1.0/go.mod h1:SyUiHgLATUR8BiYURfTirrTcGpcE+4XkV2se04Px1Ms= github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q= golang.org/x/crypto v0.0.0-20181203042331-505ab145d0a9/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= +golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= +golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20181205085412-a5c9d58dba9a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20181228144115-9a3f9b0469bb h1:pf3XwC90UUdNPYWZdFjhGBE7DUFuK3Ct1zWmZ65QN30= -golang.org/x/sys v0.0.0-20181228144115-9a3f9b0469bb/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200116001909-b77594299b42 h1:vEOn+mP2zCOVzKckCZy6YsCtDblrpj/w7B9nxGNELpg= +golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/tools v0.0.0-20190125232054-d66bd3c5d5a6/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20190515012406-7d7faa4812bd/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= +golang.org/x/tools v0.0.0-20200114235610-7ae403b6b589/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw= +gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo= +gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.4 h1:/eiJrUcujPVeJ3xlSWaiNi3uSVmDGBK1pDHUHAnao1I= +gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +sourcegraph.com/sourcegraph/appdash v0.0.0-20180110180208-2cc67fd64755/go.mod h1:hI742Nqp5OhwiqlzhgfbWU4mW4yO10fP+LoT9WOswdU= +sourcegraph.com/sourcegraph/appdash-data v0.0.0-20151005221446-73f23eafcf67/go.mod h1:L5q+DGLGOQFpo1snNEkLOJT2d1YTW66rWNzatr3He1k= diff --git a/pkg/codefresh/argo_runtime.go b/pkg/codefresh/argo_runtime.go index 0d6571c..ddf0602 100644 --- a/pkg/codefresh/argo_runtime.go +++ b/pkg/codefresh/argo_runtime.go @@ -31,14 +31,18 @@ func (r *argoRuntime) List() ([]model.Runtime, error) { jsonData := map[string]interface{}{ "query": ` { - runtimes{ - edges{ + runtimes( + pagination: {} + project: "") { + edges { node { - id - namespace - objectMeta { + metadata { + group + version + kind name - description + namespace + account } } } diff --git a/pkg/codefresh/codefresh.go b/pkg/codefresh/codefresh.go index f1e4309..b92e2d8 100644 --- a/pkg/codefresh/codefresh.go +++ b/pkg/codefresh/codefresh.go @@ -85,7 +85,7 @@ func (c *codefresh) Gitops() GitopsAPI { return newGitopsAPI(c) } -func (c *codefresh) ArgoRuntime() IArgoRuntimeAPI { +func (c *codefresh) ArgoRuntime() IArgoRuntimeAPI { return newArgoRuntimeAPI(c) } @@ -108,6 +108,7 @@ func (c *codefresh) requestAPIWithContext(ctx context.Context, opt *requestOptio } request.Header.Set("Authorization", c.token) request.Header.Set("Content-Type", "application/json") + request.Header.Set("x-access-token", "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJfaWQiOiI2MDczMDAwYTUxMDdkYTJiZjk4ZDFkZTQiLCJhY2NvdW50SWQiOiI2MDczMDAwYTUxMDdkYTJiZjk4ZDFkZTUiLCJpYXQiOjE2MjcyMDY2MTYsImV4cCI6MTYyODQxNjIxNn0.sTIcEi11dAE_Tg0PwlfHkEWv2MjABOPbZfLm_tUR9oA") response, err := c.client.Do(request) if err != nil { From 4b1b26f546689f5108d6712cbf5eef949b562b90 Mon Sep 17 00:00:00 2001 From: elad-codefresh Date: Tue, 27 Jul 2021 12:16:19 +0300 Subject: [PATCH 36/81] version --- go.mod | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/go.mod b/go.mod index fbe83d8..504f169 100644 --- a/go.mod +++ b/go.mod @@ -16,4 +16,4 @@ require ( gopkg.in/yaml.v2 v2.2.4 ) -go 1.14 +go 1.13 From 238d0d55207c686f599b0c0f23888702eac3d0b8 Mon Sep 17 00:00:00 2001 From: elad-codefresh Date: Tue, 27 Jul 2021 12:51:17 +0300 Subject: [PATCH 37/81] updated query --- pkg/codefresh/argo_runtime.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pkg/codefresh/argo_runtime.go b/pkg/codefresh/argo_runtime.go index ddf0602..15038a7 100644 --- a/pkg/codefresh/argo_runtime.go +++ b/pkg/codefresh/argo_runtime.go @@ -38,12 +38,14 @@ func (r *argoRuntime) List() ([]model.Runtime, error) { node { metadata { group - version kind name namespace account } + healthStatus + runtimeVersion + cluster } } } From 9447b5d0f602819b440bb2b89c3cbd75d7b97597 Mon Sep 17 00:00:00 2001 From: elad-codefresh Date: Tue, 27 Jul 2021 12:54:08 +0300 Subject: [PATCH 38/81] updated query --- pkg/codefresh/argo_runtime.go | 3 --- 1 file changed, 3 deletions(-) diff --git a/pkg/codefresh/argo_runtime.go b/pkg/codefresh/argo_runtime.go index 15038a7..f9f69a7 100644 --- a/pkg/codefresh/argo_runtime.go +++ b/pkg/codefresh/argo_runtime.go @@ -37,11 +37,8 @@ func (r *argoRuntime) List() ([]model.Runtime, error) { edges { node { metadata { - group - kind name namespace - account } healthStatus runtimeVersion From 5801089f8614ca6ed1d7095d4602d4850a1eb39c Mon Sep 17 00:00:00 2001 From: elad-codefresh Date: Tue, 27 Jul 2021 13:35:20 +0300 Subject: [PATCH 39/81] healthMessage --- pkg/codefresh/argo_runtime.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/codefresh/argo_runtime.go b/pkg/codefresh/argo_runtime.go index f9f69a7..f3131ab 100644 --- a/pkg/codefresh/argo_runtime.go +++ b/pkg/codefresh/argo_runtime.go @@ -40,7 +40,7 @@ func (r *argoRuntime) List() ([]model.Runtime, error) { name namespace } - healthStatus + healthMessage runtimeVersion cluster } From 3d1eeb6c405286fd1c6458b359b6b061045b39fe Mon Sep 17 00:00:00 2001 From: elad-codefresh Date: Tue, 27 Jul 2021 14:31:32 +0300 Subject: [PATCH 40/81] bump --- VERSION | 2 +- pkg/codefresh/codefresh.go | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/VERSION b/VERSION index 1b58cc1..83b4730 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.27.0 +0.27.1 diff --git a/pkg/codefresh/codefresh.go b/pkg/codefresh/codefresh.go index b92e2d8..808666f 100644 --- a/pkg/codefresh/codefresh.go +++ b/pkg/codefresh/codefresh.go @@ -108,7 +108,6 @@ func (c *codefresh) requestAPIWithContext(ctx context.Context, opt *requestOptio } request.Header.Set("Authorization", c.token) request.Header.Set("Content-Type", "application/json") - request.Header.Set("x-access-token", "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJfaWQiOiI2MDczMDAwYTUxMDdkYTJiZjk4ZDFkZTQiLCJhY2NvdW50SWQiOiI2MDczMDAwYTUxMDdkYTJiZjk4ZDFkZTUiLCJpYXQiOjE2MjcyMDY2MTYsImV4cCI6MTYyODQxNjIxNn0.sTIcEi11dAE_Tg0PwlfHkEWv2MjABOPbZfLm_tUR9oA") response, err := c.client.Do(request) if err != nil { From 5a78644de2c0fddfc928e103ee78ddb9c1bc9050 Mon Sep 17 00:00:00 2001 From: elad-codefresh Date: Wed, 28 Jul 2021 15:41:16 +0300 Subject: [PATCH 41/81] interpolated mutation --- pkg/codefresh/argo_runtime.go | 56 ++++++++++++++++++++++++++++++++--- pkg/codefresh/codefresh.go | 1 + 2 files changed, 53 insertions(+), 4 deletions(-) diff --git a/pkg/codefresh/argo_runtime.go b/pkg/codefresh/argo_runtime.go index f3131ab..d649539 100644 --- a/pkg/codefresh/argo_runtime.go +++ b/pkg/codefresh/argo_runtime.go @@ -11,6 +11,7 @@ import ( type ( IArgoRuntimeAPI interface { List() ([]model.Runtime, error) + Create(runtimeName string) (*model.RuntimeCreationResponse, error) } argoRuntime struct { codefresh *codefresh @@ -21,19 +22,65 @@ type ( } Errors []graphqlError } + + graphQlRuntimeCreationResponse struct { + Data struct { + Runtime model.RuntimeCreationResponse + } + // TODO: Errors + } ) func newArgoRuntimeAPI(codefresh *codefresh) IArgoRuntimeAPI { return &argoRuntime{codefresh: codefresh} } -func (r *argoRuntime) List() ([]model.Runtime, error) { +func (r *argoRuntime) Create(runtimeName string) (*model.RuntimeCreationResponse, error) { // TODO: should also return error + type forJsonData interface{} + + // the newlines are necessary + var interpolatedMutation forJsonData = fmt.Sprintf("mutation {\n runtime(name: \"%s\") {\n id\n newAccessToken\n }\n}\n", runtimeName) + + jsonData := map[string]interface{}{ + "query": interpolatedMutation, + } + + response, err := r.codefresh.requestAPI(&requestOptions{ + method: "POST", + path: "/argo/api/graphql", + body: jsonData, + }) + + if err != nil { + fmt.Printf("The HTTP request failed with error %s\n", err) + return nil, err + } + defer response.Body.Close() + + data, err := ioutil.ReadAll(response.Body) + if err != nil { + fmt.Printf("failed to read from response body") + return nil, err + } + res := graphQlRuntimeCreationResponse{} + + err = json.Unmarshal(data, &res) + if err != nil { + return nil, err + } + + return &res.Data.Runtime, nil +} + +func (r *argoRuntime) List() ([]model.Runtime, error) { jsonData := map[string]interface{}{ "query": ` { - runtimes( + runtimes + ( pagination: {} - project: "") { + project: "" + ) { edges { node { metadata { @@ -55,11 +102,12 @@ func (r *argoRuntime) List() ([]model.Runtime, error) { path: "/argo/api/graphql", body: jsonData, }) - defer response.Body.Close() if err != nil { fmt.Printf("The HTTP request failed with error %s\n", err) return nil, err } + defer response.Body.Close() + data, err := ioutil.ReadAll(response.Body) if err != nil { fmt.Printf("failed to read from response body") diff --git a/pkg/codefresh/codefresh.go b/pkg/codefresh/codefresh.go index 808666f..4d432c3 100644 --- a/pkg/codefresh/codefresh.go +++ b/pkg/codefresh/codefresh.go @@ -108,6 +108,7 @@ func (c *codefresh) requestAPIWithContext(ctx context.Context, opt *requestOptio } request.Header.Set("Authorization", c.token) request.Header.Set("Content-Type", "application/json") + request.Header.Set("origin", c.host) response, err := c.client.Do(request) if err != nil { From 11b0ba6dda9e911494abafe44f54fb4a0d217295 Mon Sep 17 00:00:00 2001 From: elad-codefresh Date: Wed, 28 Jul 2021 15:45:25 +0300 Subject: [PATCH 42/81] bump --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index 83b4730..697f087 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.27.1 +0.28.0 From 29152eba505e63d09289b53f8dd09f5b4da7e19f Mon Sep 17 00:00:00 2001 From: elad-codefresh Date: Wed, 28 Jul 2021 16:14:03 +0300 Subject: [PATCH 43/81] removed comment --- pkg/codefresh/argo_runtime.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/pkg/codefresh/argo_runtime.go b/pkg/codefresh/argo_runtime.go index d649539..55a98ef 100644 --- a/pkg/codefresh/argo_runtime.go +++ b/pkg/codefresh/argo_runtime.go @@ -27,7 +27,6 @@ type ( Data struct { Runtime model.RuntimeCreationResponse } - // TODO: Errors } ) @@ -37,7 +36,7 @@ func newArgoRuntimeAPI(codefresh *codefresh) IArgoRuntimeAPI { func (r *argoRuntime) Create(runtimeName string) (*model.RuntimeCreationResponse, error) { // TODO: should also return error type forJsonData interface{} - + // the newlines are necessary var interpolatedMutation forJsonData = fmt.Sprintf("mutation {\n runtime(name: \"%s\") {\n id\n newAccessToken\n }\n}\n", runtimeName) From d3b564cfcacff0a1a7040206cbfd5c20ba1ca384 Mon Sep 17 00:00:00 2001 From: elad-codefresh Date: Wed, 28 Jul 2021 16:39:14 +0300 Subject: [PATCH 44/81] with []graphqlError --- pkg/codefresh/argo_runtime.go | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/pkg/codefresh/argo_runtime.go b/pkg/codefresh/argo_runtime.go index 55a98ef..0913ead 100644 --- a/pkg/codefresh/argo_runtime.go +++ b/pkg/codefresh/argo_runtime.go @@ -27,6 +27,7 @@ type ( Data struct { Runtime model.RuntimeCreationResponse } + Errors []graphqlError } ) @@ -34,7 +35,7 @@ func newArgoRuntimeAPI(codefresh *codefresh) IArgoRuntimeAPI { return &argoRuntime{codefresh: codefresh} } -func (r *argoRuntime) Create(runtimeName string) (*model.RuntimeCreationResponse, error) { // TODO: should also return error +func (r *argoRuntime) Create(runtimeName string) (*model.RuntimeCreationResponse, error) { type forJsonData interface{} // the newlines are necessary @@ -61,13 +62,17 @@ func (r *argoRuntime) Create(runtimeName string) (*model.RuntimeCreationResponse fmt.Printf("failed to read from response body") return nil, err } - res := graphQlRuntimeCreationResponse{} + res := graphQlRuntimeCreationResponse{} err = json.Unmarshal(data, &res) if err != nil { return nil, err } + if len(res.Errors) > 0 { + return nil, graphqlErrorResponse{errors: res.Errors} + } + return &res.Data.Runtime, nil } @@ -112,11 +117,14 @@ func (r *argoRuntime) List() ([]model.Runtime, error) { fmt.Printf("failed to read from response body") return nil, err } + res := graphqlRuntimesResponse{} err = json.Unmarshal(data, &res) + if err != nil { return nil, err } + runtimes := make([]model.Runtime, len(res.Data.Runtimes.Edges)) for i := range res.Data.Runtimes.Edges { runtimes[i] = *res.Data.Runtimes.Edges[i].Node @@ -127,5 +135,4 @@ func (r *argoRuntime) List() ([]model.Runtime, error) { } return runtimes, nil - } From 267f0690c3f6bc79353126d0f7aca1accbb82dcf Mon Sep 17 00:00:00 2001 From: elad-codefresh Date: Wed, 28 Jul 2021 16:43:12 +0300 Subject: [PATCH 45/81] without separate interface{} --- pkg/codefresh/argo_runtime.go | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/pkg/codefresh/argo_runtime.go b/pkg/codefresh/argo_runtime.go index 0913ead..14a63c0 100644 --- a/pkg/codefresh/argo_runtime.go +++ b/pkg/codefresh/argo_runtime.go @@ -36,10 +36,8 @@ func newArgoRuntimeAPI(codefresh *codefresh) IArgoRuntimeAPI { } func (r *argoRuntime) Create(runtimeName string) (*model.RuntimeCreationResponse, error) { - type forJsonData interface{} - // the newlines are necessary - var interpolatedMutation forJsonData = fmt.Sprintf("mutation {\n runtime(name: \"%s\") {\n id\n newAccessToken\n }\n}\n", runtimeName) + var interpolatedMutation interface{} = fmt.Sprintf("mutation {\n runtime(name: \"%s\") {\n id\n newAccessToken\n }\n}\n", runtimeName) jsonData := map[string]interface{}{ "query": interpolatedMutation, From 8a2d883cdc03159f5124ddc86195ff30267695c7 Mon Sep 17 00:00:00 2001 From: elad-codefresh Date: Wed, 28 Jul 2021 17:19:15 +0300 Subject: [PATCH 46/81] better --- pkg/codefresh/argo_runtime.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/pkg/codefresh/argo_runtime.go b/pkg/codefresh/argo_runtime.go index 14a63c0..a154c1a 100644 --- a/pkg/codefresh/argo_runtime.go +++ b/pkg/codefresh/argo_runtime.go @@ -36,8 +36,13 @@ func newArgoRuntimeAPI(codefresh *codefresh) IArgoRuntimeAPI { } func (r *argoRuntime) Create(runtimeName string) (*model.RuntimeCreationResponse, error) { - // the newlines are necessary - var interpolatedMutation interface{} = fmt.Sprintf("mutation {\n runtime(name: \"%s\") {\n id\n newAccessToken\n }\n}\n", runtimeName) + interpolatedMutation := fmt.Sprintf(`mutation { + runtime(name: "%s") { + id + newAccessToken + } + } + `, runtimeName) jsonData := map[string]interface{}{ "query": interpolatedMutation, From 347d7fc0f8c37e86904b6191bee4172d6a61ccd6 Mon Sep 17 00:00:00 2001 From: elad-codefresh Date: Wed, 28 Jul 2021 17:22:21 +0300 Subject: [PATCH 47/81] indentation --- pkg/codefresh/argo_runtime.go | 1 + 1 file changed, 1 insertion(+) diff --git a/pkg/codefresh/argo_runtime.go b/pkg/codefresh/argo_runtime.go index a154c1a..9b3f4e3 100644 --- a/pkg/codefresh/argo_runtime.go +++ b/pkg/codefresh/argo_runtime.go @@ -58,6 +58,7 @@ func (r *argoRuntime) Create(runtimeName string) (*model.RuntimeCreationResponse fmt.Printf("The HTTP request failed with error %s\n", err) return nil, err } + defer response.Body.Close() data, err := ioutil.ReadAll(response.Body) From a6f33cffc73bc915ec30e58cc40a0e7562564168 Mon Sep 17 00:00:00 2001 From: elad-codefresh Date: Wed, 28 Jul 2021 17:22:54 +0300 Subject: [PATCH 48/81] n --- pkg/codefresh/argo_runtime.go | 1 + 1 file changed, 1 insertion(+) diff --git a/pkg/codefresh/argo_runtime.go b/pkg/codefresh/argo_runtime.go index 9b3f4e3..1a1e27f 100644 --- a/pkg/codefresh/argo_runtime.go +++ b/pkg/codefresh/argo_runtime.go @@ -36,6 +36,7 @@ func newArgoRuntimeAPI(codefresh *codefresh) IArgoRuntimeAPI { } func (r *argoRuntime) Create(runtimeName string) (*model.RuntimeCreationResponse, error) { + interpolatedMutation := fmt.Sprintf(`mutation { runtime(name: "%s") { id From 3fc03d090a98ce5c8fe2a581c824d978d990b610 Mon Sep 17 00:00:00 2001 From: elad-codefresh Date: Wed, 28 Jul 2021 17:23:15 +0300 Subject: [PATCH 49/81] n --- pkg/codefresh/argo_runtime.go | 1 - 1 file changed, 1 deletion(-) diff --git a/pkg/codefresh/argo_runtime.go b/pkg/codefresh/argo_runtime.go index 1a1e27f..9b3f4e3 100644 --- a/pkg/codefresh/argo_runtime.go +++ b/pkg/codefresh/argo_runtime.go @@ -36,7 +36,6 @@ func newArgoRuntimeAPI(codefresh *codefresh) IArgoRuntimeAPI { } func (r *argoRuntime) Create(runtimeName string) (*model.RuntimeCreationResponse, error) { - interpolatedMutation := fmt.Sprintf(`mutation { runtime(name: "%s") { id From 1ebc3cd19102c2010ab2d20822ce797a2bf4b01f Mon Sep 17 00:00:00 2001 From: Noam Gal Date: Wed, 28 Jul 2021 18:12:37 +0300 Subject: [PATCH 50/81] Create DUMMY --- pkg/codefresh/model/DUMMY | 1 + 1 file changed, 1 insertion(+) create mode 100644 pkg/codefresh/model/DUMMY diff --git a/pkg/codefresh/model/DUMMY b/pkg/codefresh/model/DUMMY new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/pkg/codefresh/model/DUMMY @@ -0,0 +1 @@ + From ad3768393246a74537d92aebcc2ae4a7218b703c Mon Sep 17 00:00:00 2001 From: Noam Gal Date: Wed, 28 Jul 2021 18:40:45 +0300 Subject: [PATCH 51/81] removed dependency on argo_platform repo --- go.mod | 5 +- go.sum | 50 - pkg/codefresh/argo_runtime.go | 2 +- pkg/codefresh/model/DUMMY | 1 - pkg/codefresh/model/models_gen.go | 1505 +++++++++++++++++++++++++++++ 5 files changed, 1510 insertions(+), 53 deletions(-) delete mode 100644 pkg/codefresh/model/DUMMY create mode 100644 pkg/codefresh/model/models_gen.go diff --git a/go.mod b/go.mod index 504f169..71fb9e5 100644 --- a/go.mod +++ b/go.mod @@ -1,10 +1,11 @@ module github.com/codefresh-io/go-sdk require ( - github.com/codefresh-io/argo-platform v1.35.0 + github.com/BurntSushi/toml v0.3.1 // indirect github.com/dustin/go-humanize v1.0.0 github.com/google/go-querystring v1.1.0 github.com/inconshreveable/mousetrap v1.0.0 // indirect + github.com/kr/pretty v0.1.0 // indirect github.com/mattn/go-runewidth v0.0.4 // indirect github.com/mitchellh/go-homedir v1.0.0 github.com/olekukonko/tablewriter v0.0.1 @@ -13,6 +14,8 @@ require ( github.com/spf13/viper v1.3.1 github.com/stretchr/objx v0.3.0 // indirect github.com/stretchr/testify v1.4.0 + golang.org/x/sys v0.0.0-20200116001909-b77594299b42 // indirect + gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 // indirect gopkg.in/yaml.v2 v2.2.4 ) diff --git a/go.sum b/go.sum index 9551493..1b7872f 100644 --- a/go.sum +++ b/go.sum @@ -1,35 +1,20 @@ -github.com/99designs/gqlgen v0.13.0/go.mod h1:NV130r6f4tpRWuAI+zsrSdooO/eWUv+Gyyoi3rEfXIk= github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= -github.com/agnivade/levenshtein v1.0.1/go.mod h1:CURSv5d9Uaml+FovSIICkLbAUZ9S4RqaHDIsdSBg7lM= -github.com/agnivade/levenshtein v1.0.3/go.mod h1:4SFRZbbXWLF4MU1T9Qg0pGgH3Pjs+t6ie5efyrwRJXs= -github.com/andreyvit/diff v0.0.0-20170406064948-c7f18ee00883/go.mod h1:rCTlJbsFo29Kk6CurOXKm700vrz8f0KW0JNfpkRJY/8= -github.com/arbovm/levenshtein v0.0.0-20160628152529-48b4e1c0c4d0/go.mod h1:t2tdKJDJF9BV14lnkjHmOQgcvEKgtqs5a1N3LNdJhGE= github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8= -github.com/codefresh-io/argo-platform v1.35.0 h1:9rboz3DYnfdH9UdQhDQ6dkVLJWhnR5eHqH7mM+kyQcc= -github.com/codefresh-io/argo-platform v1.35.0/go.mod h1:rNms+r6lqY5QPEkHROmh5jXKA8VrasuN6CfleuX2xFY= github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE= github.com/coreos/go-etcd v2.0.0+incompatible/go.mod h1:Jez6KQU2B/sWsbdaef3ED8NzMklzPG4d5KIOhIy30Tk= github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= -github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/dgryski/trifles v0.0.0-20190318185328-a8d75aae118c/go.mod h1:if7Fbed8SFyPtHLHbg49SI7NAdJiC5WIA09pe59rfAA= github.com/dustin/go-humanize v1.0.0 h1:VSnTsYCnlFHaM2/igO1h6X3HA71jcobQuxemgkq4zYo= github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= github.com/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV9I= github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= -github.com/go-chi/chi v3.3.2+incompatible/go.mod h1:eB3wogJHnLi3x/kFX2A+IbTBlXxmMeXJVKy9tTv1XzQ= -github.com/gogo/protobuf v1.0.0/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= github.com/google/go-cmp v0.5.2 h1:X2ev0eStA3AbceY54o37/0PQ/UWqKEiiO2dKL5OPaFM= github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-querystring v1.1.0 h1:AnCroh3fv4ZBgVIf1Iwtovgjaw/GiKJo8M8yD/fhyJ8= github.com/google/go-querystring v1.1.0/go.mod h1:Kcdr2DB4koayq7X8pmAG4sNG59So17icRSOU623lUBU= -github.com/gorilla/context v0.0.0-20160226214623-1ea25387ff6f/go.mod h1:kBGZzfjB9CEq2AlWe17Uuf7NDRt0dE0s8S51q0aT7Yg= -github.com/gorilla/mux v1.6.1/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs= -github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= -github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4= github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ= github.com/inconshreveable/mousetrap v1.0.0 h1:Z8tu5sraLXCXIcARxBp/8cbvlwVa7Z1NHg9XEKhtSvM= @@ -39,35 +24,20 @@ github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORN github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= -github.com/logrusorgru/aurora v0.0.0-20200102142835-e9ef32dff381/go.mod h1:7rIyQOR62GCctdiQpZ/zOJlFyk6y+94wXzv6RNZgaR4= github.com/magiconair/properties v1.8.0 h1:LLgXmsheXeRoUOBOjtwPQCWIYqM/LU1ayDtDePerRcY= github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ= -github.com/matryer/moq v0.0.0-20200106131100-75d0ddfc0007/go.mod h1:9ELz6aaclSIGnZBoaSLZ3NAl1VTufbOrXBPvtcy6WiQ= -github.com/mattn/go-colorable v0.1.4/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE= -github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= -github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= github.com/mattn/go-runewidth v0.0.4 h1:2BvfKmzob6Bmd4YsL0zygOqfdFnK7GR4QL06Do4/p7Y= github.com/mattn/go-runewidth v0.0.4/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU= github.com/mitchellh/go-homedir v1.0.0 h1:vKb8ShqSby24Yrqr/yDYkuFz8d0WUjys40rvnGC8aR0= github.com/mitchellh/go-homedir v1.0.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= -github.com/mitchellh/mapstructure v0.0.0-20180203102830-a4e142e9c047/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= github.com/mitchellh/mapstructure v1.1.2 h1:fmNYVwqnSfB9mZU6OS2O6GsXM+wcskZDuKQzvN1EDeE= github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= github.com/olekukonko/tablewriter v0.0.1 h1:b3iUnf1v+ppJiOfNX4yxxqfWKMQPZR5yoh8urCTFX88= github.com/olekukonko/tablewriter v0.0.1/go.mod h1:vsDQFd/mU46D+Z4whnwzcISnGGzXWMclvtLoiIKAKIo= -github.com/opentracing/basictracer-go v1.0.0/go.mod h1:QfBfYuafItcjQuMwinw9GhYKwFXS9KnPs5lxoYwgW74= -github.com/opentracing/opentracing-go v1.0.2/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o= github.com/pelletier/go-toml v1.2.0 h1:T5zMGML61Wp+FlcbWjRDT7yAxhJNAiPPLOFECq181zc= github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic= -github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/rs/cors v1.6.0/go.mod h1:gFx+x8UowdsKA9AchylcLynDq+nNFfI8FkUZdN/jGCU= -github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= -github.com/sergi/go-diff v1.1.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM= -github.com/shurcooL/httpfs v0.0.0-20171119174359-809beceb2371/go.mod h1:ZY1cvUeJuFPAdZ/B6v7RHavJWZn2YPVFQ1OSXhCGOkg= -github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc= -github.com/shurcooL/vfsgen v0.0.0-20180121065927-ffb13db8def0/go.mod h1:TrYk7fJVaAttu97ZZKrO9UbRa8izdowaMIZcxYMbVaw= github.com/spf13/afero v1.1.2/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ= github.com/spf13/afero v1.2.0 h1:O9FblXGxoTc51M+cqr74Bm2Tmt4PvkA5iu/j8HrkNuY= github.com/spf13/afero v1.2.0/go.mod h1:9ZxEEn6pIJ8Rxe320qSDBk6AsU0r9pR7Q4OcevTdifk= @@ -84,36 +54,18 @@ github.com/spf13/viper v1.3.1/go.mod h1:ZiWeW+zYFKm7srdB9IoDzzZXaJaI5eL9QjNiN/DM github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.3.0 h1:NGXK3lHquSN08v5vWalVI/L8XU9hdzE/G6xsrze47As= github.com/stretchr/objx v0.3.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE= -github.com/stretchr/testify v1.2.1/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= github.com/ugorji/go/codec v0.0.0-20181204163529-d75b2dcb6bc8/go.mod h1:VFNgLljTbGfSG7qAOspJ7OScBnGdDN/yBr0sguwnwf0= -github.com/urfave/cli/v2 v2.1.1/go.mod h1:SE9GqnLQmjVa0iPEY0f1w3ygNIYcIJ0OKPMoW2caLfQ= -github.com/vektah/dataloaden v0.2.1-0.20190515034641-a19b9a6e7c9e/go.mod h1:/HUdMve7rvxZma+2ZELQeNh88+003LL7Pf/CZ089j8U= -github.com/vektah/gqlparser/v2 v2.1.0/go.mod h1:SyUiHgLATUR8BiYURfTirrTcGpcE+4XkV2se04Px1Ms= github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q= golang.org/x/crypto v0.0.0-20181203042331-505ab145d0a9/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= -golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= -golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20181205085412-a5c9d58dba9a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200116001909-b77594299b42 h1:vEOn+mP2zCOVzKckCZy6YsCtDblrpj/w7B9nxGNELpg= golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/tools v0.0.0-20190125232054-d66bd3c5d5a6/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20190515012406-7d7faa4812bd/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= -golang.org/x/tools v0.0.0-20200114235610-7ae403b6b589/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= @@ -122,5 +74,3 @@ gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8 gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.4 h1:/eiJrUcujPVeJ3xlSWaiNi3uSVmDGBK1pDHUHAnao1I= gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -sourcegraph.com/sourcegraph/appdash v0.0.0-20180110180208-2cc67fd64755/go.mod h1:hI742Nqp5OhwiqlzhgfbWU4mW4yO10fP+LoT9WOswdU= -sourcegraph.com/sourcegraph/appdash-data v0.0.0-20151005221446-73f23eafcf67/go.mod h1:L5q+DGLGOQFpo1snNEkLOJT2d1YTW66rWNzatr3He1k= diff --git a/pkg/codefresh/argo_runtime.go b/pkg/codefresh/argo_runtime.go index 9b3f4e3..e18448a 100644 --- a/pkg/codefresh/argo_runtime.go +++ b/pkg/codefresh/argo_runtime.go @@ -5,7 +5,7 @@ import ( "fmt" "io/ioutil" - "github.com/codefresh-io/argo-platform/libs/ql/graph/model" + "github.com/codefresh-io/go-sdk/pkg/codefresh/model" ) type ( diff --git a/pkg/codefresh/model/DUMMY b/pkg/codefresh/model/DUMMY deleted file mode 100644 index 8b13789..0000000 --- a/pkg/codefresh/model/DUMMY +++ /dev/null @@ -1 +0,0 @@ - diff --git a/pkg/codefresh/model/models_gen.go b/pkg/codefresh/model/models_gen.go new file mode 100644 index 0000000..31bc6df --- /dev/null +++ b/pkg/codefresh/model/models_gen.go @@ -0,0 +1,1505 @@ +// Code generated by github.com/99designs/gqlgen, DO NOT EDIT. + +package model + +import ( + "fmt" + "io" + "strconv" +) + +// Base entity +type BaseEntity interface { + IsBaseEntity() +} + +// Customer +type Customer interface { + IsCustomer() +} + +// Generic edge to allow cursors +type Edge interface { + IsEdge() +} + +// Entity types +type Entity interface { + IsEntity() +} + +// Event +type Event interface { + IsEvent() +} + +// Gitops entity +type GitopsEntity interface { + IsGitopsEntity() +} + +// Page +type Page interface { + IsPage() +} + +// Project based entity +type ProjectBasedEntity interface { + IsProjectBasedEntity() +} + +// Sensor trigger +type SensorTrigger interface { + IsSensorTrigger() +} + +// Slice +type Slice interface { + IsSlice() +} + +// Workflow spec template +type WorkflowSpecTemplate interface { + IsWorkflowSpecTemplate() +} + +// Account is logical entity that group together users pipeliens and more +type Account struct { + // The account id + ID string `json:"id"` + // The account unique name + Name string `json:"name"` +} + +// "Generate api token result +type APIToken struct { + // The token to use in runtime installation and other requests + Token *string `json:"token"` +} + +// Component entity +type Component struct { + // Object metadata + Metadata *ObjectMeta `json:"metadata"` + // Errors + Errors []*Error `json:"errors"` + // Entities referencing this entity + ReferencedBy []BaseEntity `json:"referencedBy"` + // Entities referenced by this enitity + References []BaseEntity `json:"references"` + // Version of the entity + Version *int `json:"version"` + // Is this the latest version of this entity + Latest *bool `json:"latest"` + // Entity source + Source *GitopsEntitySource `json:"source"` + // Sync status + SyncStatus SyncStatus `json:"syncStatus"` + // Health status + HealthStatus *HealthStatus `json:"healthStatus"` + // Health message + HealthMessage *string `json:"healthMessage"` + // Desired manifest + DesiredManifest *string `json:"desiredManifest"` + // Actual manifest + ActualManifest *string `json:"actualManifest"` + // Projects + Projects []string `json:"projects"` +} + +func (Component) IsBaseEntity() {} +func (Component) IsGitopsEntity() {} +func (Component) IsProjectBasedEntity() {} +func (Component) IsEntity() {} + +// Component Edge +type ComponentEdge struct { + // Node contains the actual component data + Node *Component `json:"node"` + // Cursor + Cursor string `json:"cursor"` +} + +func (ComponentEdge) IsEdge() {} + +// Component Page +type ComponentPage struct { + // Total amount of components + TotalCount int `json:"totalCount"` + // Component edges + Edges []*ComponentEdge `json:"edges"` + // Page information + PageInfo *PageInfo `json:"pageInfo"` +} + +func (ComponentPage) IsPage() {} + +// Component Slice +type ComponentSlice struct { + // Component edges + Edges []*ComponentEdge `json:"edges"` + // Slice information + PageInfo *SliceInfo `json:"pageInfo"` +} + +func (ComponentSlice) IsSlice() {} + +// Environment Variable +type EnvVar struct { + // Name + Name string `json:"name"` + // Value + Value string `json:"value"` +} + +// Error +type Error struct { + // Type + Type *ErrorTypes `json:"type"` + // Code + Code *int `json:"code"` + // Title + Title *string `json:"title"` + // Message + Message *string `json:"message"` + // Suggestion + Suggestion *string `json:"suggestion"` +} + +// Event source entity +type EventSource struct { + // Object metadata + Metadata *ObjectMeta `json:"metadata"` + // Errors + Errors []*Error `json:"errors"` + // Entities referencing this entity + ReferencedBy []BaseEntity `json:"referencedBy"` + // Entities referenced by this enitity + References []BaseEntity `json:"references"` + // Version of the entity + Version *int `json:"version"` + // Is this the latest version of this entity + Latest *bool `json:"latest"` + // Entity source + Source *GitopsEntitySource `json:"source"` + // Sync status + SyncStatus SyncStatus `json:"syncStatus"` + // Health status + HealthStatus *HealthStatus `json:"healthStatus"` + // Health message + HealthMessage *string `json:"healthMessage"` + // Desired manifest + DesiredManifest *string `json:"desiredManifest"` + // Actual manifest + ActualManifest *string `json:"actualManifest"` + // Projects + Projects []string `json:"projects"` + // Eventbus + Eventbus string `json:"eventbus"` + // Events + Events []Event `json:"events"` +} + +func (EventSource) IsBaseEntity() {} +func (EventSource) IsGitopsEntity() {} +func (EventSource) IsProjectBasedEntity() {} +func (EventSource) IsEntity() {} + +// Event source Edge +type EventSourceEdge struct { + // Node contains the actual event source data + Node *EventSource `json:"node"` + // Cursor + Cursor string `json:"cursor"` +} + +func (EventSourceEdge) IsEdge() {} + +// Event source Page +type EventSourcePage struct { + // Total amount of event sources + TotalCount int `json:"totalCount"` + // Event source edges + Edges []*EventSourceEdge `json:"edges"` + // Page information + PageInfo *PageInfo `json:"pageInfo"` +} + +func (EventSourcePage) IsPage() {} + +// Event source Slice +type EventSourceSlice struct { + // Event source edges + Edges []*EventSourceEdge `json:"edges"` + // Slice information + PageInfo *SliceInfo `json:"pageInfo"` +} + +func (EventSourceSlice) IsSlice() {} + +// EventResponse +type EventsResponse struct { + // Name of event + Name EventName `json:"name"` + // Payload of event + Payload *string `json:"payload"` + // Time of event + Time string `json:"time"` +} + +// Git integration entity +type GitIntegration struct { + // Object metadata + Metadata *ObjectMeta `json:"metadata"` + // Errors + Errors []*Error `json:"errors"` + // Entities referencing this entity + ReferencedBy []BaseEntity `json:"referencedBy"` + // Entities referenced by this enitity + References []BaseEntity `json:"references"` + // Version of the entity + Version *int `json:"version"` + // Is this the latest version of this entity + Latest *bool `json:"latest"` + // Entity source + Source *GitopsEntitySource `json:"source"` + // Sync status + SyncStatus SyncStatus `json:"syncStatus"` + // Health status + HealthStatus *HealthStatus `json:"healthStatus"` + // Health message + HealthMessage *string `json:"healthMessage"` + // Desired manifest + DesiredManifest *string `json:"desiredManifest"` + // Actual manifest + ActualManifest *string `json:"actualManifest"` + // Projects + Projects []string `json:"projects"` + // Git provider + Provider *GitProviders `json:"provider"` + // API URL of the git provider + APIURL string `json:"apiUrl"` +} + +func (GitIntegration) IsGitopsEntity() {} +func (GitIntegration) IsBaseEntity() {} +func (GitIntegration) IsProjectBasedEntity() {} +func (GitIntegration) IsEntity() {} + +// Git integration Edge +type GitIntegrationEdge struct { + // Node contains the actual git integration data + Node *GitIntegration `json:"node"` + // Cursor + Cursor string `json:"cursor"` +} + +func (GitIntegrationEdge) IsEdge() {} + +// Git integration Page +type GitIntegrationPage struct { + // Total amount of git integration + TotalCount int `json:"totalCount"` + // Git integration edges + Edges []*GitIntegrationEdge `json:"edges"` + // Git integration information + PageInfo *PageInfo `json:"pageInfo"` +} + +func (GitIntegrationPage) IsPage() {} + +// Git integration Slice +type GitIntegrationSlice struct { + // Git integration edges + Edges []*GitIntegrationEdge `json:"edges"` + // Slice information + PageInfo *SliceInfo `json:"pageInfo"` +} + +func (GitIntegrationSlice) IsSlice() {} + +// Git source entity +type GitSource struct { + // Object metadata + Metadata *ObjectMeta `json:"metadata"` + // Errors + Errors []*Error `json:"errors"` + // Entities referencing this entity + ReferencedBy []BaseEntity `json:"referencedBy"` + // Entities referenced by this enitity + References []BaseEntity `json:"references"` + // Version of the entity + Version *int `json:"version"` + // Is this the latest version of this entity + Latest *bool `json:"latest"` + // Entity source + Source *GitopsEntitySource `json:"source"` + // Sync status + SyncStatus SyncStatus `json:"syncStatus"` + // Health status + HealthStatus *HealthStatus `json:"healthStatus"` + // Health message + HealthMessage *string `json:"healthMessage"` + // Desired manifest + DesiredManifest *string `json:"desiredManifest"` + // Actual manifest + ActualManifest *string `json:"actualManifest"` + // Projects + Projects []string `json:"projects"` +} + +func (GitSource) IsGitopsEntity() {} +func (GitSource) IsBaseEntity() {} +func (GitSource) IsProjectBasedEntity() {} +func (GitSource) IsEntity() {} + +// Git source Edge +type GitSourceEdge struct { + // Node contains the actual git source data + Node *GitSource `json:"node"` + // Cursor + Cursor string `json:"cursor"` +} + +func (GitSourceEdge) IsEdge() {} + +// Git source Page +type GitSourcePage struct { + // Total amount of git sources + TotalCount int `json:"totalCount"` + // Git source edges + Edges []*GitSourceEdge `json:"edges"` + // Page information + PageInfo *PageInfo `json:"pageInfo"` +} + +func (GitSourcePage) IsPage() {} + +// Git source Slice +type GitSourceSlice struct { + // Git source edges + Edges []*GitSourceEdge `json:"edges"` + // Slice information + PageInfo *SliceInfo `json:"pageInfo"` +} + +func (GitSourceSlice) IsSlice() {} + +// Github event +type GithubEvent struct { + // Name + Name string `json:"name"` + // Repository owner + Owner string `json:"owner"` + // Repository names + Repositories []string `json:"repositories"` + // Webhook events + Events []string `json:"events"` +} + +func (GithubEvent) IsEvent() {} + +// Gitops entity source +type GitopsEntitySource struct { + // Entity source + GitSource *GitSource `json:"gitSource"` + // Path + Path string `json:"path"` + // Git revision + Revision string `json:"revision"` + // Git manifest + GitManifest string `json:"gitManifest"` +} + +// Http Trigger +type HTTPTrigger struct { + // Name + Name string `json:"name"` + // Conditions + Conditions string `json:"conditions"` + // Url + URL string `json:"url"` + // Method + Method string `json:"method"` +} + +func (HTTPTrigger) IsSensorTrigger() {} + +// Me +type Me struct { + // The user id + ID string `json:"id"` + // The roles of the user provide specific permission for the current user + Roles []*UserRole `json:"roles"` + // The accounts the this user have acsess to + Accounts []*Account `json:"accounts"` + // The default account for this user + ActiveAccount *Account `json:"activeAccount"` + // The customers that this user is in + Customers []Customer `json:"customers"` + // The current status of this user + Status *UserStatus `json:"status"` + // Provide details about this user + Details *UserDetails `json:"details"` + // Provide info on user + Info *UserInfo `json:"info"` +} + +// Object metadata +type ObjectMeta struct { + // Group + Group string `json:"group"` + // Version + Version string `json:"version"` + // Kind + Kind string `json:"kind"` + // Name + Name string `json:"name"` + // Description + Description *string `json:"description"` + // Namespace + Namespace string `json:"namespace"` + // Runtime + Runtime string `json:"runtime"` + // Account name + Account string `json:"account"` + // Labels + Labels []*StringPair `json:"labels"` + // Annotations + Annotations []*StringPair `json:"annotations"` + // Last updated + LastUpdated *string `json:"lastUpdated"` + // Created + Created *string `json:"created"` +} + +// Information about current page +type PageInfo struct { + // Cursor for the first result in the page + StartCursor *string `json:"startCursor"` + // Cursor for the last result in the page + EndCursor *string `json:"endCursor"` + // Indicate if there is next page + HasNextPage bool `json:"hasNextPage"` + // Indicate if there is previous page + HasPrevPage bool `json:"hasPrevPage"` +} + +// Pipeline entity +type Pipeline struct { + // Object metadata + Metadata *ObjectMeta `json:"metadata"` + // Errors + Errors []*Error `json:"errors"` + // Entities referencing this entity + ReferencedBy []BaseEntity `json:"referencedBy"` + // Entities referenced by this enitity + References []BaseEntity `json:"references"` + // Projects + Projects []string `json:"projects"` + // Dependencies + Dependencies []*SensorDependency `json:"dependencies"` + // Trigger name + Trigger string `json:"trigger"` +} + +func (Pipeline) IsEntity() {} +func (Pipeline) IsBaseEntity() {} +func (Pipeline) IsProjectBasedEntity() {} + +// Pipeline Edge +type PipelineEdge struct { + // Node contains the actual pipeline data + Node *Pipeline `json:"node"` + // Cursor + Cursor string `json:"cursor"` +} + +func (PipelineEdge) IsEdge() {} + +// Pipeline Page +type PipelinePage struct { + // Total amount of pipelines + TotalCount int `json:"totalCount"` + // Pipeline edges + Edges []*PipelineEdge `json:"edges"` + // Page information + PageInfo *PageInfo `json:"pageInfo"` +} + +func (PipelinePage) IsPage() {} + +// Pipeline Slice +type PipelineSlice struct { + // Pipeline edges + Edges []*PipelineEdge `json:"edges"` + // Slice information + PageInfo *SliceInfo `json:"pageInfo"` +} + +func (PipelineSlice) IsSlice() {} + +// Project entity +type Project struct { + // Project name + Name string `json:"name"` + // Project description + Description *string `json:"description"` +} + +func (Project) IsEntity() {} + +// Project Edge +type ProjectEdge struct { + // Node contains the actual project data + Node *Project `json:"node"` + // Cursor + Cursor string `json:"cursor"` +} + +func (ProjectEdge) IsEdge() {} + +// Project Page +type ProjectPage struct { + // Total amount of Projects + TotalCount int `json:"totalCount"` + // Project edges + Edges []*ProjectEdge `json:"edges"` + // Page information + PageInfo *PageInfo `json:"pageInfo"` +} + +func (ProjectPage) IsPage() {} + +// Project Slice +type ProjectSlice struct { + // Project edges + Edges []*ProjectEdge `json:"edges"` + // Slice information + PageInfo *SliceInfo `json:"pageInfo"` +} + +func (ProjectSlice) IsSlice() {} + +// Resource event +type ResourceEvent struct { + // Name + Name string `json:"name"` + // Group + Group string `json:"group"` + // Version + Version string `json:"version"` + // Kind + Kind string `json:"kind"` + // Namespace + Namespace string `json:"namespace"` +} + +func (ResourceEvent) IsEvent() {} + +// Runtime entity +type Runtime struct { + // Object metadata + Metadata *ObjectMeta `json:"metadata"` + // Errors + Errors []*Error `json:"errors"` + // Entities referencing this entity + ReferencedBy []BaseEntity `json:"referencedBy"` + // Entities referenced by this enitity + References []BaseEntity `json:"references"` + // Version of the entity + Version *int `json:"version"` + // Is this the latest version of this entity + Latest *bool `json:"latest"` + // Entity source + Source *GitopsEntitySource `json:"source"` + // Sync status + SyncStatus SyncStatus `json:"syncStatus"` + // Health status + HealthStatus *HealthStatus `json:"healthStatus"` + // Health message + HealthMessage *string `json:"healthMessage"` + // Desired manifest + DesiredManifest *string `json:"desiredManifest"` + // Actual manifest + ActualManifest *string `json:"actualManifest"` + // Projects + Projects []string `json:"projects"` + // Cluster + Cluster string `json:"cluster"` + // Runtime version + RuntimeVersion string `json:"runtimeVersion"` +} + +func (Runtime) IsEntity() {} +func (Runtime) IsBaseEntity() {} +func (Runtime) IsProjectBasedEntity() {} +func (Runtime) IsGitopsEntity() {} + +// Response for creating a runtime +type RuntimeCreationResponse struct { + // The runtime access token that will be used for requests from the runtime + NewAccessToken string `json:"newAccessToken"` + // The id of the newly created runtime + ID string `json:"id"` +} + +// Runtime Edge +type RuntimeEdge struct { + // Node contains the actual runtime data + Node *Runtime `json:"node"` + // Cursor + Cursor string `json:"cursor"` +} + +func (RuntimeEdge) IsEdge() {} + +// Runtime Page +type RuntimePage struct { + // Total amount of runtimes + TotalCount int `json:"totalCount"` + // Runtime edges + Edges []*RuntimeEdge `json:"edges"` + // Page information + PageInfo *PageInfo `json:"pageInfo"` +} + +func (RuntimePage) IsPage() {} + +// Runtime Slice +type RuntimeSlice struct { + // Runtime edges + Edges []*RuntimeEdge `json:"edges"` + // Slice information + PageInfo *SliceInfo `json:"pageInfo"` +} + +func (RuntimeSlice) IsSlice() {} + +// Sensor entity +type Sensor struct { + // Object metadata + Metadata *ObjectMeta `json:"metadata"` + // Errors + Errors []*Error `json:"errors"` + // Entities referencing this entity + ReferencedBy []BaseEntity `json:"referencedBy"` + // Entities referenced by this enitity + References []BaseEntity `json:"references"` + // Version of the entity + Version *int `json:"version"` + // Is this the latest version of this entity + Latest *bool `json:"latest"` + // Entity source + Source *GitopsEntitySource `json:"source"` + // Sync status + SyncStatus SyncStatus `json:"syncStatus"` + // Health status + HealthStatus *HealthStatus `json:"healthStatus"` + // Health message + HealthMessage *string `json:"healthMessage"` + // Desired manifest + DesiredManifest *string `json:"desiredManifest"` + // Actual manifest + ActualManifest *string `json:"actualManifest"` + // Projects + Projects []string `json:"projects"` + // Dependencies + Dependencies []*SensorDependency `json:"dependencies"` + // Triggers + Triggers []SensorTrigger `json:"triggers"` +} + +func (Sensor) IsEntity() {} +func (Sensor) IsGitopsEntity() {} +func (Sensor) IsBaseEntity() {} +func (Sensor) IsProjectBasedEntity() {} + +// Sensor dependency +type SensorDependency struct { + // Name + Name string `json:"name"` + // EventSource name + EventSource string `json:"eventSource"` + // Event name + Event string `json:"event"` +} + +// Sensor Edge +type SensorEdge struct { + // Node contains the actual sensor data + Node *Sensor `json:"node"` + // Cursor + Cursor string `json:"cursor"` +} + +func (SensorEdge) IsEdge() {} + +// Sensor Page +type SensorPage struct { + // Total amount of sensors + TotalCount int `json:"totalCount"` + // Sensor edges + Edges []*SensorEdge `json:"edges"` + // Page information + PageInfo *PageInfo `json:"pageInfo"` +} + +func (SensorPage) IsPage() {} + +// Sensor Slice +type SensorSlice struct { + // Sensor edges + Edges []*SensorEdge `json:"edges"` + // Slice information + PageInfo *SliceInfo `json:"pageInfo"` +} + +func (SensorSlice) IsSlice() {} + +// Information about current slice +type SliceInfo struct { + // Cursor for the first result in the slice + StartCursor *string `json:"startCursor"` + // Cursor for the last result in the slice + EndCursor *string `json:"endCursor"` + // Indicate if there is next slice + HasNextPage bool `json:"hasNextPage"` + // Indicate if there is previous slice + HasPrevPage bool `json:"hasPrevPage"` +} + +// Pagination arguments to request slice +type SlicePaginationArgs struct { + // Returns workflow templates after the provided cursor + After *string `json:"after"` + // Returns workflow templates before the provided cursor + Before *string `json:"before"` + // Returns the first X workflow templates + First *int `json:"first"` + // Returns the last X workflow templates + Last *int `json:"last"` +} + +// Lable +type StringPair struct { + // Key + Key string `json:"key"` + // Value + Value string `json:"value"` +} + +// "response for request to switch account +type SwitchAccountResponse struct { + // The token to use for the next requests + NewAccessToken *string `json:"newAccessToken"` +} + +// "User Details +type UserDetails struct { + // The user name + Name string `json:"name"` + // User image url + Image *string `json:"image"` +} + +// "User statistics +type UserInfo struct { + // The user name + Name *string `json:"name"` + // Register date + RegisterDate *string `json:"registerDate"` + // Last time user logged in to the system + LastLoginDate *string `json:"lastLoginDate"` +} + +// Workflow entity +type Workflow struct { + // Object metadata + Metadata *ObjectMeta `json:"metadata"` + // Errors + Errors []*Error `json:"errors"` + // Entities referencing this entity + ReferencedBy []BaseEntity `json:"referencedBy"` + // Entities referenced by this enitity + References []BaseEntity `json:"references"` + // Projects + Projects []string `json:"projects"` + // Workflow spec + Spec *WorkflowSpec `json:"spec"` + // Workflow status + Status *WorkflowStatus `json:"status"` +} + +func (Workflow) IsEntity() {} +func (Workflow) IsProjectBasedEntity() {} +func (Workflow) IsBaseEntity() {} + +// Container spec +type WorkflowContainerSpec struct { + // Name + Name string `json:"name"` + // Image + Image string `json:"image"` + // Command + Command []string `json:"command"` + // Args + Args []string `json:"args"` + // Environment variables + Env []*EnvVar `json:"env"` +} + +// Workflow DAG task +type WorkflowDAGTask struct { + // Name + Name string `json:"name"` + // Template to execute + Template WorkflowSpecTemplate `json:"template"` + // Dependencies + Dependencies []string `json:"dependencies"` +} + +// Workflow DAG template +type WorkflowDAGTemplate struct { + // Name + Name string `json:"name"` + // Tasks + Tasks []*WorkflowDAGTask `json:"tasks"` + // Failfast + Failfast *bool `json:"failfast"` +} + +func (WorkflowDAGTemplate) IsWorkflowSpecTemplate() {} + +// Workflow Edge +type WorkflowEdge struct { + // Node contains the actual workflow data + Node *Workflow `json:"node"` + // Cursor + Cursor string `json:"cursor"` +} + +func (WorkflowEdge) IsEdge() {} + +// Workflow Page +type WorkflowPage struct { + // Total amount of workflows + TotalCount int `json:"totalCount"` + // Workflow edges + Edges []*WorkflowEdge `json:"edges"` + // Page information + PageInfo *PageInfo `json:"pageInfo"` +} + +func (WorkflowPage) IsPage() {} + +// Workflow template ref +type WorkflowRefTemplate struct { + // Name + Name string `json:"name"` + // Template reference + Template WorkflowSpecTemplate `json:"template"` +} + +func (WorkflowRefTemplate) IsWorkflowSpecTemplate() {} + +// Workflow Slice +type WorkflowSlice struct { + // Workflow edges + Edges []*WorkflowEdge `json:"edges"` + // Slice information + PageInfo *SliceInfo `json:"pageInfo"` +} + +func (WorkflowSlice) IsSlice() {} + +// Workflow spec +type WorkflowSpec struct { + // Entrypoint + Entrypoint string `json:"entrypoint"` + // Templates + Templates []WorkflowSpecTemplate `json:"templates"` +} + +// Workflow standard template +type WorkflowStandardTemplate struct { + // Name + Name string `json:"name"` + // Daemon + Daemon *bool `json:"daemon"` + // Container to run for this template + Container *WorkflowContainerSpec `json:"container"` +} + +func (WorkflowStandardTemplate) IsWorkflowSpecTemplate() {} + +// Workflow status +type WorkflowStatus struct { + // Creation time + CreatedAt string `json:"createdAt"` + // Start time + StartedAt *string `json:"startedAt"` + // Finish time + FinishedAt *string `json:"finishedAt"` + // Current workflow phase + Phase WorkflowPhases `json:"phase"` + // Message + Message *string `json:"message"` + // Previous statuses + Statuses []*WorkflowStatusHistoryItem `json:"statuses"` +} + +// Workflow status history item +type WorkflowStatusHistoryItem struct { + // The time the status started + Since string `json:"since"` + // Phase + Phase WorkflowPhases `json:"phase"` + // Message + Message *string `json:"message"` +} + +// Workflow step +type WorkflowStep struct { + // Name + Name string `json:"name"` + // Template to execute + Template WorkflowSpecTemplate `json:"template"` +} + +// Workflow steps template +type WorkflowStepsTemplate struct { + // Name + Name string `json:"name"` + // Steps + Steps [][]*WorkflowStep `json:"steps"` +} + +func (WorkflowStepsTemplate) IsWorkflowSpecTemplate() {} + +// Workflow template entity +type WorkflowTemplate struct { + // Object metadata + Metadata *ObjectMeta `json:"metadata"` + // Errors + Errors []*Error `json:"errors"` + // Entities referencing this entity + ReferencedBy []BaseEntity `json:"referencedBy"` + // Entities referenced by this enitity + References []BaseEntity `json:"references"` + // Version of the entity + Version *int `json:"version"` + // Is this the latest version of this entity + Latest *bool `json:"latest"` + // Entity source + Source *GitopsEntitySource `json:"source"` + // Sync status + SyncStatus SyncStatus `json:"syncStatus"` + // Health status + HealthStatus *HealthStatus `json:"healthStatus"` + // Health message + HealthMessage *string `json:"healthMessage"` + // Desired manifest + DesiredManifest *string `json:"desiredManifest"` + // Actual manifest + ActualManifest *string `json:"actualManifest"` + // Projects + Projects []string `json:"projects"` + // Workflow spec + Workflow *WorkflowSpec `json:"workflow"` +} + +func (WorkflowTemplate) IsEntity() {} +func (WorkflowTemplate) IsGitopsEntity() {} +func (WorkflowTemplate) IsBaseEntity() {} +func (WorkflowTemplate) IsProjectBasedEntity() {} + +// Workflow template Edge +type WorkflowTemplateEdge struct { + // Node contains the actual workflow template data + Node *WorkflowTemplate `json:"node"` + // Cursor + Cursor string `json:"cursor"` +} + +func (WorkflowTemplateEdge) IsEdge() {} + +// WorkflowTemplate Page +type WorkflowTemplatePage struct { + // Total amount of workflow templates + TotalCount int `json:"totalCount"` + // Workflow template edges + Edges []*WorkflowTemplateEdge `json:"edges"` + // Page information + PageInfo *PageInfo `json:"pageInfo"` +} + +func (WorkflowTemplatePage) IsPage() {} + +// WorkflowTemplate Slice +type WorkflowTemplateSlice struct { + // Workflow template edges + Edges []*WorkflowTemplateEdge `json:"edges"` + // Slice information + PageInfo *SliceInfo `json:"pageInfo"` +} + +func (WorkflowTemplateSlice) IsSlice() {} + +// Http Trigger +type WorkflowTrigger struct { + // Name + Name string `json:"name"` + // Conditions + Conditions string `json:"conditions"` + // Workflow manifest + Workflow string `json:"workflow"` + // Operation + Op WorkflowTriggerOperation `json:"op"` +} + +func (WorkflowTrigger) IsSensorTrigger() {} + +// Error types +type ErrorTypes string + +const ( + // Permission error + ErrorTypesPermission ErrorTypes = "PERMISSION" + // Syntax error + ErrorTypesSyntax ErrorTypes = "SYNTAX" +) + +var AllErrorTypes = []ErrorTypes{ + ErrorTypesPermission, + ErrorTypesSyntax, +} + +func (e ErrorTypes) IsValid() bool { + switch e { + case ErrorTypesPermission, ErrorTypesSyntax: + return true + } + return false +} + +func (e ErrorTypes) String() string { + return string(e) +} + +func (e *ErrorTypes) UnmarshalGQL(v interface{}) error { + str, ok := v.(string) + if !ok { + return fmt.Errorf("enums must be strings") + } + + *e = ErrorTypes(str) + if !e.IsValid() { + return fmt.Errorf("%s is not a valid ErrorTypes", str) + } + return nil +} + +func (e ErrorTypes) MarshalGQL(w io.Writer) { + fmt.Fprint(w, strconv.Quote(e.String())) +} + +// EventName +type EventName string + +const ( + EventNameKeepAlive EventName = "KEEP_ALIVE" + EventNameTestEventA EventName = "TEST_EVENT_A" + EventNameTestEventB EventName = "TEST_EVENT_B" +) + +var AllEventName = []EventName{ + EventNameKeepAlive, + EventNameTestEventA, + EventNameTestEventB, +} + +func (e EventName) IsValid() bool { + switch e { + case EventNameKeepAlive, EventNameTestEventA, EventNameTestEventB: + return true + } + return false +} + +func (e EventName) String() string { + return string(e) +} + +func (e *EventName) UnmarshalGQL(v interface{}) error { + str, ok := v.(string) + if !ok { + return fmt.Errorf("enums must be strings") + } + + *e = EventName(str) + if !e.IsValid() { + return fmt.Errorf("%s is not a valid EventName", str) + } + return nil +} + +func (e EventName) MarshalGQL(w io.Writer) { + fmt.Fprint(w, strconv.Quote(e.String())) +} + +// Git Providers +type GitProviders string + +const ( + // Github + GitProvidersGithub GitProviders = "GITHUB" + // Gitlab + GitProvidersGitlab GitProviders = "GITLAB" +) + +var AllGitProviders = []GitProviders{ + GitProvidersGithub, + GitProvidersGitlab, +} + +func (e GitProviders) IsValid() bool { + switch e { + case GitProvidersGithub, GitProvidersGitlab: + return true + } + return false +} + +func (e GitProviders) String() string { + return string(e) +} + +func (e *GitProviders) UnmarshalGQL(v interface{}) error { + str, ok := v.(string) + if !ok { + return fmt.Errorf("enums must be strings") + } + + *e = GitProviders(str) + if !e.IsValid() { + return fmt.Errorf("%s is not a valid GitProviders", str) + } + return nil +} + +func (e GitProviders) MarshalGQL(w io.Writer) { + fmt.Fprint(w, strconv.Quote(e.String())) +} + +// Health Status +type HealthStatus string + +const ( + // resource status indicates failure + HealthStatusDegraded HealthStatus = "DEGRADED" + // resource is healthy + HealthStatusHealthy HealthStatus = "HEALTHY" + // resource is missing from the cluster + HealthStatusMissing HealthStatus = "MISSING" + // resource not yet healthy but has a chance to become healthy + HealthStatusProgressing HealthStatus = "PROGRESSING" + // resource is suspended (for example: cronjob) + HealthStatusSuspended HealthStatus = "SUSPENDED" + // health assessment failed + HealthStatusUnknown HealthStatus = "UNKNOWN" +) + +var AllHealthStatus = []HealthStatus{ + HealthStatusDegraded, + HealthStatusHealthy, + HealthStatusMissing, + HealthStatusProgressing, + HealthStatusSuspended, + HealthStatusUnknown, +} + +func (e HealthStatus) IsValid() bool { + switch e { + case HealthStatusDegraded, HealthStatusHealthy, HealthStatusMissing, HealthStatusProgressing, HealthStatusSuspended, HealthStatusUnknown: + return true + } + return false +} + +func (e HealthStatus) String() string { + return string(e) +} + +func (e *HealthStatus) UnmarshalGQL(v interface{}) error { + str, ok := v.(string) + if !ok { + return fmt.Errorf("enums must be strings") + } + + *e = HealthStatus(str) + if !e.IsValid() { + return fmt.Errorf("%s is not a valid HealthStatus", str) + } + return nil +} + +func (e HealthStatus) MarshalGQL(w io.Writer) { + fmt.Fprint(w, strconv.Quote(e.String())) +} + +// Sync status +type SyncStatus string + +const ( + // Out of sync + SyncStatusOutOfSync SyncStatus = "OUT_OF_SYNC" + // Synced + SyncStatusSynced SyncStatus = "SYNCED" + // Unknown + SyncStatusUnknown SyncStatus = "UNKNOWN" +) + +var AllSyncStatus = []SyncStatus{ + SyncStatusOutOfSync, + SyncStatusSynced, + SyncStatusUnknown, +} + +func (e SyncStatus) IsValid() bool { + switch e { + case SyncStatusOutOfSync, SyncStatusSynced, SyncStatusUnknown: + return true + } + return false +} + +func (e SyncStatus) String() string { + return string(e) +} + +func (e *SyncStatus) UnmarshalGQL(v interface{}) error { + str, ok := v.(string) + if !ok { + return fmt.Errorf("enums must be strings") + } + + *e = SyncStatus(str) + if !e.IsValid() { + return fmt.Errorf("%s is not a valid SyncStatus", str) + } + return nil +} + +func (e SyncStatus) MarshalGQL(w io.Writer) { + fmt.Fprint(w, strconv.Quote(e.String())) +} + +// "User role provide specific permission for the current user +type UserRole string + +const ( + // Account Admin role can control codefresh + UserRoleAccountAdmin UserRole = "ACCOUNT_ADMIN" + // Admin role can control the entire system + UserRoleAdmin UserRole = "ADMIN" + // Regular user can do basic operations the current account + UserRoleUser UserRole = "USER" +) + +var AllUserRole = []UserRole{ + UserRoleAccountAdmin, + UserRoleAdmin, + UserRoleUser, +} + +func (e UserRole) IsValid() bool { + switch e { + case UserRoleAccountAdmin, UserRoleAdmin, UserRoleUser: + return true + } + return false +} + +func (e UserRole) String() string { + return string(e) +} + +func (e *UserRole) UnmarshalGQL(v interface{}) error { + str, ok := v.(string) + if !ok { + return fmt.Errorf("enums must be strings") + } + + *e = UserRole(str) + if !e.IsValid() { + return fmt.Errorf("%s is not a valid UserRole", str) + } + return nil +} + +func (e UserRole) MarshalGQL(w io.Writer) { + fmt.Fprint(w, strconv.Quote(e.String())) +} + +// "User status active or disable +type UserStatus string + +const ( + // New user + UserStatusNew UserStatus = "NEW" + // Pending user + UserStatusPending UserStatus = "PENDING" + // Suspended + UserStatusSuspended UserStatus = "SUSPENDED" + // Unverifed user + UserStatusUnverifed UserStatus = "UNVERIFED" +) + +var AllUserStatus = []UserStatus{ + UserStatusNew, + UserStatusPending, + UserStatusSuspended, + UserStatusUnverifed, +} + +func (e UserStatus) IsValid() bool { + switch e { + case UserStatusNew, UserStatusPending, UserStatusSuspended, UserStatusUnverifed: + return true + } + return false +} + +func (e UserStatus) String() string { + return string(e) +} + +func (e *UserStatus) UnmarshalGQL(v interface{}) error { + str, ok := v.(string) + if !ok { + return fmt.Errorf("enums must be strings") + } + + *e = UserStatus(str) + if !e.IsValid() { + return fmt.Errorf("%s is not a valid UserStatus", str) + } + return nil +} + +func (e UserStatus) MarshalGQL(w io.Writer) { + fmt.Fprint(w, strconv.Quote(e.String())) +} + +// Workflow phases +type WorkflowPhases string + +const ( + // Error + WorkflowPhasesError WorkflowPhases = "ERROR" + // Failed + WorkflowPhasesFailed WorkflowPhases = "FAILED" + // Pending + WorkflowPhasesPending WorkflowPhases = "PENDING" + // Running + WorkflowPhasesRunning WorkflowPhases = "RUNNING" + // Succeeded + WorkflowPhasesSucceeded WorkflowPhases = "SUCCEEDED" + // Terminated + WorkflowPhasesTerminated WorkflowPhases = "TERMINATED" +) + +var AllWorkflowPhases = []WorkflowPhases{ + WorkflowPhasesError, + WorkflowPhasesFailed, + WorkflowPhasesPending, + WorkflowPhasesRunning, + WorkflowPhasesSucceeded, + WorkflowPhasesTerminated, +} + +func (e WorkflowPhases) IsValid() bool { + switch e { + case WorkflowPhasesError, WorkflowPhasesFailed, WorkflowPhasesPending, WorkflowPhasesRunning, WorkflowPhasesSucceeded, WorkflowPhasesTerminated: + return true + } + return false +} + +func (e WorkflowPhases) String() string { + return string(e) +} + +func (e *WorkflowPhases) UnmarshalGQL(v interface{}) error { + str, ok := v.(string) + if !ok { + return fmt.Errorf("enums must be strings") + } + + *e = WorkflowPhases(str) + if !e.IsValid() { + return fmt.Errorf("%s is not a valid WorkflowPhases", str) + } + return nil +} + +func (e WorkflowPhases) MarshalGQL(w io.Writer) { + fmt.Fprint(w, strconv.Quote(e.String())) +} + +// Workflow Trigger Operation +type WorkflowTriggerOperation string + +const ( + // Resubmit + WorkflowTriggerOperationResubmit WorkflowTriggerOperation = "RESUBMIT" + // Resume + WorkflowTriggerOperationResume WorkflowTriggerOperation = "RESUME" + // Retry + WorkflowTriggerOperationRetry WorkflowTriggerOperation = "RETRY" + // Submit + WorkflowTriggerOperationSubmit WorkflowTriggerOperation = "SUBMIT" + // Suspend + WorkflowTriggerOperationSuspend WorkflowTriggerOperation = "SUSPEND" + // Terminate + WorkflowTriggerOperationTerminate WorkflowTriggerOperation = "TERMINATE" +) + +var AllWorkflowTriggerOperation = []WorkflowTriggerOperation{ + WorkflowTriggerOperationResubmit, + WorkflowTriggerOperationResume, + WorkflowTriggerOperationRetry, + WorkflowTriggerOperationSubmit, + WorkflowTriggerOperationSuspend, + WorkflowTriggerOperationTerminate, +} + +func (e WorkflowTriggerOperation) IsValid() bool { + switch e { + case WorkflowTriggerOperationResubmit, WorkflowTriggerOperationResume, WorkflowTriggerOperationRetry, WorkflowTriggerOperationSubmit, WorkflowTriggerOperationSuspend, WorkflowTriggerOperationTerminate: + return true + } + return false +} + +func (e WorkflowTriggerOperation) String() string { + return string(e) +} + +func (e *WorkflowTriggerOperation) UnmarshalGQL(v interface{}) error { + str, ok := v.(string) + if !ok { + return fmt.Errorf("enums must be strings") + } + + *e = WorkflowTriggerOperation(str) + if !e.IsValid() { + return fmt.Errorf("%s is not a valid WorkflowTriggerOperation", str) + } + return nil +} + +func (e WorkflowTriggerOperation) MarshalGQL(w io.Writer) { + fmt.Fprint(w, strconv.Quote(e.String())) +} From 2226ec14a7e8399124598d71e12f658dd714ef37 Mon Sep 17 00:00:00 2001 From: Noam Gal Date: Thu, 29 Jul 2021 09:04:12 +0300 Subject: [PATCH 52/81] bumped version to 0.29.0 --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index 697f087..ae6dd4e 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.28.0 +0.29.0 From afc8e960bf327af5755a69497b2698c99fda3546 Mon Sep 17 00:00:00 2001 From: Noam Gal Date: Thu, 29 Jul 2021 10:31:53 +0300 Subject: [PATCH 53/81] release always with "v" --- VERSION | 2 +- codefresh.yaml | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/VERSION b/VERSION index ae6dd4e..c25c8e5 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.29.0 +0.30.0 diff --git a/codefresh.yaml b/codefresh.yaml index bde7389..406005b 100644 --- a/codefresh.yaml +++ b/codefresh.yaml @@ -20,6 +20,7 @@ steps: stage: Release commands: - export VERSION=$(cat VERSION) + - VERSION=$(if [[ ${VERSION:0:1} == "v" ]] ; then echo $VERSION; else echo "v${VERSION}"; fi ) - gh release create --repo ${{CF_REPO_OWNER}}/${{CF_REPO_NAME}} -t $VERSION -n $VERSION $VERSION when: branch: From cd4b4c42069ccbbff0a48578649495afa8b335b3 Mon Sep 17 00:00:00 2001 From: elad-codefresh Date: Thu, 29 Jul 2021 12:32:03 +0300 Subject: [PATCH 54/81] removed id in Create function mutation --- pkg/codefresh/argo_runtime.go | 1 - 1 file changed, 1 deletion(-) diff --git a/pkg/codefresh/argo_runtime.go b/pkg/codefresh/argo_runtime.go index e18448a..92dca28 100644 --- a/pkg/codefresh/argo_runtime.go +++ b/pkg/codefresh/argo_runtime.go @@ -38,7 +38,6 @@ func newArgoRuntimeAPI(codefresh *codefresh) IArgoRuntimeAPI { func (r *argoRuntime) Create(runtimeName string) (*model.RuntimeCreationResponse, error) { interpolatedMutation := fmt.Sprintf(`mutation { runtime(name: "%s") { - id newAccessToken } } From 4f690779aaa95f2612d5a6c7eba50a73fdd58944 Mon Sep 17 00:00:00 2001 From: elad-codefresh Date: Thu, 29 Jul 2021 12:32:44 +0300 Subject: [PATCH 55/81] bump --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index c25c8e5..c173e42 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.30.0 +v0.30.1 From d12867f7fb34a85101d708a0c4042f98b9b66ea2 Mon Sep 17 00:00:00 2001 From: elad-codefresh Date: Fri, 30 Jul 2021 00:37:08 +0300 Subject: [PATCH 56/81] make sure models_gen.go is updated by real generation and not manually --- pkg/codefresh/argo_runtime.go | 21 +++++++++++++-------- pkg/codefresh/model/models_gen.go | 2 +- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/pkg/codefresh/argo_runtime.go b/pkg/codefresh/argo_runtime.go index 92dca28..dc07bf6 100644 --- a/pkg/codefresh/argo_runtime.go +++ b/pkg/codefresh/argo_runtime.go @@ -36,15 +36,16 @@ func newArgoRuntimeAPI(codefresh *codefresh) IArgoRuntimeAPI { } func (r *argoRuntime) Create(runtimeName string) (*model.RuntimeCreationResponse, error) { - interpolatedMutation := fmt.Sprintf(`mutation { - runtime(name: "%s") { - newAccessToken - } - } - `, runtimeName) - jsonData := map[string]interface{}{ - "query": interpolatedMutation, + "query": `mutation CreateRuntime($name: String!) { + runtime(name: $name) { + name + newAccessToken + } + }`, + "variables": map[string]string{ + "name": runtimeName, + }, } response, err := r.codefresh.requestAPI(&requestOptions{ @@ -79,6 +80,10 @@ func (r *argoRuntime) Create(runtimeName string) (*model.RuntimeCreationResponse return &res.Data.Runtime, nil } +// func GetRuntimeName(runtimeName string) string { +// return runtimeName +// } + func (r *argoRuntime) List() ([]model.Runtime, error) { jsonData := map[string]interface{}{ "query": ` diff --git a/pkg/codefresh/model/models_gen.go b/pkg/codefresh/model/models_gen.go index 31bc6df..5e5826b 100644 --- a/pkg/codefresh/model/models_gen.go +++ b/pkg/codefresh/model/models_gen.go @@ -641,7 +641,7 @@ type RuntimeCreationResponse struct { // The runtime access token that will be used for requests from the runtime NewAccessToken string `json:"newAccessToken"` // The id of the newly created runtime - ID string `json:"id"` + Name string `json:"id"` } // Runtime Edge From 81758d5f3c87a6b2018fe70fe07933880b1fc314 Mon Sep 17 00:00:00 2001 From: elad-codefresh Date: Fri, 30 Jul 2021 00:42:33 +0300 Subject: [PATCH 57/81] removed comment --- pkg/codefresh/argo_runtime.go | 4 ---- 1 file changed, 4 deletions(-) diff --git a/pkg/codefresh/argo_runtime.go b/pkg/codefresh/argo_runtime.go index dc07bf6..19faeeb 100644 --- a/pkg/codefresh/argo_runtime.go +++ b/pkg/codefresh/argo_runtime.go @@ -80,10 +80,6 @@ func (r *argoRuntime) Create(runtimeName string) (*model.RuntimeCreationResponse return &res.Data.Runtime, nil } -// func GetRuntimeName(runtimeName string) string { -// return runtimeName -// } - func (r *argoRuntime) List() ([]model.Runtime, error) { jsonData := map[string]interface{}{ "query": ` From af45f3ee5ffdf26de9f457f2c85a234a38f825db Mon Sep 17 00:00:00 2001 From: elad-codefresh Date: Tue, 3 Aug 2021 15:33:58 +0300 Subject: [PATCH 58/81] models_gen.go copy paste --- pkg/codefresh/model/models_gen.go | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/pkg/codefresh/model/models_gen.go b/pkg/codefresh/model/models_gen.go index 5e5826b..5c04aac 100644 --- a/pkg/codefresh/model/models_gen.go +++ b/pkg/codefresh/model/models_gen.go @@ -77,6 +77,22 @@ type APIToken struct { Token *string `json:"token"` } +// Cluster +type Cluster struct { + // Name + Name string `json:"name"` + // Address + Address string `json:"address"` +} + +// Mutation root +type ClusterInput struct { + // Name + Name string `json:"name"` + // Address + Address string `json:"address"` +} + // Component entity type Component struct { // Object metadata @@ -581,6 +597,12 @@ type ProjectSlice struct { func (ProjectSlice) IsSlice() {} +// Release Entity +type Release struct { + // Release version + Version string `json:"version"` +} + // Resource event type ResourceEvent struct { // Name @@ -626,7 +648,7 @@ type Runtime struct { // Projects Projects []string `json:"projects"` // Cluster - Cluster string `json:"cluster"` + Cluster *Cluster `json:"cluster"` // Runtime version RuntimeVersion string `json:"runtimeVersion"` } @@ -640,8 +662,8 @@ func (Runtime) IsGitopsEntity() {} type RuntimeCreationResponse struct { // The runtime access token that will be used for requests from the runtime NewAccessToken string `json:"newAccessToken"` - // The id of the newly created runtime - Name string `json:"id"` + // The name of the newly created runtime + Name string `json:"name"` } // Runtime Edge From a9be8596e2b44b950bb071f9dd6afac4e3c995ba Mon Sep 17 00:00:00 2001 From: elad-codefresh Date: Tue, 3 Aug 2021 15:34:19 +0300 Subject: [PATCH 59/81] bump --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index c173e42..d1b3cf0 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -v0.30.1 +v0.30.2 From 2cfa4893ec346086bd06c06734fefe7759d5b37f Mon Sep 17 00:00:00 2001 From: elad-codefresh Date: Tue, 3 Aug 2021 17:36:47 +0300 Subject: [PATCH 60/81] update --- pkg/codefresh/argo_runtime.go | 14 ++++++++------ pkg/codefresh/model/models_gen.go | 18 +----------------- 2 files changed, 9 insertions(+), 23 deletions(-) diff --git a/pkg/codefresh/argo_runtime.go b/pkg/codefresh/argo_runtime.go index 19faeeb..78509f8 100644 --- a/pkg/codefresh/argo_runtime.go +++ b/pkg/codefresh/argo_runtime.go @@ -11,7 +11,7 @@ import ( type ( IArgoRuntimeAPI interface { List() ([]model.Runtime, error) - Create(runtimeName string) (*model.RuntimeCreationResponse, error) + Create(runtimeName, cluster, runtimeVersion string) (*model.RuntimeCreationResponse, error) } argoRuntime struct { codefresh *codefresh @@ -35,16 +35,18 @@ func newArgoRuntimeAPI(codefresh *codefresh) IArgoRuntimeAPI { return &argoRuntime{codefresh: codefresh} } -func (r *argoRuntime) Create(runtimeName string) (*model.RuntimeCreationResponse, error) { +func (r *argoRuntime) Create(runtimeName, cluster, runtimeVersion string) (*model.RuntimeCreationResponse, error) { jsonData := map[string]interface{}{ - "query": `mutation CreateRuntime($name: String!) { - runtime(name: $name) { + "query": `mutation CreateRuntime($name: String!, $cluster: String!, $runtimeVersion: String!) { + runtime(name: $name, cluster: $cluster, runtimeVersion: $runtimeVersion) { name newAccessToken } }`, - "variables": map[string]string{ - "name": runtimeName, + "variables": map[string]interface{}{ + "name": runtimeName, + "cluster": cluster, + "runtimeVersion": runtimeVersion, }, } diff --git a/pkg/codefresh/model/models_gen.go b/pkg/codefresh/model/models_gen.go index 5c04aac..0432443 100644 --- a/pkg/codefresh/model/models_gen.go +++ b/pkg/codefresh/model/models_gen.go @@ -77,22 +77,6 @@ type APIToken struct { Token *string `json:"token"` } -// Cluster -type Cluster struct { - // Name - Name string `json:"name"` - // Address - Address string `json:"address"` -} - -// Mutation root -type ClusterInput struct { - // Name - Name string `json:"name"` - // Address - Address string `json:"address"` -} - // Component entity type Component struct { // Object metadata @@ -648,7 +632,7 @@ type Runtime struct { // Projects Projects []string `json:"projects"` // Cluster - Cluster *Cluster `json:"cluster"` + Cluster string `json:"cluster"` // Runtime version RuntimeVersion string `json:"runtimeVersion"` } From 79a42170f9681107b5b5006d5cc1daa53c5749ba Mon Sep 17 00:00:00 2001 From: cf-ci-bot Date: Sun, 15 Aug 2021 17:26:56 +0000 Subject: [PATCH 61/81] updated model --- VERSION | 2 +- pkg/codefresh/model/models_gen.go | 648 ++++++++++++++++++++---------- 2 files changed, 442 insertions(+), 208 deletions(-) diff --git a/VERSION b/VERSION index d1b3cf0..e8262eb 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -v0.30.2 +0.30.3 diff --git a/pkg/codefresh/model/models_gen.go b/pkg/codefresh/model/models_gen.go index 0432443..8c4653b 100644 --- a/pkg/codefresh/model/models_gen.go +++ b/pkg/codefresh/model/models_gen.go @@ -33,11 +33,26 @@ type Event interface { IsEvent() } +// Event payload data types +type EventPayloadData interface { + IsEventPayloadData() +} + // Gitops entity type GitopsEntity interface { IsGitopsEntity() } +// K8s logic entity +type K8sLogicEntity interface { + IsK8sLogicEntity() +} + +// Base entity +type K8sStandardEntity interface { + IsK8sStandardEntity() +} + // Page type Page interface { IsPage() @@ -48,6 +63,11 @@ type ProjectBasedEntity interface { IsProjectBasedEntity() } +// EventName +type PushPayload interface { + IsPushPayload() +} + // Sensor trigger type SensorTrigger interface { IsSensorTrigger() @@ -77,8 +97,75 @@ type APIToken struct { Token *string `json:"token"` } -// Component entity -type Component struct { +// AppProject entity +type AppProject struct { + // Object metadata + Metadata *ObjectMeta `json:"metadata"` + // Errors + Errors []*Error `json:"errors"` + // Entities referencing this entity + ReferencedBy []BaseEntity `json:"referencedBy"` + // Entities referenced by this enitity + References []BaseEntity `json:"references"` + // Version of the entity + Version *int `json:"version"` + // Is this the latest version of this entity + Latest *bool `json:"latest"` + // Entity source + Source *GitopsEntitySource `json:"source"` + // Sync status + SyncStatus SyncStatus `json:"syncStatus"` + // Health status + HealthStatus *HealthStatus `json:"healthStatus"` + // Health message + HealthMessage *string `json:"healthMessage"` + // Desired manifest + DesiredManifest *string `json:"desiredManifest"` + // Actual manifest + ActualManifest *string `json:"actualManifest"` + // Projects + Projects []string `json:"projects"` +} + +func (AppProject) IsGitopsEntity() {} +func (AppProject) IsBaseEntity() {} +func (AppProject) IsProjectBasedEntity() {} +func (AppProject) IsEntity() {} + +// AppProject Edge +type AppProjectEdge struct { + // Node contains the actual app-project data + Node *AppProject `json:"node"` + // Cursor + Cursor string `json:"cursor"` +} + +func (AppProjectEdge) IsEdge() {} + +// AppProject Page +type AppProjectPage struct { + // Total amount of app-projects + TotalCount int `json:"totalCount"` + // App project edges + Edges []*AppProjectEdge `json:"edges"` + // Page information + PageInfo *PageInfo `json:"pageInfo"` +} + +func (AppProjectPage) IsPage() {} + +// AppProject Slice +type AppProjectSlice struct { + // AppProject edges + Edges []*AppProjectEdge `json:"edges"` + // Slice information + PageInfo *SliceInfo `json:"pageInfo"` +} + +func (AppProjectSlice) IsSlice() {} + +// Application entity +type Application struct { // Object metadata Metadata *ObjectMeta `json:"metadata"` // Errors @@ -107,8 +194,77 @@ type Component struct { Projects []string `json:"projects"` } +func (Application) IsGitopsEntity() {} +func (Application) IsBaseEntity() {} +func (Application) IsProjectBasedEntity() {} +func (Application) IsEntity() {} + +// Application Edge +type ApplicationEdge struct { + // Node contains the actual application data + Node *Application `json:"node"` + // Cursor + Cursor string `json:"cursor"` +} + +func (ApplicationEdge) IsEdge() {} + +// Application Page +type ApplicationPage struct { + // Total amount of applications + TotalCount int `json:"totalCount"` + // Application edges + Edges []*ApplicationEdge `json:"edges"` + // Page information + PageInfo *PageInfo `json:"pageInfo"` +} + +func (ApplicationPage) IsPage() {} + +// Application Slice +type ApplicationSlice struct { + // Application edges + Edges []*ApplicationEdge `json:"edges"` + // Slice information + PageInfo *SliceInfo `json:"pageInfo"` +} + +func (ApplicationSlice) IsSlice() {} + +// Calendar event payload data +type CalendarEventPayloadData struct { + // Type + Type string `json:"type"` + // Repository + Schedule string `json:"schedule"` + // EventType + Interval string `json:"interval"` + // Branch + Timezone string `json:"timezone"` + // Initiator + Metadata string `json:"metadata"` +} + +func (CalendarEventPayloadData) IsEventPayloadData() {} + +// Component entity +type Component struct { + // Object metadata + Metadata *ObjectMeta `json:"metadata"` + // Errors + Errors []*Error `json:"errors"` + // Entities referencing this entity + ReferencedBy []BaseEntity `json:"referencedBy"` + // Entities referenced by this enitity + References []BaseEntity `json:"references"` + // Self entity reference for the real k8s entity in case of codefresh logical entity + Self *AppProject `json:"self"` + // Projects + Projects []string `json:"projects"` +} + func (Component) IsBaseEntity() {} -func (Component) IsGitopsEntity() {} +func (Component) IsK8sLogicEntity() {} func (Component) IsProjectBasedEntity() {} func (Component) IsEntity() {} @@ -144,14 +300,6 @@ type ComponentSlice struct { func (ComponentSlice) IsSlice() {} -// Environment Variable -type EnvVar struct { - // Name - Name string `json:"name"` - // Value - Value string `json:"value"` -} - // Error type Error struct { // Type @@ -166,6 +314,78 @@ type Error struct { Suggestion *string `json:"suggestion"` } +// Remove this later +type EventB struct { + // Name of event + Name *string `json:"name"` +} + +func (EventB) IsPushPayload() {} + +// Event payload entity +type EventPayload struct { + // UID of event + UID *string `json:"uid"` + // Content of the event + Data *string `json:"data"` + // Time + Time *string `json:"time"` + // Event source + EventSource *EventSource `json:"eventSource"` + // Event name + EventName *string `json:"eventName"` + // Event type + EventType *string `json:"eventType"` + // Account + Account *string `json:"account"` + // Runtime + Runtime *string `json:"runtime"` +} + +func (EventPayload) IsEntity() {} + +// EventPayload Edge +type EventPayloadEdge struct { + // Node contains the actual event payload data + Node *EventPayload `json:"node"` + // Cursor + Cursor string `json:"cursor"` +} + +func (EventPayloadEdge) IsEdge() {} + +// EventPayload Page +type EventPayloadPage struct { + // Total amount of EventPayload + TotalCount int `json:"totalCount"` + // EventPayload edges + Edges []*EventPayloadEdge `json:"edges"` + // Page information + PageInfo *PageInfo `json:"pageInfo"` +} + +func (EventPayloadPage) IsPage() {} + +// EventPayload Slice +type EventPayloadSlice struct { + // EventPayload edges + Edges []*EventPayloadEdge `json:"edges"` + // Slice information + PageInfo *SliceInfo `json:"pageInfo"` +} + +func (EventPayloadSlice) IsSlice() {} + +// EventResponse +type EventResponse struct { + // Account ID + AccountID string `json:"accountId"` + // Time of event + Time string `json:"time"` + // Payload of event + Payload PushPayload `json:"payload"` +} + // Event source entity type EventSource struct { // Object metadata @@ -194,10 +414,6 @@ type EventSource struct { ActualManifest *string `json:"actualManifest"` // Projects Projects []string `json:"projects"` - // Eventbus - Eventbus string `json:"eventbus"` - // Events - Events []Event `json:"events"` } func (EventSource) IsBaseEntity() {} @@ -237,16 +453,24 @@ type EventSourceSlice struct { func (EventSourceSlice) IsSlice() {} -// EventResponse -type EventsResponse struct { - // Name of event - Name EventName `json:"name"` - // Payload of event - Payload *string `json:"payload"` - // Time of event - Time string `json:"time"` +// Git event payload data +type GitEventPayloadData struct { + // Type + Type string `json:"type"` + // Repository + Repository string `json:"repository"` + // EventType + EventType string `json:"eventType"` + // Branch + Branch string `json:"branch"` + // Initiator + Initiator string `json:"initiator"` + // Commit data + Commit *string `json:"commit"` } +func (GitEventPayloadData) IsEventPayloadData() {} + // Git integration entity type GitIntegration struct { // Object metadata @@ -328,27 +552,13 @@ type GitSource struct { ReferencedBy []BaseEntity `json:"referencedBy"` // Entities referenced by this enitity References []BaseEntity `json:"references"` - // Version of the entity - Version *int `json:"version"` - // Is this the latest version of this entity - Latest *bool `json:"latest"` - // Entity source - Source *GitopsEntitySource `json:"source"` - // Sync status - SyncStatus SyncStatus `json:"syncStatus"` - // Health status - HealthStatus *HealthStatus `json:"healthStatus"` - // Health message - HealthMessage *string `json:"healthMessage"` - // Desired manifest - DesiredManifest *string `json:"desiredManifest"` - // Actual manifest - ActualManifest *string `json:"actualManifest"` + // Self entity reference for the real k8s entity in case of codefresh logical entity + Self *AppProject `json:"self"` // Projects Projects []string `json:"projects"` } -func (GitSource) IsGitopsEntity() {} +func (GitSource) IsK8sLogicEntity() {} func (GitSource) IsBaseEntity() {} func (GitSource) IsProjectBasedEntity() {} func (GitSource) IsEntity() {} @@ -445,6 +655,34 @@ type Me struct { Info *UserInfo `json:"info"` } +// Node status +type NodeStatus struct { + // Type + Type string `json:"type"` + // Name + Name string `json:"name"` + // Display name + DisplayName string `json:"displayName"` + // Template Name + TemplateName string `json:"templateName"` + // Node children + Children []*string `json:"children"` + // Current step phase + Phase *Phases `json:"phase"` + // Progress + Progress *Progress `json:"progress"` + // Message + Message *string `json:"message"` + // Start time + StartedAt *string `json:"startedAt"` + // Finish time + FinishedAt *string `json:"finishedAt"` + // Inputs + Inputs *string `json:"inputs"` + // Previous statuses + Statuses []*StatusHistoryItem `json:"statuses"` +} + // Object metadata type ObjectMeta struct { // Group @@ -495,6 +733,8 @@ type Pipeline struct { ReferencedBy []BaseEntity `json:"referencedBy"` // Entities referenced by this enitity References []BaseEntity `json:"references"` + // Self entity reference for the real k8s entity in case of codefresh logical entity + Self *Sensor `json:"self"` // Projects Projects []string `json:"projects"` // Dependencies @@ -503,9 +743,10 @@ type Pipeline struct { Trigger string `json:"trigger"` } -func (Pipeline) IsEntity() {} func (Pipeline) IsBaseEntity() {} +func (Pipeline) IsK8sLogicEntity() {} func (Pipeline) IsProjectBasedEntity() {} +func (Pipeline) IsEntity() {} // Pipeline Edge type PipelineEdge struct { @@ -539,6 +780,14 @@ type PipelineSlice struct { func (PipelineSlice) IsSlice() {} +// Progress +type Progress struct { + // Total + Total *int `json:"total"` + // Done + Done *int `json:"done"` +} + // Project entity type Project struct { // Project name @@ -613,34 +862,20 @@ type Runtime struct { ReferencedBy []BaseEntity `json:"referencedBy"` // Entities referenced by this enitity References []BaseEntity `json:"references"` - // Version of the entity - Version *int `json:"version"` - // Is this the latest version of this entity - Latest *bool `json:"latest"` - // Entity source - Source *GitopsEntitySource `json:"source"` - // Sync status - SyncStatus SyncStatus `json:"syncStatus"` - // Health status - HealthStatus *HealthStatus `json:"healthStatus"` - // Health message - HealthMessage *string `json:"healthMessage"` - // Desired manifest - DesiredManifest *string `json:"desiredManifest"` - // Actual manifest - ActualManifest *string `json:"actualManifest"` + // Self entity reference for the real k8s entity in case of codefresh logical entity + Self *AppProject `json:"self"` // Projects Projects []string `json:"projects"` // Cluster - Cluster string `json:"cluster"` + Cluster *string `json:"cluster"` // Runtime version - RuntimeVersion string `json:"runtimeVersion"` + RuntimeVersion *string `json:"runtimeVersion"` } -func (Runtime) IsEntity() {} func (Runtime) IsBaseEntity() {} func (Runtime) IsProjectBasedEntity() {} -func (Runtime) IsGitopsEntity() {} +func (Runtime) IsK8sLogicEntity() {} +func (Runtime) IsEntity() {} // Response for creating a runtime type RuntimeCreationResponse struct { @@ -672,6 +907,14 @@ type RuntimePage struct { func (RuntimePage) IsPage() {} +// RuntimePushPayload +type RuntimePushPayload struct { + // Name of event + Name *string `json:"name"` +} + +func (RuntimePushPayload) IsPushPayload() {} + // Runtime Slice type RuntimeSlice struct { // Runtime edges @@ -716,10 +959,10 @@ type Sensor struct { Triggers []SensorTrigger `json:"triggers"` } -func (Sensor) IsEntity() {} func (Sensor) IsGitopsEntity() {} func (Sensor) IsBaseEntity() {} func (Sensor) IsProjectBasedEntity() {} +func (Sensor) IsEntity() {} // Sensor dependency type SensorDependency struct { @@ -787,6 +1030,16 @@ type SlicePaginationArgs struct { Last *int `json:"last"` } +// Workflow status history item +type StatusHistoryItem struct { + // The time the status started + Since string `json:"since"` + // Phase + Phase Phases `json:"phase"` + // Message + Message *string `json:"message"` +} + // Lable type StringPair struct { // Key @@ -835,34 +1088,35 @@ type Workflow struct { Spec *WorkflowSpec `json:"spec"` // Workflow status Status *WorkflowStatus `json:"status"` + // Events payload Data + EventsPayloadData []EventPayloadData `json:"eventsPayloadData"` + // Events payload references + EventsPayload []*EventPayload `json:"eventsPayload"` + // Pipeline refernece + Pipeline *Pipeline `json:"pipeline"` + // Actual manifest + ActualManifest *string `json:"actualManifest"` } -func (Workflow) IsEntity() {} func (Workflow) IsProjectBasedEntity() {} func (Workflow) IsBaseEntity() {} +func (Workflow) IsK8sStandardEntity() {} +func (Workflow) IsEntity() {} -// Container spec -type WorkflowContainerSpec struct { +// Workflow container template +type WorkflowContainerTemplate struct { // Name Name string `json:"name"` - // Image - Image string `json:"image"` - // Command - Command []string `json:"command"` - // Args - Args []string `json:"args"` - // Environment variables - Env []*EnvVar `json:"env"` } +func (WorkflowContainerTemplate) IsWorkflowSpecTemplate() {} + // Workflow DAG task type WorkflowDAGTask struct { // Name Name string `json:"name"` // Template to execute Template WorkflowSpecTemplate `json:"template"` - // Dependencies - Dependencies []string `json:"dependencies"` } // Workflow DAG template @@ -871,8 +1125,6 @@ type WorkflowDAGTemplate struct { Name string `json:"name"` // Tasks Tasks []*WorkflowDAGTask `json:"tasks"` - // Failfast - Failfast *bool `json:"failfast"` } func (WorkflowDAGTemplate) IsWorkflowSpecTemplate() {} @@ -899,15 +1151,21 @@ type WorkflowPage struct { func (WorkflowPage) IsPage() {} -// Workflow template ref -type WorkflowRefTemplate struct { +// Workflow Resource template +type WorkflowResourceTemplate struct { // Name Name string `json:"name"` - // Template reference - Template WorkflowSpecTemplate `json:"template"` } -func (WorkflowRefTemplate) IsWorkflowSpecTemplate() {} +func (WorkflowResourceTemplate) IsWorkflowSpecTemplate() {} + +// Workflow script template +type WorkflowScriptTemplate struct { + // Name + Name string `json:"name"` +} + +func (WorkflowScriptTemplate) IsWorkflowSpecTemplate() {} // Workflow Slice type WorkflowSlice struct { @@ -925,20 +1183,10 @@ type WorkflowSpec struct { Entrypoint string `json:"entrypoint"` // Templates Templates []WorkflowSpecTemplate `json:"templates"` + // Workflow template reference + WorkflowTemplateRef *WorkflowTemplateRef `json:"workflowTemplateRef"` } -// Workflow standard template -type WorkflowStandardTemplate struct { - // Name - Name string `json:"name"` - // Daemon - Daemon *bool `json:"daemon"` - // Container to run for this template - Container *WorkflowContainerSpec `json:"container"` -} - -func (WorkflowStandardTemplate) IsWorkflowSpecTemplate() {} - // Workflow status type WorkflowStatus struct { // Creation time @@ -948,21 +1196,15 @@ type WorkflowStatus struct { // Finish time FinishedAt *string `json:"finishedAt"` // Current workflow phase - Phase WorkflowPhases `json:"phase"` + Phase Phases `json:"phase"` + // Progress + Progress *Progress `json:"progress"` + // Current workflow nodes status + Nodes []*NodeStatus `json:"nodes"` // Message Message *string `json:"message"` // Previous statuses - Statuses []*WorkflowStatusHistoryItem `json:"statuses"` -} - -// Workflow status history item -type WorkflowStatusHistoryItem struct { - // The time the status started - Since string `json:"since"` - // Phase - Phase WorkflowPhases `json:"phase"` - // Message - Message *string `json:"message"` + Statuses []*StatusHistoryItem `json:"statuses"` } // Workflow step @@ -983,6 +1225,14 @@ type WorkflowStepsTemplate struct { func (WorkflowStepsTemplate) IsWorkflowSpecTemplate() {} +// Workflow Resource template +type WorkflowSuspendedTemplate struct { + // Name + Name string `json:"name"` +} + +func (WorkflowSuspendedTemplate) IsWorkflowSpecTemplate() {} + // Workflow template entity type WorkflowTemplate struct { // Object metadata @@ -1015,10 +1265,10 @@ type WorkflowTemplate struct { Workflow *WorkflowSpec `json:"workflow"` } -func (WorkflowTemplate) IsEntity() {} func (WorkflowTemplate) IsGitopsEntity() {} func (WorkflowTemplate) IsBaseEntity() {} func (WorkflowTemplate) IsProjectBasedEntity() {} +func (WorkflowTemplate) IsEntity() {} // Workflow template Edge type WorkflowTemplateEdge struct { @@ -1042,6 +1292,12 @@ type WorkflowTemplatePage struct { func (WorkflowTemplatePage) IsPage() {} +// Workflow template ref +type WorkflowTemplateRef struct { + // Name + Name *string `json:"name"` +} + // WorkflowTemplate Slice type WorkflowTemplateSlice struct { // Workflow template edges @@ -1066,6 +1322,28 @@ type WorkflowTrigger struct { func (WorkflowTrigger) IsSensorTrigger() {} +// Workflow filter arguments +type WorkflowsFilterArgs struct { + // Filter workflows from a specific project + Project *string `json:"project"` + // Filter workflows from a specific runtime + Runtime *string `json:"runtime"` + // Filter workflows from a specific pipeline + Pipeline *string `json:"pipeline"` + // Filter workflows from a specific repositories + Repositories []*string `json:"repositories"` + // Filter workflows from a specific branches + Branches []*string `json:"branches"` + // Filter workflows from a specific event types + EventTypes []*string `json:"eventTypes"` + // Filter workflows from a specific initiators + Initiators []*string `json:"initiators"` + // Filter workflows from a specific statuses + Statuses []*Phases `json:"statuses"` + // Filter workflows from a specific start date + StartDate *string `json:"startDate"` +} + // Error types type ErrorTypes string @@ -1110,50 +1388,6 @@ func (e ErrorTypes) MarshalGQL(w io.Writer) { fmt.Fprint(w, strconv.Quote(e.String())) } -// EventName -type EventName string - -const ( - EventNameKeepAlive EventName = "KEEP_ALIVE" - EventNameTestEventA EventName = "TEST_EVENT_A" - EventNameTestEventB EventName = "TEST_EVENT_B" -) - -var AllEventName = []EventName{ - EventNameKeepAlive, - EventNameTestEventA, - EventNameTestEventB, -} - -func (e EventName) IsValid() bool { - switch e { - case EventNameKeepAlive, EventNameTestEventA, EventNameTestEventB: - return true - } - return false -} - -func (e EventName) String() string { - return string(e) -} - -func (e *EventName) UnmarshalGQL(v interface{}) error { - str, ok := v.(string) - if !ok { - return fmt.Errorf("enums must be strings") - } - - *e = EventName(str) - if !e.IsValid() { - return fmt.Errorf("%s is not a valid EventName", str) - } - return nil -} - -func (e EventName) MarshalGQL(w io.Writer) { - fmt.Fprint(w, strconv.Quote(e.String())) -} - // Git Providers type GitProviders string @@ -1254,6 +1488,62 @@ func (e HealthStatus) MarshalGQL(w io.Writer) { fmt.Fprint(w, strconv.Quote(e.String())) } +// Workflow phases +type Phases string + +const ( + // Error + PhasesError Phases = "Error" + // Failed + PhasesFailed Phases = "Failed" + // Pending + PhasesPending Phases = "Pending" + // Running + PhasesRunning Phases = "Running" + // Succeeded + PhasesSucceeded Phases = "Succeeded" + // Terminated + PhasesTerminated Phases = "Terminated" +) + +var AllPhases = []Phases{ + PhasesError, + PhasesFailed, + PhasesPending, + PhasesRunning, + PhasesSucceeded, + PhasesTerminated, +} + +func (e Phases) IsValid() bool { + switch e { + case PhasesError, PhasesFailed, PhasesPending, PhasesRunning, PhasesSucceeded, PhasesTerminated: + return true + } + return false +} + +func (e Phases) String() string { + return string(e) +} + +func (e *Phases) UnmarshalGQL(v interface{}) error { + str, ok := v.(string) + if !ok { + return fmt.Errorf("enums must be strings") + } + + *e = Phases(str) + if !e.IsValid() { + return fmt.Errorf("%s is not a valid Phases", str) + } + return nil +} + +func (e Phases) MarshalGQL(w io.Writer) { + fmt.Fprint(w, strconv.Quote(e.String())) +} + // Sync status type SyncStatus string @@ -1398,62 +1688,6 @@ func (e UserStatus) MarshalGQL(w io.Writer) { fmt.Fprint(w, strconv.Quote(e.String())) } -// Workflow phases -type WorkflowPhases string - -const ( - // Error - WorkflowPhasesError WorkflowPhases = "ERROR" - // Failed - WorkflowPhasesFailed WorkflowPhases = "FAILED" - // Pending - WorkflowPhasesPending WorkflowPhases = "PENDING" - // Running - WorkflowPhasesRunning WorkflowPhases = "RUNNING" - // Succeeded - WorkflowPhasesSucceeded WorkflowPhases = "SUCCEEDED" - // Terminated - WorkflowPhasesTerminated WorkflowPhases = "TERMINATED" -) - -var AllWorkflowPhases = []WorkflowPhases{ - WorkflowPhasesError, - WorkflowPhasesFailed, - WorkflowPhasesPending, - WorkflowPhasesRunning, - WorkflowPhasesSucceeded, - WorkflowPhasesTerminated, -} - -func (e WorkflowPhases) IsValid() bool { - switch e { - case WorkflowPhasesError, WorkflowPhasesFailed, WorkflowPhasesPending, WorkflowPhasesRunning, WorkflowPhasesSucceeded, WorkflowPhasesTerminated: - return true - } - return false -} - -func (e WorkflowPhases) String() string { - return string(e) -} - -func (e *WorkflowPhases) UnmarshalGQL(v interface{}) error { - str, ok := v.(string) - if !ok { - return fmt.Errorf("enums must be strings") - } - - *e = WorkflowPhases(str) - if !e.IsValid() { - return fmt.Errorf("%s is not a valid WorkflowPhases", str) - } - return nil -} - -func (e WorkflowPhases) MarshalGQL(w io.Writer) { - fmt.Fprint(w, strconv.Quote(e.String())) -} - // Workflow Trigger Operation type WorkflowTriggerOperation string From 9062261930febf9c5119129d986157320e96334e Mon Sep 17 00:00:00 2001 From: Noam Gal Date: Mon, 16 Aug 2021 08:48:17 +0300 Subject: [PATCH 62/81] changed ql endpoint to use `2.0` instead of `argo` --- VERSION | 2 +- pkg/codefresh/argo_runtime.go | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/VERSION b/VERSION index e8262eb..26bea73 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.30.3 +0.31.0 diff --git a/pkg/codefresh/argo_runtime.go b/pkg/codefresh/argo_runtime.go index 78509f8..be64e77 100644 --- a/pkg/codefresh/argo_runtime.go +++ b/pkg/codefresh/argo_runtime.go @@ -31,6 +31,8 @@ type ( } ) +var qlEndPoint = "/2.0/api/graphql" + func newArgoRuntimeAPI(codefresh *codefresh) IArgoRuntimeAPI { return &argoRuntime{codefresh: codefresh} } @@ -52,7 +54,7 @@ func (r *argoRuntime) Create(runtimeName, cluster, runtimeVersion string) (*mode response, err := r.codefresh.requestAPI(&requestOptions{ method: "POST", - path: "/argo/api/graphql", + path: qlEndPoint, body: jsonData, }) @@ -109,7 +111,7 @@ func (r *argoRuntime) List() ([]model.Runtime, error) { response, err := r.codefresh.requestAPI(&requestOptions{ method: "POST", - path: "/argo/api/graphql", + path: qlEndPoint, body: jsonData, }) if err != nil { From 87b762f66c227f9d755f7ceeab025927da1840e5 Mon Sep 17 00:00:00 2001 From: elad-codefresh Date: Mon, 16 Aug 2021 12:24:30 +0300 Subject: [PATCH 63/81] updated --- pkg/codefresh/argo_runtime.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/pkg/codefresh/argo_runtime.go b/pkg/codefresh/argo_runtime.go index be64e77..b438cd9 100644 --- a/pkg/codefresh/argo_runtime.go +++ b/pkg/codefresh/argo_runtime.go @@ -93,6 +93,7 @@ func (r *argoRuntime) List() ([]model.Runtime, error) { pagination: {} project: "" ) { + runtimes() { edges { node { metadata { @@ -101,10 +102,12 @@ func (r *argoRuntime) List() ([]model.Runtime, error) { } healthMessage runtimeVersion + self { + healthMessage + version + } cluster } - } - } } `, } From 88f33adc1561186868ef1ec6ec40c62c35927e48 Mon Sep 17 00:00:00 2001 From: elad-codefresh Date: Mon, 16 Aug 2021 12:26:03 +0300 Subject: [PATCH 64/81] bump --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index 26bea73..f176c94 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.31.0 +0.31.1 From 7ad7b81f809c7809344f6b286f541d33358aab98 Mon Sep 17 00:00:00 2001 From: elad-codefresh Date: Mon, 16 Aug 2021 13:50:54 +0300 Subject: [PATCH 65/81] first error check and fix query --- pkg/codefresh/argo_runtime.go | 44 +++++++++++++++-------------------- 1 file changed, 19 insertions(+), 25 deletions(-) diff --git a/pkg/codefresh/argo_runtime.go b/pkg/codefresh/argo_runtime.go index b438cd9..e2868bc 100644 --- a/pkg/codefresh/argo_runtime.go +++ b/pkg/codefresh/argo_runtime.go @@ -86,29 +86,23 @@ func (r *argoRuntime) Create(runtimeName, cluster, runtimeVersion string) (*mode func (r *argoRuntime) List() ([]model.Runtime, error) { jsonData := map[string]interface{}{ - "query": ` - { - runtimes - ( - pagination: {} - project: "" - ) { - runtimes() { - edges { - node { - metadata { - name - namespace - } - healthMessage - runtimeVersion - self { - healthMessage - version - } - cluster + "query": `{ + runtimes { + edges { + node { + metadata { + name + namespace } + self { + healthStatus + version + } + cluster + } + } } + } `, } @@ -136,14 +130,14 @@ func (r *argoRuntime) List() ([]model.Runtime, error) { return nil, err } + if len(res.Errors) > 0 { + return nil, graphqlErrorResponse{errors: res.Errors} + } + runtimes := make([]model.Runtime, len(res.Data.Runtimes.Edges)) for i := range res.Data.Runtimes.Edges { runtimes[i] = *res.Data.Runtimes.Edges[i].Node } - if len(res.Errors) > 0 { - return nil, graphqlErrorResponse{errors: res.Errors} - } - return runtimes, nil } From 243278f562a9eef3d456a4b7823a7e1f4ac921aa Mon Sep 17 00:00:00 2001 From: elad-codefresh Date: Sun, 8 Aug 2021 23:24:11 +0300 Subject: [PATCH 66/81] bump --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index f176c94..c415e1c 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.31.1 +0.31.2 From 91f6dadedc1ffd2cb5c9de6fa72ca27487144ac6 Mon Sep 17 00:00:00 2001 From: elad-codefresh Date: Sun, 8 Aug 2021 23:49:56 +0300 Subject: [PATCH 67/81] list function --- pkg/codefresh/gitops.go | 67 +++++++++++++++++++++++++++++++++++++++-- 1 file changed, 64 insertions(+), 3 deletions(-) diff --git a/pkg/codefresh/gitops.go b/pkg/codefresh/gitops.go index f343d3e..b0bb88e 100644 --- a/pkg/codefresh/gitops.go +++ b/pkg/codefresh/gitops.go @@ -1,6 +1,10 @@ package codefresh -import "fmt" +import ( + "fmt" + + "github.com/codefresh-io/go-sdk/pkg/codefresh/model" +) type ( GitopsAPI interface { @@ -10,6 +14,7 @@ type ( GetEnvironments() ([]CFEnvironment, error) SendEvent(name string, props map[string]string) error SendApplicationResources(resources *ApplicationResources) error + List(gitSources model.GitSource) ([]model.GitSource, error) } gitops struct { @@ -103,7 +108,7 @@ type ( ParentApp string `json:"parentApp"` Namespace string `json:"namespace"` Server string `json:"server"` - Context *string `json:"context"` + Context *string `json:"context"` } EnvironmentActivity struct { @@ -119,7 +124,7 @@ type ( HistoryId int64 `json:"historyId"` Revision string `json:"revision, omitempty"` Resources interface{} `json:"resources"` - Context *string `json:"context"` + Context *string `json:"context"` } ) @@ -224,3 +229,59 @@ func (a *gitops) SendApplicationResources(resources *ApplicationResources) error } return nil } + +func (a *gitops) List(gitSources model.GitSource) ([]model.GitSource, error) { + jsonData := map[string]interface{}{ + "query": ` + { + gitSources(pagination: {}, project: "") { + edges { + node { + metadata { + name + } + source { + path + } + } + } + } + } + `, + } + + response, err := a.codefresh.requestAPI(&requestOptions{ + method: "POST", + path: "/argo/api/graphql", + body: jsonData, + }) + if err != nil { + fmt.Printf("The HTTP request failed with error %s\n", err) + return nil, err + } + defer response.Body.Close() + + // data, err := ioutil.ReadAll(response.Body) + // if err != nil { + // fmt.Printf("failed to read from response body") + // return nil, err + // } + + // res := graphqlRuntimesResponse{} + // err = json.Unmarshal(data, &res) + + // if err != nil { + // return nil, err + // } + + // gitSources := make([]model.GitSource, len(res.Data.Runtimes.Edges)) + // for i := range res.Data.Runtimes.Edges { + // gitSources[i] = *res.Data.Runtimes.Edges[i].Node + // } + + // if len(res.Errors) > 0 { + // return nil, graphqlErrorResponse{errors: res.Errors} + // } + + return nil, nil +} From a8fdb5170e20b59d8833d344cd7abdccd9bb90ff Mon Sep 17 00:00:00 2001 From: elad-codefresh Date: Tue, 10 Aug 2021 21:59:49 +0300 Subject: [PATCH 68/81] IgitSourceAPI --- pkg/codefresh/codefresh.go | 5 +++ pkg/codefresh/gitops.go | 59 -------------------------------- pkg/codefresh/mocks/codefresh.go | 16 +++++++++ 3 files changed, 21 insertions(+), 59 deletions(-) diff --git a/pkg/codefresh/codefresh.go b/pkg/codefresh/codefresh.go index 4d432c3..3e6b3e9 100644 --- a/pkg/codefresh/codefresh.go +++ b/pkg/codefresh/codefresh.go @@ -29,6 +29,7 @@ type ( Argo() ArgoAPI Gitops() GitopsAPI ArgoRuntime() IArgoRuntimeAPI + GitSource() IGitSourceAPI } ) @@ -89,6 +90,10 @@ func (c *codefresh) ArgoRuntime() IArgoRuntimeAPI { return newArgoRuntimeAPI(c) } +func (c *codefresh) GitSource() IGitSourceAPI { + return newGitSourceAPI(c) +} + func (c *codefresh) requestAPI(opt *requestOptions) (*http.Response, error) { return c.requestAPIWithContext(context.Background(), opt) } diff --git a/pkg/codefresh/gitops.go b/pkg/codefresh/gitops.go index b0bb88e..191cec7 100644 --- a/pkg/codefresh/gitops.go +++ b/pkg/codefresh/gitops.go @@ -2,8 +2,6 @@ package codefresh import ( "fmt" - - "github.com/codefresh-io/go-sdk/pkg/codefresh/model" ) type ( @@ -14,7 +12,6 @@ type ( GetEnvironments() ([]CFEnvironment, error) SendEvent(name string, props map[string]string) error SendApplicationResources(resources *ApplicationResources) error - List(gitSources model.GitSource) ([]model.GitSource, error) } gitops struct { @@ -229,59 +226,3 @@ func (a *gitops) SendApplicationResources(resources *ApplicationResources) error } return nil } - -func (a *gitops) List(gitSources model.GitSource) ([]model.GitSource, error) { - jsonData := map[string]interface{}{ - "query": ` - { - gitSources(pagination: {}, project: "") { - edges { - node { - metadata { - name - } - source { - path - } - } - } - } - } - `, - } - - response, err := a.codefresh.requestAPI(&requestOptions{ - method: "POST", - path: "/argo/api/graphql", - body: jsonData, - }) - if err != nil { - fmt.Printf("The HTTP request failed with error %s\n", err) - return nil, err - } - defer response.Body.Close() - - // data, err := ioutil.ReadAll(response.Body) - // if err != nil { - // fmt.Printf("failed to read from response body") - // return nil, err - // } - - // res := graphqlRuntimesResponse{} - // err = json.Unmarshal(data, &res) - - // if err != nil { - // return nil, err - // } - - // gitSources := make([]model.GitSource, len(res.Data.Runtimes.Edges)) - // for i := range res.Data.Runtimes.Edges { - // gitSources[i] = *res.Data.Runtimes.Edges[i].Node - // } - - // if len(res.Errors) > 0 { - // return nil, graphqlErrorResponse{errors: res.Errors} - // } - - return nil, nil -} diff --git a/pkg/codefresh/mocks/codefresh.go b/pkg/codefresh/mocks/codefresh.go index 67721eb..2b4db91 100644 --- a/pkg/codefresh/mocks/codefresh.go +++ b/pkg/codefresh/mocks/codefresh.go @@ -44,6 +44,22 @@ func (_m *Codefresh) ArgoRuntime() codefresh.IArgoRuntimeAPI { return r0 } +// GitSource provides a mock function with given fields: +func (_m *Codefresh) GitSource() codefresh.IGitSourceAPI { + ret := _m.Called() + + var r0 codefresh.IGitSourceAPI + if rf, ok := ret.Get(0).(func() codefresh.IGitSourceAPI); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(codefresh.IGitSourceAPI) + } + } + + return r0 +} + // Clusters provides a mock function with given fields: func (_m *Codefresh) Clusters() codefresh.IClusterAPI { ret := _m.Called() From 4efa7f7b5a0f9c8fe9d462bafb5dfcb70e281def Mon Sep 17 00:00:00 2001 From: elad-codefresh Date: Tue, 10 Aug 2021 22:42:12 +0300 Subject: [PATCH 69/81] . --- pkg/codefresh/git-source.go | 95 +++++++++++++++++++++++++++++++++++++ 1 file changed, 95 insertions(+) create mode 100644 pkg/codefresh/git-source.go diff --git a/pkg/codefresh/git-source.go b/pkg/codefresh/git-source.go new file mode 100644 index 0000000..43e3c3f --- /dev/null +++ b/pkg/codefresh/git-source.go @@ -0,0 +1,95 @@ +package codefresh + +import ( + "encoding/json" + "fmt" + "io/ioutil" + + "github.com/codefresh-io/go-sdk/pkg/codefresh/model" +) + +type ( + IGitSourceAPI interface { + List(runtimeName string) ([]model.GitSource, error) + } + + gitSource struct { + codefresh *codefresh + } + + graphQlGitSourcesListResponse struct { + Data struct { + name string + repoUrl string + path string + } + Errors []graphqlError + } + + // graphQlRuntimeCreationResponse struct { + // Data struct { + // Runtime model.RuntimeCreationResponse + // } + // Errors []graphqlError + // } +) + +func newGitSourceAPI(codefresh *codefresh) IGitSourceAPI { + return &gitSource{codefresh: codefresh} +} + +func (g *gitSource) List(runtimeName string) ([]model.GitSource, error) { + jsonData := map[string]interface{}{ + "query": `GetGitSourcesList(pagination: SlicePaginationArgs!, project: String!, $runtime: String!) { + gitSources(pagination: {}, project: "", runtime: $runtime) { + edges { + node { + metadata { + name + } + path + repoURL + } + } + } + }`, + "variables": map[string]interface{}{ + "runtime": runtimeName, + }, + } + + response, err := g.codefresh.requestAPI(&requestOptions{ + method: "POST", + path: "/argo/api/graphql", + body: jsonData, + }) + if err != nil { + fmt.Printf("The HTTP request failed with error %s\n", err) + return nil, err + } + defer response.Body.Close() + + data, err := ioutil.ReadAll(response.Body) + if err != nil { + fmt.Printf("failed to read from response body") + return nil, err + } + + res := graphQlGitSourcesListResponse{} + err = json.Unmarshal(data, &res) + + if err != nil { + return nil, err + } + + gitSources := make([]model.GitSource, 3) + // for i := range res.Data.GitSourceEdge { + // gitSources[i] = *res.Data.GitSourceEdges. + // } + + // if len(res.Errors) > 0 { + // return nil, graphqlErrorResponse{errors: res.Errors} + // } + + return gitSources, nil +} From 514dcd5ab90feff8f893179d13b89496a48cdd93 Mon Sep 17 00:00:00 2001 From: elad-codefresh Date: Tue, 10 Aug 2021 23:26:48 +0300 Subject: [PATCH 70/81] with query the works from playground --- pkg/codefresh/git-source.go | 36 ++++++++++++++++++++---------------- 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/pkg/codefresh/git-source.go b/pkg/codefresh/git-source.go index 43e3c3f..d6698aa 100644 --- a/pkg/codefresh/git-source.go +++ b/pkg/codefresh/git-source.go @@ -39,23 +39,27 @@ func newGitSourceAPI(codefresh *codefresh) IGitSourceAPI { } func (g *gitSource) List(runtimeName string) ([]model.GitSource, error) { + // jsonData := map[string]interface{}{ + // "query": `GetGitSourcesList(pagination: SlicePaginationArgs!, project: String!, $runtime: String!) { + // gitSources(pagination: {}, project: "", runtime: $runtime) { + // edges { + // node { + // metadata { + // name + // } + // path + // repoURL + // } + // } + // } + // }`, + // "variables": map[string]interface{}{ + // "runtime": runtimeName, + // }, + // } + jsonData := map[string]interface{}{ - "query": `GetGitSourcesList(pagination: SlicePaginationArgs!, project: String!, $runtime: String!) { - gitSources(pagination: {}, project: "", runtime: $runtime) { - edges { - node { - metadata { - name - } - path - repoURL - } - } - } - }`, - "variables": map[string]interface{}{ - "runtime": runtimeName, - }, + "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}`, } response, err := g.codefresh.requestAPI(&requestOptions{ From 400d9e1bc0c5790b449c8a7e69a75c924a47752c Mon Sep 17 00:00:00 2001 From: elad-codefresh Date: Thu, 12 Aug 2021 10:35:59 +0300 Subject: [PATCH 71/81] . --- pkg/codefresh/git-source.go | 39 +++++++++++++++++++++++++------------ 1 file changed, 27 insertions(+), 12 deletions(-) diff --git a/pkg/codefresh/git-source.go b/pkg/codefresh/git-source.go index d6698aa..d550df8 100644 --- a/pkg/codefresh/git-source.go +++ b/pkg/codefresh/git-source.go @@ -19,9 +19,7 @@ type ( graphQlGitSourcesListResponse struct { Data struct { - name string - repoUrl string - path string + GitSources model.GitSourcePage } Errors []graphqlError } @@ -40,7 +38,7 @@ func newGitSourceAPI(codefresh *codefresh) IGitSourceAPI { func (g *gitSource) List(runtimeName string) ([]model.GitSource, error) { // jsonData := map[string]interface{}{ - // "query": `GetGitSourcesList(pagination: SlicePaginationArgs!, project: String!, $runtime: String!) { + // "query": `query GetGitSourcesList(pagination: SlicePaginationArgs!, project: String!, $runtime: String!) { // gitSources(pagination: {}, project: "", runtime: $runtime) { // edges { // node { @@ -59,7 +57,24 @@ func (g *gitSource) List(runtimeName string) ([]model.GitSource, error) { // } jsonData := map[string]interface{}{ - "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}`, + "query": `query ListGitSources($runtime: String, $pagination: SlicePaginationArgs) { + gitSources(runtime: $runtime, pagination: $pagination) { + edges { + node { + metadata { + name + } + app { + repoURL + path + } + } + } + } + }`, + "variables": map[string]interface{}{ + "runtime": runtimeName, + }, } response, err := g.codefresh.requestAPI(&requestOptions{ @@ -86,14 +101,14 @@ func (g *gitSource) List(runtimeName string) ([]model.GitSource, error) { return nil, err } - gitSources := make([]model.GitSource, 3) - // for i := range res.Data.GitSourceEdge { - // gitSources[i] = *res.Data.GitSourceEdges. - // } + gitSources := make([]model.GitSource, len(res.Data.GitSources.Edges)) + for i := range res.Data.GitSources.Edges { + gitSources[i] = *res.Data.GitSources.Edges[i].Node + } - // if len(res.Errors) > 0 { - // return nil, graphqlErrorResponse{errors: res.Errors} - // } + if len(res.Errors) > 0 { + return nil, graphqlErrorResponse{errors: res.Errors} + } return gitSources, nil } From 1d66ba541fc50f5f11ac6fad011a50e12506b1e8 Mon Sep 17 00:00:00 2001 From: elad-codefresh Date: Mon, 16 Aug 2021 09:19:27 +0300 Subject: [PATCH 72/81] . --- pkg/codefresh/git-source.go | 53 ++++++++++++++----------------------- 1 file changed, 20 insertions(+), 33 deletions(-) diff --git a/pkg/codefresh/git-source.go b/pkg/codefresh/git-source.go index d550df8..1496c07 100644 --- a/pkg/codefresh/git-source.go +++ b/pkg/codefresh/git-source.go @@ -37,44 +37,31 @@ func newGitSourceAPI(codefresh *codefresh) IGitSourceAPI { } func (g *gitSource) List(runtimeName string) ([]model.GitSource, error) { - // jsonData := map[string]interface{}{ - // "query": `query GetGitSourcesList(pagination: SlicePaginationArgs!, project: String!, $runtime: String!) { - // gitSources(pagination: {}, project: "", runtime: $runtime) { - // edges { - // node { - // metadata { - // name - // } - // path - // repoURL - // } - // } - // } - // }`, - // "variables": map[string]interface{}{ - // "runtime": runtimeName, - // }, - // } - jsonData := map[string]interface{}{ - "query": `query ListGitSources($runtime: String, $pagination: SlicePaginationArgs) { - gitSources(runtime: $runtime, pagination: $pagination) { - edges { - node { - metadata { - name - } - app { - repoURL - path - } + "query": `{ + gitSources { + edges { + node { + metadata { + name + } + self { + path + repoURL + revision + size + status { + syncStatus + syncStartedAt + syncFinishedAt + healthStatus + revision } + } + } } } }`, - "variables": map[string]interface{}{ - "runtime": runtimeName, - }, } response, err := g.codefresh.requestAPI(&requestOptions{ From 8e0200def11436e32ca93613c3873454fd59c704 Mon Sep 17 00:00:00 2001 From: elad-codefresh Date: Mon, 16 Aug 2021 14:55:04 +0300 Subject: [PATCH 73/81] . --- pkg/codefresh/git-source.go | 7 ------- 1 file changed, 7 deletions(-) diff --git a/pkg/codefresh/git-source.go b/pkg/codefresh/git-source.go index 1496c07..75fafe5 100644 --- a/pkg/codefresh/git-source.go +++ b/pkg/codefresh/git-source.go @@ -23,13 +23,6 @@ type ( } Errors []graphqlError } - - // graphQlRuntimeCreationResponse struct { - // Data struct { - // Runtime model.RuntimeCreationResponse - // } - // Errors []graphqlError - // } ) func newGitSourceAPI(codefresh *codefresh) IGitSourceAPI { From 13b375d21109b052315ae15d567d3b838ed47a8d Mon Sep 17 00:00:00 2001 From: elad-codefresh Date: Mon, 16 Aug 2021 15:49:59 +0300 Subject: [PATCH 74/81] path prefix change --- pkg/codefresh/git-source.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/codefresh/git-source.go b/pkg/codefresh/git-source.go index 75fafe5..ebb7721 100644 --- a/pkg/codefresh/git-source.go +++ b/pkg/codefresh/git-source.go @@ -59,7 +59,7 @@ func (g *gitSource) List(runtimeName string) ([]model.GitSource, error) { response, err := g.codefresh.requestAPI(&requestOptions{ method: "POST", - path: "/argo/api/graphql", + path: "/2.0/api/graphql", body: jsonData, }) if err != nil { From a80938b02139de3fd80b39fbc5a08cf73b8dc663 Mon Sep 17 00:00:00 2001 From: elad-codefresh Date: Mon, 16 Aug 2021 18:40:21 +0300 Subject: [PATCH 75/81] models_gen --- pkg/codefresh/git-source.go | 7 +- pkg/codefresh/model/models_gen.go | 324 +++++++++++++++++++++++++++--- 2 files changed, 303 insertions(+), 28 deletions(-) diff --git a/pkg/codefresh/git-source.go b/pkg/codefresh/git-source.go index ebb7721..c0f7d70 100644 --- a/pkg/codefresh/git-source.go +++ b/pkg/codefresh/git-source.go @@ -31,8 +31,8 @@ func newGitSourceAPI(codefresh *codefresh) IGitSourceAPI { func (g *gitSource) List(runtimeName string) ([]model.GitSource, error) { jsonData := map[string]interface{}{ - "query": `{ - gitSources { + "query": `query GitSources($runtime: String) { + gitSources(runtime: $runtime) { edges { node { metadata { @@ -55,6 +55,9 @@ func (g *gitSource) List(runtimeName string) ([]model.GitSource, error) { } } }`, + "variables": map[string]interface{}{ + "runtime": runtimeName, + }, } response, err := g.codefresh.requestAPI(&requestOptions{ diff --git a/pkg/codefresh/model/models_gen.go b/pkg/codefresh/model/models_gen.go index 8c4653b..b2741ed 100644 --- a/pkg/codefresh/model/models_gen.go +++ b/pkg/codefresh/model/models_gen.go @@ -13,6 +13,11 @@ type BaseEntity interface { IsBaseEntity() } +// "Common events properties +type CommonGitEventPayloadData interface { + IsCommonGitEventPayloadData() +} + // Customer type Customer interface { IsCustomer() @@ -192,6 +197,18 @@ type Application struct { ActualManifest *string `json:"actualManifest"` // Projects Projects []string `json:"projects"` + // Updated At + UpdatedAt *string `json:"updatedAt"` + // Path + Path string `json:"path"` + // RepoURL + RepoURL string `json:"repoURL"` + // Number of resources + Size *int `json:"size"` + // Revision + Revision string `json:"revision"` + // Status + Status *ArgoCDApplicationStatus `json:"status"` } func (Application) IsGitopsEntity() {} @@ -231,17 +248,33 @@ type ApplicationSlice struct { func (ApplicationSlice) IsSlice() {} +// Argo CD Application status +type ArgoCDApplicationStatus struct { + // Sync status + SyncStatus SyncStatus `json:"syncStatus"` + // Sync started at + SyncStartedAt string `json:"syncStartedAt"` + // Sync finished at + SyncFinishedAt *string `json:"syncFinishedAt"` + // Health status + HealthStatus *HealthStatus `json:"healthStatus"` + // Health message + HealthMessage *string `json:"healthMessage"` + // Revision + Revision string `json:"revision"` +} + // Calendar event payload data type CalendarEventPayloadData struct { - // Type - Type string `json:"type"` - // Repository + // Event payload type + Type PayloadDataTypes `json:"type"` + // TBD Schedule string `json:"schedule"` - // EventType + // TBD Interval string `json:"interval"` - // Branch + // TBD Timezone string `json:"timezone"` - // Initiator + // TBD Metadata string `json:"metadata"` } @@ -258,7 +291,7 @@ type Component struct { // Entities referenced by this enitity References []BaseEntity `json:"references"` // Self entity reference for the real k8s entity in case of codefresh logical entity - Self *AppProject `json:"self"` + Self *Application `json:"self"` // Projects Projects []string `json:"projects"` } @@ -453,23 +486,36 @@ type EventSourceSlice struct { func (EventSourceSlice) IsSlice() {} -// Git event payload data -type GitEventPayloadData struct { - // Type - Type string `json:"type"` +// "Commit data +type GitCommit struct { + // Commit message + Message string `json:"message"` + // Commit url + URL string `json:"url"` + // Commit head + Head *GitRevision `json:"head"` + // Modified files + ModifiedFiles []string `json:"modifiedFiles"` +} + +// "Commit event +type GitCommitEventPayloadData struct { + // Event payload type + Type PayloadDataTypes `json:"type"` + // Name of the git event + Event string `json:"event"` + // Git provider + Provider string `json:"provider"` // Repository - Repository string `json:"repository"` - // EventType - EventType string `json:"eventType"` - // Branch - Branch string `json:"branch"` - // Initiator - Initiator string `json:"initiator"` + Repository *Repository `json:"repository"` + // Event initiator + Initiator *Initiator `json:"initiator"` // Commit data - Commit *string `json:"commit"` + Commit *GitCommit `json:"commit"` } -func (GitEventPayloadData) IsEventPayloadData() {} +func (GitCommitEventPayloadData) IsEventPayloadData() {} +func (GitCommitEventPayloadData) IsCommonGitEventPayloadData() {} // Git integration entity type GitIntegration struct { @@ -542,6 +588,108 @@ type GitIntegrationSlice struct { func (GitIntegrationSlice) IsSlice() {} +// "PR data +type GitPr struct { + // PR action + Action string `json:"action"` + // PR id + ID string `json:"id"` + // PR title + Title string `json:"title"` + // PR url + URL string `json:"url"` + // PR number + Number int `json:"number"` + // PR labels + Labels []string `json:"labels"` + // PR head + Head *GitRevision `json:"head"` + // PR target + Target *GitRevision `json:"target"` + // Indicates if a PR was merged + Merged *bool `json:"merged"` + // Merge commit SHA + MergeCommitSha *string `json:"mergeCommitSHA"` + // Indicates if a PR comes from forked repo + Fork *bool `json:"fork"` + // PR comment + Comment *GitPRComment `json:"comment"` + // Modified files + ModifiedFiles []string `json:"modifiedFiles"` +} + +// "PR Comment data +type GitPRComment struct { + // Comment message + Message string `json:"message"` + // Comment author + Author string `json:"author"` + // Comment author association + AuthorAssociation *string `json:"authorAssociation"` +} + +// "PR event +type GitPREventPayloadData struct { + // Event payload type + Type PayloadDataTypes `json:"type"` + // Name of the git event + Event string `json:"event"` + // Git provider + Provider string `json:"provider"` + // Repository + Repository *Repository `json:"repository"` + // Event initiator + Initiator *Initiator `json:"initiator"` + // PR data + Pr *GitPr `json:"pr"` +} + +func (GitPREventPayloadData) IsEventPayloadData() {} +func (GitPREventPayloadData) IsCommonGitEventPayloadData() {} + +// "Release data +type GitRelease struct { + // Release action + Action string `json:"action"` + // Release id + ID string `json:"id"` + // Release name + Name string `json:"name"` + // Release tag name + TagName string `json:"tagName"` + // Indicates if current release is a pre release + IsPreRelease bool `json:"isPreRelease"` +} + +// "Release event +type GitReleaseEventPayloadData struct { + // Event payload type + Type PayloadDataTypes `json:"type"` + // Name of the git event + Event string `json:"event"` + // Git provider + Provider string `json:"provider"` + // Repository + Repository *Repository `json:"repository"` + // Event initiator + Initiator *Initiator `json:"initiator"` + // Release data + Release *GitRelease `json:"release"` +} + +func (GitReleaseEventPayloadData) IsEventPayloadData() {} +func (GitReleaseEventPayloadData) IsCommonGitEventPayloadData() {} + +// "Revision data +type GitRevision struct { + // Branch name + Branch string `json:"branch"` + // Branch url + BranchURL string `json:"branchURL"` + // Revision SHA + Sha string `json:"sha"` +} + // Git source entity type GitSource struct { // Object metadata @@ -553,7 +701,7 @@ type GitSource struct { // Entities referenced by this enitity References []BaseEntity `json:"references"` // Self entity reference for the real k8s entity in case of codefresh logical entity - Self *AppProject `json:"self"` + Self *Application `json:"self"` // Projects Projects []string `json:"projects"` } @@ -635,6 +783,20 @@ type HTTPTrigger struct { func (HTTPTrigger) IsSensorTrigger() {} +// "Event initiator +type Initiator struct { + // Git user username + UserName string `json:"userName"` + // Git user id + UserID string `json:"userId"` + // Git user email + UserEmail string `json:"userEmail"` + // Link to the user avatar image + UserAvatarURL string `json:"userAvatarUrl"` + // Link to the user git profile + UserProfileURL string `json:"userProfileUrl"` +} + // Me type Me struct { // The user id @@ -696,7 +858,7 @@ type ObjectMeta struct { // Description Description *string `json:"description"` // Namespace - Namespace string `json:"namespace"` + Namespace *string `json:"namespace"` // Runtime Runtime string `json:"runtime"` // Account name @@ -836,6 +998,18 @@ type Release struct { Version string `json:"version"` } +// "Repository +type Repository struct { + // Repository name + Name string `json:"name"` + // Repository owner + Owner string `json:"owner"` + // Repository name in format {owner}/{name} + FullName string `json:"fullName"` + // Repository URL + URL string `json:"url"` +} + // Resource event type ResourceEvent struct { // Name @@ -1054,6 +1228,16 @@ type SwitchAccountResponse struct { NewAccessToken *string `json:"newAccessToken"` } +// Calendar event payload data +type UnknownEventPayloadData struct { + // Event payload type + Type PayloadDataTypes `json:"type"` + // Event name + Event string `json:"event"` +} + +func (UnknownEventPayloadData) IsEventPayloadData() {} + // "User Details type UserDetails struct { // The user name @@ -1103,10 +1287,28 @@ func (Workflow) IsBaseEntity() {} func (Workflow) IsK8sStandardEntity() {} func (Workflow) IsEntity() {} +// Workflow step +type WorkflowContainerSpec struct { + // Name + Name *string `json:"name"` + // Image + Image *string `json:"image"` + // Command array + Command []*string `json:"command"` + // Args + Args []*string `json:"args"` + // Env map + Env []*StringPair `json:"env"` +} + // Workflow container template type WorkflowContainerTemplate struct { // Name Name string `json:"name"` + // Daemon + Daemon *bool `json:"daemon"` + // Container + Container *WorkflowContainerSpec `json:"container"` } func (WorkflowContainerTemplate) IsWorkflowSpecTemplate() {} @@ -1116,7 +1318,9 @@ type WorkflowDAGTask struct { // Name Name string `json:"name"` // Template to execute - Template WorkflowSpecTemplate `json:"template"` + TemplateName *string `json:"templateName"` + // Workflow template ref + WorkflowTemplateRef *WorkflowTemplateRef `json:"workflowTemplateRef"` } // Workflow DAG template @@ -1125,6 +1329,8 @@ type WorkflowDAGTemplate struct { Name string `json:"name"` // Tasks Tasks []*WorkflowDAGTask `json:"tasks"` + // Fail on first failed task + FailFast *bool `json:"failFast"` } func (WorkflowDAGTemplate) IsWorkflowSpecTemplate() {} @@ -1180,13 +1386,21 @@ func (WorkflowSlice) IsSlice() {} // Workflow spec type WorkflowSpec struct { // Entrypoint - Entrypoint string `json:"entrypoint"` + Entrypoint *string `json:"entrypoint"` // Templates Templates []WorkflowSpecTemplate `json:"templates"` // Workflow template reference WorkflowTemplateRef *WorkflowTemplateRef `json:"workflowTemplateRef"` } +// Workflow spec name only template +type WorkflowSpecNameOnlyTemplate struct { + // Name + Name string `json:"name"` +} + +func (WorkflowSpecNameOnlyTemplate) IsWorkflowSpecTemplate() {} + // Workflow status type WorkflowStatus struct { // Creation time @@ -1212,7 +1426,9 @@ type WorkflowStep struct { // Name Name string `json:"name"` // Template to execute - Template WorkflowSpecTemplate `json:"template"` + TemplateName *string `json:"templateName"` + // Workflow template ref + WorkflowTemplateRef *WorkflowTemplateRef `json:"workflowTemplateRef"` } // Workflow steps template @@ -1262,7 +1478,7 @@ type WorkflowTemplate struct { // Projects Projects []string `json:"projects"` // Workflow spec - Workflow *WorkflowSpec `json:"workflow"` + Spec *WorkflowSpec `json:"spec"` } func (WorkflowTemplate) IsGitopsEntity() {} @@ -1296,6 +1512,14 @@ func (WorkflowTemplatePage) IsPage() {} type WorkflowTemplateRef struct { // Name Name *string `json:"name"` + // Group + Group string `json:"group"` + // Kind + Kind string `json:"kind"` + // Version + Version string `json:"version"` + // Namespace + Namespace *string `json:"namespace"` } // WorkflowTemplate Slice @@ -1488,6 +1712,54 @@ func (e HealthStatus) MarshalGQL(w io.Writer) { fmt.Fprint(w, strconv.Quote(e.String())) } +// Types of event payload +type PayloadDataTypes string + +const ( + PayloadDataTypesCalendar PayloadDataTypes = "CALENDAR" + PayloadDataTypesGitPr PayloadDataTypes = "GIT_PR" + PayloadDataTypesGitPush PayloadDataTypes = "GIT_PUSH" + PayloadDataTypesGitRelease PayloadDataTypes = "GIT_RELEASE" + PayloadDataTypesUnknown PayloadDataTypes = "UNKNOWN" +) + +var AllPayloadDataTypes = []PayloadDataTypes{ + PayloadDataTypesCalendar, + PayloadDataTypesGitPr, + PayloadDataTypesGitPush, + PayloadDataTypesGitRelease, + PayloadDataTypesUnknown, +} + +func (e PayloadDataTypes) IsValid() bool { + switch e { + case PayloadDataTypesCalendar, PayloadDataTypesGitPr, PayloadDataTypesGitPush, PayloadDataTypesGitRelease, PayloadDataTypesUnknown: + return true + } + return false +} + +func (e PayloadDataTypes) String() string { + return string(e) +} + +func (e *PayloadDataTypes) UnmarshalGQL(v interface{}) error { + str, ok := v.(string) + if !ok { + return fmt.Errorf("enums must be strings") + } + + *e = PayloadDataTypes(str) + if !e.IsValid() { + return fmt.Errorf("%s is not a valid PayloadDataTypes", str) + } + return nil +} + +func (e PayloadDataTypes) MarshalGQL(w io.Writer) { + fmt.Fprint(w, strconv.Quote(e.String())) +} + // Workflow phases type Phases string From aae7b9858034a17f13d00b883bfa226d49dced97 Mon Sep 17 00:00:00 2001 From: elad-codefresh Date: Mon, 16 Aug 2021 19:13:33 +0300 Subject: [PATCH 76/81] . --- pkg/codefresh/git-source.go | 5 ----- 1 file changed, 5 deletions(-) diff --git a/pkg/codefresh/git-source.go b/pkg/codefresh/git-source.go index c0f7d70..276371d 100644 --- a/pkg/codefresh/git-source.go +++ b/pkg/codefresh/git-source.go @@ -41,14 +41,9 @@ func (g *gitSource) List(runtimeName string) ([]model.GitSource, error) { self { path repoURL - revision - size status { syncStatus - syncStartedAt - syncFinishedAt healthStatus - revision } } } From 67ee8292e2514867d4c62570e0508caf5f930cdc Mon Sep 17 00:00:00 2001 From: Noam Gal Date: Mon, 16 Aug 2021 19:16:07 +0300 Subject: [PATCH 77/81] added component list refactored code into codefresh.go --- pkg/codefresh/argo_runtime.go | 2 - pkg/codefresh/codefresh.go | 34 +++++++++++++++++ pkg/codefresh/component.go | 72 +++++++++++++++++++++++++++++++++++ 3 files changed, 106 insertions(+), 2 deletions(-) create mode 100644 pkg/codefresh/component.go diff --git a/pkg/codefresh/argo_runtime.go b/pkg/codefresh/argo_runtime.go index e2868bc..239e9ba 100644 --- a/pkg/codefresh/argo_runtime.go +++ b/pkg/codefresh/argo_runtime.go @@ -31,8 +31,6 @@ type ( } ) -var qlEndPoint = "/2.0/api/graphql" - func newArgoRuntimeAPI(codefresh *codefresh) IArgoRuntimeAPI { return &argoRuntime{codefresh: codefresh} } diff --git a/pkg/codefresh/codefresh.go b/pkg/codefresh/codefresh.go index 3e6b3e9..3704dcf 100644 --- a/pkg/codefresh/codefresh.go +++ b/pkg/codefresh/codefresh.go @@ -9,6 +9,7 @@ import ( "net/http" "strings" + "github.com/codefresh-io/go-sdk/pkg/codefresh/model" "github.com/google/go-querystring/query" ) @@ -30,9 +31,19 @@ type ( Gitops() GitopsAPI ArgoRuntime() IArgoRuntimeAPI GitSource() IGitSourceAPI + Component() IComponentAPI + } + + graphqlResponse struct { + Data struct { + Runtimes model.RuntimePage + } + Errors []graphqlError } ) +var qlEndPoint = "/2.0/api/graphql" + func New(opt *ClientOptions) Codefresh { httpClient := &http.Client{} if opt.Client != nil { @@ -94,6 +105,10 @@ func (c *codefresh) GitSource() IGitSourceAPI { return newGitSourceAPI(c) } +func (c *codefresh) Component() IComponentAPI { + return newComponentAPI(c) +} + func (c *codefresh) requestAPI(opt *requestOptions) (*http.Response, error) { return c.requestAPIWithContext(context.Background(), opt) } @@ -122,6 +137,25 @@ func (c *codefresh) requestAPIWithContext(ctx context.Context, opt *requestOptio return response, nil } +func (c *codefresh) graphqlAPI(ctx context.Context, body map[string]interface{}, res interface{}) error { + response, err := c.requestAPIWithContext(ctx, &requestOptions{ + method: "POST", + path: qlEndPoint, + body: body, + }) + if err != nil { + return fmt.Errorf("The HTTP request failed: %w", err) + } + defer response.Body.Close() + + data, err := ioutil.ReadAll(response.Body) + if err != nil { + return fmt.Errorf("failed to read from response body: %w", err) + } + + return json.Unmarshal(data, res) +} + func buildQSFromMap(qs map[string]string) string { var arr = []string{} for k, v := range qs { diff --git a/pkg/codefresh/component.go b/pkg/codefresh/component.go new file mode 100644 index 0000000..a49a51a --- /dev/null +++ b/pkg/codefresh/component.go @@ -0,0 +1,72 @@ +package codefresh + +import ( + "context" + "fmt" + + "github.com/codefresh-io/go-sdk/pkg/codefresh/model" +) + +type ( + IComponentAPI interface { + List(ctx context.Context, runtimeName string) ([]model.Component, error) + } + + component struct { + codefresh *codefresh + } + + graphqlComponentsResponse struct { + Data struct { + Components model.ComponentPage + } + Errors []graphqlError + } +) + +func newComponentAPI(codefresh *codefresh) IComponentAPI { + return &component{codefresh: codefresh} +} + +func (r *component) List(ctx context.Context, runtimeName string) ([]model.Component, error) { + jsonData := map[string]interface{}{ + "query": ` + query Components($runtime: String!) { + components(runtime: $runtime) { + edges { + node { + metadata { + name + } + self { + status { + syncStatus + healthStatus + } + } + } + } + } + }`, + "variables": map[string]interface{}{ + "runtime": runtimeName, + }, + } + + res := &graphqlComponentsResponse{} + err := r.codefresh.graphqlAPI(ctx, jsonData, res) + if err != nil { + return nil, fmt.Errorf("failed getting components list: %w", err) + } + + if len(res.Errors) > 0 { + return nil, graphqlErrorResponse{errors: res.Errors} + } + + components := make([]model.Component, len(res.Data.Components.Edges)) + for i := range res.Data.Components.Edges { + components[i] = *res.Data.Components.Edges[i].Node + } + + return components, nil +} From 487371bc9e4add88c9ef6136b1362190c1b7d786 Mon Sep 17 00:00:00 2001 From: Noam Gal Date: Tue, 17 Aug 2021 11:42:01 +0300 Subject: [PATCH 78/81] use the graphqlAPI in all relevant calls handle non-error responses which represent server errors. --- VERSION | 2 +- pkg/codefresh/argo_runtime.go | 133 +++++++++++++--------------------- pkg/codefresh/codefresh.go | 14 ++-- pkg/codefresh/git-source.go | 66 ++++++----------- 4 files changed, 81 insertions(+), 134 deletions(-) diff --git a/VERSION b/VERSION index c415e1c..9eb2aa3 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.31.2 +0.32.0 diff --git a/pkg/codefresh/argo_runtime.go b/pkg/codefresh/argo_runtime.go index 239e9ba..4632f0c 100644 --- a/pkg/codefresh/argo_runtime.go +++ b/pkg/codefresh/argo_runtime.go @@ -1,17 +1,16 @@ package codefresh import ( - "encoding/json" + "context" "fmt" - "io/ioutil" "github.com/codefresh-io/go-sdk/pkg/codefresh/model" ) type ( IArgoRuntimeAPI interface { - List() ([]model.Runtime, error) - Create(runtimeName, cluster, runtimeVersion string) (*model.RuntimeCreationResponse, error) + List(ctx context.Context) ([]model.Runtime, error) + Create(ctx context.Context, runtimeName, cluster, runtimeVersion string) (*model.RuntimeCreationResponse, error) } argoRuntime struct { codefresh *codefresh @@ -35,107 +34,75 @@ func newArgoRuntimeAPI(codefresh *codefresh) IArgoRuntimeAPI { return &argoRuntime{codefresh: codefresh} } -func (r *argoRuntime) Create(runtimeName, cluster, runtimeVersion string) (*model.RuntimeCreationResponse, error) { +func (r *argoRuntime) List(ctx context.Context) ([]model.Runtime, error) { jsonData := map[string]interface{}{ - "query": `mutation CreateRuntime($name: String!, $cluster: String!, $runtimeVersion: String!) { - runtime(name: $name, cluster: $cluster, runtimeVersion: $runtimeVersion) { - name - newAccessToken - } - }`, - "variables": map[string]interface{}{ - "name": runtimeName, - "cluster": cluster, - "runtimeVersion": runtimeVersion, - }, - } - - response, err := r.codefresh.requestAPI(&requestOptions{ - method: "POST", - path: qlEndPoint, - body: jsonData, - }) - - if err != nil { - fmt.Printf("The HTTP request failed with error %s\n", err) - return nil, err - } - - defer response.Body.Close() - - data, err := ioutil.ReadAll(response.Body) - if err != nil { - fmt.Printf("failed to read from response body") - return nil, err + "query": `{ + runtimes { + edges { + node { + metadata { + name + namespace + } + self { + healthStatus + version + } + cluster + } + } + } + }`, } - res := graphQlRuntimeCreationResponse{} - err = json.Unmarshal(data, &res) + res := &graphqlRuntimesResponse{} + err := r.codefresh.graphqlAPI(ctx, jsonData, res) if err != nil { - return nil, err + return nil, fmt.Errorf("failed getting runtime list: %w", err) } if len(res.Errors) > 0 { return nil, graphqlErrorResponse{errors: res.Errors} } - return &res.Data.Runtime, nil + runtimes := make([]model.Runtime, len(res.Data.Runtimes.Edges)) + for i := range res.Data.Runtimes.Edges { + runtimes[i] = *res.Data.Runtimes.Edges[i].Node + } + + return runtimes, nil } -func (r *argoRuntime) List() ([]model.Runtime, error) { +func (r *argoRuntime) Create(ctx context.Context, runtimeName, cluster, runtimeVersion string) (*model.RuntimeCreationResponse, error) { jsonData := map[string]interface{}{ - "query": `{ - runtimes { - edges { - node { - metadata { - name - namespace - } - self { - healthStatus - version + "query": ` + mutation CreateRuntime( + $name: String! + $cluster: String! + $runtimeVersion: String! + ) { + runtime(name: $name, cluster: $cluster, runtimeVersion: $runtimeVersion) { + name + newAccessToken } - cluster - } } - } - } - `, - } - - response, err := r.codefresh.requestAPI(&requestOptions{ - method: "POST", - path: qlEndPoint, - body: jsonData, - }) - if err != nil { - fmt.Printf("The HTTP request failed with error %s\n", err) - return nil, err - } - defer response.Body.Close() - - data, err := ioutil.ReadAll(response.Body) - if err != nil { - fmt.Printf("failed to read from response body") - return nil, err + `, + "variables": map[string]interface{}{ + "name": runtimeName, + "cluster": cluster, + "runtimeVersion": runtimeVersion, + }, } - res := graphqlRuntimesResponse{} - err = json.Unmarshal(data, &res) - + res := &graphQlRuntimeCreationResponse{} + err := r.codefresh.graphqlAPI(ctx, jsonData, res) if err != nil { - return nil, err + return nil, fmt.Errorf("failed getting runtime list: %w", err) } if len(res.Errors) > 0 { return nil, graphqlErrorResponse{errors: res.Errors} } - runtimes := make([]model.Runtime, len(res.Data.Runtimes.Edges)) - for i := range res.Data.Runtimes.Edges { - runtimes[i] = *res.Data.Runtimes.Edges[i].Node - } - - return runtimes, nil + return &res.Data.Runtime, nil } diff --git a/pkg/codefresh/codefresh.go b/pkg/codefresh/codefresh.go index 3704dcf..5cee35e 100644 --- a/pkg/codefresh/codefresh.go +++ b/pkg/codefresh/codefresh.go @@ -4,12 +4,12 @@ import ( "bytes" "context" "encoding/json" + "errors" "fmt" "io/ioutil" "net/http" "strings" - "github.com/codefresh-io/go-sdk/pkg/codefresh/model" "github.com/google/go-querystring/query" ) @@ -33,13 +33,6 @@ type ( GitSource() IGitSourceAPI Component() IComponentAPI } - - graphqlResponse struct { - Data struct { - Runtimes model.RuntimePage - } - Errors []graphqlError - } ) var qlEndPoint = "/2.0/api/graphql" @@ -148,6 +141,11 @@ func (c *codefresh) graphqlAPI(ctx context.Context, body map[string]interface{}, } defer response.Body.Close() + statusOK := response.StatusCode >= 200 && response.StatusCode < 300 + if !statusOK { + return errors.New(response.Status) + } + data, err := ioutil.ReadAll(response.Body) if err != nil { return fmt.Errorf("failed to read from response body: %w", err) diff --git a/pkg/codefresh/git-source.go b/pkg/codefresh/git-source.go index 276371d..4b36b03 100644 --- a/pkg/codefresh/git-source.go +++ b/pkg/codefresh/git-source.go @@ -1,16 +1,15 @@ package codefresh import ( - "encoding/json" + "context" "fmt" - "io/ioutil" "github.com/codefresh-io/go-sdk/pkg/codefresh/model" ) type ( IGitSourceAPI interface { - List(runtimeName string) ([]model.GitSource, error) + List(ctc context.Context, runtimeName string) ([]model.GitSource, error) } gitSource struct { @@ -29,54 +28,37 @@ func newGitSourceAPI(codefresh *codefresh) IGitSourceAPI { return &gitSource{codefresh: codefresh} } -func (g *gitSource) List(runtimeName string) ([]model.GitSource, error) { +func (g *gitSource) List(ctx context.Context, runtimeName string) ([]model.GitSource, error) { jsonData := map[string]interface{}{ - "query": `query GitSources($runtime: String) { - gitSources(runtime: $runtime) { - edges { - node { - metadata { - name - } - self { - path - repoURL - status { - syncStatus - healthStatus + "query": ` + query GitSources($runtime: String) { + gitSources(runtime: $runtime) { + edges { + node { + metadata { + name + } + self { + path + repoURL + status { + syncStatus + healthStatus + } + } + } } - } } - } - } - }`, + }`, "variables": map[string]interface{}{ "runtime": runtimeName, }, } - response, err := g.codefresh.requestAPI(&requestOptions{ - method: "POST", - path: "/2.0/api/graphql", - body: jsonData, - }) + res := &graphQlGitSourcesListResponse{} + err := g.codefresh.graphqlAPI(ctx, jsonData, res) if err != nil { - fmt.Printf("The HTTP request failed with error %s\n", err) - return nil, err - } - defer response.Body.Close() - - data, err := ioutil.ReadAll(response.Body) - if err != nil { - fmt.Printf("failed to read from response body") - return nil, err - } - - res := graphQlGitSourcesListResponse{} - err = json.Unmarshal(data, &res) - - if err != nil { - return nil, err + return nil, fmt.Errorf("failed getting git-source list: %w", err) } gitSources := make([]model.GitSource, len(res.Data.GitSources.Edges)) From 3ffd0a290c23c7c0a9ef45c09f52f5613336a661 Mon Sep 17 00:00:00 2001 From: Noam Gal Date: Tue, 17 Aug 2021 13:39:28 +0300 Subject: [PATCH 79/81] updated model, request component version --- pkg/codefresh/component.go | 1 + pkg/codefresh/model/models_gen.go | 2 ++ 2 files changed, 3 insertions(+) diff --git a/pkg/codefresh/component.go b/pkg/codefresh/component.go index a49a51a..27003c0 100644 --- a/pkg/codefresh/component.go +++ b/pkg/codefresh/component.go @@ -38,6 +38,7 @@ func (r *component) List(ctx context.Context, runtimeName string) ([]model.Compo metadata { name } + version self { status { syncStatus diff --git a/pkg/codefresh/model/models_gen.go b/pkg/codefresh/model/models_gen.go index b2741ed..f5021ee 100644 --- a/pkg/codefresh/model/models_gen.go +++ b/pkg/codefresh/model/models_gen.go @@ -294,6 +294,8 @@ type Component struct { Self *Application `json:"self"` // Projects Projects []string `json:"projects"` + // Component's version + Version string `json:"version"` } func (Component) IsBaseEntity() {} From de93f9ddc12a7d1bca317bcffb8795a4eabe6121 Mon Sep 17 00:00:00 2001 From: Noam Gal Date: Tue, 17 Aug 2021 13:55:45 +0300 Subject: [PATCH 80/81] created V2API interface --- pkg/codefresh/argo_runtime.go | 6 ++++-- pkg/codefresh/codefresh.go | 16 +++++++++++----- pkg/codefresh/mocks/codefresh.go | 8 ++++---- 3 files changed, 19 insertions(+), 11 deletions(-) diff --git a/pkg/codefresh/argo_runtime.go b/pkg/codefresh/argo_runtime.go index 4632f0c..f08d303 100644 --- a/pkg/codefresh/argo_runtime.go +++ b/pkg/codefresh/argo_runtime.go @@ -8,13 +8,15 @@ import ( ) type ( - IArgoRuntimeAPI interface { + IRuntimeAPI interface { List(ctx context.Context) ([]model.Runtime, error) Create(ctx context.Context, runtimeName, cluster, runtimeVersion string) (*model.RuntimeCreationResponse, error) } + argoRuntime struct { codefresh *codefresh } + graphqlRuntimesResponse struct { Data struct { Runtimes model.RuntimePage @@ -30,7 +32,7 @@ type ( } ) -func newArgoRuntimeAPI(codefresh *codefresh) IArgoRuntimeAPI { +func newArgoRuntimeAPI(codefresh *codefresh) IRuntimeAPI { return &argoRuntime{codefresh: codefresh} } diff --git a/pkg/codefresh/codefresh.go b/pkg/codefresh/codefresh.go index 5cee35e..67b4198 100644 --- a/pkg/codefresh/codefresh.go +++ b/pkg/codefresh/codefresh.go @@ -29,14 +29,16 @@ type ( Users() UsersAPI Argo() ArgoAPI Gitops() GitopsAPI - ArgoRuntime() IArgoRuntimeAPI + V2() V2API + } + + V2API interface { + Runtime() IRuntimeAPI GitSource() IGitSourceAPI Component() IComponentAPI } ) -var qlEndPoint = "/2.0/api/graphql" - func New(opt *ClientOptions) Codefresh { httpClient := &http.Client{} if opt.Client != nil { @@ -90,7 +92,11 @@ func (c *codefresh) Gitops() GitopsAPI { return newGitopsAPI(c) } -func (c *codefresh) ArgoRuntime() IArgoRuntimeAPI { +func (c *codefresh) V2() V2API { + return c +} + +func (c *codefresh) Runtime() IRuntimeAPI { return newArgoRuntimeAPI(c) } @@ -133,7 +139,7 @@ func (c *codefresh) requestAPIWithContext(ctx context.Context, opt *requestOptio func (c *codefresh) graphqlAPI(ctx context.Context, body map[string]interface{}, res interface{}) error { response, err := c.requestAPIWithContext(ctx, &requestOptions{ method: "POST", - path: qlEndPoint, + path: "/2.0/api/graphql", body: body, }) if err != nil { diff --git a/pkg/codefresh/mocks/codefresh.go b/pkg/codefresh/mocks/codefresh.go index 2b4db91..96e8d3f 100644 --- a/pkg/codefresh/mocks/codefresh.go +++ b/pkg/codefresh/mocks/codefresh.go @@ -29,15 +29,15 @@ func (_m *Codefresh) Argo() codefresh.ArgoAPI { } // ArgoRuntime provides a mock function with given fields: -func (_m *Codefresh) ArgoRuntime() codefresh.IArgoRuntimeAPI { +func (_m *Codefresh) ArgoRuntime() codefresh.IRuntimeAPI { ret := _m.Called() - var r0 codefresh.IArgoRuntimeAPI - if rf, ok := ret.Get(0).(func() codefresh.IArgoRuntimeAPI); ok { + var r0 codefresh.IRuntimeAPI + if rf, ok := ret.Get(0).(func() codefresh.IRuntimeAPI); ok { r0 = rf() } else { if ret.Get(0) != nil { - r0 = ret.Get(0).(codefresh.IArgoRuntimeAPI) + r0 = ret.Get(0).(codefresh.IRuntimeAPI) } } From d2d4545dcd6f7bac000280f36454bc1a4fd6c32d Mon Sep 17 00:00:00 2001 From: Oren Gurfinkel Date: Tue, 17 Aug 2021 15:33:37 +0300 Subject: [PATCH 81/81] generate mocks --- VERSION | 2 +- pkg/codefresh/mocks/codefresh.go | 48 +++++++++++--------------------- 2 files changed, 17 insertions(+), 33 deletions(-) diff --git a/VERSION b/VERSION index 9eb2aa3..fd9620c 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.32.0 +0.32.1 diff --git a/pkg/codefresh/mocks/codefresh.go b/pkg/codefresh/mocks/codefresh.go index 96e8d3f..caea0d8 100644 --- a/pkg/codefresh/mocks/codefresh.go +++ b/pkg/codefresh/mocks/codefresh.go @@ -28,38 +28,6 @@ func (_m *Codefresh) Argo() codefresh.ArgoAPI { return r0 } -// ArgoRuntime provides a mock function with given fields: -func (_m *Codefresh) ArgoRuntime() codefresh.IRuntimeAPI { - ret := _m.Called() - - var r0 codefresh.IRuntimeAPI - if rf, ok := ret.Get(0).(func() codefresh.IRuntimeAPI); ok { - r0 = rf() - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(codefresh.IRuntimeAPI) - } - } - - return r0 -} - -// GitSource provides a mock function with given fields: -func (_m *Codefresh) GitSource() codefresh.IGitSourceAPI { - ret := _m.Called() - - var r0 codefresh.IGitSourceAPI - if rf, ok := ret.Get(0).(func() codefresh.IGitSourceAPI); ok { - r0 = rf() - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(codefresh.IGitSourceAPI) - } - } - - return r0 -} - // Clusters provides a mock function with given fields: func (_m *Codefresh) Clusters() codefresh.IClusterAPI { ret := _m.Called() @@ -188,6 +156,22 @@ func (_m *Codefresh) Users() codefresh.UsersAPI { return r0 } +// V2 provides a mock function with given fields: +func (_m *Codefresh) V2() codefresh.V2API { + ret := _m.Called() + + var r0 codefresh.V2API + if rf, ok := ret.Get(0).(func() codefresh.V2API); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(codefresh.V2API) + } + } + + return r0 +} + // Workflows provides a mock function with given fields: func (_m *Codefresh) Workflows() codefresh.IWorkflowAPI { ret := _m.Called()