Skip to content

Commit

Permalink
Add flag to conjurctl server to skip migrations
Browse files Browse the repository at this point in the history
  • Loading branch information
telday committed Aug 9, 2023
1 parent 3555c40 commit 8ac49d3
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 3 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- Telemetry support
[cyberark/conjur#2854](https://github.com/cyberark/conjur/pull/2854)

### Added
- New flag to `conjurctl server` command called `--no-migrate` which allows for skipping
the database migration step when starting the server.
[cyberark/conjur#2895](https://github.com/cyberark/conjur/pull/2895)

### Fixed
- Support Authn-IAM regional requests when host value is missing from signed headers.
[cyberark/conjur#2827](https://github.com/cyberark/conjur/pull/2827)
Expand Down
7 changes: 6 additions & 1 deletion bin/conjur-cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@
c.default_value(ENV['PORT'] || '80')
c.flag [ :p, :port ]

c.desc 'Skip running database migrations on start'
c.default_value false
c.switch :'no-migrate'

c.desc 'Server bind address'
c.default_value(ENV['BIND_ADDRESS'] || '0.0.0.0')
c.arg_name :ip
Expand All @@ -55,7 +59,8 @@
password_from_stdin: options["password-from-stdin"],
file_name: options[:file],
bind_address: options[:'bind-address'],
port: options[:port]
port: options[:port],
no_migrate: options[:'no-migrate']
)
end
end
Expand Down
10 changes: 8 additions & 2 deletions bin/conjur-cli/commands/server.rb
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
# frozen_string_literal: true

require 'command_class'
require 'sequel'

# Required to use $CHILD_STATUS
require 'English'

require_relative 'db/migrate'
require_relative 'connect_database'

module Commands
Server ||= CommandClass.new(
dependencies: {
migrate_database: DB::Migrate.new
migrate_database: DB::Migrate.new,
connect_database: ConnectDatabase.new
},

inputs: %i[
Expand All @@ -19,14 +22,17 @@ module Commands
file_name
bind_address
port
no_migrate
]
) do
def call
# Ensure the database is available
# and the schema is up-to-date
@migrate_database.call(
preview: false
)
) unless @no_migrate

@connect_database.call if @no_migrate

# Create and bootstrap the initial
# Conjur account and policy
Expand Down

0 comments on commit 8ac49d3

Please sign in to comment.