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

Expose source.license through the API #854

Merged
merged 3 commits into from
Jul 28, 2022
Merged
Show file tree
Hide file tree
Changes from 2 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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added

* Add `elastic.subscription` condition to package index metadata, use this value for backwards compatibility with previous `license` field. [#826](https://github.com/elastic/package-registry/pull/826)
* Add `source.license` to relevant API responses when available. [#854](https://github.com/elastic/package-registry/pull/854)

### Deprecated

Expand Down
6 changes: 6 additions & 0 deletions packages/package.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ type BasePackage struct {
Title *string `config:"title,omitempty" json:"title,omitempty" yaml:"title,omitempty"`
Version string `config:"version" json:"version"`
Release string `config:"release,omitempty" json:"release,omitempty"`
Source *Source `config:"source,omitempty" json:"source,omitempty"`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you want a yaml:"source,omitempty" here too? This struct inconsistently uses yaml tags.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, good point, we should take a look to these differences. @mtojek do you know why there are fields with different sets of annotations?

Description string `config:"description" json:"description"`
Type string `config:"type" json:"type"`
Download string `json:"download" yaml:"download,omitempty"`
Expand Down Expand Up @@ -121,6 +122,11 @@ type PolicyTemplate struct {
TemplatePath string `config:"template_path,omitempty" json:"template_path,omitempty" yaml:"template_path,omitempty"`
}

// Source contains metadata about the source of the package and its distribution.
type Source struct {
License string `config:"license,omitempty" json:"license,omitempty" yaml:"license,omitempty"`
}

type Conditions struct {
Kibana *KibanaConditions `config:"kibana,omitempty" json:"kibana,omitempty" yaml:"kibana,omitempty"`
Elastic *ElasticConditions `config:"elastic,omitempty" json:"elastic,omitempty" yaml"elastic,omitempty"`
Expand Down
6 changes: 6 additions & 0 deletions packages/testdata/marshaler/packages.json
Original file line number Diff line number Diff line change
Expand Up @@ -700,6 +700,9 @@
"title": "Example Integration",
"version": "1.1.0",
"release": "ga",
"source": {
"license": "Elastic-2.0"
},
"description": "This is the example integration",
"type": "integration",
"download": "/epr/example/example-1.1.0.zip",
Expand Down Expand Up @@ -799,6 +802,9 @@
"title": "Example Integration",
"version": "1.2.0-rc1",
"release": "ga",
"source": {
"license": "Elastic-2.0"
},
"description": "This is the example integration",
"type": "integration",
"download": "/epr/example/example-1.2.0-rc1.zip",
Expand Down
3 changes: 3 additions & 0 deletions testdata/generated/package/example/1.1.0/index.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
"title": "Example Integration",
"version": "1.1.0",
"release": "ga",
"source": {
"license": "Elastic-2.0"
},
"description": "This is the example integration",
"type": "integration",
"download": "/epr/example/example-1.1.0.zip",
Expand Down
3 changes: 3 additions & 0 deletions testdata/generated/package/example/1.2.0-rc1/index.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
"title": "Example Integration",
"version": "1.2.0-rc1",
"release": "ga",
"source": {
"license": "Elastic-2.0"
},
"description": "This is the example integration",
"type": "integration",
"download": "/epr/example/example-1.2.0-rc1.zip",
Expand Down
3 changes: 3 additions & 0 deletions testdata/generated/search-all.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,9 @@
"title": "Example Integration",
"version": "1.1.0",
"release": "ga",
"source": {
"license": "Elastic-2.0"
},
"description": "This is the example integration",
"type": "integration",
"download": "/epr/example/example-1.1.0.zip",
Expand Down
3 changes: 3 additions & 0 deletions testdata/generated/search-category-datastore-prerelease.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@
"title": "Example Integration",
"version": "1.2.0-rc1",
"release": "ga",
"source": {
"license": "Elastic-2.0"
},
"description": "This is the example integration",
"type": "integration",
"download": "/epr/example/example-1.2.0-rc1.zip",
Expand Down
3 changes: 3 additions & 0 deletions testdata/generated/search-category-datastore.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@
"title": "Example Integration",
"version": "1.2.0-rc1",
"release": "ga",
"source": {
"license": "Elastic-2.0"
},
"description": "This is the example integration",
"type": "integration",
"download": "/epr/example/example-1.2.0-rc1.zip",
Expand Down
3 changes: 3 additions & 0 deletions testdata/generated/search-kibana800.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@
"title": "Example Integration",
"version": "1.1.0",
"release": "ga",
"source": {
"license": "Elastic-2.0"
},
"description": "This is the example integration",
"type": "integration",
"download": "/epr/example/example-1.1.0.zip",
Expand Down
3 changes: 3 additions & 0 deletions testdata/generated/search-package-example-all.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@
"title": "Example Integration",
"version": "1.1.0",
"release": "ga",
"source": {
"license": "Elastic-2.0"
},
"description": "This is the example integration",
"type": "integration",
"download": "/epr/example/example-1.1.0.zip",
Expand Down
3 changes: 3 additions & 0 deletions testdata/generated/search-package-example.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
"title": "Example Integration",
"version": "1.1.0",
"release": "ga",
"source": {
"license": "Elastic-2.0"
},
"description": "This is the example integration",
"type": "integration",
"download": "/epr/example/example-1.1.0.zip",
Expand Down
3 changes: 3 additions & 0 deletions testdata/generated/search-package-experimental.json
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,9 @@
"title": "Example Integration",
"version": "1.2.0-rc1",
"release": "ga",
"source": {
"license": "Elastic-2.0"
},
"description": "This is the example integration",
"type": "integration",
"download": "/epr/example/example-1.2.0-rc1.zip",
Expand Down
3 changes: 3 additions & 0 deletions testdata/generated/search-package-internal.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@
"title": "Example Integration",
"version": "1.1.0",
"release": "ga",
"source": {
"license": "Elastic-2.0"
},
"description": "This is the example integration",
"type": "integration",
"download": "/epr/example/example-1.1.0.zip",
Expand Down
3 changes: 3 additions & 0 deletions testdata/generated/search-package-prerelease.json
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,9 @@
"title": "Example Integration",
"version": "1.2.0-rc1",
"release": "ga",
"source": {
"license": "Elastic-2.0"
},
"description": "This is the example integration",
"type": "integration",
"download": "/epr/example/example-1.2.0-rc1.zip",
Expand Down
3 changes: 3 additions & 0 deletions testdata/generated/search.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@
"title": "Example Integration",
"version": "1.1.0",
"release": "ga",
"source": {
"license": "Elastic-2.0"
},
"description": "This is the example integration",
"type": "integration",
"download": "/epr/example/example-1.1.0.zip",
Expand Down
2 changes: 2 additions & 0 deletions testdata/package/example/1.1.0/manifest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ title: Example Integration
categories: ["crm", "azure"]
type: integration
release: ga
source:
license: Elastic-2.0

owner.github: "ruflin"

Expand Down
2 changes: 2 additions & 0 deletions testdata/package/example/1.2.0-rc1/manifest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ title: Example Integration
categories: ["crm", "azure", "cloud"]
type: integration
release: ga
source:
license: Elastic-2.0

owner.github: "ruflin"

Expand Down