Documentation
¶
Overview ¶
Package project provides functionality for managing Ansible-like projects in KubeKey. It handles project file operations, playbook parsing, and task execution.
Index ¶
- Constants
- func GetImportPlaybookRelPath(basePlaybook string, includePlaybook string) []string
- func GetIncludeTaskRelPath(top string, source string, includeTask string) []string
- func GetProjectPath(basePlaybook string) string
- func GetRoleDefaultsRelDirPath(baseRole string) []string
- func GetRoleDefaultsRelPath(baseRole string) []string
- func GetRoleMetaRelPath(baseRole string) []string
- func GetRoleRelPath(basePlaybook string, role string) []string
- func GetRoleTaskRelPath(baseRole string) []string
- func GetVarsFilesRelPath(basePlaybook string, varsFile string) []string
- type Project
Constants ¶
const ( // PathFormatImportPlaybook defines the directory structure for importing playbooks // The structure supports three formats: // 1. Import playbook in same directory as base playbook // 2. Import playbook from playbooks/ subdirectory // 3. Import playbook from project root playbooks/ directory PathFormatImportPlaybook = `` /* 165-byte string literal not displayed */ // PathFormatVarsFile defines the directory structure for vars files // Vars files are expected to be in the same directory as the base playbook PathFormatVarsFile = ` |-- base-playbook.yaml |-- [VarsFile] ` // PathFormatRole defines the directory structure for roles // Roles can be found in three locations: // 1. roles/ directory at project root // 2. roles/ directory next to playbook // 3. roles/ directory at project root PathFormatRole = `` /* 157-byte string literal not displayed */ // PathFormatRoleMeta defines the directory structure for role meta information. // The meta/main.yaml (or main.yml) file can contain dependencies on other roles via the "dependencies" key. PathFormatRoleMeta = ` |-- baseRole/ | |-- meta/ | | |-- main.yaml |-- baseRole/ | |-- meta/ | | |-- main.yml ` // PathFormatRoleTask defines the directory structure for role tasks // Role tasks are expected to be in tasks/main.yaml or tasks/main.yml under the role directory PathFormatRoleTask = ` |-- baseRole/ | |-- tasks/ | | |-- main.yaml |-- baseRole/ | |-- tasks/ | | |-- main.yml ` // PathFormatIncludeTask defines the directory structure for included tasks // Tasks can be included from: // 1. Direct path under source role // 2. tasks/ directory under source role // 3. Direct path under top level role // 4. tasks/ directory under top level role PathFormatIncludeTask = `` /* 218-byte string literal not displayed */ )
Variables ¶
This section is empty.
Functions ¶
func GetImportPlaybookRelPath ¶
GetImportPlaybookRelPath returns possible relative paths for an imported playbook based on the base playbook location The format follows PathFormatImportPlaybook structure
func GetIncludeTaskRelPath ¶
GetIncludeTaskRelPath returns possible relative paths for included task files The format follows PathFormatIncludeTask structure
func GetProjectPath ¶
GetProjectPath from basePlaybook. the Project directory structure can be either:
|-- projectFS/ | |-- basePlaybook.yaml
|-- projectFS/ | |-- playbooks/ | | |-- basePlaybook.yaml
func GetRoleDefaultsRelDirPath ¶
GetRoleDefaultsRelDirPath returns possible relative dir paths for a role's defaults files The format follows similar structure to role tasks
func GetRoleDefaultsRelPath ¶
GetRoleDefaultsRelPath returns possible relative paths for a role's defaults file The format follows similar structure to role tasks
func GetRoleMetaRelPath ¶
GetRoleMetaRelPath returns possible relative paths for a role's meta file (main.yaml or main.yml) within the meta directory. The format follows the standard Ansible role meta directory structure.
func GetRoleRelPath ¶
GetRoleRelPath returns possible relative paths for a role based on the base playbook location The format follows PathFormatRole structure
func GetRoleTaskRelPath ¶
GetRoleTaskRelPath returns possible relative paths for a role's main task file The format follows PathFormatRoleTask structure
func GetVarsFilesRelPath ¶
GetVarsFilesRelPath returns possible relative paths for vars files based on the base playbook location The format follows PathFormatVarsFile structure
Types ¶
type Project ¶
type Project interface {
// MarshalPlaybook project file to playbook.
MarshalPlaybook() (*kkprojectv1.Playbook, error)
// Stat file or dir in project
Stat(path string) (os.FileInfo, error)
// WalkDir dir in project
WalkDir(path string, f fs.WalkDirFunc) error
// ReadFile file or dir in project
ReadFile(path string) ([]byte, error)
// Rel path file or dir in project
Rel(root string, path string) (string, error)
}
Project represent location of actual project. get project file should base on it