Skip to content

Commit de93f9d

Browse files
committed
created V2API interface
1 parent 3ffd0a2 commit de93f9d

File tree

3 files changed

+19
-11
lines changed

3 files changed

+19
-11
lines changed

pkg/codefresh/argo_runtime.go

+4-2
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,15 @@ import (
88
)
99

1010
type (
11-
IArgoRuntimeAPI interface {
11+
IRuntimeAPI interface {
1212
List(ctx context.Context) ([]model.Runtime, error)
1313
Create(ctx context.Context, runtimeName, cluster, runtimeVersion string) (*model.RuntimeCreationResponse, error)
1414
}
15+
1516
argoRuntime struct {
1617
codefresh *codefresh
1718
}
19+
1820
graphqlRuntimesResponse struct {
1921
Data struct {
2022
Runtimes model.RuntimePage
@@ -30,7 +32,7 @@ type (
3032
}
3133
)
3234

33-
func newArgoRuntimeAPI(codefresh *codefresh) IArgoRuntimeAPI {
35+
func newArgoRuntimeAPI(codefresh *codefresh) IRuntimeAPI {
3436
return &argoRuntime{codefresh: codefresh}
3537
}
3638

pkg/codefresh/codefresh.go

+11-5
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,16 @@ type (
2929
Users() UsersAPI
3030
Argo() ArgoAPI
3131
Gitops() GitopsAPI
32-
ArgoRuntime() IArgoRuntimeAPI
32+
V2() V2API
33+
}
34+
35+
V2API interface {
36+
Runtime() IRuntimeAPI
3337
GitSource() IGitSourceAPI
3438
Component() IComponentAPI
3539
}
3640
)
3741

38-
var qlEndPoint = "/2.0/api/graphql"
39-
4042
func New(opt *ClientOptions) Codefresh {
4143
httpClient := &http.Client{}
4244
if opt.Client != nil {
@@ -90,7 +92,11 @@ func (c *codefresh) Gitops() GitopsAPI {
9092
return newGitopsAPI(c)
9193
}
9294

93-
func (c *codefresh) ArgoRuntime() IArgoRuntimeAPI {
95+
func (c *codefresh) V2() V2API {
96+
return c
97+
}
98+
99+
func (c *codefresh) Runtime() IRuntimeAPI {
94100
return newArgoRuntimeAPI(c)
95101
}
96102

@@ -133,7 +139,7 @@ func (c *codefresh) requestAPIWithContext(ctx context.Context, opt *requestOptio
133139
func (c *codefresh) graphqlAPI(ctx context.Context, body map[string]interface{}, res interface{}) error {
134140
response, err := c.requestAPIWithContext(ctx, &requestOptions{
135141
method: "POST",
136-
path: qlEndPoint,
142+
path: "/2.0/api/graphql",
137143
body: body,
138144
})
139145
if err != nil {

pkg/codefresh/mocks/codefresh.go

+4-4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)