rules_gitopsAPI docs @1.0.0-rc.1

@rules_gitops//adapters:external_image.bzl

Implementation of external image information provider suitable for injection into manifests

Rules

external_image
AttributeTypeDescription
*namename

A unique name for this target.

*imagestring

The image location, e.g. gcr.io/foo/bar:baz

image_namestring

Image name, e.g. exernalserver. DEPRECATED: Use full target label instead, e.g. //images:externalserver

Default: ""
*digeststring

The image digest, e.g. sha256:deadbeef

@rules_gitops//adapters:providers.bzl

Provider definitions for container image adapters.

Providers

K8sPushInfo

Information required to inject image into a manifest and optionally push it

Fields
image_label

bazel target label of the image

legacy_image_name

Optional: short name

registry

registry where the image resides

repository

repository where the image resides

digestfile

a file containing the digest of the image

pusher

Optional: an executable target used to push the image to a remote registry

run_environment

Optional: a run environment info provider used for pushing the image

@rules_gitops//adapters:rules_img.bzl

Adapter for rules_img container images.

Rules

k8s_push_info
AttributeTypeDescription
*namename

A unique name for this target.

*imagelabel
*pushlabel
*registrystring
*repositorystring

@rules_gitops//e2e/util:util.bzl

Utility macros for e2e testing with kind clusters.

Functions & Macros

e2e_test

Declares an e2e test interacting with a kind cluster

Parameters
*name

name of the test target

*steps

a list of labels producing binaries to run

kwargs

additional options to pass to the underlying test rule

kubectl_cmd
Parameters
*name
*args

@rules_gitops//gitops:defs.bzl

GitOps rules public interface

Functions & Macros

k8s_deploy

Generates Kubernetes deployment targets with optional GitOps support.

This macro creates kustomization targets and kubectl binaries for deploying
Kubernetes manifests. When gitops is enabled, it also creates a gitops target
for managing deployments through a GitOps workflow.

Parameters
*name

Name of the rule. Important for gitops since it becomes part of
the target manifest file name in the gitops_path directory.

cluster

Target Kubernetes cluster name. Defaults to "dev".

Default: "dev"
user

Kubernetes user for authentication. Defaults to "{BUILD_USER}"
which is substituted at runtime.

Default: "{BUILD_USER}"
namespace

Target Kubernetes namespace. Required when gitops=True.
Defaults to "{BUILD_USER}" when gitops=False.

Default: None
configmaps_srcs

List of source files for generating ConfigMaps.

Default: None
secrets_srcs

List of source files for generating Secrets.

Default: None
configmaps_renaming

ConfigMap renaming policy. Can be None (no renaming)
or "hash" (append content hash to names).

Default: None
manifests

List of Kubernetes manifest files. Defaults to all .yaml and
.yaml.tpl files in the package via glob.

Default: None
name_prefix

Prefix to add to all resource names via kustomize.

Default: None
name_suffix

Suffix to add to all resource names via kustomize.

Default: None
prefix_suffix_app_labels

If True, applies kustomize configuration to
modify "app" labels in Deployments when name_prefix or name_suffix
is applied.

Default: False
patches

List of kustomize patches to apply to the manifests.

Default: None
image_name_patches

Dict mapping original image names to new image names.

Default: {}
image_tag_patches

Dict mapping image names to new tags.

Default: {}
substitutions

Dict of template parameter substitutions. CLUSTER and
NAMESPACE parameters are added automatically and should not be
included.

Default: {}
configurations

List of additional kustomize configuration files.

Default: []
common_labels

Dict of labels to apply to all Kubernetes objects.
See kustomize commonLabels documentation.

Default: {}
common_annotations

Dict of annotations to apply to all Kubernetes
objects. See kustomize commonAnnotations documentation.

Default: {}
deps

List of dependency targets.

Default: []
deps_aliases

Dict mapping aliases to dependency targets.

Default: {}
images

List of container image targets to include in the deployment.

Default: []
objects

List of additional Kubernetes objects to include.

Default: []
gitops

If True, creates a gitops target for GitOps workflow. Set to
False to work with individual namespaces. Automatically set to
False if namespace is "{BUILD_USER}".

Default: True
gitops_path

Directory path for gitops manifests. Defaults to "cloud".

Default: "cloud"
deployment_branch

Git branch for deployments. If None, uses default.

Default: None
release_branch_prefix

Prefix for release branches. Defaults to "main".

Default: "main"
start_tag

Opening delimiter for template substitutions. Defaults to "{{".

Default: "{{"
end_tag

Closing delimiter for template substitutions. Defaults to "}}".

Default: "}}"
tags

List of tags to apply to all generated targets.

Default: []
visibility

Visibility specification for generated targets.

Default: None
verify_images

Whether or not to fail if a Bazel image could not be resolved.

Default: True

Rules

gitops
AttributeTypeDescription
*namename

A unique name for this target.

srcslist of labels
Default: []
*clusterstring
*namespacestring
deployment_branchstring
Default: ""
gitops_pathstring
Default: ""
release_branch_prefixstring
Default: ""
strip_prefixeslist of strings
Default: []

@rules_gitops//kubectl:defs.bzl

Public API for kubectl rules.

Rules

kubectl_binary
AttributeTypeDescription
*namename

A unique name for this target.

srcslist of labels
Default: []
*clusterstring
*namespacestring
commandstring
Default: "apply"
userstring
Default: "{BUILD_USER}"
pushboolean
Default: True
kubectl_toolchain
AttributeTypeDescription
*namename

A unique name for this target.

*executablelabel

A hermetically downloaded executable target for the target platform.

resolved_toolchain

Exposes a concrete toolchain which is the result of Bazel resolving the
toolchain for the execution or target platform.
Workaround for https://github.com/bazelbuild/bazel/issues/14009

AttributeTypeDescription
*namename

A unique name for this target.

Module Extensions

kubectl
Tag Classes
toolchain
AttributeTypeDescription
versionstring

kubectl binary version

Default: ""

@rules_gitops//kustomize:defs.bzl

Public API for kustomize rules.

Rules

kustomization
AttributeTypeDescription
*namename

A unique name for this target.

configmaps_srcslist of labels
Default: []
secrets_srcslist of labels
Default: []
deps_aliasesdictionary: String → String
Default: {}
disable_name_suffix_hashboolean
Default: True
end_tagstring
Default: "}}"
imageslist of labels

a list of image pushes used in manifests

Default: []
manifestslist of labels
Default: []
name_prefixstring
Default: ""
name_suffixstring
Default: ""
namespacestring
Default: ""
objectslist of labels

a list of dependent kustomize objects

Default: []
patcheslist of labels
Default: []
image_name_patchesdictionary: String → String

set new names for selected images

Default: {}
image_tag_patchesdictionary: String → String

set new tags for selected images

Default: {}
start_tagstring
Default: "{{"
substitutionsdictionary: String → String
Default: {}
depslist of labels
Default: []
configurationslist of labels
Default: []
common_labelsdictionary: String → String
Default: {}
common_annotationsdictionary: String → String
Default: {}
verify_imagesboolean

check whether all images which point to bazel labels were resolved

Default: True
kustomize_binary
AttributeTypeDescription
*namename

A unique name for this target.

kustomize_toolchain
AttributeTypeDescription
*namename

A unique name for this target.

*executablelabel

A hermetically downloaded executable target for the target platform.

show
AttributeTypeDescription
*namename

A unique name for this target.

*srclabel

Input file.

*namespacestring

kubernetes namespace.

Module Extensions

kustomize
Tag Classes
toolchain
AttributeTypeDescription
versionstring

kustomize binary version

Default: ""

Providers

KustomizeInfo

Information about a kustomization target

Fields
image_pushes

depset of image push executables for images referenced by this kustomization

@rules_gitops//stamper:stamp.bzl

Stamping utilities for replacing placeholders in strings.

Functions & Macros

stamp

Stamp provided string replacing placeholders like {BUILD_USER}.

Uses an optimization shortcut for BUILD_USER

Parameters
*ctx

The rule context.

*string

The string containing placeholders to stamp.

*_tmpfiles

Unused, kept for API compatibility.

*tmpfilename

Base name for temporary files.

Rules

stamp_value
AttributeTypeDescription
*namename

A unique name for this target.

strstring
Default: "{BUILD_USER}"
more_stable_status
AttributeTypeDescription
*namename

A unique name for this target.

*varslist of strings

Variables to extract from stable_status.txt

@rules_gitops//testing:defs.bzl

Public API for Kubernetes testing rules.

Rules

k8s_test_namespace
AttributeTypeDescription
*namename

A unique name for this target.

kubeconfiglabel
Default: None
kubectllabel
Default: None
k8s_test_setup
AttributeTypeDescription
*namename

A unique name for this target.

kubeconfiglabel
Default: "@@[unknown repo 'k8s_test' requested from @@]//:kubeconfig"
kubectllabel
Default: "@@[unknown repo 'k8s_test' requested from @@]//:kubectl"
objectslist of labels
Default: []
portforward_serviceslist of strings
Default: []
setup_timeoutstring
Default: "10m"
wait_for_appslist of strings
Default: []
clusterlabel
Default: "@@[unknown repo 'k8s_test' requested from @@]//:cluster"

@rules_gitops//tools:util.bzl

Utility functions for golden testing.

Functions & Macros

golden_test
Parameters
*name
*in_file
extension
Default: ""