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

[BUG] Conflicting name assigned to configmap generated for compose referencing ".env" files #1793

Closed
Pratham1812 opened this issue Dec 26, 2023 · 2 comments · Fixed by #1798
Labels
kind/bug Categorizes issue or PR as related to a bug.

Comments

@Pratham1812
Copy link

Pratham1812 commented Dec 26, 2023

Expected Behavior

Compose files which refer to environment variables from files such as ".env" or ".env.local" in a simple React application should produce a configmap file whose filename follows the appropriate regex rules required by kubernetes.

Actual Behavior

For compose referencing env_files begining with ".env", the generated file name of configmap does not follow appropriate regex rules, which prevents deployment on minikube or any other platform.

Steps To Reproduce

  1. For this docker-compose.yaml
version: '3.8'
services:
  mongodb:
    image: mongo:latest
    restart: always
    expose:
      - 27017
  app:
    depends_on:
      - mongodb
    env_file:
      - ./src/app/.env.local
    build: src/
    ports:
      - "3000:3000"
  1. On running kompose convert -f docker-compose.yaml
  2. File name for configmap < path with '/' replace with '-' >-app--env-configmap.yaml
  3. On minikube run kubectl apply -f app-deployment.yaml
  4. The deployment is not created
    image

Kompose Version

1.31.2 (a92241f79)

Docker-Compose file

version: '3.8'
services:
  mongodb:
    image: mongo:latest
    restart: always
    expose:
      - 27017
  app:
    depends_on:
      - mongodb
    env_file:
      - ./src/app/.env
    build: src/
    ports:
      - "3000:3000"

Anything else?

The issue seems to be in kompose/pkg/transformer/kubernetes/k8sutils.go in the FormatEnvName function where the '.' has been replaced with '-' and can be resolved as shown in the below screen shot .

image

Thanks

@Pratham1812 Pratham1812 added the kind/bug Categorizes issue or PR as related to a bug. label Dec 26, 2023
@realgam3
Copy link
Contributor

Can you check if my PR fix the issue?
#1684

@Pratham1812
Copy link
Author

@realgam3 it does not
image

sosan added a commit to sosan/kompose that referenced this issue Jan 9, 2024
* fix issue 1793  kubernetes#1793
*add tests

Signed-off-by: jose luis <[email protected]>
@sosan sosan mentioned this issue Jan 9, 2024
sosan added a commit to sosan/kompose that referenced this issue Jan 22, 2024
* fix issue 1793  kubernetes#1793
*add tests

Signed-off-by: jose luis <[email protected]>
sosan added a commit to sosan/kompose that referenced this issue Jan 22, 2024
* fix issue 1793  kubernetes#1793
*add tests

Signed-off-by: jose luis <[email protected]>
sosan added a commit to sosan/kompose that referenced this issue Jan 22, 2024
* fix issue 1793  kubernetes#1793
*add tests

Signed-off-by: jose luis <[email protected]>
sosan added a commit to sosan/kompose that referenced this issue Jan 24, 2024
* fix issue 1793  kubernetes#1793
*add tests

Signed-off-by: jose luis <[email protected]>

formated k8utils_test.go

Signed-off-by: jose luis <[email protected]>

labels formatted as name"-"envName to match fixtures when performing the gitHub action

Signed-off-by: jose luis <[email protected]>

removed this piece code because apply it later, and it is redundant

Signed-off-by: jose luis <[email protected]>

Refactor test in k8sutils_test.go to extract the last 63 characters. This addresses the impact of the removed code that previously truncated the input with if len(envName) > 63 { envName = envName[len(envName)-63:] }

Signed-off-by: jose luis <[email protected]>

changed to name function to getUsableNameEnvFile

Signed-off-by: jose luis <[email protected]>

fix issue 1793

* fix issue 1793  kubernetes#1793
*add tests

Signed-off-by: jose luis <[email protected]>

labels formatted as name"-"envName to match fixtures when performing the gitHub action

Signed-off-by: jose luis <[email protected]>

changed to name function to getUsableNameEnvFile

Signed-off-by: jose luis <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Categorizes issue or PR as related to a bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants