Skip to content

Commit 7275792

Browse files
add promotion template query (#476)
1 parent 4646b3e commit 7275792

File tree

6 files changed

+108
-25
lines changed

6 files changed

+108
-25
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
VERSION=v1.4.3
1+
VERSION=v1.4.4
22

33
ifndef GOBIN
44
ifndef GOPATH

pkg/graphql/graphql.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ type (
1313
Runtime() RuntimeAPI
1414
User() UserAPI
1515
Workflow() WorkflowAPI
16+
PromotionTemplate() PromotionTemplateAPI
1617
}
1718

1819
gqlImpl struct {
@@ -59,3 +60,7 @@ func (v2 *gqlImpl) User() UserAPI {
5960
func (v2 *gqlImpl) Workflow() WorkflowAPI {
6061
return &workflow{client: v2.client}
6162
}
63+
64+
func (v2 *gqlImpl) PromotionTemplate() PromotionTemplateAPI {
65+
return &promotionTemplate{client: v2.client}
66+
}

pkg/graphql/promotion-template.go

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
package graphql
2+
3+
import (
4+
"context"
5+
"fmt"
6+
platmodel "github.com/codefresh-io/go-sdk/pkg/model/platform"
7+
8+
"github.com/codefresh-io/go-sdk/pkg/client"
9+
)
10+
11+
type (
12+
PromotionTemplateAPI interface {
13+
GetVersionSourceByRuntime(ctx context.Context, app *platmodel.ObjectMeta) (*platmodel.PromotionTemplateShort, error)
14+
}
15+
16+
promotionTemplate struct {
17+
client *client.CfClient
18+
}
19+
)
20+
21+
func (c *promotionTemplate) GetVersionSourceByRuntime(ctx context.Context, app *platmodel.ObjectMeta) (*platmodel.PromotionTemplateShort, error) {
22+
query := `
23+
query ($applicationMetadata: Object!) {
24+
promotionTemplateByRuntime(applicationMetadata: $applicationMetadata) {
25+
versionSource {
26+
file
27+
jsonPath
28+
}
29+
}
30+
}`
31+
variables := map[string]any{
32+
"applicationMetadata": app,
33+
}
34+
versionSource, err := client.GraphqlAPI[platmodel.PromotionTemplateShort](ctx, c.client, query, variables)
35+
if err != nil {
36+
return nil, fmt.Errorf("failed to get promotion template: %w", err)
37+
}
38+
39+
return &versionSource, nil
40+
}

pkg/model/app-proxy/models_gen.go

Lines changed: 17 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/model/platform/models_gen.go

Lines changed: 18 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/model/promotion-orchestrator/models_gen.go

Lines changed: 27 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)