# Secret Type - PROPERTIES

The PROPERTIES-Type is for rendering property-files based on secrets stored in HashiCorp Vault in the mountpoints for kv-1 or kv-2.

### How To

First store some secrets in HashiCorp Vault:

```bash
$ vault write datasource/host host=localhost
$ vault kv put database/root username=root password=verysecure
```

After this create the following Vault-Resource and apply it to Kubernetes:

```yaml
apiVersion: "koudingspawn.de/v1"
kind: Vault
metadata:
  name: properties-example
spec:
  type: "PROPERTIES"
  propertiesConfiguration:
    files:
      application.properties: |
        datasource.username={{ vault.lookupV2('database/root').get('username') }}
        datasource.password={{ vault.lookupV2('database/root').get('password') }}
        datasource.host={{ vault.lookup('datasource/host', 'host') }}
```

Now you should see, that the secret gets rendered and stored in Kubernetes and the Vault resource is also available:

```
$ kubectl get vault properties-example
NAME                  AGE
properties-example    10s
```

```
$ kubectl get secret properties-example
NAME                                   TYPE                                  DATA      AGE
properties-example                     Opaque                                1         9s
```

### Rendering Options

The following expressions are available for rendering secrets stored in HashiCorp Vault:

| Method                                               | returns      | Description                                                                                                                      |
| ---------------------------------------------------- | ------------ | -------------------------------------------------------------------------------------------------------------------------------- |
| vault.lookup(String path)                            | Java:HashMap | Looks inside a KV-1 Store for stored key-value pairs. The secrets are now available via .get('key')                              |
| vault.lookup(String path, String key)                | String       | Looks inside a KV-1 Store for stored key in key-value path.                                                                      |
| vault.lookupV2(String path)                          | Java:HashMap | Looks inside a KV-2 Store for stored key-value pairs. The secrets are now available via .get('key'). It uses the latest version. |
| vault.lookupV2(String path, String key)              | String       | Looks inside a KV-2 Store for stored key in key-value path. It uses the latest version.                                          |
| vault.lookupV2(String path, int version, String key) | String       | Looks inside a KV-2 Store for stored key in key-value path with a specific version.                                              |

### Change Adjustment Callback

For more details please see [Change Detection](/change-detection.md)!


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://vault.koudingspawn.de/supported-secret-types/secret-type-properties.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
