Documentation
¶
Index ¶
- Constants
- type ContextMatchMode
- type EnvFileProviderConfig
- type EnvironmentSpec
- type ExistNonExistArgs
- type GenesisSecret
- type GenesisSecretGenerate
- type GenesisSecretGenerateItem
- type GenesisSecretOutput
- type GenesisSecretOutputKubernetesSecret
- type GenesisSecretOutputStdout
- type GenesisSecretSpec
- type HelmFileVar
- type HintFormat
- type HintRule
- type HintRuleType
- type HintVar
- type HintVarType
- type IncludeFile
- type Manifest
- type ManifestGenesisSecret
- type ManifestHelmfile
- type ManifestKustomize
- type ManifestORAS
- type ManifestType
- type ORASAuth
- type ORASDelegate
- type ORASDelegateType
- type OnePasswordProviderConfig
- type OnePasswordVaultSelector
- type Provider
- type ProviderConfig
- type ProviderRequirement
- type ProviderSpec
- type ProviderType
- type Tazuna
- type TazunaHint
- type TazunaSpec
- type TestPluginSpec
- type TestPluginType
- type WaitUntilArgs
- type WaitUntilResource
Constants ¶
const ( // TazunaAPIVersion は Tazuna リソースが取りうる apiVersion の正規値です。 TazunaAPIVersion = "tazuna.pepabo.com/v1" // TazunaKind は Tazuna リソースが取りうる kind の正規値です。 TazunaKind = "Tazuna" )
const ( HelmFileVarFromEnv = "env" HelmFileVarFromStatic = "static" HelmFileVarFromOp = "op" HelmFileVarOpKeyID = "id" HelmFileVarOpKeyLabel = "label" )
const DefaultOnePasswordProviderName = "default-op"
DefaultOnePasswordProviderName is the reserved name of the built-in 1Password provider that is always available without explicit declaration in tazuna.yaml. GenesisSecret manifests with empty .spec.provider fall back to this provider to preserve backward compatibility.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ContextMatchMode ¶
type ContextMatchMode string
ContextMatchMode はcontext_matchesの評価モードを定義します
const ( // ContextMatchModeOR はいずれかのパターンにマッチすればOK(デフォルト) ContextMatchModeOR ContextMatchMode = "or" // ContextMatchModeAND はすべてのパターンにマッチする必要がある ContextMatchModeAND ContextMatchMode = "and" )
type EnvFileProviderConfig ¶ added in v0.2.0
type EnvFileProviderConfig struct {
// Path is the path to a dotenv style file. Relative paths are resolved
// against the directory containing tazuna.yaml.
Path string `json:"path"`
}
EnvFileProviderConfig は .env ファイルから値を読む provider の設定です。
type EnvironmentSpec ¶ added in v0.4.0
type EnvironmentSpec struct {
// ContextMatches はこの環境で有効にする context_matches パターンのリストです。
// ルート直下の context_matches を完全に置き換えます (マージはしません)。
ContextMatches []string `json:"context_matches,omitempty"`
// ContextMatchMode はこの環境における context_matches の評価モードです。
// 空の場合はルート直下の context_match_mode を継承し、それも空なら "or" になります。
ContextMatchMode ContextMatchMode `json:"context_match_mode,omitempty"`
}
EnvironmentSpec は 1 つの環境 (`environments.<name>`) の設定を定義します。 `-e/--environment <name>` が渡されたとき、ルート直下の同名フィールドの代わりに ここで宣言した値が使われます。
type ExistNonExistArgs ¶
type ExistNonExistArgs struct {
Resource WaitUntilResource `json:"resource"`
Namespace string `json:"namespace"`
Name string `json:"name"`
ShouldExist bool `json:"shouldExist"`
}
type GenesisSecret ¶
type GenesisSecret struct {
Spec GenesisSecretSpec `json:"spec"`
}
type GenesisSecretGenerate ¶
type GenesisSecretGenerate struct {
// PreferLabelはID->ValueのマッピングではなくLabel->Valueを作る
// カスタムのkey-valueを作るとIDがランダム文字列になるので、それを可能にするために定義する
PreferLabel bool `json:"preferLabel"`
URI string `json:"uri"`
Items map[string]GenesisSecretGenerateItem `json:"items"`
}
type GenesisSecretGenerateItem ¶
type GenesisSecretGenerateItem struct {
MapTo string `json:"mapTo"`
}
type GenesisSecretOutput ¶
type GenesisSecretOutput struct {
Stdout *GenesisSecretOutputStdout `json:"stdout,omitempty"`
KubernetesSecret *GenesisSecretOutputKubernetesSecret `json:"kubernetesSecret,omitempty"`
}
type GenesisSecretOutputStdout ¶
type GenesisSecretOutputStdout struct{}
type GenesisSecretSpec ¶
type GenesisSecretSpec struct {
Provider string `json:"provider"`
Secrets []GenesisSecretGenerate `json:"secrets"`
Outputs []GenesisSecretOutput `json:"outputs"`
}
type HelmFileVar ¶
type HelmFileVar struct {
// Fromはどこからhelmfile varの値を取得するかを指定します。
// 現状は `env` と `op`, `static` をサポートしています
From string `json:"from,omitempty"`
Op *OnePasswordVaultSelector `json:"op,omitempty"`
Static *string `json:"static,omitempty"` // staticな値を指定する
StaticSlice []string `json:"staticSlice,omitempty"` // staticなslice値を指定する
StaticMap map[string]string `json:"staticMap,omitempty"` // staticなmap値を指定する
Env *string `json:"env,omitempty"` // 環境変数から値を取得する
}
type HintFormat ¶
type HintFormat string
HintFormat はstring型varのフォーマット検証ルールを表します。 format検証は値が非空文字列の場合のみ実行されます(ゼロ値注入による空文字列はスキップ)。
対応フォーマットと検証基準:
- hostname: RFC 952/1123に準拠したホスト名(英数字、ハイフン、ドット)
- url: net/url.ParseRequestURIで解析可能かつschemeが存在する
- email: 簡易的な正規表現による検証(user@domain形式)
- ip: net.ParseIPで解析可能なIPv4/IPv6アドレス
- cidr: net.ParseCIDRで解析可能なCIDR表記
- uuid: RFC 4122形式のUUID(ハイフン区切り)
- semver: セマンティックバージョニング(v接頭辞はオプション)
- datetime: time.RFC3339形式の日時文字列
const ( HintFormatHostname HintFormat = "hostname" HintFormatURL HintFormat = "url" HintFormatEmail HintFormat = "email" HintFormatIP HintFormat = "ip" HintFormatCIDR HintFormat = "cidr" HintFormatUUID HintFormat = "uuid" HintFormatSemver HintFormat = "semver" HintFormatDatetime HintFormat = "datetime" )
type HintRule ¶
type HintRule struct {
// Type はルールの種別です。現在は "oneof_required" のみ対応。
Type HintRuleType `json:"type"`
// Vars はルールの対象となるvar名のリストです。2件以上が必要です。
Vars []string `json:"vars"`
// Message はバリデーションエラー時に表示するカスタムメッセージです。
Message string `json:"message,omitempty"`
}
HintRule はトップレベルのバリデーションルールを表します。 MergeVarsWithHintの実行時に、個別varの検証後に評価されます。
type HintRuleType ¶
type HintRuleType string
HintRuleType はトップレベルバリデーションルールの種別を表します。
const ( // HintRuleTypeOneofRequired は指定されたvarのうち少なくとも1つがユーザーから提供されることを要求します。 // 「提供済み」の判定はユーザーから明示的に渡されたresolvedVarsの存在で行い、 // ゼロ値注入後のresultは参照しません。 HintRuleTypeOneofRequired HintRuleType = "oneof_required" )
type HintVar ¶
type HintVar struct {
Type HintVarType `json:"type"`
Required bool `json:"required"`
Default any `json:"default,omitempty"`
Description string `json:"description,omitempty"`
// Format はstring型varに対するフォーマット検証ルールです。
// string型以外のvarに指定するとValidateHintでエラーになります。
// 値が空文字列(ゼロ値注入を含む)の場合、検証はスキップされます。
Format HintFormat `json:"format,omitempty"`
// RequiredWith は、指定されたvarのいずれかがユーザーから提供された場合に、
// このvarも必須になることを示します。
// required:trueとの併用は矛盾するためValidateHintでエラーになります。
RequiredWith []string `json:"required_with,omitempty"`
// RequiredWithout は、指定されたvarが全てユーザーから未提供の場合に、
// このvarが必須になることを示します。
// required:trueとの併用は矛盾するためValidateHintでエラーになります。
RequiredWithout []string `json:"required_without,omitempty"`
}
HintVar はhint varsの定義です
type HintVarType ¶
type HintVarType string
HintVarType はhint varsの型を表します
const ( HintVarTypeString HintVarType = "string" HintVarTypeSlice HintVarType = "slice" HintVarTypeMap HintVarType = "map" )
type IncludeFile ¶
type IncludeFile struct {
// Path はincludeするファイルのパス(tazuna.yamlからの相対パス)
Path string `json:"path"`
}
IncludeFile はincludeするファイルを定義します
type Manifest ¶
type Manifest struct {
Name string `json:"name,omitempty"` // マニフェストの名前
Description string `json:"description,omitempty"` // マニフェストの説明
// Includes はincludeするファイルのリストを指定します
// includesが指定された場合、他のフィールド(Type, Path, Tags など)は無視されます
Includes []IncludeFile `json:"includes,omitempty"`
// Path はマニフェストのパスを指定します
// GenesisSecretの場合はGenesisSecretのリソースマニフェストのパス
// Kustomizeの場合はkustomization.yamlがあるディレクトリ
// Helmfileの場合はhelmfile.yamlがあるディレクトリ
Path string `json:"path"`
Type ManifestType `json:"type"`
// Tagsはマニフェストに付与するタグを指定します
// タグはマニフェストの選択に利用できます
// 例えば、`tazuna apply --tags foo,bar`とすると、fooとbarのタグが付与されたマニフェストのみが適用されます
Tags []string `json:"tags,omitempty"`
Kustomize *ManifestKustomize `json:"kustomize,omitempty"`
GenesisSecret *ManifestGenesisSecret `json:"genesisSecret,omitempty"`
Helmfile *ManifestHelmfile `json:"helmfile,omitempty"`
ORAS *ManifestORAS `json:"oras,omitempty"`
// DependsOn はこのマニフェスト適用前に完了している必要があるマニフェスト名のリスト。
// dependsOn に列挙された全マニフェストが apply 成功した後でのみ、このマニフェストの
// apply が開始される。同じ層に属するマニフェスト (依存関係上同じ深度) は並列に
// 適用される。dependsOn が tazuna.yaml 内で一度も使われていなければ従来通りの
// 宣言順・順次実行となるため後方互換性が保たれる。
// 自分自身の参照、未知のマニフェスト名、循環依存はいずれもバリデーションエラー。
DependsOn []string `json:"dependsOn,omitempty"`
// Testsはマニフェストapply後に行われる各種テストを記載します
Tests []TestPluginSpec `json:"tests"`
}
Manifest はtazunaのマニフェスト管理方式を定義します
type ManifestGenesisSecret ¶
type ManifestGenesisSecret struct{}
type ManifestHelmfile ¶
type ManifestHelmfile struct {
IncludeCRDs bool `json:"includeCRDs"`
Vars map[string]HelmFileVar `json:"vars,omitempty"`
DefaultNamespace string `json:"defaultNamespace,omitempty"` // helmfile assetsのデフォルトネームスペース
ExtraValueFiles []string `json:"extraValueFiles,omitempty"` // 追加のvalue filesを指定
Wait bool `json:"wait,omitempty"` // helmfile syncに--waitオプションを渡す
TimeoutSeconds int `json:"timeoutSeconds,omitempty"` // リソースのReady待機のタイムアウト秒数
KubeVersion string `json:"kubeVersion,omitempty"` // helm templateに渡す--kube-versionの値
}
func DefaultHelmfile ¶
func DefaultHelmfile() *ManifestHelmfile
type ManifestKustomize ¶
type ManifestKustomize struct {
DefaultNamespace string `json:"defaultNamespace,omitempty"` // kustomize assetsのデフォルトネームスペース
}
type ManifestORAS ¶
type ManifestORAS struct {
// Reference はOCI artifactのreferenceを指定します。
// tag形式 (`ghcr.io/example/foo:v1.0.0`) と digest形式
// (`ghcr.io/example/foo@sha256:...`) の両方を受け付けます。
Reference string `json:"reference"`
// Target はartifact展開後のルートからの相対サブパスを指定します。
// 省略時はrootを指します。
Target string `json:"target,omitempty"`
// PlainHTTP はregistryへの接続にHTTP (非TLS) を使うかどうかを指定します。
PlainHTTP bool `json:"plainHTTP,omitempty"`
// InsecureSkipVerify はregistry接続時のTLS証明書検証をスキップします。
InsecureSkipVerify bool `json:"insecureSkipVerify,omitempty"`
// Auth はregistryの認証情報をoverrideします。省略時は docker config.json を使用します。
Auth *ORASAuth `json:"auth,omitempty"`
// Delegate はpull後の委譲先managerの設定を指定します。
Delegate ORASDelegate `json:"delegate"`
}
ManifestORAS はOCI registry (ORAS) からpullするmanifestの設定を表します。 詳細は docs/adr/004-oras-manager.md を参照してください。
type ManifestType ¶
type ManifestType string
const ( ManifestTypeKustomize ManifestType = "kustomize" ManifestTypeGenesisSecret ManifestType = "genesissecret" ManifestTypeHelmfile ManifestType = "helmfile" ManifestTypeORAS ManifestType = "oras" )
type ORASAuth ¶
type ORASAuth struct {
Username string `json:"username,omitempty"`
Password string `json:"password,omitempty"`
}
ORASAuth はORAS pull時の認証情報のoverrideを表します。
type ORASDelegate ¶
type ORASDelegate struct {
// Type は委譲先managerの種別 (helmfile / kustomize) を指定します。
Type ORASDelegateType `json:"type"`
// Helmfile は Type が helmfile の場合に委譲先に渡す設定です。
Helmfile *ManifestHelmfile `json:"helmfile,omitempty"`
// Kustomize は Type が kustomize の場合に委譲先に渡す設定です。
Kustomize *ManifestKustomize `json:"kustomize,omitempty"`
}
ORASDelegate はORAS managerが委譲する先のmanager設定を表します。
type ORASDelegateType ¶
type ORASDelegateType string
ORASDelegateType はORAS managerが委譲する先のmanager種別を表します
const ( // ORASDelegateTypeHelmfile はhelmfile managerに委譲します ORASDelegateTypeHelmfile ORASDelegateType = "helmfile" // ORASDelegateTypeKustomize はkustomize managerに委譲します ORASDelegateTypeKustomize ORASDelegateType = "kustomize" )
type OnePasswordProviderConfig ¶ added in v0.2.0
type OnePasswordProviderConfig struct{}
OnePasswordProviderConfig は OnePassword provider 用の追加設定です。 現状は空ですが、vault のホワイトリストや prefer-cli 等の拡張余地のために 構造体を分離しています。
type Provider ¶
type Provider struct {
Spec ProviderSpec `json:"spec"`
}
Provider は (legacy) provider 要件宣言です。tazuna check のための環境前提として 必要な CLI コマンドを列挙する用途で利用されています。Secret provider の宣言 (ProviderConfig) とは別物として残しています。
type ProviderConfig ¶ added in v0.2.0
type ProviderConfig struct {
// Name は GenesisSecret の .spec.provider から参照される識別子です。
// "default-op" は組み込みの 1Password provider 用に予約されています。
Name string `json:"name"`
// Type は provider の種類です。"onepassword" / "envfile" のいずれかを指定します。
Type ProviderType `json:"type"`
// OnePassword は Type が "onepassword" のときに使う追加設定です。現状は空でも
// OK ですが、将来的な拡張余地のために存在しています。
OnePassword *OnePasswordProviderConfig `json:"onepassword,omitempty"`
// EnvFile は Type が "envfile" のときに使う追加設定です。Path に .env ファイル
// (tazuna.yaml からの相対パス) を指定します。
EnvFile *EnvFileProviderConfig `json:"envfile,omitempty"`
}
ProviderConfig は tazuna.yaml の spec.providers[] エントリで、単一の Secret provider 宣言を表現します。GenesisSecret の .spec.provider フィールドが この Name を参照することで、複数 provider の中から呼び分けることができます。
type ProviderRequirement ¶
type ProviderSpec ¶
type ProviderSpec struct {
Requirements []ProviderRequirement `json:"requirements"`
}
type ProviderType ¶ added in v0.2.0
type ProviderType string
ProviderType は Secret provider の種類を表す識別子です。
const ( // ProviderTypeOnePassword represents the built-in 1Password backed Secret provider. ProviderTypeOnePassword ProviderType = "onepassword" // ProviderTypeEnvFile represents the Secret provider that reads from a .env file. ProviderTypeEnvFile ProviderType = "envfile" )
type Tazuna ¶
type Tazuna struct {
// APIVersion は Kubernetes manifest と同形式の TypeMeta フィールドです。
// 設定する場合は TazunaAPIVersion と一致している必要があります。
APIVersion string `json:"apiVersion,omitempty"`
// Kind は Kubernetes manifest と同形式の TypeMeta フィールドです。
// 設定する場合は TazunaKind と一致している必要があります。
Kind string `json:"kind,omitempty"`
Spec TazunaSpec `json:"spec"`
}
Tazuna はtazuna applyの挙動を制御するルートリソースです
type TazunaHint ¶
type TazunaHint struct {
APIVersion string `json:"apiVersion"`
Kind string `json:"kind"`
Vars map[string]HintVar `json:"vars"`
// Rules はvar横断のトップレベルバリデーションルールです。
Rules []HintRule `json:"rules,omitempty"`
}
TazunaHint はtazuna.hint.yamlのルートリソースです
type TazunaSpec ¶
type TazunaSpec struct {
// MinimumSupportedTazunaVersion はこの tazuna.yaml を処理するのに必要な
// tazuna バイナリの最小バージョンを semver 形式で宣言します(例: "1.4.0")。
// 指定した場合、tazuna.yaml を読み込んだ任意の操作で、実行中の tazuna の
// バージョンがこの値を下回るとエラーで終了します。未指定なら制約はありません。
// 先頭の "v" は許容されます("v1.4.0" も可)。
MinimumSupportedTazunaVersion string `json:"minimumSupportedTazunaVersion,omitempty"`
// ContextMatchesは現在のkubeconfigコンテキスト名がマッチすべき正規表現パターンのリストです
// 指定した場合、apply/destroy時にコンテキスト名がパターンにマッチしないとエラーになります
ContextMatches []string `json:"context_matches,omitempty"`
// ContextMatchModeはcontext_matchesの評価モードです("or" または "and"、デフォルトは "or")
ContextMatchMode ContextMatchMode `json:"context_match_mode,omitempty"`
// Environments は環境ごとの設定を宣言するマップです。キーが環境名になります。
// `-e/--environment <name>` が渡されたとき、ルート直下の context_matches /
// context_match_mode ではなく、ここで宣言した環境固有の値が使われます。
// 未指定または `-e` が渡されない場合はルート直下の設定がそのまま使われます。
Environments map[string]EnvironmentSpec `json:"environments,omitempty"`
Manifests []Manifest `json:"manifests"`
// Testsはすべてのマニフェスト適用が終わったあとに実行されます
Tests []TestPluginSpec `json:"tests"`
// Providers は Secret provider の宣言リストです。未指定時は組み込みの "default-op"
// (1Password) のみが利用可能であり、これは GenesisSecret の .spec.provider が空文字
// だった場合の後方互換フォールバックとして利用されます。
Providers []ProviderConfig `json:"providers,omitempty"`
}
type TestPluginSpec ¶
type TestPluginSpec struct {
Type TestPluginType `json:"type"`
// N回の連続したテスト関数の成功を、テストプラグインの通過とする
// 指定されていない場合、一度でも成功したらOKとする
MinConsecutiveSuccessCount int `json:"minConsecutiveSuccessCount"`
// N回の連続したテスト関数の失敗を、テストプラグインの失敗とする
// 指定されていない場合無視される
MinConsecutiveFailureCount int `json:"minConsecutiveFailureCount"`
// テストプラグイン自体の失敗とするタイムアウト秒
// 指定されなければSuccessするまで待ち続ける
TimeoutSeconds int `json:"timeoutSeconds"`
// テスト関数の実行の間にいれるinterval
// 指定されなければ即座に再実行される
IntervalSeconds int `json:"intervalSeconds"`
WaitUntil *WaitUntilArgs `json:"waitUntil,omitempty"`
ExistNonExist *ExistNonExistArgs `json:"existNonExist,omitempty"`
}
type TestPluginType ¶
type TestPluginType string
const ( TestPluginTypeWaitUntil TestPluginType = "WaitUntil" TestPluginTypeExistNonExist TestPluginType = "ExistNonExist" )
type WaitUntilArgs ¶
type WaitUntilArgs struct {
Resource WaitUntilResource `json:"resource"`
Namespace string `json:"namespace"`
Name string `json:"name"`
Condition string `json:"condition"`
}