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

[Fleet] Expose agent privileges root in package endpoint #1109

Merged
merged 5 commits into from
Nov 2, 2023
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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Added

- Add package and datastream agent privileges in the package endpoint [#1109](https://github.com/elastic/package-registry/pull/1109)

### Deprecated

### Known Issues
Expand Down
9 changes: 9 additions & 0 deletions packages/datastream.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ type DataStream struct {
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"`
Agent *DataStreamAgent `config:"agent,omitempty" json:"agent,omitempty" yaml:"agent,omitempty"`

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

type DataStreamAgent struct {
Privileges *DataStreamAgentPrivileges `config:"privileges,omitempty" json:"privileges,omitempty" yaml:"privileges,omitempty"`
}

type DataStreamAgentPrivileges struct {
Root bool `config:"root,omitempty" json:"root,omitempty" yaml:"root,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"`
Expand Down
9 changes: 9 additions & 0 deletions packages/package.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ type Package struct {
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"`
Agent *PackageAgent `config:"agent,omitempty" json:"agent,omitempty" yaml:"agent,omitempty"`
// Local path to the package dir
BasePath string `json:"-" yaml:"-"`

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

type PackageAgent struct {
Privileges *PackageAgentPrivileges `config:"privileges,omitempty" json:"privileges,omitempty" yaml:"privileges,omitempty"`
}

type PackageAgentPrivileges struct {
Root bool `config:"root,omitempty" json:"root,omitempty" yaml:"root,omitempty"`
}

type PackageElasticsearch struct {
Privileges *PackageElasticsearchPrivileges `config:"privileges,omitempty" json:"privileges,omitempty" yaml:"privileges,omitempty"`
}
Expand Down
47 changes: 47 additions & 0 deletions packages/testdata/marshaler/packages.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,53 @@
"/package/multiversion/1.1.0/img/icon.svg"
]
},
{
"name": "agent_privileges",
"title": "Agent Privileges",
"version": "1.0.0",
"release": "beta",
"description": "Test package-specified agent privileges",
"type": "solution",
"download": "/epr/agent_privileges/agent_privileges-1.0.0.zip",
"path": "/package/agent_privileges/1.0.0",
"conditions": {
"kibana": {
"version": "\u003e=7.16.0"
jsoriano marked this conversation as resolved.
Show resolved Hide resolved
}
},
"categories": [
"custom"
],
"format_version": "1.0.0",
"readme": "/package/agent_privileges/1.0.0/docs/README.md",
"license": "basic",
"assets": [
"/package/agent_privileges/1.0.0/manifest.yml",
"/package/agent_privileges/1.0.0/docs/README.md",
"/package/agent_privileges/1.0.0/data_stream/agent_privileges/manifest.yml",
"/package/agent_privileges/1.0.0/data_stream/agent_privileges/fields/base-fields.yml"
],
"data_streams": [
{
"type": "metrics",
"dataset": "agent_privileges.agent_privileges",
"title": "Agent privileges data stream",
"release": "beta",
"package": "agent_privileges",
"agent": {
"privileges": {
"root": true
}
},
"path": "agent_privileges"
}
],
"agent": {
"privileges": {
"root": true
}
}
},
{
"name": "dataset_is_prefix",
"title": "DatasetIsPrefix Flag",
Expand Down
2 changes: 1 addition & 1 deletion testdata/generated/categories-experimental.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
{
"id": "custom",
"title": "Custom",
"count": 16
"count": 17
},
{
"id": "datastore",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
{
"id": "custom",
"title": "Custom",
"count": 13
"count": 14
},
{
"id": "datastore",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
{
"id": "custom",
"title": "Custom",
"count": 15
"count": 16
},
{
"id": "datastore",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
{
"id": "custom",
"title": "Custom",
"count": 15
"count": 16
},
{
"id": "datastore",
Expand Down
2 changes: 1 addition & 1 deletion testdata/generated/categories-prerelease.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
{
"id": "custom",
"title": "Custom",
"count": 16
"count": 17
},
{
"id": "datastore",
Expand Down
2 changes: 1 addition & 1 deletion testdata/generated/categories-spec-max-2.10.0.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
{
"id": "custom",
"title": "Custom",
"count": 16
"count": 17
},
{
"id": "datastore",
Expand Down
2 changes: 1 addition & 1 deletion testdata/generated/categories.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
{
"id": "custom",
"title": "Custom",
"count": 13
"count": 14
},
{
"id": "datastore",
Expand Down
47 changes: 47 additions & 0 deletions testdata/generated/package/agent_privileges/1.0.0/index.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
{
"name": "agent_privileges",
"title": "Agent Privileges",
"version": "1.0.0",
"release": "beta",
"description": "Test package-specified agent privileges",
"type": "solution",
"download": "/epr/agent_privileges/agent_privileges-1.0.0.zip",
"path": "/package/agent_privileges/1.0.0",
"conditions": {
"kibana": {
"version": ">=7.16.0"
}
},
"categories": [
"custom"
],
"format_version": "1.0.0",
"readme": "/package/agent_privileges/1.0.0/docs/README.md",
"license": "basic",
"assets": [
"/package/agent_privileges/1.0.0/manifest.yml",
"/package/agent_privileges/1.0.0/docs/README.md",
"/package/agent_privileges/1.0.0/data_stream/agent_privileges/manifest.yml",
"/package/agent_privileges/1.0.0/data_stream/agent_privileges/fields/base-fields.yml"
],
"data_streams": [
{
"type": "metrics",
"dataset": "agent_privileges.agent_privileges",
"title": "Agent privileges data stream",
"release": "beta",
"package": "agent_privileges",
"agent": {
"privileges": {
"root": true
}
},
"path": "agent_privileges"
}
],
"agent": {
"privileges": {
"root": true
}
}
}
18 changes: 18 additions & 0 deletions testdata/generated/search-all-proxy.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,22 @@
[
{
"name": "agent_privileges",
"title": "Agent Privileges",
"version": "1.0.0",
"release": "beta",
"description": "Test package-specified agent privileges",
"type": "solution",
"download": "/epr/agent_privileges/agent_privileges-1.0.0.zip",
"path": "/package/agent_privileges/1.0.0",
"conditions": {
"kibana": {
"version": ">=7.16.0"
}
},
"categories": [
"custom"
]
},
{
"name": "datasources",
"title": "Default datasource Integration",
Expand Down
18 changes: 18 additions & 0 deletions testdata/generated/search-all.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,22 @@
[
{
"name": "agent_privileges",
"title": "Agent Privileges",
"version": "1.0.0",
"release": "beta",
"description": "Test package-specified agent privileges",
"type": "solution",
"download": "/epr/agent_privileges/agent_privileges-1.0.0.zip",
"path": "/package/agent_privileges/1.0.0",
"conditions": {
"kibana": {
"version": ">=7.16.0"
}
},
"categories": [
"custom"
]
},
{
"name": "datasources",
"title": "Default datasource Integration",
Expand Down
18 changes: 18 additions & 0 deletions testdata/generated/search-category-custom.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,22 @@
[
{
"name": "agent_privileges",
"title": "Agent Privileges",
"version": "1.0.0",
"release": "beta",
"description": "Test package-specified agent privileges",
"type": "solution",
"download": "/epr/agent_privileges/agent_privileges-1.0.0.zip",
"path": "/package/agent_privileges/1.0.0",
"conditions": {
"kibana": {
"version": ">=7.16.0"
}
},
"categories": [
"custom"
]
},
{
"name": "datasources",
"title": "Default datasource Integration",
Expand Down
18 changes: 18 additions & 0 deletions testdata/generated/search-just-latest-proxy.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,22 @@
[
{
"name": "agent_privileges",
"title": "Agent Privileges",
"version": "1.0.0",
"release": "beta",
"description": "Test package-specified agent privileges",
"type": "solution",
"download": "/epr/agent_privileges/agent_privileges-1.0.0.zip",
"path": "/package/agent_privileges/1.0.0",
"conditions": {
"kibana": {
"version": ">=7.16.0"
}
},
"categories": [
"custom"
]
},
{
"name": "datasources",
"title": "Default datasource Integration",
Expand Down
18 changes: 18 additions & 0 deletions testdata/generated/search-kibana800.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,22 @@
[
{
"name": "agent_privileges",
"title": "Agent Privileges",
"version": "1.0.0",
"release": "beta",
"description": "Test package-specified agent privileges",
"type": "solution",
"download": "/epr/agent_privileges/agent_privileges-1.0.0.zip",
"path": "/package/agent_privileges/1.0.0",
"conditions": {
"kibana": {
"version": ">=7.16.0"
}
},
"categories": [
"custom"
]
},
{
"name": "datasources",
"title": "Default datasource Integration",
Expand Down
18 changes: 18 additions & 0 deletions testdata/generated/search-package-experimental.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,22 @@
[
{
"name": "agent_privileges",
"title": "Agent Privileges",
"version": "1.0.0",
"release": "beta",
"description": "Test package-specified agent privileges",
"type": "solution",
"download": "/epr/agent_privileges/agent_privileges-1.0.0.zip",
"path": "/package/agent_privileges/1.0.0",
"conditions": {
"kibana": {
"version": ">=7.16.0"
}
},
"categories": [
"custom"
]
},
{
"name": "datastream_without_release",
"title": "Apache Spark",
Expand Down
18 changes: 18 additions & 0 deletions testdata/generated/search-package-internal.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,22 @@
[
{
"name": "agent_privileges",
"title": "Agent Privileges",
"version": "1.0.0",
"release": "beta",
"description": "Test package-specified agent privileges",
"type": "solution",
"download": "/epr/agent_privileges/agent_privileges-1.0.0.zip",
"path": "/package/agent_privileges/1.0.0",
"conditions": {
"kibana": {
"version": ">=7.16.0"
}
},
"categories": [
"custom"
]
},
{
"name": "datasources",
"title": "Default datasource Integration",
Expand Down
Loading