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

Fill deprecated license field with the value of the new subscription condition #826

Merged
merged 5 commits into from
Jul 19, 2022
Merged
Show file tree
Hide file tree
Changes from 3 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
15 changes: 13 additions & 2 deletions packages/package.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,8 @@ type PolicyTemplate struct {
}

type Conditions struct {
Kibana *KibanaConditions `config:"kibana,omitempty" json:"kibana,omitempty" yaml:"kibana,omitempty"`
Kibana *KibanaConditions `config:"kibana,omitempty" json:"kibana,omitempty" yaml:"kibana,omitempty"`
Elastic *ElasticConditions `config:"elastic,omitempty" json:"elastic,omitempty" yaml"elastic,omitempty"`
}

// KibanaConditions defines conditions for Kibana (e.g. required version).
Expand All @@ -130,6 +131,11 @@ type KibanaConditions struct {
constraint *semver.Constraints
}

// ElasticConditions defines conditions related to Elastic subscriptions or partnerships.
type ElasticConditions struct {
Subscription string `config:"subscription" json:"subscription" yaml:"subscription"`
}

type Version struct {
Min string `config:"min,omitempty" json:"min,omitempty"`
Max string `config:"max,omitempty" json:"max,omitempty"`
Expand Down Expand Up @@ -250,7 +256,12 @@ func NewPackage(basePath string, fsBuilder FileSystemBuilder) (*Package, error)

// If not license is set, basic is assumed
if p.License == "" {
p.License = DefaultLicense
// Keep compatibility with deprecated license field.
if p.Conditions != nil && p.Conditions.Elastic != nil && p.Conditions.Elastic.Subscription != "" {
p.License = p.Conditions.Elastic.Subscription
} else {
p.License = DefaultLicense
}
}

err = p.setRuntimeFields()
Expand Down
10 changes: 8 additions & 2 deletions packages/testdata/marshaler/packages.json
Original file line number Diff line number Diff line change
Expand Up @@ -806,6 +806,9 @@
"conditions": {
"kibana": {
"version": "^7.16.0 || ^8.0.0"
},
"elastic": {
"subscription": "gold"
}
},
"owner": {
Expand All @@ -818,7 +821,7 @@
],
"format_version": "1.0.0",
"readme": "/package/example/1.2.0-rc1/docs/README.md",
"license": "basic",
"license": "gold",
"screenshots": [
{
"src": "/img/kibana-envoyproxy.jpg",
Expand Down Expand Up @@ -1544,6 +1547,9 @@
"conditions": {
"kibana": {
"version": "\u003e6.7.0"
},
"elastic": {
"subscription": "gold"
}
},
"categories": [
Expand All @@ -1552,7 +1558,7 @@
],
"format_version": "1.0.0",
"readme": "/package/longdocs/1.0.4/docs/README.md",
"license": "basic",
"license": "gold",
"assets": [
"/package/longdocs/1.0.4/manifest.yml",
"/package/longdocs/1.0.4/docs/README.md",
Expand Down
5 changes: 4 additions & 1 deletion testdata/generated/package/example/1.2.0-rc1/index.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
"conditions": {
"kibana": {
"version": "^7.16.0 || ^8.0.0"
},
"elastic": {
"subscription": "gold"
}
},
"owner": {
Expand All @@ -22,7 +25,7 @@
],
"format_version": "1.0.0",
"readme": "/package/example/1.2.0-rc1/docs/README.md",
"license": "basic",
"license": "gold",
"screenshots": [
{
"src": "/img/kibana-envoyproxy.jpg",
Expand Down
5 changes: 4 additions & 1 deletion testdata/generated/package/longdocs/1.0.4/index.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
"conditions": {
"kibana": {
"version": ">6.7.0"
},
"elastic": {
"subscription": "gold"
}
},
"categories": [
Expand All @@ -25,7 +28,7 @@
],
"format_version": "1.0.0",
"readme": "/package/longdocs/1.0.4/docs/README.md",
"license": "basic",
"license": "gold",
"assets": [
"/package/longdocs/1.0.4/manifest.yml",
"/package/longdocs/1.0.4/docs/README.md",
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 @@ -267,6 +267,9 @@
"conditions": {
"kibana": {
"version": ">6.7.0"
},
"elastic": {
"subscription": "gold"
}
},
"categories": [
Expand Down
3 changes: 3 additions & 0 deletions testdata/generated/search-category-custom.json
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,9 @@
"conditions": {
"kibana": {
"version": ">6.7.0"
},
"elastic": {
"subscription": "gold"
}
},
"categories": [
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 @@ -59,6 +59,9 @@
"conditions": {
"kibana": {
"version": "^7.16.0 || ^8.0.0"
},
"elastic": {
"subscription": "gold"
}
},
"owner": {
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 @@ -59,6 +59,9 @@
"conditions": {
"kibana": {
"version": "^7.16.0 || ^8.0.0"
},
"elastic": {
"subscription": "gold"
}
},
"owner": {
Expand Down
3 changes: 3 additions & 0 deletions testdata/generated/search-category-web-all.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
"conditions": {
"kibana": {
"version": ">6.7.0"
},
"elastic": {
"subscription": "gold"
}
},
"categories": [
Expand Down
3 changes: 3 additions & 0 deletions testdata/generated/search-category-web.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
"conditions": {
"kibana": {
"version": ">6.7.0"
},
"elastic": {
"subscription": "gold"
}
},
"categories": [
Expand Down
3 changes: 3 additions & 0 deletions testdata/generated/search-kibana721.json
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,9 @@
"conditions": {
"kibana": {
"version": ">6.7.0"
},
"elastic": {
"subscription": "gold"
}
},
"categories": [
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 @@ -167,6 +167,9 @@
"conditions": {
"kibana": {
"version": ">6.7.0"
},
"elastic": {
"subscription": "gold"
}
},
"categories": [
Expand Down
6 changes: 6 additions & 0 deletions testdata/generated/search-package-experimental.json
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,9 @@
"conditions": {
"kibana": {
"version": "^7.16.0 || ^8.0.0"
},
"elastic": {
"subscription": "gold"
}
},
"owner": {
Expand Down Expand Up @@ -356,6 +359,9 @@
"conditions": {
"kibana": {
"version": ">6.7.0"
},
"elastic": {
"subscription": "gold"
}
},
"categories": [
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 @@ -203,6 +203,9 @@
"conditions": {
"kibana": {
"version": ">6.7.0"
},
"elastic": {
"subscription": "gold"
}
},
"categories": [
Expand Down
6 changes: 6 additions & 0 deletions testdata/generated/search-package-prerelease.json
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,9 @@
"conditions": {
"kibana": {
"version": "^7.16.0 || ^8.0.0"
},
"elastic": {
"subscription": "gold"
}
},
"owner": {
Expand Down Expand Up @@ -356,6 +359,9 @@
"conditions": {
"kibana": {
"version": ">6.7.0"
},
"elastic": {
"subscription": "gold"
}
},
"categories": [
Expand Down
3 changes: 3 additions & 0 deletions testdata/generated/search.json
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,9 @@
"conditions": {
"kibana": {
"version": ">6.7.0"
},
"elastic": {
"subscription": "gold"
}
},
"categories": [
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 @@ -13,6 +13,8 @@ owner.github: "ruflin"
conditions:
kibana:
version: "^7.16.0 || ^8.0.0"
elastic:
subscription: "gold"

screenshots:
- src: /img/kibana-envoyproxy.jpg
Expand Down
3 changes: 2 additions & 1 deletion testdata/package/longdocs/1.0.4/manifest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,12 @@ description: >
version: 1.0.4
categories: ["custom", "web"]
release: ga
license: basic

conditions:
kibana:
version: ">6.7.0"
elastic:
subscription: "gold"

icons:
- src: "/img/icon.svg"
Expand Down