{"modulePath":"github.com/giantswarm/gitops-commit","version":"v0.12.0-rc.13","isLatest":false,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package target\n\nPackage target answers where a commit about a live object goes: the repository, branch and directory its file lives in (an edit), or where a new object in a namespace goes. A Resolver reads the GitOps objects on the cluster with the client the caller passes in; it holds no credentials of its own, and the caller cannot name a repository.\n\nFlux is the only implementation. Another GitOps tool can be added as another Resolver without a change in the callers.\n\n## Constants\n\n```go\nconst (\n\tLabelKustomizeName      = \"kustomize.toolkit.fluxcd.io/name\"\n\tLabelKustomizeNamespace = \"kustomize.toolkit.fluxcd.io/namespace\"\n)\n```\nThe labels kustomize-controller sets on every object a Kustomization applies.\n\n## Variables\n\n```go\nvar (\n\tKustomizationGVR = schema.GroupVersionResource{Group: \"kustomize.toolkit.fluxcd.io\", Version: \"v1\", Resource: \"kustomizations\"}\n\tGitRepositoryGVR = schema.GroupVersionResource{Group: \"source.toolkit.fluxcd.io\", Version: \"v1\", Resource: \"gitrepositories\"}\n)\n```\nThe Flux and core resources the Flux resolver reads.\n\n```go\nvar ErrNotApplied = errors.New(\"not GitOps-applied\")\n```\nErrNotApplied is returned for an object, or a namespace, that no GitOps tool applies from a file: it has no target. The message says why.\n\n```go\nvar ErrTargetNamespace = errors.New(\"kustomization moves objects to another namespace\")\n```\nErrTargetNamespace is returned for a namespace whose applying Kustomization sets spec.targetNamespace to another namespace: a new object in its directory would land in that other namespace.\n\n```go\nvar ErrUnconfirmed = fmt.Errorf(\"%w: labels unconfirmed\", ErrNotApplied)\n```\nErrUnconfirmed is returned when an object's labels name a GitOps object that cannot confirm them: it is gone, it has recorded no inventory yet, or the object's inventory id is ambiguous. It is an ErrNotApplied: there is no target. A caller that refuses a live write on an object GitOps may still apply can tell it apart with errors.Is.\n\n## Types\n\n```go\ntype Flux struct {\n\t// contains filtered or unexported fields\n}\n```\nFlux is the Resolver for objects a Flux Kustomization applies from a GitRepository.\n\nLabels can be set by whoever may write an object, so they alone are no proof. An object counts as applied, and its labels as its target, only when the Kustomization the labels name lists the object in its inventory (status.inventory): forged labels yield ErrNotApplied, never another target. A Kustomization that is gone or has recorded no inventory yet cannot confirm the labels: ErrUnconfirmed, which is an ErrNotApplied. An object a HelmRelease renders has no file of its own and is not applied from a file either.\n\nThe object must live on the cluster the client reads: an inventory names no cluster, so a Kustomization that applies to another cluster (spec.kubeConfig) does not apply the object, whatever its inventory lists.\n\n```go\nfunc NewFlux(client dynamic.Interface) *Flux\n```\nNewFlux returns the Flux resolver that reads the Namespace, the Kustomization and its GitRepository with client: the caller's own, on the cluster Flux runs on.\n\n```go\nfunc (f *Flux) ForNamespace(ctx context.Context, namespace string) (Target, error)\n```\nForNamespace implements Resolver: the target of the Namespace object itself, refused when its Kustomization moves objects to another namespace.\n\n```go\nfunc (f *Flux) ForObject(ctx context.Context, obj *unstructured.Unstructured) (Target, error)\n```\nForObject implements Resolver.\n\n```go\ntype Resolver interface {\n\t// ForObject returns the target of obj, an object read from the cluster\n\t// the resolver reads:\n\t// where its file lives. ErrNotApplied when no GitOps tool applies obj\n\t// from a file.\n\tForObject(ctx context.Context, obj *unstructured.Unstructured) (Target, error)\n\t// ForNamespace returns the target of a new object in namespace: the\n\t// directory that applies the namespace. ErrNotApplied when no GitOps\n\t// tool applies the namespace from a file.\n\tForNamespace(ctx context.Context, namespace string) (Target, error)\n}\n```\nResolver returns the commit target of a live object or of a new object.\n\n```go\ntype Target struct {\n\t// Location is the repository, branch and directory the files live in.\n\tprovenance.Location\n\t// Kustomization is the Flux Kustomization that applies the directory.\n\tKustomization provenance.Kustomization\n}\n```\nTarget is where a commit goes and what lands it after the merge.\n\n","path":"github.com/giantswarm/gitops-commit/target","name":"target","synopsis":"Package target answers where a commit about a live object goes: the repository, branch and directory its file lives in (an edit), or where a new object in a namespace goes.","isRedistributable":true}
