Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
jfahrer committed Nov 28, 2023
1 parent b10cc91 commit 0de1e8d
Show file tree
Hide file tree
Showing 9 changed files with 19 additions and 3 deletions.
4 changes: 4 additions & 0 deletions TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,17 @@

## DeploymentConfig

- Content is not rendering correctly (need to read file instead of passing filename)
- Directory is there twice
- Don't upload configs if they already exist
- Use `service` instead of `deployment` for config generation
- Make `config` part of a `deployment`
- Tests should go through the whole flow and actually upload something

## Bugs

- If the container count changes, it is mixing up stopping with replacing
- Changing order of role/service definitions should not change the version

## Naming

Expand Down
1 change: 1 addition & 0 deletions lib/cove/configuration/service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ def roles
ports: role_config["ingress"],
mounts: role_config["mounts"],
environment_variables: role_environment,
configs: role_config["configs"],
hosts: role_config["hosts"].map { |host_id| @host_registry[host_id] }
)
end
Expand Down
2 changes: 1 addition & 1 deletion lib/cove/deployment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def labels
private

def build_version
Digest::SHA2.hexdigest([role.id, role.image, role.command, role.environment_variables, role.ports].to_json)[0..12]
Digest::SHA2.hexdigest([role.id, role.image, role.command, role.environment_variables, role.ports, role.configs].to_json)[0..12]
end
end
end
2 changes: 2 additions & 0 deletions lib/cove/deployment_config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ module Cove
class DeploymentConfig
def self.prepare(registry, deployment)
entries = deployment.configs.map do |name, definition|
# TODO: Make sure we always symbolize keys when parsing the config
definition = definition.with_indifferent_access
Entry.new(
registry: registry, deployment: deployment,
name: name, source: definition[:source],
Expand Down
5 changes: 5 additions & 0 deletions lib/cove/deployment_config/config_file.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ def initialize(path:, content:)
@path = path
@content = content
end

def directory
dir = File.dirname(path)
dir unless dir == "."
end
end
end
end
2 changes: 1 addition & 1 deletion lib/cove/deployment_config/entry.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def digestables
end

def directories
files.map(&:directory).uniq
files.map(&:directory).compact.uniq
end

def files
Expand Down
2 changes: 2 additions & 0 deletions lib/cove/invocation/service_up.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,10 @@ def initialize(connection, registry, service, roles)
def run
roles.each do |role|
deployment = Deployment.new(role)
config = DeploymentConfig.prepare(registry, deployment)

Steps::EnsureEnvironmentFileExists.call(connection, deployment)
Steps::EnsureConfigsExist.call(connection, config)
Steps::PullImage.call(connection, deployment)
Steps::CreateMissingContainers.call(connection, deployment)
Steps::RollContainers.call(connection, deployment)
Expand Down
2 changes: 1 addition & 1 deletion lib/cove/role.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class Role
# @return [String] The name of the service this role belongs to
delegate :name, to: :service, prefix: true

def initialize(name:, service:, hosts:, container_count: 1, command: [], environment_variables: {}, ports: [], mounts: [], configs: [])
def initialize(name:, service:, hosts:, container_count: 1, command: [], environment_variables: {}, ports: [], mounts: [], configs: {})
@name = name
@service = service
@hosts = hosts
Expand Down
2 changes: 2 additions & 0 deletions lib/cove/steps/ensure_configs_exist.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
module Cove
module Steps
class EnsureConfigsExist
include Callable

attr_reader :connection, :deployment_config

def initialize(connection, deployment_config)
Expand Down

0 comments on commit 0de1e8d

Please sign in to comment.