akuity / kargo-render

Tool and library for managing rendered, environment-specific branches
Apache License 2.0
41 stars 17 forks source link

Kargo Render should ignore contents of configmap when rendering #278

Open jimil749 opened 5 months ago

jimil749 commented 5 months ago

I am trying to render manifest for apache airflow (by using kustomize + upstream helm charts). It includes a configmap manifest which looks like following:

apiVersion: v1
data:
  mappings.yml: |-
    # Licensed to the Apache Software Foundation (ASF) under one
    # or more contributor license agreements.  See the NOTICE file
    # distributed with this work for additional information
    # regarding copyright ownership.  The ASF licenses this file
    # to you under the Apache License, Version 2.0 (the
    # "License"); you may not use this file except in compliance
    # with the License.  You may obtain a copy of the License at
    #
    #   http://www.apache.org/licenses/LICENSE-2.0
    #
    # Unless required by applicable law or agreed to in writing,
    # software distributed under the License is distributed on an
    # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
    # KIND, either express or implied.  See the License for the
    # specific language governing permissions and limitations
    # under the License.
    ---
    mappings:
     ...
kind: ConfigMap
metadata:
  labels:
    chart: airflow-1.11.0
    component: config
    heritage: Helm
    release: airflow
    tier: airflow
  name: airflow-statsd

This breaks the render with the following error:

level=fatal msg="error writing manifests for app \"airflow\" to \"/tmp/2142585927/repo/airflow\": resource is missing kind field"

This is because of "---" in the configmap data. Render splits the above manifest into 2 parts (since it uses "---" as the separator) which cause the render to fail.

Render would work fine if it is possible to just ignore the contents of cm.

krancour commented 4 months ago

@jimil749 I assume you don't mean that the contents of a cm shouldn't be rendered. I assume you mean we should take greater care here to only split on --- if it appears at the beginning of a line?

https://github.com/akuity/kargo-render/blob/6de5d791532d0d73dd15c699acaf241f240b35ce/internal/manifests/manifests.go#L29-L56

If that was your meaning, I agree.

jimil749 commented 4 months ago

@krancour exactly. Contents of a cm should be rendered but greater care needs to take to split on ---.

benjamin-bergia commented 2 months ago

This seems to be happening a quite a few charts.