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

kubernetes: dynamic file name based on deploy_group permalink #4085

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions plugins/kubernetes/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,12 @@ metadata.annotations.samson/recreate: "true"

Set the kubernetes roles to `kubernetes/$deploy_group/server.yml`

You may also reference the permalink of a deploy group via `kubernetes/$deploy_group_permalink/server.yml`

### Static config per environment

Set the kubernetes roles to `kubernetes/$environment/server.yml`

### Ignoring warning events

If a warning event fails deploys, but application owners deem them safe to ignore, add this:
Expand Down
1 change: 1 addition & 0 deletions plugins/kubernetes/app/models/kubernetes/role.rb
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ def role_config_file(reference, deploy_group:, project: project(), **args) # rub
file = config_file
if deploy_group && dynamic_folders?
file = file.
sub('$deploy_group_permalink', deploy_group.permalink).
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it has to come before $deploy_group otherwise it will replace it to pod998_permalink

sub('$deploy_group', deploy_group.env_value).
sub('$environment', deploy_group.environment.permalink)
end
Expand Down
8 changes: 8 additions & 0 deletions plugins/kubernetes/test/models/kubernetes/role_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -492,5 +492,13 @@ def commit
role.config_file = "kubernetes/$deploy_group/foo.yaml"
assert role.role_config_file("master", deploy_group: deploy_groups(:pod100))
end

it "can read from dynamic deploy_group_permalink" do
GitRepository.any_instance.
expects(:file_content).with('kubernetes/pod100/foo.yaml', "master", anything).
returns(read_kubernetes_sample_file('kubernetes_job.yml'))
role.config_file = "kubernetes/$deploy_group_permalink/foo.yaml"
assert role.role_config_file("master", deploy_group: deploy_groups(:pod100))
end
end
end
Loading