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

Add support for elasticsearch.privileges.cluster #750

Merged
merged 6 commits into from
Oct 14, 2021
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
* Configuration file path can be selected with the `-config` flag. [#745](https://github.com/elastic/package-registry/pull/745)
* Configuration flags can be provided using environment variables. [#745](https://github.com/elastic/package-registry/pull/745)
* Add `-tls-cert` and `-tls-key` flags to configure HTTPS. [#711](https://github.com/elastic/package-registry/issues/711) [#746](https://github.com/elastic/package-registry/issues/746)
* Support for `elasticsearch.privileges.cluster` in package manifest. [#750](https://github.com/elastic/package-registry/pull/750)
* Update Go runtime to 1.17.1. [#753](https://github.com/elastic/package-registry/pull/753)

### Deprecated
Expand Down
20 changes: 10 additions & 10 deletions packages/datastream.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@ type DataStream struct {
Release string `config:"release" json:"release"`

// Deprecated: Replaced by elasticsearch.ingest_pipeline.name
IngestPipeline string `config:"ingest_pipeline,omitempty" config:"ingest_pipeline" json:"ingest_pipeline,omitempty" yaml:"ingest_pipeline,omitempty"`
Streams []Stream `config:"streams" json:"streams,omitempty" yaml:"streams,omitempty" `
Package string `json:"package,omitempty" yaml:"package,omitempty"`
Elasticsearch *Elasticsearch `config:"elasticsearch,omitempty" json:"elasticsearch,omitempty" yaml:"elasticsearch,omitempty"`
IngestPipeline string `config:"ingest_pipeline,omitempty" config:"ingest_pipeline" json:"ingest_pipeline,omitempty" yaml:"ingest_pipeline,omitempty"`
Streams []Stream `config:"streams" json:"streams,omitempty" yaml:"streams,omitempty" `
Package string `json:"package,omitempty" yaml:"package,omitempty"`
Elasticsearch *DataStreamElasticsearch `config:"elasticsearch,omitempty" json:"elasticsearch,omitempty" yaml:"elasticsearch,omitempty"`

// Generated fields
Path string `json:"path,omitempty" yaml:"path,omitempty"`
Expand Down Expand Up @@ -94,14 +94,14 @@ type Variable struct {
Default interface{} `config:"default" json:"default,omitempty" yaml:"default,omitempty"`
}

type Elasticsearch struct {
IndexTemplateSettings map[string]interface{} `config:"index_template.settings" json:"index_template.settings,omitempty" yaml:"index_template.settings,omitempty"`
IndexTemplateMappings map[string]interface{} `config:"index_template.mappings" json:"index_template.mappings,omitempty" yaml:"index_template.mappings,omitempty"`
IngestPipelineName string `config:"ingest_pipeline.name,omitempty" json:"ingest_pipeline.name,omitempty" yaml:"ingest_pipeline.name,omitempty"`
Privileges *ElasticsearchPrivileges `config:"privileges,omitempty" json:"privileges,omitempty" yaml:"privileges,omitempty"`
type DataStreamElasticsearch struct {
IndexTemplateSettings map[string]interface{} `config:"index_template.settings" json:"index_template.settings,omitempty" yaml:"index_template.settings,omitempty"`
IndexTemplateMappings map[string]interface{} `config:"index_template.mappings" json:"index_template.mappings,omitempty" yaml:"index_template.mappings,omitempty"`
IngestPipelineName string `config:"ingest_pipeline.name,omitempty" json:"ingest_pipeline.name,omitempty" yaml:"ingest_pipeline.name,omitempty"`
Privileges *DataStreamElasticsearchPrivileges `config:"privileges,omitempty" json:"privileges,omitempty" yaml:"privileges,omitempty"`
}

type ElasticsearchPrivileges struct {
type DataStreamElasticsearchPrivileges struct {
Indices []string `config:"indices,omitempty" json:"indices,omitempty" yaml:"indices,omitempty"`
}

Expand Down
20 changes: 14 additions & 6 deletions packages/package.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,12 @@ type Package struct {
Readme *string `config:"readme,omitempty" json:"readme,omitempty" yaml:"readme,omitempty"`
License string `config:"license,omitempty" json:"license,omitempty" yaml:"license,omitempty"`
versionSemVer *semver.Version
Screenshots []Image `config:"screenshots,omitempty" json:"screenshots,omitempty" yaml:"screenshots,omitempty"`
Assets []string `config:"assets,omitempty" json:"assets,omitempty" yaml:"assets,omitempty"`
PolicyTemplates []PolicyTemplate `config:"policy_templates,omitempty" json:"policy_templates,omitempty" yaml:"policy_templates,omitempty"`
DataStreams []*DataStream `config:"data_streams,omitempty" json:"data_streams,omitempty" yaml:"data_streams,omitempty"`
Vars []Variable `config:"vars" json:"vars,omitempty" yaml:"vars,omitempty"`

Screenshots []Image `config:"screenshots,omitempty" json:"screenshots,omitempty" yaml:"screenshots,omitempty"`
Assets []string `config:"assets,omitempty" json:"assets,omitempty" yaml:"assets,omitempty"`
PolicyTemplates []PolicyTemplate `config:"policy_templates,omitempty" json:"policy_templates,omitempty" yaml:"policy_templates,omitempty"`
DataStreams []*DataStream `config:"data_streams,omitempty" json:"data_streams,omitempty" yaml:"data_streams,omitempty"`
Vars []Variable `config:"vars" json:"vars,omitempty" yaml:"vars,omitempty"`
Elasticsearch *PackageElasticsearch `config:"elasticsearch,omitempty" json:"elasticsearch,omitempty" yaml:"elasticsearch,omitempty"`
// Local path to the package dir
BasePath string `json:"-" yaml:"-"`

Expand Down Expand Up @@ -143,6 +143,14 @@ type Image struct {
Type string `config:"type" json:"type,omitempty"`
}

type PackageElasticsearch struct {
Privileges *PackageElasticsearchPrivileges `config:"privileges,omitempty" json:"privileges,omitempty" yaml:"privileges,omitempty"`
}

type PackageElasticsearchPrivileges struct {
Cluster []string `config:"cluster,omitempty" json:"cluster,omitempty" yaml:"cluster,omitempty"`
}

func (i Image) getPath(p *Package) string {
return path.Join(packagePathPrefix, p.Name, p.Version, i.Src)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"title": "Elasticsearch Privileges",
"version": "1.0.0",
"release": "beta",
"description": "Test package-specified Elasticsearch index privileges",
"description": "Test package-specified Elasticsearch index privileges and cluster privileges",
"type": "solution",
"download": "/epr/elasticsearch_privileges/elasticsearch_privileges-1.0.0.zip",
"path": "/package/elasticsearch_privileges/1.0.0",
Expand Down Expand Up @@ -44,5 +44,12 @@
},
"path": "elasticsearch_privileges"
}
]
],
"elasticsearch": {
"privileges": {
"cluster": [
"monitor"
]
}
}
}
2 changes: 1 addition & 1 deletion testdata/generated/search-all.json
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
"title": "Elasticsearch Privileges",
"version": "1.0.0",
"release": "beta",
"description": "Test package-specified Elasticsearch index privileges",
"description": "Test package-specified Elasticsearch index privileges and cluster privileges",
"type": "solution",
"download": "/epr/elasticsearch_privileges/elasticsearch_privileges-1.0.0.zip",
"path": "/package/elasticsearch_privileges/1.0.0",
Expand Down
2 changes: 1 addition & 1 deletion testdata/generated/search-category-custom.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"title": "Elasticsearch Privileges",
"version": "1.0.0",
"release": "beta",
"description": "Test package-specified Elasticsearch index privileges",
"description": "Test package-specified Elasticsearch index privileges and cluster privileges",
"type": "solution",
"download": "/epr/elasticsearch_privileges/elasticsearch_privileges-1.0.0.zip",
"path": "/package/elasticsearch_privileges/1.0.0",
Expand Down
2 changes: 1 addition & 1 deletion testdata/generated/search-package-experimental.json
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
"title": "Elasticsearch Privileges",
"version": "1.0.0",
"release": "beta",
"description": "Test package-specified Elasticsearch index privileges",
"description": "Test package-specified Elasticsearch index privileges and cluster privileges",
"type": "solution",
"download": "/epr/elasticsearch_privileges/elasticsearch_privileges-1.0.0.zip",
"path": "/package/elasticsearch_privileges/1.0.0",
Expand Down
2 changes: 1 addition & 1 deletion testdata/generated/search-package-internal.json
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
"title": "Elasticsearch Privileges",
"version": "1.0.0",
"release": "beta",
"description": "Test package-specified Elasticsearch index privileges",
"description": "Test package-specified Elasticsearch index privileges and cluster privileges",
"type": "solution",
"download": "/epr/elasticsearch_privileges/elasticsearch_privileges-1.0.0.zip",
"path": "/package/elasticsearch_privileges/1.0.0",
Expand Down
2 changes: 1 addition & 1 deletion testdata/generated/search.json
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
"title": "Elasticsearch Privileges",
"version": "1.0.0",
"release": "beta",
"description": "Test package-specified Elasticsearch index privileges",
"description": "Test package-specified Elasticsearch index privileges and cluster privileges",
"type": "solution",
"download": "/epr/elasticsearch_privileges/elasticsearch_privileges-1.0.0.zip",
"path": "/package/elasticsearch_privileges/1.0.0",
Expand Down
7 changes: 5 additions & 2 deletions testdata/package/elasticsearch_privileges/1.0.0/manifest.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
format_version: 1.0.0

name: elasticsearch_privileges
description: Test package-specified Elasticsearch index privileges
description: Test package-specified Elasticsearch index privileges and cluster privileges
version: 1.0.0
title: Elasticsearch Privileges
categories: ["custom"]
type: solution
release: beta

elasticsearch:
privileges:
cluster: ["monitor"]

conditions:
kibana:
version: ">=7.16.0"