Skip to content

Commit

Permalink
resolve merge conflict
Browse files Browse the repository at this point in the history
  • Loading branch information
janitha09 committed Aug 17, 2021
2 parents 1f27776 + 532428d commit a71757f
Show file tree
Hide file tree
Showing 26 changed files with 2,810 additions and 123 deletions.
27 changes: 0 additions & 27 deletions .goreleaser.yml

This file was deleted.

2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.24.2
0.32.1
44 changes: 13 additions & 31 deletions codefresh.yaml
Original file line number Diff line number Diff line change
@@ -1,46 +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
- 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:
steps:
- name: CreatingGitTag
on:
- finished
branch:
only:
- master
- master
10 changes: 7 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,20 @@ 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/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
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/testify v1.7.0 // indirect
golang.org/x/sys v0.0.0-20181228144115-9a3f9b0469bb // indirect
gopkg.in/yaml.v2 v2.2.2
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
)

go 1.13
32 changes: 22 additions & 10 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,19 @@ 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=
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/magiconair/properties v1.8.0 h1:LLgXmsheXeRoUOBOjtwPQCWIYqM/LU1ayDtDePerRcY=
github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ=
github.com/mattn/go-runewidth v0.0.4 h1:2BvfKmzob6Bmd4YsL0zygOqfdFnK7GR4QL06Do4/p7Y=
Expand Down Expand Up @@ -42,23 +51,26 @@ 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/objx v0.1.0 h1:4G4v2dO3VZwixGIRoQ5Lfboy6nUhCyYzaqnIAPPhYs4=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.2.2 h1:bSDNvY7ZPG5RlJ8otE/7V6gMiyenm9RtJ7IUVIAoJ1w=
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.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
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/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/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-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=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
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=
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.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v2 v2.2.4 h1:/eiJrUcujPVeJ3xlSWaiNi3uSVmDGBK1pDHUHAnao1I=
gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
4 changes: 2 additions & 2 deletions pkg/codefresh/argo.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ type (
}

argo struct {
codefresh Codefresh
codefresh *codefresh
}

IntegrationItem struct {
Expand Down Expand Up @@ -50,7 +50,7 @@ type (
}
)

func newArgoAPI(codefresh Codefresh) ArgoAPI {
func newArgoAPI(codefresh *codefresh) ArgoAPI {
return &argo{codefresh}
}

Expand Down
110 changes: 110 additions & 0 deletions pkg/codefresh/argo_runtime.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
package codefresh

import (
"context"
"fmt"

"github.com/codefresh-io/go-sdk/pkg/codefresh/model"
)

type (
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
}
Errors []graphqlError
}

graphQlRuntimeCreationResponse struct {
Data struct {
Runtime model.RuntimeCreationResponse
}
Errors []graphqlError
}
)

func newArgoRuntimeAPI(codefresh *codefresh) IRuntimeAPI {
return &argoRuntime{codefresh: codefresh}
}

func (r *argoRuntime) List(ctx context.Context) ([]model.Runtime, error) {
jsonData := map[string]interface{}{
"query": `{
runtimes {
edges {
node {
metadata {
name
namespace
}
self {
healthStatus
version
}
cluster
}
}
}
}`,
}

res := &graphqlRuntimesResponse{}
err := r.codefresh.graphqlAPI(ctx, jsonData, res)
if err != nil {
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
}

func (r *argoRuntime) Create(ctx context.Context, runtimeName, cluster, runtimeVersion string) (*model.RuntimeCreationResponse, 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,
},
}

res := &graphQlRuntimeCreationResponse{}
err := r.codefresh.graphqlAPI(ctx, jsonData, res)
if err != nil {
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
}
4 changes: 2 additions & 2 deletions pkg/codefresh/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ type (
}

cluster struct {
codefresh Codefresh
codefresh *codefresh
}

Cluster struct {
Expand All @@ -31,7 +31,7 @@ type (
}
)

func newClusterAPI(codefresh Codefresh) IClusterAPI {
func newClusterAPI(codefresh *codefresh) IClusterAPI {
return &cluster{codefresh}
}

Expand Down
Loading

0 comments on commit a71757f

Please sign in to comment.