storage

package
v1.0.4 Latest Latest
Warning

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

Go to latest
Published: Jun 2, 2026 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Overview

Copyright 2025 HAProxy Technologies LLC

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Index

Constants

View Source
const (
	PATH_EXACT_MAP                    = "path_exact"
	PATH_PREFIX_MAP                   = "path_prefix"
	PATH_REGEX_MAP                    = "path_regex"
	SNI_MAP                           = "sni"
	MAP_LISTENER_EXACT_MATCH          = "listener_exact_match"
	MAP_LISTENER_WILDCARD_MATCH       = "listener_wildcard_match"
	MAP_LISTENER_ROUTE_EXACT_MATCH    = "listener_route_exact_match"
	MAP_LISTENER_ROUTE_WILDCARD_MATCH = "listener_route_wildcard_match"
)
View Source
const (
	// StructureTypeCertDefault handles a default storage algorithm
	// Default algorithm for Certificate Storage
	// namespace/take two first characters of a secret name as folder
	// For example for secrets: namespace/secret-name-1 , namespace/secret-name-2, namespace/my-secret-name-1
	// - /etc/unified.../certs/<namespace>/se/
	// - /etc/unified.../certs/<namespace>/se/
	// - /etc/unified.../certs/<namespace>/my/
	StructureTypeCertDefault = "default"
	// StructureTypeMapsDefault handles a default storage algorithm
	// Default algorithm for Maps Storage
	// TODO
	StructureTypeMapsDefault = "default"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type CertStorage

type CertStorage interface {
	// CertPath returns the FilePath for the a Certificate
	CertPath(secretKey client.ObjectKey) futils.FilePath
	// NewCertificateData returns the new CertificateData for a given secret
	NewCertificateData(secret *v1.Secret) (certificate.CertificateData, error)
	WriteOnDisk(certData certificate.CertificateData) error
	DeleteFromDisk(certData certificate.CertificateData) error
	// DeleteEmptyCertsDir checks and deletes subdirectories directly
	// under the certs Base Dir (namespace level)
	DeleteEmptyCertsDir() error
}

type CertificateStorage

type CertificateStorage interface {
	CertStorage
	CrtListStorage
}

func NewCertificateStorage

func NewCertificateStorage(logger *slog.Logger, extractGVK utilsk8s.ExtractGVK, structureType StructureType, linkID, certsBaseDir, certFileBaseDir string) (CertificateStorage, error)

type CertificateStorageDefault

type CertificateStorageDefault struct {

	// CertsBaseDir the base directory to store certificates
	// /usr/local/hug/certs/<namespace>/my/
	CertsBaseDir string
	// CertFilesBaseDir is the base directory where crt-list files are stored
	CertFilesBaseDir string
	LinkID           string
	// contains filtered or unexported fields
}

CertificateStorageDefault handles a default storage for certificates

func (*CertificateStorageDefault) CertListPath

func (c *CertificateStorageDefault) CertListPath(virtualListenerName string) futils.FilePath

func (*CertificateStorageDefault) CertPath

func (c *CertificateStorageDefault) CertPath(secretKey client.ObjectKey) futils.FilePath

CertPath returns the FilePath for the a Certificate Default algorithm for Certificate Storage - For directory: certificates are grouped in directories based on:

  • namespace/[take two first characters of a secret name as folder] to avoid having too many of them in the same directory For example for secrets: namespace/secret-name-1 , namespace/secret-name-2, namespace/my-secret-name-1 -/usr/local/hug/certs/<namespace>/se/ -/usr/local/hug/certs/<namespace>/se/ -/usr/local/hug/certs/<namespace>/my/

For file name: secret name.pem -/usr/local/hug/certs/<namespace>/se/secret-name-1.pem -/usr/local/hug/certs/<namespace>/se/secret-name-2.pem -/usr/local/hug/certs/<namespace>/my/my-secret-name-1.pem

func (*CertificateStorageDefault) DeleteCrtListFromDisk

func (c *CertificateStorageDefault) DeleteCrtListFromDisk(crtListData certificate.CrtListData) error

func (*CertificateStorageDefault) DeleteEmptyCertsDir

func (c *CertificateStorageDefault) DeleteEmptyCertsDir() error

DeleteEmptyCertsDir checks and deletes subdirectories directly under the certs BaseDir path if they are empty

func (*CertificateStorageDefault) DeleteFromDisk

func (c *CertificateStorageDefault) DeleteFromDisk(certData certificate.CertificateData) error

func (*CertificateStorageDefault) NewCertificateData

func (c *CertificateStorageDefault) NewCertificateData(secret *v1.Secret) (certificate.CertificateData, error)

func (*CertificateStorageDefault) NewCrtListData

func (c *CertificateStorageDefault) NewCrtListData(virtualListenerName string, secretKeys map[client.ObjectKey]struct{}) certificate.CrtListData

func (*CertificateStorageDefault) UpdateCrtListOnDisk

func (c *CertificateStorageDefault) UpdateCrtListOnDisk(virtualListenerName string, newSecretKeys, removedSecretKeys map[client.ObjectKey]struct{}) error

func (*CertificateStorageDefault) WriteCrtListOnDisk

func (c *CertificateStorageDefault) WriteCrtListOnDisk(crtList certificate.CrtListData) error

func (*CertificateStorageDefault) WriteOnDisk

type CrtListStorage

type CrtListStorage interface {
	// CertListPath returns the FilePath for the crt-file file.
	CertListPath(virtualListenerName string) futils.FilePath
	// DeleteCrtListFromDisk deletes a crt-list from disk
	DeleteCrtListFromDisk(crtListData certificate.CrtListData) error
	// NewCrtListData returns the new CrtListData
	NewCrtListData(virtualListenerName string, secretKeys map[client.ObjectKey]struct{}) certificate.CrtListData
	// WriteCrtListOnDisk writes a new crt-list on disk
	WriteCrtListOnDisk(crtList certificate.CrtListData) error
	// UpdateCrtListOnDisk updates a crt-list on disk with new certificates and removed ones
	UpdateCrtListOnDisk(virtualListenerName string, newSecretKeys, removedSecretKeys map[client.ObjectKey]struct{}) error
}

type MapsStorage

type MapsStorage interface {
	DeleteMapsDirectoryForFrontend(frontendName string) error
	DeleteMapsDirectory() error
	GetPathExactMapFile(frontendName string) *maps.MapFileState
	GetPathPrefixMapFile(frontendName string) *maps.MapFileState
	GetPathRegexMapFile(frontendName string) *maps.MapFileState
	GetSniMapFile(frontendName string) *maps.MapFileState
	GetListenerExactMatchMapFile(frontendName string) *maps.MapFileState
	GetListenerWildcardMatchMapFile(frontendName string) *maps.MapFileState
	GetListenerRouteExactMatchMapFile(frontendName string) *maps.MapFileState
	GetListenerRouteWildcardMatchMapFile(frontendName string) *maps.MapFileState
	GetMaps() map[string]map[string]*maps.MapFileState
	ProcessMapFiles()
}

func NewMapsStorage

func NewMapsStorage(logger *slog.Logger, mapsBaseDir string) MapsStorage

NewMapsStorage creates a new instance of MapsStorageEx with the given logger and maps base directory. It returns a pointer to the new instance. The logger is used to log messages related to the MapsStorageEx instance. The maps base directory is the directory where the maps storage will store the maps files.

type MapsStorageDefault

type MapsStorageDefault struct {
	MapsBaseDir string
	// contains filtered or unexported fields
}

func (*MapsStorageDefault) DeleteMapsDirectory added in v1.0.3

func (m *MapsStorageDefault) DeleteMapsDirectory() error

func (*MapsStorageDefault) DeleteMapsDirectoryForFrontend added in v1.0.3

func (m *MapsStorageDefault) DeleteMapsDirectoryForFrontend(frontendName string) error

func (*MapsStorageDefault) GetListenerExactMatchMapFile added in v1.0.3

func (m *MapsStorageDefault) GetListenerExactMatchMapFile(frontendName string) *maps.MapFileState

func (*MapsStorageDefault) GetListenerRouteExactMatchMapFile added in v1.0.3

func (m *MapsStorageDefault) GetListenerRouteExactMatchMapFile(frontendName string) *maps.MapFileState

func (*MapsStorageDefault) GetListenerRouteWildcardMatchMapFile added in v1.0.3

func (m *MapsStorageDefault) GetListenerRouteWildcardMatchMapFile(frontendName string) *maps.MapFileState

func (*MapsStorageDefault) GetListenerWildcardMatchMapFile added in v1.0.3

func (m *MapsStorageDefault) GetListenerWildcardMatchMapFile(frontendName string) *maps.MapFileState

func (*MapsStorageDefault) GetMaps

func (m *MapsStorageDefault) GetMaps() map[string]map[string]*maps.MapFileState

GetMaps returns a map of all MapFileState objects currently stored in MapsStorageExDefault. It returns a map of string (map file path) to MapFileState objects. The map file path is the full path to the map file including the base directory. The MapFileState objects contain the current state of the map file including the entries, desired values, and diff values. The map is read-only and should not be modified directly.

func (*MapsStorageDefault) GetPathExactMapFile added in v1.0.3

func (m *MapsStorageDefault) GetPathExactMapFile(frontendName string) *maps.MapFileState

func (*MapsStorageDefault) GetPathPrefixMapFile added in v1.0.3

func (m *MapsStorageDefault) GetPathPrefixMapFile(frontendName string) *maps.MapFileState

func (*MapsStorageDefault) GetPathRegexMapFile added in v1.0.3

func (m *MapsStorageDefault) GetPathRegexMapFile(frontendName string) *maps.MapFileState

func (*MapsStorageDefault) GetSniMapFile added in v1.0.3

func (m *MapsStorageDefault) GetSniMapFile(frontendName string) *maps.MapFileState

func (*MapsStorageDefault) ProcessMapFiles added in v1.0.3

func (m *MapsStorageDefault) ProcessMapFiles()

ProcessMapFiles processes all the map files stored in MapsStorageExDefault. It iterates over each map file and calls ProcessMapFiles on each map file. ProcessMapFiles is a blocking call and should be called in a goroutine to avoid blocking the application.

type StructureType

type StructureType string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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