# Compile a catalog

Compile and push a cluster catalog from local machine to update dependencies.

## Requirements

• Access to a running Lieutenant instance. See the next section for details on how to connect to Lieutenant instances with OIDC or long-lived tokens.

• An existing Cluster in Lieutenant.

## Prepare Commodore

The following snippet sets up needed environment variables in your current working directory.

 You can skip this step if you have already defined them already with another method.
1. Setup required environment variables

Lieutenant instance using OIDC token
``````LIEUTENANT_URL="the-public-lieutenant-API-URL"

cat << EOF > .env
LIEUTENANT_AUTH="Authorization:Bearer \$(commodore fetch-token)" LIEUTENANT_URL="${LIEUTENANT_URL}"
COMMODORE_API_URL="${LIEUTENANT_URL}" EOF``````  The command `commodore fetch-token` in variable `LIEUTENANT_AUTH` will be executed when you source the `.env` file. You may need to re-source the file when following a longer guide as the OIDC token will usually have a lifetime of only a few minutes. Lieutenant instance using long-lived Kubernetes token ``````# Assuming "syn-synfra" is the user in your kubeconfig LIEUTENANT_TOKEN=$(kubectl config view -o jsonpath='{.users[?(@.name == "syn-synfra")].user.token}'  --raw)
LIEUTENANT_URL="the-public-lieutenant-API-URL"

cat << EOF > .env
LIEUTENANT_AUTH="Authorization:Bearer ${LIEUTENANT_TOKEN}" LIEUTENANT_URL="${LIEUTENANT_URL}"
COMMODORE_API_TOKEN="${LIEUTENANT_TOKEN}" COMMODORE_API_URL="${LIEUTENANT_URL}"
EOF``````
2. Activate the configured environment variables

``````# Double check the environment variables
less .env

# Export the variables
set -a; source .env; set +a``````

## Compilation

Choose cluster
1. Get the Cluster ID from Lieutenant.

``commodore catalog list -v``
2. Set the cluster ID and prepare directory.

``````export CLUSTER_ID = <target-cluster-name-from-above>
dir=$(mktemp -d) pushd "${dir}"``````
Choose operation
1. Compile the catalog and display a diff.

``commodore catalog compile $CLUSTER_ID`` 2. Compile the catalog and push. ``commodore catalog compile$CLUSTER_ID --push --interactive``
Cleanup
``````popd
rm -rf "\${dir}"``````