-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
26 changed files
with
2,810 additions
and
123 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
0.24.2 | ||
0.32.1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.