Skip to content

Commit a2366bc

Browse files
authored
Add deployment_modes and hide_in_deployment_modes (#17)
Add support for definitions related to deployment modes - Policy templates can indicate on what deployment modes they can be used. - Variables can be hidden per deployment mode. See elastic/package-spec 738.
1 parent e417702 commit a2366bc

File tree

1 file changed

+39
-23
lines changed

1 file changed

+39
-23
lines changed

fleetpkg.go

Lines changed: 39 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ type Manifest struct {
121121
Owner Owner `json:"owner,omitempty" yaml:"owner,omitempty"`
122122
Elasticsearch *ElasticsearchRequirements `json:"elasticsearch,omitempty" yaml:"elasticsearch,omitempty"`
123123
Agent *AgentRequirements `json:"agent,omitempty" yaml:"agent,omitempty"`
124+
DeploymentModes *DeploymentModes `json:"deployment_modes,omitempty" yaml:"deployment_modes,omitempty"`
124125

125126
sourceFile string
126127
}
@@ -207,16 +208,17 @@ type Screenshots struct {
207208
}
208209

209210
type Var struct {
210-
Name string `json:"name,omitempty" yaml:"name,omitempty"`
211-
Default any `json:"default,omitempty" yaml:"default,omitempty"`
212-
Description string `json:"description,omitempty" yaml:"description,omitempty"`
213-
Type string `json:"type,omitempty" yaml:"type,omitempty"`
214-
Title string `json:"title,omitempty" yaml:"title,omitempty"`
215-
Multi *bool `json:"multi,omitempty" yaml:"multi,omitempty"`
216-
Required *bool `json:"required,omitempty" yaml:"required,omitempty"`
217-
Secret *bool `json:"secret,omitempty" yaml:"secret,omitempty"`
218-
ShowUser *bool `json:"show_user,omitempty" yaml:"show_user,omitempty"`
219-
Options []Option `json:"options,omitempty" yaml:"options,omitempty"` // List of options for 'type: select'.
211+
Name string `json:"name,omitempty" yaml:"name,omitempty"`
212+
Default any `json:"default,omitempty" yaml:"default,omitempty"`
213+
Description string `json:"description,omitempty" yaml:"description,omitempty"`
214+
Type string `json:"type,omitempty" yaml:"type,omitempty"`
215+
Title string `json:"title,omitempty" yaml:"title,omitempty"`
216+
Multi *bool `json:"multi,omitempty" yaml:"multi,omitempty"`
217+
Required *bool `json:"required,omitempty" yaml:"required,omitempty"`
218+
Secret *bool `json:"secret,omitempty" yaml:"secret,omitempty"`
219+
ShowUser *bool `json:"show_user,omitempty" yaml:"show_user,omitempty"`
220+
Options []Option `json:"options,omitempty" yaml:"options,omitempty"` // List of options for 'type: select'.
221+
HideInDeploymentModes []string `json:"hide_in_deployment_modes,omitempty" yaml:"hide_in_deployment_modes,omitempty"` // Whether this variable should be hidden in the UI for agent policies intended to some specific deployment modes.
220222

221223
FileMetadata `json:"-" yaml:"-"`
222224
}
@@ -250,19 +252,33 @@ type Input struct {
250252
}
251253

252254
type PolicyTemplate struct {
253-
Name string `json:"name,omitempty" yaml:"name,omitempty"`
254-
Title string `json:"title,omitempty" yaml:"title,omitempty"`
255-
Categories []string `json:"categories,omitempty" yaml:"categories,omitempty"`
256-
Description string `json:"description,omitempty" yaml:"description,omitempty"`
257-
DataStreams []string `json:"data_streams,omitempty" yaml:"data_streams,omitempty"`
258-
Inputs []Input `json:"inputs,omitempty" yaml:"inputs,omitempty"`
259-
Icons []Icons `json:"icons,omitempty" yaml:"icons,omitempty"`
260-
Screenshots []Screenshots `json:"screenshots,omitempty" yaml:"screenshots,omitempty"`
261-
Multiple *bool `json:"multiple,omitempty" yaml:"multiple,omitempty"`
262-
Type string `json:"type,omitempty" yaml:"type,omitempty"` // Type of data stream.
263-
Input string `json:"input,omitempty" yaml:"input,omitempty"`
264-
TemplatePath string `json:"template_path,omitempty" yaml:"template_path,omitempty"`
265-
Vars []Var `json:"vars,omitempty" yaml:"vars,omitempty"` // Policy template level variables.
255+
Name string `json:"name,omitempty" yaml:"name,omitempty"`
256+
Title string `json:"title,omitempty" yaml:"title,omitempty"`
257+
Categories []string `json:"categories,omitempty" yaml:"categories,omitempty"`
258+
Description string `json:"description,omitempty" yaml:"description,omitempty"`
259+
DataStreams []string `json:"data_streams,omitempty" yaml:"data_streams,omitempty"`
260+
Inputs []Input `json:"inputs,omitempty" yaml:"inputs,omitempty"`
261+
Icons []Icons `json:"icons,omitempty" yaml:"icons,omitempty"`
262+
Screenshots []Screenshots `json:"screenshots,omitempty" yaml:"screenshots,omitempty"`
263+
Multiple *bool `json:"multiple,omitempty" yaml:"multiple,omitempty"`
264+
Type string `json:"type,omitempty" yaml:"type,omitempty"` // Type of data stream.
265+
Input string `json:"input,omitempty" yaml:"input,omitempty"`
266+
TemplatePath string `json:"template_path,omitempty" yaml:"template_path,omitempty"`
267+
Vars []Var `json:"vars,omitempty" yaml:"vars,omitempty"` // Policy template level variables.
268+
DeploymentModes *DeploymentModes `json:"deployment_modes,omitempty" yaml:"deployment_modes,omitempty"`
269+
}
270+
271+
// DeploymentModes options. The deployment mode refers to the mode used to deploy the Elastic Agents running this policy.
272+
type DeploymentModes struct {
273+
// Options specific to the default deployment mode, where agents are normally managed by users, explicitly enrolled to Fleet and visible in UIs.
274+
Default struct {
275+
Enabled *bool `json:"enabled,omitempty" yaml:"enabled,omitempty"` // Defaults to true in Fleet.
276+
} `json:"default,omitempty" yaml:"default,omitempty"`
277+
278+
// Options specific to the Agentless deployment mode. This mode is used in offerings where the Elastic Agents running these policies are fully managed for the user.
279+
Agentless struct {
280+
Enabled *bool `json:"enabled,omitempty" yaml:"enabled,omitempty"`
281+
} `json:"agentless,omitempty" yaml:"agentless,omitempty"`
266282
}
267283

268284
type Owner struct {

0 commit comments

Comments
 (0)