Documentation
¶
Index ¶
Constants ¶
const ( NoteNamespace = "hydrator.metadata" // NoteNamespace is the custom git notes namespace used by the hydrator to store and retrieve commit-related metadata. ManifestYaml = "manifest.yaml" // ManifestYaml constant for the manifest yaml )
Variables ¶
This section is empty.
Functions ¶
func AddNote ¶
AddNote attaches a commit note containing the specified dry SHA (`drySha`) to the given commit (`commitSha`) in the configured note namespace. The note is marshaled as JSON and pushed to the remote repository using the provided gitClient. Returns an error if marshalling or note addition fails.
func IsHydrated ¶
IsHydrated checks whether the given commit (commitSha) has already been hydrated with the specified Dry SHA (drySha). It does this by retrieving the commit note in the NoteNamespace and examining the DrySHA value. Returns true if the stored DrySHA matches the provided drySha, false if not or if no note exists. Gracefully handles missing notes as a normal outcome (not an error), but returns an error on retrieval or parse failures.
func WriteForPaths ¶
func WriteForPaths(root *os.Root, repoUrl, drySha string, dryCommitMetadata *appv1.RevisionMetadata, paths []*apiclient.PathDetails, gitClient git.Client) (bool, error)
WriteForPaths writes the manifests, hydrator.metadata, and README.md files for each path in the provided paths. It also writes a root-level hydrator.metadata file containing the repo URL and dry SHA.
Types ¶
type CommitNote ¶
type CommitNote struct {
DrySHA string `json:"drySha"` // SHA of original commit that triggerd the hydrator
}
CommitNote represents the structure of the git note associated with a hydrated commit. This struct is used to serialize/deserialize commit metadata (such as the dry run SHA) stored in the custom note namespace by the hydrator.
type RepoClientFactory ¶
type RepoClientFactory interface {
NewClient(repo *v1alpha1.Repository, rootPath string) (git.Client, error)
}
RepoClientFactory is a factory for creating git clients for a repository.
func NewRepoClientFactory ¶
func NewRepoClientFactory(gitCredsStore git.CredsStore, metricsServer *metrics.Server) RepoClientFactory
NewRepoClientFactory returns a new instance of the repo client factory.
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service is the service that handles commit requests.
func NewService ¶
func NewService(gitCredsStore git.CredsStore, metricsServer *metrics.Server) *Service
NewService returns a new instance of the commit service.
func (*Service) CommitHydratedManifests ¶
func (s *Service) CommitHydratedManifests(_ context.Context, r *apiclient.CommitHydratedManifestsRequest) (*apiclient.CommitHydratedManifestsResponse, error)
CommitHydratedManifests handles a commit request. It clones the repository, checks out the sync branch, checks out the target branch, clears the repository contents, writes the manifests to the repository, commits the changes, and pushes the changes. It returns the hydrated revision SHA and an error if one occurred.