Method: Command::SetupApp#call

Defined in:
lib/command/setup_app.rb

#callObject

rubocop:disable Metrics/CyclomaticComplexity, Metrics/MethodLength



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/command/setup_app.rb', line 28

def call # rubocop:disable Metrics/CyclomaticComplexity, Metrics/MethodLength
  templates = config[:setup_app_templates]

  app = cp.fetch_gvc
  if app
    raise "App '#{config.app}' already exists. If you want to update this app, " \
          "either run 'cpflow delete -a #{config.app}' and then re-run this command, " \
          "or run 'cpflow apply-template #{templates.join(' ')} -a #{config.app}'."
  end

  skip_secrets_setup = config.options[:skip_secret_access_binding] ||
                       config.options[:skip_secrets_setup] || config.current[:skip_secrets_setup]

  create_secret_and_policy_if_not_exist unless skip_secrets_setup

  args = []
  args.push("--add-app-identity") unless skip_secrets_setup
  Cpflow::Cli.start(["apply-template", *templates, "-a", config.app, *args])

  bind_identity_to_policy unless skip_secrets_setup
  run_post_creation_hook unless config.options[:skip_post_creation_hook]
end