-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
93 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
9.0.1 | ||
9.1.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
module MetadataServices; end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
module MetadataServices | ||
## | ||
# Clients are given write access to `db/` on the metadata service. Load that and parse | ||
class LoadWritableService | ||
|
||
attr_reader :service | ||
|
||
# @param [Deployment::ContainerService] service | ||
def initialize(service) | ||
@service = service | ||
end | ||
|
||
def all | ||
Diplomat::Kv.get_all("#{consul_base_path}", consul_config) | ||
end | ||
|
||
# @param [String] path "modules/database" | ||
def get(path) | ||
Diplomat::Kv.get("#{consul_base_path}/#{path}", consul_config) | ||
end | ||
|
||
# @param [String] path "modules/database" | ||
def get_json(path) | ||
Oj.load get(path) | ||
rescue JSON::ParserError | ||
nil | ||
end | ||
|
||
protected | ||
|
||
def consul_base_path | ||
"projects/#{@service.deployment.token}/db" | ||
end | ||
|
||
def consul_config | ||
return {} if Rails.env.test? # for test, we dont want any config here! | ||
return {} if @service.nodes.online.empty? | ||
dc = @service.region.nil? ? @service.nodes.online.first.region.name.strip.downcase : @service.region.name.strip.downcase | ||
token = @service.region.nil? ? @service.nodes.online.first.region.consul_token : @service.region.consul_token | ||
return {} if token.blank? | ||
consul_ip = @service.nodes.online.first.primary_ip | ||
{ | ||
http_addr: Diplomat.configuration.options.empty? ? "http://#{consul_ip}:8500" : "https://#{consul_ip}:8501", | ||
dc: dc.blank? ? nil : dc, | ||
token: token | ||
} | ||
end | ||
|
||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
class UpdateConsulAuth < ActiveRecord::Migration[7.0] | ||
def change | ||
|
||
## | ||
# Ensure we have the new bastion config loaded | ||
Setting.computestacks_bastion_image | ||
|
||
## | ||
# Add write permission to all existing keys | ||
Deployment.all.each do |project| | ||
d = { | ||
'ID' => project.consul_policy_id, | ||
'Name' => "proj-#{project.token}", | ||
'Description' => "MetaData Policy for Project #{project.name}", | ||
'Rules' => %Q(key_prefix "projects/#{project.token}/" { policy = "read" } key_prefix "projects/#{project.token}/db/" { policy = "write" }) | ||
} | ||
Diplomat::Policy.update d, project.region.consul_config | ||
end | ||
|
||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
class AddInitToContainerImages < ActiveRecord::Migration[7.0] | ||
def change | ||
add_column :container_images, :docker_init, :boolean, default: false, null: false | ||
end | ||
end |