storage

package
v0.9.2 Latest Latest
Warning

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

Go to latest
Published: Mar 19, 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.

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_EXACT_DOMAIN_WILDCARD_MAP = "domain_wildcard_path_exact"
	PATH_PREFIX_MAP                = "path_prefix"
	PATH_REGEX_MAP                 = "path_regex"
	SNI_MAP                        = "sni"
	SNI_DOMAIN_WILDCARD_MAP        = "domain_wildcard_sni"
)
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 {
	// MapPath returns the FilePath for a Map
	MapPath(frontendName string, mapName string) futils.FilePath
	// NewMapData returns the new Map
	GetMapData(filePath futils.FilePath) *maps.MapData
	EnsureMapData(filePath futils.FilePath)
	GetMaps() map[string]*maps.MapData
	WriteOnDisk(data maps.MapData) error
	DeleteFromDisk(data maps.MapData) error
	// DeleteEmptyMapsDir checks and deletes subdirectories directly
	// under the maps Base Dir (namespace level)
	DeleteEmptyMapsDir() error
}

func NewMapsStorage

func NewMapsStorage(logger *slog.Logger, extractGVK utilsk8s.ExtractGVK, structureType StructureType, mapsBaseDir string) (MapsStorage, error)

type MapsStorageDefault

type MapsStorageDefault struct {
	Maps map[string]*maps.MapData
	// MapsBaseDir the base directory to store maps
	MapsBaseDir string
	// contains filtered or unexported fields
}

func (*MapsStorageDefault) DeleteEmptyMapsDir

func (m *MapsStorageDefault) DeleteEmptyMapsDir() error

func (MapsStorageDefault) DeleteFromDisk

func (MapsStorageDefault) DeleteFromDisk(data maps.MapData) error

func (*MapsStorageDefault) EnsureMapData

func (m *MapsStorageDefault) EnsureMapData(filePath futils.FilePath)

func (*MapsStorageDefault) GetMapData

func (m *MapsStorageDefault) GetMapData(filePath futils.FilePath) *maps.MapData

func (*MapsStorageDefault) GetMaps

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

func (*MapsStorageDefault) MapPath

func (m *MapsStorageDefault) MapPath(frontendName string, mapName string) futils.FilePath

MapPath returns the FilePath for the map Default algorithm for Maps Storage - For directory: maps are grouped in directories based on:

  • frontend_name
  • /etc/unified.../maps/<frontend>/

func (MapsStorageDefault) WriteOnDisk

func (MapsStorageDefault) WriteOnDisk(data maps.MapData) error

type MapsStorageEx added in v0.9.0

type MapsStorageEx interface {
	DeleteMapsDirectoryForFrontend(frontendName string) error
	GetPathExactMapFile(frontendName string) *maps.MapFileState
	GetPathPrefixMapFile(frontendName string) *maps.MapFileState
	GetPathRegexMapFile(frontendName string) *maps.MapFileState
	GetSniMapFile(frontendName string) *maps.MapFileState
	GetSniDomainWildcardMapFile(frontendName string) *maps.MapFileState
	GetPathExactDomainWildcardMapFile(frontendName string) *maps.MapFileState
	GetMaps() map[string]map[string]*maps.MapFileState
	ProcessMapFiles()
}

func NewMapsStorageEx added in v0.9.0

func NewMapsStorageEx(logger *slog.Logger, mapsBaseDir string) MapsStorageEx

NewMapsStorageEx 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 MapsStorageExDefault added in v0.9.0

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

func (*MapsStorageExDefault) DeleteFromDisk added in v0.9.0

func (m *MapsStorageExDefault) DeleteFromDisk(mapFilePath string) error

func (*MapsStorageExDefault) DeleteMapsDirectoryForFrontend added in v0.9.0

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

func (*MapsStorageExDefault) GetMaps added in v0.9.0

func (m *MapsStorageExDefault) 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 (*MapsStorageExDefault) GetPathExactDomainWildcardMapFile added in v0.9.0

func (m *MapsStorageExDefault) GetPathExactDomainWildcardMapFile(frontendName string) *maps.MapFileState

func (*MapsStorageExDefault) GetPathExactMapFile added in v0.9.0

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

func (*MapsStorageExDefault) GetPathPrefixMapFile added in v0.9.0

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

func (*MapsStorageExDefault) GetPathRegexMapFile added in v0.9.0

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

func (*MapsStorageExDefault) GetSniDomainWildcardMapFile added in v0.9.0

func (m *MapsStorageExDefault) GetSniDomainWildcardMapFile(frontendName string) *maps.MapFileState

func (*MapsStorageExDefault) GetSniMapFile added in v0.9.0

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

func (*MapsStorageExDefault) ProcessMapFiles added in v0.9.0

func (m *MapsStorageExDefault) 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