list-setters

KRM function for list-setters

list-setters #

Overview #

Lists information about [setters] like setter name, values and count.

Refer to the create-setters function documentation for information about creating new setters or [apply-setters] function documentation for information about updating the field values parameterized by setters.

Usage #

list-setters function is expected to be executed imperatively like

$ kpt fn eval -i list-setters:v0.1.0

list-setters function performs the following steps:

  1. Searches for setter comments in input list of resources.
  2. Lists discovered setters and related information.

Examples #

Listing setters in a package #

Let’s start with the input resource in a package

# resources.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
  name: my-nginx
spec:
  replicas: 4 # kpt-set: ${nginx-replicas}
  selector:
    matchLabels:
      app: nginx
  template:
    metadata:
      labels:
        app: nginx
    spec:
      containers:
      - name: nginx
        image: "nginx:1.16.1" # kpt-set: nginx:${tag}
        ports:
        - protocol: TCP
          containerPort: 80

Invoke the function:

$ kpt fn eval --image gcr.io/kpt-fn/list-setters:v0.1.0

Output looks like the following:

  Results:
    [INFO] Name: nginx-replicas, Value: 4, Type: int, Count: 1
    [INFO] Name: tag, Value: 1.16.1, Type: str, Count: 1