Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: Update template filter #2150

Merged
merged 4 commits into from
Nov 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions api/templates/design.go
Original file line number Diff line number Diff line change
Expand Up @@ -570,8 +570,9 @@ var TemplateRequest = Type("TemplateRequest", func() {

var TemplatesRequest = Type("TemplatesRequest", func() {
Extend(RepositoryRequest)
Attribute("filter", String, "The 'filter' attribute specifies the category of templates to retrieve from the repository.", func() {
Enum("keboola.components", "keboola.data-apps")
Attribute("filter", String, func() {
Description("The 'filter' attribute specifies the category of templates to retrieve from the repository.")
Example("keboola.data-apps")
})
})

Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion internal/pkg/service/templates/api/openapi/openapi.json

Large diffs are not rendered by default.

3 changes: 0 additions & 3 deletions internal/pkg/service/templates/api/openapi/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -516,9 +516,6 @@ paths:
description: The 'filter' attribute specifies the category of templates to retrieve from the repository.
required: false
type: string
enum:
- keboola.components
- keboola.data-apps
- name: repository
in: path
description: Name of the template repository. Use "keboola" for default Keboola repository.
Expand Down
2 changes: 1 addition & 1 deletion internal/pkg/service/templates/api/openapi/openapi3.json

Large diffs are not rendered by default.

6 changes: 0 additions & 6 deletions internal/pkg/service/templates/api/openapi/openapi3.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -977,9 +977,6 @@ paths:
type: string
description: The 'filter' attribute specifies the category of templates to retrieve from the repository.
example: keboola.data-apps
enum:
- keboola.components
- keboola.data-apps
example: keboola.data-apps
- name: repository
in: path
Expand Down Expand Up @@ -4051,9 +4048,6 @@ components:
type: string
description: The 'filter' attribute specifies the category of templates to retrieve from the repository.
example: keboola.data-apps
enum:
- keboola.components
- keboola.data-apps
repository:
type: string
description: Name of the template repository. Use "keboola" for default Keboola repository.
Expand Down
16 changes: 2 additions & 14 deletions internal/pkg/service/templates/api/service/mapper.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,21 +137,9 @@ func TemplatesResponse(ctx context.Context, d dependencies.ProjectRequestScope,
}

if filterBy != nil && *filterBy != "" {
t, found := tmpl.DefaultVersion()
if !found {
continue
}

filterString := *filterBy
switch filterString {
case KeboolaDataApps:
if !slices.Contains(t.Components, filterString) {
continue
}
case KeboolaComponents:
if slices.Contains(t.Components, KeboolaDataApps) {
continue
}
if !slices.Contains(tmpl.Requirements.Components, filterString) {
continue
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@
],
"components": [
"keboola.wr-%s",
"foo.bar",
"keboola.data-apps"
],
"versions": [
Expand All @@ -60,31 +59,6 @@
}
]
},
{
"id": "my-template-id-6",
"name": "My Template-snowflake-6",
"deprecated": false,
"author": {
"name": "Example Author",
"url": "https://example.com"
},
"description": "Full workflow to ...",
"defaultVersion": "1.2.3",
"categories": [
"Other"
],
"components": [
"keboola.wr-%s",
"foo.bar"
],
"versions": [
{
"version": "1.2.3",
"stable": false,
"description": ""
}
]
},
{
"id": "my-template-id-7",
"name": "My Template-snowflake-7",
Expand All @@ -100,8 +74,8 @@
],
"components": [
"keboola.wr-%s",
"foo.bar",
"keboola.data-apps"
"keboola.data-apps",
"keboola.wr-google-sheets"
],
"versions": [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
],
"components": [
"keboola.wr-%s",
"foo.bar",
"keboola.data-apps"
],
"versions": [
Expand All @@ -50,8 +49,8 @@
],
"components": [
"keboola.wr-%s",
"foo.bar",
"keboola.data-apps"
"keboola.data-apps",
"keboola.wr-google-sheets"
],
"versions": [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
},
"templates": [
{
"id": "my-template-id-3",
"name": "My Template-snowflake-3",
"id": "my-template-id-7",
"name": "My Template-snowflake-7",
"deprecated": false,
"author": {
"name": "Example Author",
Expand All @@ -24,32 +24,8 @@
],
"components": [
"keboola.wr-%s",
"foo.bar"
],
"versions": [
{
"version": "1.2.3",
"stable": false,
"description": ""
}
]
},
{
"id": "my-template-id-6",
"name": "My Template-snowflake-6",
"deprecated": false,
"author": {
"name": "Example Author",
"url": "https://example.com"
},
"description": "Full workflow to ...",
"defaultVersion": "1.2.3",
"categories": [
"Other"
],
"components": [
"keboola.wr-%s",
"foo.bar"
"keboola.data-apps",
"keboola.wr-google-sheets"
],
"versions": [
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"path": "/v1/repositories/keboola/templates?filter=keboola.components",
"path": "/v1/repositories/keboola/templates?filter=keboola.wr-google-sheets",
"method": "GET",
"headers": {
"Content-Type": "application/json",
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
400
200
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
{
"statusCode": 400,
"error": "templates.invalidEnumValue",
"message": "Value of filter must be one of \"keboola.components\", \"keboola.data-apps\" but got value \"312312\"."
"repository": {
"name": "keboola",
"url": "%s/test/templates/api/repositories/template-list-filter/repository",
"ref": "",
"author": {
"name": "Example Author",
"url": "https://example.com"
}
},
"templates": []
}
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,9 @@
"requirements": {
"backends":[
"bigquery"
],
"components": [
"keboola.data-apps"
]
},
"versions": [
Expand All @@ -127,6 +130,9 @@
"requirements": {
"backends":[
"snowflake"
],
"components": [
"keboola.data-apps"
]
},
"versions": [
Expand All @@ -137,7 +143,6 @@
"path": "v1",
"components": [
"<keboola.wr-snowflake>",
"foo.bar",
"keboola.data-apps"
]
}
Expand All @@ -151,6 +156,9 @@
"requirements": {
"backends":[
"snowflake"
],
"components": [
"<keboola.wr-snowflake>"
]
},
"versions": [
Expand All @@ -174,6 +182,10 @@
"requirements": {
"backends":[
"snowflake"
],
"components": [
"keboola.data-apps",
"keboola.wr-google-sheets"
]
},
"versions": [
Expand All @@ -184,8 +196,8 @@
"path": "v1",
"components": [
"<keboola.wr-snowflake>",
"foo.bar",
"keboola.data-apps"
"keboola.data-apps",
"keboola.wr-google-sheets"
]
}
]
Expand Down