entity

package
v0.0.0-...-cc36674 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 15, 2025 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ProjectTypeLocal represents a local project
	ProjectTypeLocal = "local"
	// ProjectFormatPlain represents project in plain format
	ProjectFormatPlain = "plain"
	// ProjectFormatTarGz represents a project in tar.gz format
	ProjectFormatTarGz = "targz"

	// ExtensionTarGz represents the tar.gz extension
	ExtensionTarGz = ".tar.gz"
)
View Source
const (
	// ACCEPTED status when the task is accepted to be executed
	ACCEPTED = "ACCEPTED"
	// FAILED status when the task is failed
	FAILED = "FAILED"
	// PENDING status when the task is pending. This status is used when the task is not yet accepted to be executed
	PENDING = "PENDING"
	// RUNNING status when the task starts running
	RUNNING = "RUNNING"
	// SUCCESS status when the task is successfully executed
	SUCCESS = "SUCCESS"

	// AnsiblePlaybookCommand identifies the task as an Ansible playbook task
	AnsiblePlaybookCommand = "ansible-playbook"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AnsiblePlaybookCollectionRequirements

type AnsiblePlaybookCollectionRequirements struct {

	// Collections is a list of collections to install.
	Collections []string `json:"collections,omitempty"`

	// APIKey is the Ansible Galaxy API key.
	APIKey string `json:"api_key,omitempty"`

	// ForceWithDeps forces overwriting an existing collection and its dependencies.
	ForceWithDeps bool `json:"force_with_deps,omitempty" validate:"boolean"`

	// Pre includes pre-release versions. Semantic versioning pre-releases are ignored by default.
	Pre bool `json:"pre,omitempty" validate:"boolean"`

	// Timeout is the time to wait for operations against the galaxy server, defaults to 60s.
	Timeout string `json:"timeout,omitempty"`

	// Token is the Ansible Galaxy API key.
	Token string `json:"token,omitempty"`

	// IgnoreErrors ignores errors during installation and continue with the next specified collection.
	IgnoreErrors bool `json:"ignore_errors,omitempty" validate:"boolean"`

	// RequirementsFile is a file containing a list of collections to be installed.
	RequirementsFile string `json:"requirements_file,omitempty"`

	// Server is the Galaxy API server URL.
	Server string `json:"server,omitempty"`

	// Verbose verbose mode enabled
	Verbose bool `json:"verbose,omitempty" validate:"boolean"`
}

AnsiblePlaybookCollectionRequirements represents an entity containing the parameters to install collections dependencies

type AnsiblePlaybookParameters

type AnsiblePlaybookParameters struct {

	// Playbooks is the ansible's playbooks list to be executed
	Playbooks []string `json:"playbooks" validate:"required"`

	// Check don't make any changes; instead, try to predict some of the changes that may occur
	Check bool `json:"check,omitempty" validate:"boolean"`

	// Diff when changing (small) files and templates, show the differences in those files; works great with --check
	Diff bool `json:"diff,omitempty" validate:"boolean"`

	// Requirements is a list of role and collection dependencies
	Requirements *AnsiblePlaybookRequirements `json:"requirements,omitempty"`

	// ExtraVars is a map of extra variables used on ansible-playbook execution
	ExtraVars map[string]interface{} `json:"extra_vars,omitempty"`

	// ExtraVarsFile is a list of files used to load extra-vars
	ExtraVarsFile []string `json:"extra_vars_file,omitempty"`

	// FlushCache is the flush cache flag for ansible-playbook
	FlushCache bool `json:"flush_cache,omitempty" validate:"boolean"`

	// ForceHandlers run handlers even if a task fails
	ForceHandlers bool `json:"force_handlers,omitempty" validate:"boolean"`

	// Forks specify number of parallel processes to use (default=50)
	Forks int `json:"forks,omitempty" validate:"number"`

	// Inventory specify inventory host path
	Inventory string `json:"inventory,omitempty" validate:"required"`

	// Limit is selected hosts additional pattern
	Limit string `json:"limit,omitempty"`

	// ListHosts outputs a list of matching hosts
	ListHosts bool `json:"list_hosts,omitempty" validate:"boolean"`

	// ListTags is the list tags flag for ansible-playbook
	ListTags bool `json:"list_tags,omitempty" validate:"boolean"`

	// ListTasks is the list tasks flag for ansible-playbook
	ListTasks bool `json:"list_tasks,omitempty" validate:"boolean"`

	// SkipTags only run plays and tasks whose tags do not match these values
	SkipTags string `json:"skip_tags,omitempty"`

	// StartAtTask start the playbook at the task matching this name
	StartAtTask string `json:"start_at_task,omitempty"`

	// SyntaxCheck is the syntax check flag for ansible-playbook
	SyntaxCheck bool `json:"syntax_check,omitempty" validate:"boolean"`

	// Tags is the tags flag for ansible-playbook
	Tags string `json:"tags,omitempty"`

	// VaultID the vault identity to use
	VaultID string `json:"vault_id,omitempty"`

	// VaultPasswordFile path to the file holding vault decryption key
	VaultPasswordFile string `json:"vault_password_file,omitempty"`

	// Verbose verbose mode enabled
	Verbose bool `json:"verbose,omitempty" validate:"boolean"`

	// Version show program's version number, config file location, configured module search path, module location, executable location and exit
	Version bool `json:"version,omitempty" validate:"boolean"`

	// Connection is the type of connection used by ansible-playbook. It must not accept local connection
	Connection string `json:"connection,omitempty"`

	// SCPExtraArgs specify extra arguments to pass to scp only
	SCPExtraArgs string `json:"scp_extra_args,omitempty"`

	// SFTPExtraArgs specify extra arguments to pass to sftp only
	SFTPExtraArgs string `json:"sftp_extra_args,omitempty"`

	// SSHCommonArgs specify common arguments to pass to sftp/scp/ssh
	SSHCommonArgs string `json:"ssh_common_args,omitempty"`

	// SSHExtraArgs specify extra arguments to pass to ssh only
	SSHExtraArgs string `json:"ssh_extra_args,omitempty"`

	// Timeout is the connection timeout on ansible-playbook. Take care because Timeout is defined ad string
	Timeout int `json:"timeout,omitempty" validate:"numeric"`

	// User is the user to use to connect to a host
	User string `json:"user,omitempty"`

	// Become is ansble-playbook's become flag
	Become bool `json:"become,omitempty" validate:"boolean"`

	// BecomeMethod is ansble-playbook's become method. The accepted become methods are:
	// 	- ksu        Kerberos substitute user
	// 	- pbrun      PowerBroker run
	// 	- enable     Switch to elevated permissions on a network device
	// 	- sesu       CA Privileged Access Manager
	// 	- pmrun      Privilege Manager run
	// 	- runas      Run As user
	// 	- sudo       Substitute User DO
	// 	- su         Substitute User
	// 	- doas       Do As user
	// 	- pfexec     profile based execution
	// 	- machinectl Systemd's machinectl privilege escalation
	// 	- dzdo       Centrify's Direct Authorize
	BecomeMethod string `json:"become_method,omitempty"`

	// BecomeUser is ansble-playbook's become user
	BecomeUser string `json:"become_user,omitempty"`
}

AnsiblePlaybookParameters represents an entity containing the parameters to execute an ansible-playbook command

func (*AnsiblePlaybookParameters) Validate

func (params *AnsiblePlaybookParameters) Validate() error

Validate method validates the AnsiblePlaybookParameters entity struct

type AnsiblePlaybookRequirements

type AnsiblePlaybookRequirements struct {
	// Roles defines how to install roles dependencies
	Roles *AnsiblePlaybookRoleRequirements `json:"roles,omitempty"`
	// Collections defines how to install collections dependencies
	Collections *AnsiblePlaybookCollectionRequirements `json:"collections,omitempty"`
}

AnsiblePlaybookRequirements represents an entity containing the parameters to install roles and collections dependencies

type AnsiblePlaybookRoleRequirements

type AnsiblePlaybookRoleRequirements struct {

	// Roles is a list of roles to install
	Roles []string `json:"roles,omitempty"`

	// APIKey represent the API key to use to authenticate against the galaxy server. Same as --token
	APIKey string `json:"api_key,omitempty"`

	// IgnoreErrors represents whether to continue processing even if a role fails to install.
	IgnoreErrors bool `json:"ignore_errors,omitempty" validate:"boolean"`

	// NoDeps represents whether to install dependencies.
	NoDeps bool `json:"no_deps,omitempty" validate:"boolean"`

	// RoleFile represents the path to a file containing a list of roles to install.
	RoleFile string `json:"role_file,omitempty"`

	// Server represent the flag to specify the galaxy server to use
	Server string `json:"server,omitempty"`

	// Timeout represent the time to wait for operations against the galaxy server, defaults to 60s
	Timeout string `json:"timeout,omitempty" validate:"numeric"`

	// Token represent the token to use to authenticate against the galaxy server. Same as --api-key
	Token string `json:"token,omitempty"`

	// Verbose verbose mode enabled
	Verbose bool `json:"verbose,omitempty" validate:"boolean"`
}

AnsiblePlaybookRoleRequirements represents an entity containing the parameters to install roles dependencies

type Project

type Project struct {
	// Format represents the project format. This field is required and must be one of the following values: plain, targz
	Format string `json:"format" validate:"required,oneof=plain targz"`
	// Name represents the project name. This field is required
	Name string `json:"name" validate:"required"`
	// Source represents the project source. This field is required
	Reference string `json:"reference" validate:"required"`
	// Storage represents the project type. This field is required and must be one of the following values: local
	Storage string `json:"storage" validate:"required,oneof=local"`
}

Project entity represents a project

func NewProject

func NewProject(name, referene, format, storage string) *Project

NewProject creates a new project instance

func (*Project) Validate

func (p *Project) Validate() error

Validate validates the project entity

type Task

type Task struct {
	// Command represents the command type to be executed. This field is required and must be one of the following values: ansible-playbook
	Command string `json:"command" validate:"required,oneof=ansible-playbook"`
	// CompletedAt represents the time when the task is completed
	CompletedAt string `json:"completed_at"`
	// CreatedAt represents the time when the task is created
	CreatedAt string `json:"created_at"`
	// ErrorMessage represents the error message when the task is failed
	ErrorMessage string `json:"error_message,omitempty"`
	// ExecutedAt represents the time when the task is executed
	ExecutedAt string `json:"executed_at"`
	// ID represents the task ID. This field is required
	ID string `json:"id" validate:"required"`
	// Parameters represents the task parameters. This field is required
	Parameters interface{} `json:"parameters" validate:"required"`
	// ProjectID represents the project ID. This field is required when the command is ansible-playbook
	ProjectID string `json:"project_id" validate:"required_if=Command ansible-playbook"`
	// Status represents the task status. This field is required and must be one of the following values: ACCEPTED, FAILED, PENDING, RUNNING, SUCCESS
	Status string `json:"status" validate:"required,oneof=ACCEPTED FAILED PENDING RUNNING SUCCESS"`
	// contains filtered or unexported fields
}

Task entity represents a task to be executed

func NewTask

func NewTask(id string, projectID string, command string, parameters interface{}) *Task

NewTask creates a new task

func (*Task) Accepted

func (t *Task) Accepted()

Accepted sets the task status to ACCEPTED

func (*Task) Failed

func (t *Task) Failed(errorMsg string)

Failed sets the task status to FAILED

func (*Task) Running

func (t *Task) Running()

Running sets the task status to RUNNING

func (*Task) Success

func (t *Task) Success()

Success sets the task status to SUCCESS

func (*Task) Validate

func (t *Task) Validate() error

Validate validates the task entity

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL