Skip to content

Commit

Permalink
feat: Add config name into configuration instead of putting it into i…
Browse files Browse the repository at this point in the history
…nstance name.
  • Loading branch information
Matovidlo committed Dec 17, 2024
1 parent af96fc1 commit b058f50
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 27 deletions.
2 changes: 2 additions & 0 deletions internal/pkg/service/templates/api/service/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,7 @@ func (s *service) Preview(ctx context.Context, d dependencies.ProjectRequestScop

// Options
options := preview.Options{
ConfigName: payload.Name,
TargetBranch: branchKey,
Inputs: values,
}
Expand Down Expand Up @@ -858,6 +859,7 @@ func generateTemplatePreview(ctx context.Context, tmpl *template.Template, d dep
plan, err := useTemplate.PrepareTemplate(ctx, d, useTemplate.ExtendedOptions{
TargetBranch: o.TargetBranch,
Inputs: o.Inputs,
ConfigName: o.ConfigName,
ProjectState: projectState,
Template: tmpl,
TemplateCtx: tmplCtx,
Expand Down
2 changes: 1 addition & 1 deletion internal/pkg/template/context/preview/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ type Context struct {
}

type Options struct {
InstanceName string
ConfigName string
TargetBranch model.BranchKey
Inputs template.InputsValues
SkipEncrypt bool
Expand Down
2 changes: 2 additions & 0 deletions pkg/lib/operation/project/local/template/use/operation.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ type ExtendedOptions struct {
Inputs template.InputsValues
InstanceID string
InstanceName string
ConfigName string
ProjectState *project.State
Template *template.Template
TemplateCtx template.Context
Expand Down Expand Up @@ -215,6 +216,7 @@ func PrepareTemplate(ctx context.Context, d dependencies, o ExtendedOptions) (pl
config.Local.Name = plan.options.ConfigName
}

// Save config ID
configID := objectState.ObjectID()
if plan.result == nil {
plan.result = &Result{ConfigID: configID}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,36 @@
"description": "",
"isDefault": true,
"metadata": {
"KBC.KAC.templates.instances": "[{\"instanceId\":\"\",\"instanceName\":\"inst-001\",\"templateId\":\"my-template-id\",\"repositoryName\":\"keboola\",\"version\":\"1.2.3\",\"created\":{\"date\":\"%s\",\"tokenId\":\"%s\"},\"updated\":{\"date\":\"%s\",\"tokenId\":\"%s\"}}]"
"KBC.KAC.templates.instances": "[{\"instanceId\":\"\",\"instanceName\":\"\",\"templateId\":\"my-template-id\",\"repositoryName\":\"keboola\",\"version\":\"1.2.3\",\"created\":{\"date\":\"%s\",\"tokenId\":\"%s\"},\"updated\":{\"date\":\"%s\",\"tokenId\":\"%s\"}}]"
}
},
"configs": [
{
"componentId": "ex-generic-v2",
"name": "inst-001",
"description": "test fixture",
"changeDescription": "From template keboola/my-template-id/1.2.3",
"configuration": {
"authorization": {
"oauth_api": {}
},
"parameters": {
"shop": "shop",
"token": "token"
}
},
"rows": [],
"metadata": {
"KBC.KAC.templates.configId": "{\"idInTemplate\":\"shopify\"}",
"KBC.KAC.templates.configInputs": "[{\"input\":\"oauth\",\"key\":\"authorization.oauth_api\"},{\"input\":\"shopify-token\",\"key\":\"parameters.token\"}]",
"KBC.KAC.templates.repository": "keboola",
"KBC.KAC.templates.templateId": "my-template-id"
},
"isDisabled": false
},
{
"componentId": "keboola.data-apps",
"name": "My Data App /%s",
"name": "inst-001",
"description": "test fixture",
"changeDescription": "From template keboola/my-template-id/1.2.3",
"configuration": {
Expand All @@ -32,7 +55,7 @@
},
{
"componentId": "keboola.ex-instagram",
"name": "instagram",
"name": "inst-001",
"description": "test fixture",
"changeDescription": "From template keboola/my-template-id/1.2.3",
"configuration": {
Expand Down Expand Up @@ -62,29 +85,6 @@
"KBC.KAC.templates.templateId": "my-template-id"
},
"isDisabled": false
},
{
"componentId": "ex-generic-v2",
"name": "shopify",
"description": "test fixture",
"changeDescription": "From template keboola/my-template-id/1.2.3",
"configuration": {
"authorization": {
"oauth_api": {}
},
"parameters": {
"shop": "shop",
"token": "token"
}
},
"rows": [],
"metadata": {
"KBC.KAC.templates.configId": "{\"idInTemplate\":\"shopify\"}",
"KBC.KAC.templates.configInputs": "[{\"input\":\"oauth\",\"key\":\"authorization.oauth_api\"},{\"input\":\"shopify-token\",\"key\":\"parameters.token\"}]",
"KBC.KAC.templates.repository": "keboola",
"KBC.KAC.templates.templateId": "my-template-id"
},
"isDisabled": false
}
]
}
Expand Down

0 comments on commit b058f50

Please sign in to comment.