redis

package
v0.0.0-...-ad986b0 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	BindingPolicyHashKey = "binding_policies"
	DefaultExpiration    = 24 * time.Hour
)

Variables

This section is empty.

Functions

func ClearBindingPolicyCache

func ClearBindingPolicyCache() error

ClearBindingPolicyCache clears the entire binding policy cache

func DeleteAllBindingPolicies

func DeleteAllBindingPolicies() error

DeleteAllBindingPolicies removes all binding policies from Redis

func DeleteBindingPolicy

func DeleteBindingPolicy(name string) error

DeleteBindingPolicy removes a binding policy from Redis

func DeleteBpcmd

func DeleteBpcmd(name string) error

removes binding policy from the hash

func GetAllJSONHash

func GetAllJSONHash(hashKey string) (map[string]json.RawMessage, error)

GetAllJSONHash retrieves all JSON values from a Redis hash hashKey: The Redis hash key Returns a map of field names to unmarshaled JSON values

func GetBranch

func GetBranch() (string, error)

func GetFilePath

func GetFilePath() (string, error)

GetFilePath retrieves the file path from Redis

func GetGitToken

func GetGitToken() (string, error)

func GetJSONHash

func GetJSONHash(hashKey string, field string, dest interface{}) (bool, error)

GetJSONHash retrieves a JSON value from a Redis hash and unmarshals it hashKey: The Redis hash key field: The field within the hash dest: Pointer to a struct or map where the unmarshaled JSON will be stored Returns true if the field was found, false if it was not found

func GetJSONValue

func GetJSONValue(key string, dest interface{}) (bool, error)

GetJSONValue retrieves a JSON value from Redis and unmarshals it into the provided destination key: Redis key to retrieve dest: Pointer to a struct or map where the unmarshaled JSON will be stored Returns true if the key was found, false if it was a cache miss

func GetNamespaceCache

func GetNamespaceCache(key string) (string, error)

GetNamespaceCache retrieves cached namespace data from Redis

func GetRepoURL

func GetRepoURL() (string, error)

func GetWorkloadLabel

func GetWorkloadLabel() (string, error)

GetWorkloadLabel gets the workload label from Redis

func GetallBpCmd

func GetallBpCmd() ([]string, error)

returns all BPs in the hash

func SetBpCmd

func SetBpCmd(name string, bpJson string) error

stores binding policy

func SetBranch

func SetBranch(branch string) error

func SetFilePath

func SetFilePath(filepath string) error

SetFilePath sets the file path in Redis

func SetGitToken

func SetGitToken(token string) error

func SetJSONHash

func SetJSONHash(hashKey string, field string, value interface{}) error

SetJSONHash stores a JSON value in a Redis hash hashKey: The Redis hash key field: The field within the hash value: Any Go struct or map that can be marshalled to JSON

func SetJSONValue

func SetJSONValue(key string, value interface{}, expiration time.Duration) error

SetJSONValue sets a JSON value in Redis with an optional expiration key: Redis key to store the JSON under value: Any Go struct or map that can be marshalled to JSON expiration: Time until the key expires (0 for no expiration)

func SetNamespaceCache

func SetNamespaceCache(key string, value string, expiration time.Duration) error

SetNamespaceCache sets a namespace data cache in Redis

func SetRepoURL

func SetRepoURL(repoURL string) error

func SetWorkloadLabel

func SetWorkloadLabel(label string) error

SetWorkloadLabel stores the workload label in Redis

func StoreBindingPolicy

func StoreBindingPolicy(policy *BindingPolicyCache) error

StoreBindingPolicy stores a binding policy in Redis with proper type handling

Types

type BindingPolicyCache

type BindingPolicyCache struct {
	Name              string              `json:"name"`
	Namespace         string              `json:"namespace"`
	ClusterSelectors  []map[string]string `json:"clusterSelectors"`
	APIGroups         []string            `json:"apiGroups"`
	Resources         []string            `json:"resources"`
	Namespaces        []string            `json:"namespaces"`
	SpecificWorkloads []WorkloadInfo      `json:"specificWorkloads"`
	RawYAML           string              `json:"rawYAML"`
	Status            string              `json:"status"`
	BindingMode       string              `json:"bindingMode"`
	Clusters          []string            `json:"clusters"`
	Workloads         []string            `json:"workloads"`
	CreationTimestamp string              `json:"creationTimestamp"`
}

BindingPolicyCache represents a binding policy in the cache

func GetAllBindingPolicies

func GetAllBindingPolicies() ([]*BindingPolicyCache, error)

GetAllBindingPolicies retrieves all binding policies from Redis

func GetBindingPolicy

func GetBindingPolicy(name string) (*BindingPolicyCache, error)

GetBindingPolicy retrieves a binding policy from Redis by name

type WorkloadInfo

type WorkloadInfo struct {
	APIVersion string `json:"apiVersion"`
	Kind       string `json:"kind"`
	Name       string `json:"name"`
	Namespace  string `json:"namespace"`
}

Jump to

Keyboard shortcuts

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