Documentation
¶
Index ¶
- Constants
- func ComputeContentHash(obj *unstructured.Unstructured) (string, error)
- func ConfigMapName(manifestName string) string
- func EnsureNamespace(ctx context.Context, c client.Client) error
- type ConfigMapStateStore
- type DiffEntry
- type DiffType
- type StateData
- type StateEntry
- type StateKey
- type StateMetadata
- type StateStore
Constants ¶
const (
// TazunaNamespace はステートConfigMapを格納するnamespace
TazunaNamespace = "tazuna"
)
Variables ¶
This section is empty.
Functions ¶
func ComputeContentHash ¶
func ComputeContentHash(obj *unstructured.Unstructured) (string, error)
ComputeContentHash はunstructured.UnstructuredオブジェクトからSHA-256コンテンツハッシュを算出する。 server-side付与のフィールド(resourceVersion, uid等)とstatusは除外してハッシュを計算する。
func ConfigMapName ¶
ConfigMapName はmanifest名からConfigMap名を生成する
Types ¶
type ConfigMapStateStore ¶
type ConfigMapStateStore struct {
// contains filtered or unexported fields
}
ConfigMapStateStore はConfigMapベースのStateStore実装
func NewConfigMapStateStore ¶
func NewConfigMapStateStore(c client.Client) *ConfigMapStateStore
NewConfigMapStateStore はConfigMapStateStoreを生成する
func (*ConfigMapStateStore) Get ¶
Get はmanifest名に対応するステートをConfigMapから読み込む。 ConfigMapが存在しない場合は空のStateDataを返す。
type DiffEntry ¶
type DiffEntry struct {
Key string // ステートキー文字列
DiffType DiffType // 差分の種類
OldHash string // removed/modified時の旧ハッシュ
NewHash string // added/modified/always-sync時の新ハッシュ
}
DiffEntry は個別リソースの差分情報を表す
func ComputeDiff ¶
func ComputeDiff(stateData *StateData, currentEntries map[string]StateEntry, alwaysSyncKeys map[string]bool) []DiffEntry
ComputeDiff は既存ステートと現在のエントリを比較して差分を算出する。 alwaysSyncKeys に含まれるキーは always-sync として扱う。
type StateData ¶
type StateData struct {
Metadata StateMetadata
Entries map[string]StateEntry // キー: ステートキー文字列
}
StateData はmanifest単位のステート全体を表す
type StateEntry ¶
type StateEntry struct {
ContentHash string `json:"contentHash"`
}
StateEntry はステートに保存される個別リソースのエントリ
type StateKey ¶
type StateKey struct {
ManifestName string
Group string
Version string
Kind string
Namespace string // クラスタスコープリソースの場合は空文字
Name string
}
StateKey はステートエントリのキーを表す構造体
func NewStateKey ¶
NewStateKey はK8sオブジェクトからステートキーを生成する
func ParseStateKey ¶
ParseStateKey は文字列からStateKeyをパースする。 namespaced (6パート): {manifest}/{group}/{version}/{kind}/{namespace}/{name} cluster-scoped (5パート): {manifest}/{group}/{version}/{kind}/{name}
type StateMetadata ¶
type StateMetadata struct {
GitCommitHash string `json:"gitCommitHash"`
LastSyncedAt string `json:"lastSyncedAt"`
}
StateMetadata はステートConfigMapのメタデータ (_metadata キー)
type StateStore ¶
type StateStore interface {
// Get はmanifest名に対応するステートを取得する。
// ConfigMapが存在しない場合は空のStateDataを返す。
Get(ctx context.Context, manifestName string) (*StateData, error)
// Save はmanifest名に対応するステートを保存する。
Save(ctx context.Context, manifestName string, data *StateData) error
}
StateStore はステートの読み書きインターフェース