webhook

package
v0.152.0 Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2025 License: Apache-2.0 Imports: 12 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DeployItemWebhookLogic webhooklib.WebhookLogic = func(ctx context.Context, req admission.Request, dec runtime.Decoder) admission.Response {
	logger, _ := logging.FromContextOrNew(ctx, []interface{}{lc.KeyMethod, "DeployItemWebhookLogic"})

	di := &lscore.DeployItem{}
	if _, _, err := dec.Decode(req.Object.Raw, nil, di); err != nil {
		logger.Debug("Decoding failed: " + err.Error())
		return admission.Errored(http.StatusBadRequest, err)
	}

	if errs := validation.ValidateDeployItem(di); len(errs) > 0 {
		aggErr := errs.ToAggregate().Error()
		logger.Debug("Validation failed: " + aggErr)
		return admission.Denied(aggErr)
	}

	if req.Operation == admissionv1.Update {
		oldDi := &lscore.DeployItem{}
		if _, _, err := dec.Decode(req.OldObject.Raw, nil, oldDi); err != nil {
			logger.Debug("Decoding old failed: " + err.Error())
			return admission.Errored(http.StatusBadRequest, err)
		}
		if oldDi.Spec.Type != di.Spec.Type {
			logger.Debug(fmt.Sprintf("deployitem type is immutable, got %q but expected %q", di.Spec.Type, oldDi.Spec.Type))
			return admission.Errored(http.StatusForbidden, field.Forbidden(field.NewPath(".spec.type"), "type is immutable"))
		}
	}

	return admission.Allowed("DeployItem is valid")
}
View Source
var ExecutionWebhookLogic webhooklib.WebhookLogic = func(ctx context.Context, req admission.Request, dec runtime.Decoder) admission.Response {
	logger, _ := logging.FromContextOrNew(ctx, []interface{}{lc.KeyMethod, "ExecutionWebhookLogic"})

	exec := &lscore.Execution{}
	if _, _, err := dec.Decode(req.Object.Raw, nil, exec); err != nil {
		logger.Debug("Decoding failed: " + err.Error())
		return admission.Errored(http.StatusBadRequest, err)
	}

	if errs := validation.ValidateExecution(exec); len(errs) > 0 {
		aggErr := errs.ToAggregate().Error()
		logger.Debug("Validation failed: " + aggErr)
		return admission.Denied(aggErr)
	}

	return admission.Allowed("Execution is valid")
}
View Source
var InstallationWebhookLogic webhooklib.WebhookLogic = func(ctx context.Context, req admission.Request, dec runtime.Decoder) admission.Response {
	logger, _ := logging.FromContextOrNew(ctx, []interface{}{lc.KeyMethod, "InstallationWebhookLogic"})
	inst := &lscore.Installation{}
	if _, _, err := dec.Decode(req.Object.Raw, nil, inst); err != nil {
		logger.Debug("Decoding failed: " + err.Error())
		return admission.Errored(http.StatusBadRequest, err)
	}

	if errs := validation.ValidateInstallation(inst); len(errs) > 0 {
		aggErr := errs.ToAggregate().Error()
		logger.Debug("Validation failed: " + aggErr)
		return admission.Denied(aggErr)
	}

	return admission.Allowed("Installation is valid")
}
View Source
var TargetWebhookLogic webhooklib.WebhookLogic = func(ctx context.Context, req admission.Request, dec runtime.Decoder) admission.Response {
	logger, _ := logging.FromContextOrNew(ctx, []interface{}{lc.KeyMethod, "ExecutionWebhookLogic"})

	t := &lscore.Target{}
	if _, _, err := dec.Decode(req.Object.Raw, nil, t); err != nil {
		logger.Debug("Decoding failed: " + err.Error())
		return admission.Errored(http.StatusBadRequest, err)
	}

	if errs := validation.ValidateTarget(t); len(errs) > 0 {
		aggErr := errs.ToAggregate().Error()
		logger.Debug("Validation failed: " + aggErr)
		return admission.Denied(aggErr)
	}

	return admission.Allowed("Target is valid")
}

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

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