Skip to content
Merged
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
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
aptible-cli (0.26.6)
aptible-cli (0.26.7)
activesupport (>= 4.0, < 6.0)
aptible-api (~> 1.12)
aptible-auth (~> 1.4)
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ Commands:
aptible apps:deprovision [--app APP] # Deprovision an app
aptible apps:rename OLD_HANDLE NEW_HANDLE [--environment ENVIRONMENT_HANDLE] # Rename an app handle. In order for the new app handle to appear in log drain and metric drain destinations, you must restart the app.
aptible apps:scale [--app APP] SERVICE [--container-count COUNT] [--container-size SIZE_MB] [--container-profile PROFILE] # Scale a service
aptible apps:settings HANDLE # Display deployment related settings for an app
aptible backup:list DB_HANDLE # List backups for a database
aptible backup:orphaned # List backups associated with deprovisioned databases
aptible backup:purge BACKUP_ID # Permanently delete a backup and any copies of it
Expand Down
11 changes: 11 additions & 0 deletions lib/aptible/cli/helpers/app.rb
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,17 @@ def current_configuration(app)
)
end

def current_setting(app)
setting_link = app.links['current_setting']
return unless setting_link

Aptible::Api::Setting.find_by_url(
setting_link.href,
token: fetch_token,
headers: { 'Prefer' => 'no_sensitive_extras=false' }
)
end

private

def handle_strategies
Expand Down
24 changes: 18 additions & 6 deletions lib/aptible/cli/resource_formatter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,14 @@ def inject_operation(node, operation)
node.value('created_at', operation.created_at)
end

def inject_app(node, app, account)
def inject_app(node, app, account, setting = nil,
include_services: true)
node.value('id', app.id)
node.value('handle', app.handle)
node.value('created_at', app.created_at)

attach_account(node, account)

node.value('status', app.status)
node.value('git_remote', app.git_repo)

Expand All @@ -109,15 +112,24 @@ def inject_app(node, app, account)
end
end

node.list('services') do |services_list|
app.each_service do |service|
services_list.object do |n|
inject_service(n, service, NO_NESTING)
if include_services
node.list('services') do |services_list|
app.each_service do |service|
services_list.object do |n|
inject_service(n, service, NO_NESTING)
end
end
end
end

attach_account(node, account)
unless setting.nil?
node.value('docker_image',
setting.settings['APTIBLE_DOCKER_IMAGE'])
node.value('private_registry_username',
setting.sensitive_settings['APTIBLE_PRIVATE_REGISTRY_USERNAME'])
node.value('private_registry_password',
setting.sensitive_settings['APTIBLE_PRIVATE_REGISTRY_PASSWORD'])
end
end

def inject_database_minimal(node, database, account)
Expand Down
29 changes: 28 additions & 1 deletion lib/aptible/cli/subcommands/apps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ def apps
accounts.each do |account|
account.each_app do |app|
node.object do |n|
ResourceFormatter.inject_app(n, app, account)
setting = current_setting(app)
ResourceFormatter.inject_app(n, app, account, setting)
end
end
end
Expand Down Expand Up @@ -125,6 +126,32 @@ def apps
end
end

desc 'apps:settings HANDLE', 'Display deployment related settings for an app'
option :environment, aliases: '--env'
define_method 'apps:settings' do |handle|
telemetry(__method__, options.merge(handle: handle))

environment = nil
if options[:environment]
environment = environment_from_handle(options[:environment])
end
app = app_from_handle(handle, environment)

raise Thor::Error, "Could not find app #{handle}" if app.nil?

app = with_sensitive(app)
setting = current_setting(app)

Formatter.render(Renderer.current) do |root|
root.object do |node|
ResourceFormatter.inject_app(
node, app, app.account, setting,
include_services: false
)
end
end
end

desc 'apps:rename OLD_HANDLE NEW_HANDLE [--environment'\
' ENVIRONMENT_HANDLE]', 'Rename an app handle. In order'\
' for the new app handle to appear in log drain and metric'\
Expand Down
2 changes: 1 addition & 1 deletion lib/aptible/cli/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module Aptible
module CLI
VERSION = '0.26.6'.freeze
VERSION = '0.26.7'.freeze
end
end
Loading
Loading