Documentation
¶
Overview ¶
Copyright 2026 The BlanketOps Authors. 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.
Package gitrepository implements the GitRepository prerequisite mediator. The mediator owns the cross-cutting prerequisites a GitRepository requires before the application layer may act: the GitHub provider credentials, the GitHub ProviderConfig, and the per-repository webhook URL secret. It is invoked by the GitRepository domain during command handling — after resolution, before execution — and again during teardown. Prerequisite provisioning is gated on the Environment: the Environment CR must pre-exist as the root of the delivery chain, and it is the sole authority for the ClusterSecretStore binding used by every store-dependent secret this mediator reconciles. The provider credentials and ProviderConfig are shared, cluster-level prerequisites serving every GitRepository — they are ensured per-CR but never torn down per-CR. Only the webhook URL secret is scoped to a single GitRepository and follows its lifecycle.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Mediator ¶
type Mediator struct {
// Client is the Kubernetes client used for all prerequisite operations.
Client client.Client
// Scheme is the runtime scheme used for owner reference wiring.
Scheme *runtime.Scheme
// Log is the logger instance for this mediator.
Log logr.Logger
// Recorder handles logging of Kubernetes events.
Recorder events.EventRecorder
// GitHubProviderConfigReconciler has no store dependency.
GitHubProviderConfigReconciler *providerconfig.GitHubProviderConfigReconciler
}
Mediator manages the prerequisite resources a GitRepository depends on.
func New ¶
func New( c client.Client, scheme *runtime.Scheme, log logr.Logger, rec events.EventRecorder, ) *Mediator
New returns a new Mediator instance configured with the necessary dependencies.
func (*Mediator) CleanupPrerequisites ¶
func (m *Mediator) CleanupPrerequisites(ctx context.Context, resolved *gitrepoResolution.ResolvedGitRepository) error
CleanupPrerequisites reverses the per-CR portion of EnsurePrerequisites — deletes the webhook URL secret this mediator provisioned for the GitRepository. Called from the domain's CmdDelete branch, gated by the finalizer at the controller level. Teardown runs in reverse provisioning order. All teardown steps are attempted regardless of individual failures, and errors are aggregated. Any returned error keeps the finalizer in place for retry on next reconcile.
The GitHub provider credentials (Stage 1) and ProviderConfig (Stage 2) are deliberately NOT torn down here: they are shared, cluster-level prerequisites serving every GitRepository. Deleting them when one CR is torn down would sever provider access for all others. Their removal belongs to platform-level uninstall paths only.
func (*Mediator) EnsurePrerequisites ¶
func (m *Mediator) EnsurePrerequisites(ctx context.Context, resolved *gitrepoResolution.ResolvedGitRepository) error
EnsurePrerequisites provisions the prerequisites a GitRepository requires before execution: the GitHub provider credentials, the GitHub ProviderConfig, and the per-repository webhook URL secret. Called from the domain's CmdCreate/CmdUpdate branch after resolution succeeds. Provisioning is fail-fast — the first failing step returns its error and the domain records GitRepositoryPrerequisitesCreateFailed.