Skip to main content

Git Repository

TypeComponent

The Git Repository component creates a Flux GitRepository resource. Check out the official GitRepository documentation for more information.

Example Usage

An example of a Git Repository for a GitHub repository is shown below. When the provider is GitHub, a secretRef containing a GitHub token is required.

apiVersion: spectrocloud.com/v1beta1
kind: WorkloadProfile
metadata:
name: palette-docs
namespace: docs-ns
spec:
workload:
components:
- name: palette-docs
type: gitrepository
properties:
url: 'https://github.com/spectrocloud/librarium'
labels:
environment: production
app: librarium
team: docs
interval: '60m0s'
provider: 'github'
secretRef:
name: 'github-token'
ref:
branch: 'main'
---
apiVersion: v1
kind: Secret
metadata:
name: github-token
type: Opaque
data:
bearerToken: <BASE64 encoded GitHub token>

Parameters

Parameter
Type
Required
DefaultDescription
intervalstringYes

Interval at which the GitRepository URL is checked for updates. This interval is approximate and may be subject to jitter to ensure efficient use of resources.

urlstringYes

URL specifies the Git repository URL, it can be an HTTP/S or SSH address.

annotationsmapNo

Annotations for the workload

ignorestringNo

Ignore overrides the set of excluded patterns in the .sourceignore format (which is the same as .gitignore). If not provided, a default will be used, consult the documentation for your version to find out what those are.

includearrayNo

Include specifies a list of GitRepository resources which Artifacts should be included in the Artifact produced for this GitRepository.

labelsmapNo

Labels for the workload

providerstringNo

"generic"

Provider used for authentication, can be 'azure', 'github', 'generic'. When not specified, defaults to 'generic'.

proxySecretRefobjectNo

ProxySecretRef specifies the Secret containing the proxy configuration to use while communicating with the Git server. SecretRef is required for 'github' provider.

recurseSubmodulesbooleanNo

RecurseSubmodules enables the initialization of all submodules within the GitRepository as cloned from the URL, using their default settings.

refobjectNo

Reference specifies the Git reference to resolve and monitor for changes, defaults to the 'master' branch.

secretRefobjectNo

SecretRef specifies the Secret containing authentication credentials for the GitRepository. For HTTPS repositories the Secret must contain 'username' and 'password' fields for basic auth or 'bearerToken' field for token auth. For SSH repositories the Secret must contain 'identity' and 'known_hosts' fields.

suspendbooleanNo

Suspend tells the controller to suspend the reconciliation of this GitRepository.

timeoutstringNo

"60s"

Timeout for Git operations like cloning, defaults to 60s.

verifyobjectNo

Verification specifies the configuration to verify the Git commit signature(s).

Template

The following tabs display the definition's Cue template and the rendered YAML. The rendered YAML is the output of the Cue template when the definition is applied to a cluster.

gitrepository: {
type: "component"
description: "GitRepository is the Schema for the gitrepositories API."
labels: {
"componentdefinition.spectrocloud.com/type": "application"
"wl.spectrocloud.com/provider": "source.toolkit.fluxcd.io"
"definition.spectrocloud.com/category": "Flux"
}
attributes: {
status: {
healthPolicy: {
ready: {
readyCondition: *false | bool
} & {
if context.output.status.conditions != _|_ {
for condition in context.output.status.conditions {
if condition.type == "Ready" && condition.status == "True" {
readyCondition: true
}
}
}
}
_isHealth: ready.readyCondition
isHealth: *_isHealth | bool
if context.output.metadata.annotations != _|_ {
if context.output.metadata.annotations["wl.spectrocloud.com/disable-health-check"] != _|_ {
isHealth: true
}
}
}
}
}
}

template: {
output: {
apiVersion: "source.toolkit.fluxcd.io/v1"
kind: "GitRepository"
metadata: {
labels: {
if parameter.labels != _|_ {
parameter.labels
}
"wl.spectrocloud.com/name": context.workloadName
"wl.spectrocloud.com/component": context.name
}
if parameter.annotations != _|_ {
annotations: parameter.annotations
}
}
spec: {
if parameter.ignore != _|_ {
ignore: parameter.ignore
}
if parameter.include != _|_ {
include: parameter.include
}
interval: parameter.interval
if parameter.provider != _|_ {
provider: parameter.provider
}
if parameter.proxySecretRef != _|_ {
proxySecretRef: parameter.proxySecretRef
}
if parameter.recurseSubmodules != _|_ {
recurseSubmodules: parameter.recurseSubmodules
}
if parameter.ref != _|_ {
ref: parameter.ref
}
if parameter.secretRef != _|_ {
secretRef: parameter.secretRef
}
if parameter.suspend != _|_ {
suspend: parameter.suspend
}
if parameter.timeout != _|_ {
timeout: parameter.timeout
}
url: parameter.url
if parameter.verify != _|_ {
verify: parameter.verify
}
}
}

parameter: {
// +usage=Annotations for the workload
annotations?: [string]: string

// +usage=Labels for the workload
labels?: [string]: string

// +usage=Ignore overrides the set of excluded patterns in the .sourceignore format (which is the same as .gitignore). If not provided, a default will be used, consult the documentation for your version to find out what those are.
ignore?: string

// +usage=Include specifies a list of GitRepository resources which Artifacts should be included in the Artifact produced for this GitRepository.
include?: [...{

// +usage=FromPath specifies the path to copy contents from, defaults to the root of the Artifact.
fromPath?: string

// +usage=GitRepositoryRef specifies the GitRepository which Artifact contents must be included.
repository: {

// +usage=Name of the referent.
name: string
}

// +usage=ToPath specifies the path to copy contents to, defaults to the name of the GitRepositoryRef.
toPath?: string
}]

// +usage=Interval at which the GitRepository URL is checked for updates. This interval is approximate and may be subject to jitter to ensure efficient use of resources.
interval: =~"^([0-9]+(\\.[0-9]+)?(ms|s|m|h))+$"

// +usage=Provider used for authentication, can be 'azure', 'github', 'generic'. When not specified, defaults to 'generic'.
provider?: *"generic" | "azure" | "github"

// +usage=ProxySecretRef specifies the Secret containing the proxy configuration to use while communicating with the Git server. SecretRef is required for 'github' provider.
proxySecretRef?: {

// +usage=Name of the referent.
name: string
}

// +usage=RecurseSubmodules enables the initialization of all submodules within the GitRepository as cloned from the URL, using their default settings.
recurseSubmodules?: bool

// +usage=Reference specifies the Git reference to resolve and monitor for changes, defaults to the 'master' branch.
ref?: {

// +usage=Branch to check out, defaults to 'master' if no other field is defined.
branch?: string

// +usage=Commit SHA to check out, takes precedence over all reference fields. This can be combined with Branch to shallow clone the branch, in which the commit is expected to exist.
commit?: string

// +usage=Name of the reference to check out; takes precedence over Branch, Tag and SemVer. It must be a valid Git reference: https://git-scm.com/docs/git-check-ref-format#_description Examples: "refs/heads/main", "refs/tags/v0.1.0", "refs/pull/420/head", "refs/merge-requests/1/head"
name?: string

// +usage=SemVer tag expression to check out, takes precedence over Tag.
semver?: string

// +usage=Tag to check out, takes precedence over Branch.
tag?: string
}

// +usage=SecretRef specifies the Secret containing authentication credentials for the GitRepository. For HTTPS repositories the Secret must contain 'username' and 'password' fields for basic auth or 'bearerToken' field for token auth. For SSH repositories the Secret must contain 'identity' and 'known_hosts' fields.
secretRef?: {

// +usage=Name of the referent.
name: string
}

// +usage=Suspend tells the controller to suspend the reconciliation of this GitRepository.
suspend?: bool

// +usage=Timeout for Git operations like cloning, defaults to 60s.
timeout?: *"60s" | =~"^([0-9]+(\\.[0-9]+)?(ms|s|m))+$"

// +usage=URL specifies the Git repository URL, it can be an HTTP/S or SSH address.
url: =~"^(http|https|ssh)://.*$"

// +usage=Verification specifies the configuration to verify the Git commit signature(s).
verify?: {

// +usage=Mode specifies which Git object(s) should be verified. The variants "head" and "HEAD" both imply the same thing, i.e. verify the commit that the HEAD of the Git repository points to. The variant "head" solely exists to ensure backwards compatibility.
mode?: *"head" | "HEAD" | "Tag" | "TagAndHEAD"

// +usage=SecretRef specifies the Secret containing the public keys of trusted Git authors.
secretRef: {

// +usage=Name of the referent.
name: string
}
}
}
}