Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add no-interpolate to allow the generated files to keep the variable placeholder #1953

Open
jvitor83 opened this issue Nov 6, 2024 · 0 comments · May be fixed by #1955
Open

Add no-interpolate to allow the generated files to keep the variable placeholder #1953

jvitor83 opened this issue Nov 6, 2024 · 0 comments · May be fixed by #1955
Labels
kind/feature Categorizes issue or PR as related to a new feature.

Comments

@jvitor83
Copy link
Contributor

jvitor83 commented Nov 6, 2024

What would you like to be added?

Context:

Sometimes we want the generated file to keep the environment variable placeholder, so we can take advantage os scenarios where the generated files still act as a template where the environment variables could be interpolated in a later moment.

Example:

version: '3.8'

services:
  foo:
    image: ${DOCKER_REGISTRY-}foo:${IMAGE_TAG:-latest}
    build: .
    environment:
      - VERSION=${IMAGE_TAG:-latest}
    ports:
      - 80:80

to generate:

apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    io.kompose.service: foo
  name: foo
spec:
  # ... brevity
    spec:
      containers:
        - env:
            - name: VERSION
              value: ${IMAGE_TAG:-latest}
          image: ${DOCKER_REGISTRY-}foo:${IMAGE_TAG:-latest}
          name: foo
          ports:
            - containerPort: 80
              protocol: TCP
  # ... brevity

How:

Just like we have with docker compose config --no-interpolate, we can use the same feature idea.

Known Problems:

Some of the code we have at this moment "dont support/take in consideration" the possibility of having a "env var placeholder" value like:

    ports:
      - ${PORT:-80} # not supported as of now
    labels:
      kompose.image-pull-policy: "${IMAGE_PULL_POLICY:-IfNotPresent}" # not supported as of now

as ports expects a integer and not string (and it may have some logic related also). But there is more like labels, for example kompose.image-pull-policy: "${IMAGE_PULL_POLICY:-IfNotPresent}" also didn't work because it expect to be have specific "pre-defined" values.

I think initial work in this is to support the basics like "image" and "environments" keys. I believe all the others attributes, can be done in a on-demand basis by others issues specific to each need.

Why is this needed?

Allow the generated files to keep the environment variable placeholders in order to be interpolated in a later moment.

@jvitor83 jvitor83 added the kind/feature Categorizes issue or PR as related to a new feature. label Nov 6, 2024
jvitor83 added a commit to jvitor83/kompose that referenced this issue Nov 6, 2024
jvitor83 added a commit to jvitor83/kompose that referenced this issue Nov 6, 2024
@jvitor83 jvitor83 linked a pull request Nov 6, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/feature Categorizes issue or PR as related to a new feature.
Projects
None yet
1 participant