Documentation
¶
Index ¶
- Constants
- Variables
- func EncodeCertPEM(cert *x509.Certificate) []byte
- func ModuleAddHostvars(ctx context.Context, options ExecOptions) (string, string, error)
- func ModuleAssert(ctx context.Context, options ExecOptions) (string, string, error)
- func ModuleCommand(ctx context.Context, options ExecOptions) (string, string, error)
- func ModuleCopy(ctx context.Context, options ExecOptions) (string, string, error)
- func ModuleDebug(_ context.Context, options ExecOptions) (string, string, error)
- func ModuleFetch(ctx context.Context, options ExecOptions) (string, string, error)
- func ModuleGenCert(ctx context.Context, options ExecOptions) (string, string, error)
- func ModuleImage(ctx context.Context, options ExecOptions) (string, string, error)
- func ModuleIncludeVars(ctx context.Context, options ExecOptions) (string, string, error)
- func ModulePrometheus(ctx context.Context, options ExecOptions) (string, string, error)
- func ModuleResult(ctx context.Context, options ExecOptions) (string, string, error)
- func ModuleSetFact(_ context.Context, options ExecOptions) (string, string, error)
- func ModuleSetup(ctx context.Context, options ExecOptions) (string, string, error)
- func ModuleTemplate(ctx context.Context, options ExecOptions) (string, string, error)
- func NewSelfSignedCACert(cfg cgutilcert.Config, after time.Duration, key crypto.Signer) (*x509.Certificate, error)
- func NewSignedCert(cfg cgutilcert.Config, after time.Duration, key crypto.Signer, ...) (*x509.Certificate, error)
- func RegisterModule(moduleName string, exec ModuleExecFunc) error
- func RemoveDuplicateAltNames(altNames *cgutilcert.AltNames)
- func TryLoadCertChainFromDisk(rootCert string) ([]*x509.Certificate, error)
- func TryLoadKeyFromDisk(rootKey string) (crypto.Signer, error)
- func ValidateCertPeriod(cert *x509.Certificate, offset time.Duration) error
- func VerifyCertChain(cert *x509.Certificate, intermediates []*x509.Certificate, ...) error
- func WriteCert(outCert string, cert *x509.Certificate, policy string) error
- func WriteKey(outKey string, key crypto.Signer, policy string) error
- type ExecOptions
- type ModuleExecFunc
Constants ¶
const ( // StdoutSuccess is the standard message indicating a successful module execution. StdoutSuccess = "success" // StdoutFailed is the standard message indicating a failed module execution. StdoutFailed = "failed" // StdoutSkip is the standard message indicating a skipped module execution. StdoutSkip = "skip" // StderrGetConnector is returned when the connector cannot be obtained. StderrGetConnector = "failed to get connector" // StderrGetHostVariable is returned when host variables cannot be retrieved. StderrGetHostVariable = "failed to get host variable" // StderrParseArgument is returned when module arguments cannot be parsed. StderrParseArgument = "failed to parse argument" // StderrUnsupportArgs is returned when the provided arguments are not supported. StderrUnsupportArgs = "unsupport args" // StderrGetPlaybook is returned when get playbook error StderrGetPlaybook = "failed to get playbook" )
Variables ¶
var ConnKey = &key{}
ConnKey is the context key for storing/retrieving a connector in context.Context.
Functions ¶
func EncodeCertPEM ¶
func EncodeCertPEM(cert *x509.Certificate) []byte
EncodeCertPEM encodes the given certificate into PEM format.
func ModuleAddHostvars ¶
ModuleAddHostvars handles the "add_hostvars" module, merging variables into the specified hosts. Returns empty stdout and stderr on success, or error message in stderr on failure.
func ModuleAssert ¶
ModuleAssert handles the "assert" module, evaluating boolean conditions and returning appropriate messages
func ModuleCommand ¶
ModuleCommand handles the "command" module, executing shell commands on remote hosts
func ModuleCopy ¶
ModuleCopy handles the "copy" module, copying files or content to remote hosts.
func ModuleDebug ¶
ModuleDebug handles the "debug" module, printing debug information
func ModuleFetch ¶
ModuleFetch handles the "fetch" module, retrieving files from remote hosts
func ModuleGenCert ¶
ModuleGenCert is the entry point for the "gen_cert" module, responsible for generating SSL/TLS certificates.
func ModuleImage ¶
ModuleImage handles the "image" module, managing container image operations including pulling and pushing images
func ModuleIncludeVars ¶
ModuleIncludeVars handle the "include_vars" module ,add other var files into playbook
func ModulePrometheus ¶
ModulePrometheus handles the "prometheus" module, using prometheus connector to execute PromQL queries
func ModuleResult ¶
ModuleResult handles the "result" module, setting result variables during playbook execution
func ModuleSetFact ¶
ModuleSetFact handles the "set_fact" module, setting variables during playbook execution
func ModuleSetup ¶
ModuleSetup establishes a connection to a remote host and gathers facts about it. It returns StdoutSuccess if successful, or an error message if any step fails.
func ModuleTemplate ¶
ModuleTemplate handles the "template" module, processing files with Go templates
func NewSelfSignedCACert ¶
func NewSelfSignedCACert(cfg cgutilcert.Config, after time.Duration, key crypto.Signer) (*x509.Certificate, error)
NewSelfSignedCACert creates a new self-signed CA certificate.
func NewSignedCert ¶
func NewSignedCert(cfg cgutilcert.Config, after time.Duration, key crypto.Signer, caCert *x509.Certificate, caKey crypto.Signer, isCA bool) (*x509.Certificate, error)
NewSignedCert creates a certificate signed by the given CA certificate and key.
func RegisterModule ¶
func RegisterModule(moduleName string, exec ModuleExecFunc) error
RegisterModule registers a module execution function under the given module name. Returns an error if the module name is already registered.
func RemoveDuplicateAltNames ¶
func RemoveDuplicateAltNames(altNames *cgutilcert.AltNames)
RemoveDuplicateAltNames eliminates duplicate entries from the AltNames struct.
func TryLoadCertChainFromDisk ¶
func TryLoadCertChainFromDisk(rootCert string) ([]*x509.Certificate, error)
TryLoadCertChainFromDisk loads a certificate chain from the specified file.
func TryLoadKeyFromDisk ¶
TryLoadKeyFromDisk attempts to load and validate a private key from disk.
func ValidateCertPeriod ¶
func ValidateCertPeriod(cert *x509.Certificate, offset time.Duration) error
ValidateCertPeriod checks whether the certificate is currently valid, considering the given offset.
func VerifyCertChain ¶
func VerifyCertChain(cert *x509.Certificate, intermediates []*x509.Certificate, root *x509.Certificate) error
VerifyCertChain ensures that a certificate has a valid chain of trust back to the root CA.
Types ¶
type ExecOptions ¶
type ExecOptions struct {
// Args contains the defined arguments for the module.
Args runtime.RawExtension
// Host specifies which host to execute the module on.
Host string
// Variable provides the variables needed by the module.
variable.Variable
// Task is the task to be executed.
Task kkcorev1alpha1.Task
// Playbook is the playbook to be executed.
Playbook kkcorev1.Playbook
// LogOutput is the output writer for module logs.
LogOutput io.Writer
}
ExecOptions represents options for module execution.
type ModuleExecFunc ¶
type ModuleExecFunc func(ctx context.Context, options ExecOptions) (stdout string, stderr string, err error)
ModuleExecFunc defines the function signature for executing a module. It takes a context and ExecOptions, and returns stdout and stderr strings.
func FindModule ¶
func FindModule(moduleName string) ModuleExecFunc
FindModule retrieves a registered module execution function by its name. Returns nil if the module is not found.