# Conditional block in manifest

**URL:** https://community.replicated.com/t/conditional-block-in-manifest/944
**Category:** How do I?
**Created:** [August 29, 2022, 1:30pm UTC](https://community.replicated.com/t/conditional-block-in-manifest/944 "2022-08-29T13:30:50Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![chbrosso](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.replicated.com/chbrosso/32/454_2.png) [@chbrosso](https://community.replicated.com/u/chbrosso)
#### Post date: [August 29, 2022, 1:30pm UTC](https://community.replicated.com/t/conditional-block-in-manifest/944/1 "2022-08-29T13:30:50Z")

</div>

Hello,

I have a config field for CPU limit, and I want to include the CPU limit in my Deployment manifest only if the field has a value. I tried the following in the deployment manifest since I read in the documentation that the full Go templating library is supported:

```
    resources:
      requests:
        cpu: 50m
        memory: 500Mi
      {{ if repl ConfigOption "cpu_limit" }}
      limits:
          cpu: repl {{ ConfigOption "cpu_limit" }}
          #memory: 500Mi
      {{ end}}

```

But I get the following error at lint:

```
$ replicated release lint --app "gitguardian-seal" --yaml-dir manifests
RULE TYPE FILENAME LINE MESSAGE
invalid-yaml error manifests/app-deployment.yaml 133 yaml: line 133: could not find expected ':'    
Error: One or more errors of severity "error" or higher were found

```

---

<div class="post-metadata">

### Author: ![Fernando\_Cremer](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.replicated.com/fernando_cremer/32/436_2.png) [@Fernando\_Cremer](https://community.replicated.com/u/Fernando_Cremer)
#### Post date: [August 31, 2022, 1:20pm UTC](https://community.replicated.com/t/conditional-block-in-manifest/944/2 "2022-08-31T13:20:14Z")

</div>

I believe that using something like `repl if` only really works if you use it for the value of a key, not an entire block of a manifest. There is an example of using this [here](https://github.com/replicatedhq/kots-sentry/blob/70ba4ac66375e91adba7f61ca4857073296bc655/manifests/web-deployment.yaml#L32).

While maybe not the ideal solution, you could instead have two manifests, one with the limits and one without. Then use the `kots.io/when` label annotation (example [here](https://github.com/replicatedhq/kots-sentry/blob/70ba4ac66375e91adba7f61ca4857073296bc655/manifests/postgres-deployment.yaml#L8) ) to only deploy the one based on the config option.

---

<div class="post-metadata">

### Author: ![chbrosso](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.replicated.com/chbrosso/32/454_2.png) [@chbrosso](https://community.replicated.com/u/chbrosso)
#### Post date: [February 10, 2023, 2:06pm UTC](https://community.replicated.com/t/conditional-block-in-manifest/944/3 "2023-02-10T14:06:10Z")

</div>

Hello, this is unfortunate since we need to disable some manifest mapping depending on the configuration, on all our deployments. This force us to duplicate hundreds of lines.

---

<div class="post-metadata">

### Author: ![dex](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.replicated.com/dex/32/26_2.png) [@dex](https://community.replicated.com/u/dex)
#### Post date: [February 10, 2023, 3:05pm UTC](https://community.replicated.com/t/conditional-block-in-manifest/944/4 "2023-02-10T15:05:15Z")

</div>

Hi @chbrosso - your alternative option is to package your app as a Helm Chart, in which case you get to use full plain-text templating. [About Packaging with Helm | Replicated Docs](https://docs.replicated.com/vendor/helm-overview)

---

<div class="post-metadata">

### Author: ![chbrosso](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.replicated.com/chbrosso/32/454_2.png) [@chbrosso](https://community.replicated.com/u/chbrosso)
#### Post date: [February 10, 2023, 3:29pm UTC](https://community.replicated.com/t/conditional-block-in-manifest/944/5 "2023-02-10T15:29:26Z")

</div>

Yes that’s what we want to do but existing customers can’t be easily migrated to Helm.

---

<div class="post-metadata">

### Author: ![dex](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.replicated.com/dex/32/26_2.png) [@dex](https://community.replicated.com/u/dex)
#### Post date: [February 12, 2023, 6:03pm UTC](https://community.replicated.com/t/conditional-block-in-manifest/944/6 "2023-02-12T18:03:27Z")

</div>

Hi @chbrosso - can you help me understand that a little better? What is making that difficult for you? If there is a manual workaround involved, what steps would you use and how long do you expect it to take per customer?

As another option, have you considered exposing the options to your customers via the [kustomize.io](http://kustomize.io) guide: [Patching with Kustomize | Replicated Docs](https://docs.replicated.com/enterprise/updating-patching-with-kustomize)
