checksum

package
v0.9.2 Latest Latest
Warning

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

Go to latest
Published: Feb 6, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package checksum provides checksum computation and comparison for ConfigMaps

Index

Constants

View Source
const (
	// ContentChecksumAnnotation is the annotation key used to store the ConfigMap content checksum
	ContentChecksumAnnotation = "toolhive.stacklok.dev/content-checksum"

	// RunConfigChecksumAnnotation is the annotation key used to store the RunConfig checksum
	// in pod template annotations to trigger pod restarts when configuration changes
	RunConfigChecksumAnnotation = "toolhive.stacklok.dev/runconfig-checksum"
)

Variables

This section is empty.

Functions

func AddRunConfigChecksumToPodTemplate added in v0.5.0

func AddRunConfigChecksumToPodTemplate(annotations map[string]string, checksum string) map[string]string

AddRunConfigChecksumToPodTemplate adds the RunConfig checksum as an annotation to the provided annotations map. This triggers Kubernetes to perform a rolling update when the checksum changes.

If the checksum is empty, no annotation is added. This allows callers to gracefully handle cases where the checksum is not yet available.

Returns the updated annotations map.

Types

type RunConfigChecksumFetcher added in v0.5.0

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

RunConfigChecksumFetcher provides methods for fetching RunConfig ConfigMap checksums. This is used to detect configuration changes and trigger pod restarts.

func NewRunConfigChecksumFetcher added in v0.5.0

func NewRunConfigChecksumFetcher(c client.Client) *RunConfigChecksumFetcher

NewRunConfigChecksumFetcher creates a new RunConfigChecksumFetcher

func (*RunConfigChecksumFetcher) GetRunConfigChecksum added in v0.5.0

func (f *RunConfigChecksumFetcher) GetRunConfigChecksum(
	ctx context.Context,
	namespace string,
	resourceName string,
) (string, error)

GetRunConfigChecksum fetches the RunConfig ConfigMap checksum annotation for a resource.

This checksum is used to trigger pod restarts when the RunConfig content changes. The function retrieves the checksum from the ConfigMap's annotations and validates that it is non-empty.

Parameters:

  • ctx: Context for the operation
  • namespace: Namespace of the ConfigMap
  • resourceName: Name of the resource (used to construct ConfigMap name as "<resourceName>-runconfig")

Returns:

  • (checksum, nil) on success - checksum is a non-empty SHA256 hex string
  • ("", error) on failure - error indicates the specific failure reason

The returned error preserves the error type, allowing callers to check for errors.IsNotFound() to handle missing ConfigMaps gracefully during initial creation.

type RunConfigConfigMapChecksum

type RunConfigConfigMapChecksum interface {
	ComputeConfigMapChecksum(cm *corev1.ConfigMap) string
	ConfigMapChecksumHasChanged(current, desired *corev1.ConfigMap) bool
}

RunConfigConfigMapChecksum provides methods for computing and comparing ConfigMap checksums

func NewRunConfigConfigMapChecksum

func NewRunConfigConfigMapChecksum() RunConfigConfigMapChecksum

NewRunConfigConfigMapChecksum creates a new RunConfigConfigMapChecksum

Jump to

Keyboard shortcuts

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