Skip to content

Commit ad99aea

Browse files
committed
resolve merge conflict
2 parents 1f27776 + 532428d commit ad99aea

26 files changed

+2810
-123
lines changed

.goreleaser.yml

-27
This file was deleted.

VERSION

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.24.2
1+
0.32.1

codefresh.yaml

+13-31
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,28 @@
11
version: '1.0'
22

33
stages:
4+
- Prepare
45
- Release
56

6-
mode: parallel
7-
87
steps:
98

10-
CreatingGitTag:
11-
title: Push tag to git
12-
image: codefresh/cli
13-
stage: Release
14-
commands:
15-
- export VERSION=$(cat VERSION)
16-
- export OLD_ORIGIN=$(git remote get-url origin)
17-
- git remote rm origin
18-
- git remote add origin https://${{GITHUB_TOKEN}}@github.com/codefresh-io/go-sdk.git
19-
- git tag v$VERSION
20-
- git push --tags
21-
- git remote rm origin
22-
- git remote add origin $OLD_ORIGIN
23-
fail_fast: false
24-
when:
25-
steps:
26-
- name: main_clone
27-
branch:
28-
only:
29-
- master
9+
main_clone:
10+
stage: Prepare
11+
title: clone repository
12+
type: git-clone
13+
git: cf_github
14+
repo: ${{CF_REPO_OWNER}}/${{CF_REPO_NAME}}
15+
revision: ${{CF_BRANCH}}
3016

3117
ReleasingBinaries:
3218
title: Create release in Github
33-
image: goreleaser/goreleaser
19+
image: quay.io/codefresh/golang-ci-helper:latest
3420
stage: Release
35-
fail_fast: false
3621
commands:
37-
- go mod download
38-
- goreleaser release -f .goreleaser.yml --rm-dist --skip-validate
22+
- export VERSION=$(cat VERSION)
23+
- VERSION=$(if [[ ${VERSION:0:1} == "v" ]] ; then echo $VERSION; else echo "v${VERSION}"; fi )
24+
- gh release create --repo ${{CF_REPO_OWNER}}/${{CF_REPO_NAME}} -t $VERSION -n $VERSION $VERSION
3925
when:
40-
steps:
41-
- name: CreatingGitTag
42-
on:
43-
- finished
4426
branch:
4527
only:
46-
- master
28+
- master

go.mod

+7-3
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,20 @@ module github.com/codefresh-io/go-sdk
33
require (
44
github.com/BurntSushi/toml v0.3.1 // indirect
55
github.com/dustin/go-humanize v1.0.0
6+
github.com/google/go-querystring v1.1.0
67
github.com/inconshreveable/mousetrap v1.0.0 // indirect
8+
github.com/kr/pretty v0.1.0 // indirect
79
github.com/mattn/go-runewidth v0.0.4 // indirect
810
github.com/mitchellh/go-homedir v1.0.0
911
github.com/olekukonko/tablewriter v0.0.1
1012
github.com/spf13/afero v1.2.0 // indirect
1113
github.com/spf13/cobra v0.0.3
1214
github.com/spf13/viper v1.3.1
13-
github.com/stretchr/testify v1.7.0 // indirect
14-
golang.org/x/sys v0.0.0-20181228144115-9a3f9b0469bb // indirect
15-
gopkg.in/yaml.v2 v2.2.2
15+
github.com/stretchr/objx v0.3.0 // indirect
16+
github.com/stretchr/testify v1.4.0
17+
golang.org/x/sys v0.0.0-20200116001909-b77594299b42 // indirect
18+
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 // indirect
19+
gopkg.in/yaml.v2 v2.2.4
1620
)
1721

1822
go 1.13

go.sum

+22-10
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,19 @@ github.com/dustin/go-humanize v1.0.0 h1:VSnTsYCnlFHaM2/igO1h6X3HA71jcobQuxemgkq4
1111
github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk=
1212
github.com/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV9I=
1313
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
14+
github.com/google/go-cmp v0.5.2 h1:X2ev0eStA3AbceY54o37/0PQ/UWqKEiiO2dKL5OPaFM=
15+
github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
16+
github.com/google/go-querystring v1.1.0 h1:AnCroh3fv4ZBgVIf1Iwtovgjaw/GiKJo8M8yD/fhyJ8=
17+
github.com/google/go-querystring v1.1.0/go.mod h1:Kcdr2DB4koayq7X8pmAG4sNG59So17icRSOU623lUBU=
1418
github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4=
1519
github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ=
1620
github.com/inconshreveable/mousetrap v1.0.0 h1:Z8tu5sraLXCXIcARxBp/8cbvlwVa7Z1NHg9XEKhtSvM=
1721
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
22+
github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI=
23+
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
24+
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
25+
github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
26+
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
1827
github.com/magiconair/properties v1.8.0 h1:LLgXmsheXeRoUOBOjtwPQCWIYqM/LU1ayDtDePerRcY=
1928
github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ=
2029
github.com/mattn/go-runewidth v0.0.4 h1:2BvfKmzob6Bmd4YsL0zygOqfdFnK7GR4QL06Do4/p7Y=
@@ -42,23 +51,26 @@ github.com/spf13/pflag v1.0.3 h1:zPAT6CGy6wXeQ7NtTnaTerfKOsV6V6F8agHXFiazDkg=
4251
github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4=
4352
github.com/spf13/viper v1.3.1 h1:5+8j8FTpnFV4nEImW/ofkzEt8VoOiLXxdYIDsB73T38=
4453
github.com/spf13/viper v1.3.1/go.mod h1:ZiWeW+zYFKm7srdB9IoDzzZXaJaI5eL9QjNiN/DMA2s=
45-
github.com/stretchr/objx v0.1.0 h1:4G4v2dO3VZwixGIRoQ5Lfboy6nUhCyYzaqnIAPPhYs4=
4654
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
47-
github.com/stretchr/testify v1.2.2 h1:bSDNvY7ZPG5RlJ8otE/7V6gMiyenm9RtJ7IUVIAoJ1w=
55+
github.com/stretchr/objx v0.3.0 h1:NGXK3lHquSN08v5vWalVI/L8XU9hdzE/G6xsrze47As=
56+
github.com/stretchr/objx v0.3.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE=
4857
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
49-
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
50-
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
58+
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
59+
github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk=
60+
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
5161
github.com/ugorji/go/codec v0.0.0-20181204163529-d75b2dcb6bc8/go.mod h1:VFNgLljTbGfSG7qAOspJ7OScBnGdDN/yBr0sguwnwf0=
5262
github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q=
5363
golang.org/x/crypto v0.0.0-20181203042331-505ab145d0a9/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
5464
golang.org/x/sys v0.0.0-20181205085412-a5c9d58dba9a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
55-
golang.org/x/sys v0.0.0-20181228144115-9a3f9b0469bb h1:pf3XwC90UUdNPYWZdFjhGBE7DUFuK3Ct1zWmZ65QN30=
56-
golang.org/x/sys v0.0.0-20181228144115-9a3f9b0469bb/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
65+
golang.org/x/sys v0.0.0-20200116001909-b77594299b42 h1:vEOn+mP2zCOVzKckCZy6YsCtDblrpj/w7B9nxGNELpg=
66+
golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
5767
golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg=
5868
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
59-
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
69+
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4=
70+
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
6071
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
61-
gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw=
72+
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo=
73+
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
6274
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
63-
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
64-
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
75+
gopkg.in/yaml.v2 v2.2.4 h1:/eiJrUcujPVeJ3xlSWaiNi3uSVmDGBK1pDHUHAnao1I=
76+
gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=

pkg/codefresh/argo.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ type (
1414
}
1515

1616
argo struct {
17-
codefresh Codefresh
17+
codefresh *codefresh
1818
}
1919

2020
IntegrationItem struct {
@@ -50,7 +50,7 @@ type (
5050
}
5151
)
5252

53-
func newArgoAPI(codefresh Codefresh) ArgoAPI {
53+
func newArgoAPI(codefresh *codefresh) ArgoAPI {
5454
return &argo{codefresh}
5555
}
5656

pkg/codefresh/argo_runtime.go

+110
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
package codefresh
2+
3+
import (
4+
"context"
5+
"fmt"
6+
7+
"github.com/codefresh-io/go-sdk/pkg/codefresh/model"
8+
)
9+
10+
type (
11+
IRuntimeAPI interface {
12+
List(ctx context.Context) ([]model.Runtime, error)
13+
Create(ctx context.Context, runtimeName, cluster, runtimeVersion string) (*model.RuntimeCreationResponse, error)
14+
}
15+
16+
argoRuntime struct {
17+
codefresh *codefresh
18+
}
19+
20+
graphqlRuntimesResponse struct {
21+
Data struct {
22+
Runtimes model.RuntimePage
23+
}
24+
Errors []graphqlError
25+
}
26+
27+
graphQlRuntimeCreationResponse struct {
28+
Data struct {
29+
Runtime model.RuntimeCreationResponse
30+
}
31+
Errors []graphqlError
32+
}
33+
)
34+
35+
func newArgoRuntimeAPI(codefresh *codefresh) IRuntimeAPI {
36+
return &argoRuntime{codefresh: codefresh}
37+
}
38+
39+
func (r *argoRuntime) List(ctx context.Context) ([]model.Runtime, error) {
40+
jsonData := map[string]interface{}{
41+
"query": `{
42+
runtimes {
43+
edges {
44+
node {
45+
metadata {
46+
name
47+
namespace
48+
}
49+
self {
50+
healthStatus
51+
version
52+
}
53+
cluster
54+
}
55+
}
56+
}
57+
}`,
58+
}
59+
60+
res := &graphqlRuntimesResponse{}
61+
err := r.codefresh.graphqlAPI(ctx, jsonData, res)
62+
if err != nil {
63+
return nil, fmt.Errorf("failed getting runtime list: %w", err)
64+
}
65+
66+
if len(res.Errors) > 0 {
67+
return nil, graphqlErrorResponse{errors: res.Errors}
68+
}
69+
70+
runtimes := make([]model.Runtime, len(res.Data.Runtimes.Edges))
71+
for i := range res.Data.Runtimes.Edges {
72+
runtimes[i] = *res.Data.Runtimes.Edges[i].Node
73+
}
74+
75+
return runtimes, nil
76+
}
77+
78+
func (r *argoRuntime) Create(ctx context.Context, runtimeName, cluster, runtimeVersion string) (*model.RuntimeCreationResponse, error) {
79+
jsonData := map[string]interface{}{
80+
"query": `
81+
mutation CreateRuntime(
82+
$name: String!
83+
$cluster: String!
84+
$runtimeVersion: String!
85+
) {
86+
runtime(name: $name, cluster: $cluster, runtimeVersion: $runtimeVersion) {
87+
name
88+
newAccessToken
89+
}
90+
}
91+
`,
92+
"variables": map[string]interface{}{
93+
"name": runtimeName,
94+
"cluster": cluster,
95+
"runtimeVersion": runtimeVersion,
96+
},
97+
}
98+
99+
res := &graphQlRuntimeCreationResponse{}
100+
err := r.codefresh.graphqlAPI(ctx, jsonData, res)
101+
if err != nil {
102+
return nil, fmt.Errorf("failed getting runtime list: %w", err)
103+
}
104+
105+
if len(res.Errors) > 0 {
106+
return nil, graphqlErrorResponse{errors: res.Errors}
107+
}
108+
109+
return &res.Data.Runtime, nil
110+
}

pkg/codefresh/cluster.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ type (
99
}
1010

1111
cluster struct {
12-
codefresh Codefresh
12+
codefresh *codefresh
1313
}
1414

1515
Cluster struct {
@@ -31,7 +31,7 @@ type (
3131
}
3232
)
3333

34-
func newClusterAPI(codefresh Codefresh) IClusterAPI {
34+
func newClusterAPI(codefresh *codefresh) IClusterAPI {
3535
return &cluster{codefresh}
3636
}
3737

0 commit comments

Comments
 (0)