Skip to content

Commit 0d3c89a

Browse files
authored
Merge pull request #422 from UffizziCloud/feature/1320-fix-env-vars-with-dollar-sign-2
[#1320] fixed env vars with dollar sign in the value
2 parents af065a9 + 47c592a commit 0d3c89a

File tree

7 files changed

+48
-15
lines changed

7 files changed

+48
-15
lines changed

.github/workflows/code-quality.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,13 @@ jobs:
2727
runs-on: ubuntu-latest
2828
steps:
2929
- name: Checkout
30-
uses: actions/checkout@v2
30+
uses: actions/checkout@v4
3131
- uses: ruby/setup-ruby@v1
3232
with:
3333
ruby-version: 3.0.2
3434
bundler-cache: false
3535
- name: Build Image
36-
uses: docker/build-push-action@v2
36+
uses: docker/build-push-action@v5
3737
with:
3838
tags: uffizzi/cli:test-install
3939
platforms: linux/amd64

.github/workflows/docker-image-release.yml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,24 +8,25 @@ jobs:
88
runs-on: ubuntu-latest
99
steps:
1010
- name: Checkout
11-
uses: actions/checkout@v2
11+
uses: actions/checkout@v4
1212
- name: Set up Docker Buildx
13-
uses: docker/setup-buildx-action@v1
13+
uses: docker/setup-buildx-action@v2
1414
- name: Login to DockerHub
15-
uses: docker/login-action@v1
15+
uses: docker/login-action@v2
1616
with:
1717
username: ${{ secrets.DOCKERHUB_USERNAME }}
1818
password: ${{ secrets.DOCKERHUB_TOKEN }}
1919
- name: Docker meta
2020
id: meta
21-
uses: docker/metadata-action@v4
21+
uses: docker/metadata-action@v5
2222
with:
2323
images: uffizzi/cli
2424
tags: |
2525
type=semver,pattern=v{{version}}
2626
type=semver,pattern=v{{major}}
2727
- name: Build and push
28-
uses: docker/build-push-action@v2
28+
uses: docker/build-push-action@v5
2929
with:
30+
platforms: linux/amd64,linux/arm64
3031
push: true
3132
tags: ${{ steps.meta.outputs.tags }}

.github/workflows/gem-release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ jobs:
88
runs-on: ubuntu-latest
99
steps:
1010
- name: Checkout
11-
uses: actions/checkout@v2
11+
uses: actions/checkout@v4
1212
- name: Release Ruby Gem
1313
run: make release_gem
1414
env:

Dockerfile

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# Builder stage
12
FROM ruby:3.0.3-alpine AS builder
23

34
RUN apk --update add --no-cache \
@@ -29,13 +30,11 @@ COPY . .
2930

3031
RUN bundle exec rake install
3132

32-
# M-M-M-M-MULTISTAGE!!!
33-
FROM ruby:3.0.3 AS shell
33+
FROM ruby:3.0.3-alpine AS shell
3434

35-
RUN apt-get update && apt-get install -y \
36-
vim \
35+
RUN apk --update add --no-cache \
3736
bash \
38-
&& rm -rf /var/lib/apt/lists/*
37+
vim
3938

4039
WORKDIR /root/
4140

lib/uffizzi/services/env_variables_service.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
class EnvVariablesService
88
class << self
99
def substitute_env_variables(compose_file_data)
10-
compose_file_data.gsub(/\${1,2}\{?([?:\-_A-Za-z0-9]+)\}?/) do |variable|
10+
compose_file_data.gsub(/(?<![^ \t\n])\${1,2}\{?([?:\-_A-Za-z0-9]+)\}?/) do |variable|
1111
next variable if variable.start_with?('$$')
1212

1313
variable_content = variable.match(/[?:\-_A-Za-z0-9]+/).to_s
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
services:
2+
hello-world:
3+
image: ${IMAGE:-nginx}
4+
environment:
5+
KEY: 'lkjlkjk@^$lkjj'
6+
7+
configs:
8+
vote_conf:
9+
file: ./vote.conf
10+
defaulf_conf:
11+
file: config_files/config_file.conf
12+
13+
x-uffizzi-ingress:
14+
service: hello-world
15+
port: $PORT

test/uffizzi/cli/preview_test.rb

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -426,7 +426,6 @@ def test_preview_create_with_env_vars_failed
426426
stubbed_uffizzi_preview_create = stub_uffizzi_preview_create_success(create_body, @project_slug)
427427
ENV['IMAGE'] = 'nginx'
428428
ENV['CONFIG_SOURCE'] = 'vote.conf'
429-
430429
error = assert_raises(Uffizzi::Error) do
431430
@preview.create('test/compose_files/test_compose_with_env_vars.yml')
432431
end
@@ -683,4 +682,23 @@ def test_create_preview_with_failed_deployment
683682
" finished_at: #{k8s_container_last_state[:finished_at]}\n"
684683
assert_equal(render_server_error(expected_msg), error.message)
685684
end
685+
686+
def test_preview_update_with_env_var_containing_dollar_sign_success
687+
update_body = json_fixture('files/uffizzi/uffizzi_preview_create_success.json')
688+
activity_items_body = json_fixture('files/uffizzi/uffizzi_preview_activity_items_deployed.json')
689+
deployment_id = update_body[:deployment][:id]
690+
stubbed_uffizzi_preview_update = stub_uffizzi_preview_update_success(update_body, @project_slug, deployment_id)
691+
stubbed_uffizzi_preview_deploy_containers = stub_uffizzi_preview_deploy_containers_success(@project_slug, deployment_id)
692+
stubbed_uffizzi_preview_activity_items = stub_uffizzi_preview_activity_items_success(activity_items_body, @project_slug, deployment_id)
693+
ENV['PORT'] = '80'
694+
695+
@preview.update("deployment-#{deployment_id}", 'test/compose_files/test_compose_with_env_vars_with_dollar_sign.yml')
696+
697+
*_, url_message, proxy_url_message = Uffizzi.ui.messages
698+
assert_equal("Deployment url: https://#{update_body[:deployment][:preview_url]}", url_message)
699+
assert_equal("Deployment proxy url: https://#{update_body[:deployment][:proxy_preview_url]}", proxy_url_message)
700+
assert_requested(stubbed_uffizzi_preview_activity_items, times: 2)
701+
assert_requested(stubbed_uffizzi_preview_deploy_containers)
702+
assert_requested(stubbed_uffizzi_preview_update)
703+
end
686704
end

0 commit comments

Comments
 (0)