preflight

package
v0.33.0 Latest Latest
Warning

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

Go to latest
Published: Jul 29, 2025 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

Copyright 2025 Nutanix. All rights reserved. SPDX-License-Identifier: Apache-2.0

Copyright 2025 Nutanix. All rights reserved. SPDX-License-Identifier: Apache-2.0

Index

Constants

View Source
const (
	// Timeout is the duration, in seconds, that the preflight checks handler has to respond.
	// IMPORTANT Keep in sync timeoutSeconds in the kubebuilder:webhook marker defined in this package.
	Timeout = 30 * time.Second
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Cause

type Cause struct {
	// Message is a human-readable message describing the cause of the failure.
	Message string

	// Field is an optional field that the cause relates to.
	// It is used to indicate which part of the cluster configuration the cause relates to.
	// It is a JSONPath expression that points to the field in the cluster configuration.
	// For example, "spec.topology.variables[.name=clusterConfig].value.imageRegistries[0]".
	Field string
}

Cause represents a cause of a check failure. It contains a message and an optional field that the cause relates to. The field is used to indicate which part of the cluster configuration the cause relates to.

type Check

type Check interface {
	// Name returns the name of the check.
	// The name should be unique across all checks, and should be used to identify the check
	// in the CheckResult.
	// It is also used to skip the check if the cluster has skipped it.
	Name() string

	// Run executes the check and returns a CheckResult.
	Run(ctx context.Context) CheckResult
}

Check represents a single preflight check that can be run against a cluster. It has a Name method that returns the name of the check, and a Run method executes the check, and returns a CheckResult. The Name method is used to identify the check if Run fails to return a result, for example if it panics.

type CheckResult

type CheckResult struct {
	// Allowed indicates whether the check passed.
	Allowed bool

	// InternalError indicates whether there was an internal error running the check.
	// This should be false for most check failures. It can be true in case of an unexpected
	// error, like a network error, an API rate-limit error, etc.
	InternalError bool

	// Causes contains a list of causes for the failure. Each cause has a message and an
	// optional field that the cause relates to. The field is used to indicate which part of
	// the cluster configuration the cause relates to.
	Causes []Cause

	// Warnings contains a list of warnings returned by the check.
	// For example, a check should return a warning when the cluster uses configuration
	// not yet supported by the check.
	Warnings []string
}

CheckResult represents the result of a check. It contains the name of the check, a boolean indicating whether the check passed, an error boolean indicating whether there was an internal error running the check, and a list of causes for the failure. It also contains a list of warnings that were generated during the check.

type Checker

type Checker interface {
	// Init returns the checks that should run for the cluster.
	Init(ctx context.Context, client ctrlclient.Client, cluster *clusterv1.Cluster) []Check
}

Checker returns a set of checks that have been initialized with common dependencies, such as an infrastructure API client.

type WebhookHandler

type WebhookHandler struct {
	// contains filtered or unexported fields
}

func New

func New(client ctrlclient.Client, decoder admission.Decoder, checkers ...Checker) *WebhookHandler

func (*WebhookHandler) Handle

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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