Sha256: fc66dce8e316de711df197d5a0cdc869f98846836e9e08a72ebe858062843964

Contents?: true

Size: 1.39 KB

Versions: 1

Compression:

Stored size: 1.39 KB

Contents

require 'aptible/comply'
require 'json'

module Comply
  module CLI
    module Helpers
      module Integration
        def prettify_integration(integration)
          integration.integration_type
        end

        def pretty_print_integration(integration)
          "#{prettify_integration(integration)} (#{integration.id})"
        end

        def prompt_and_create_integration(type)
          env = prompt_for_env(type)
          default_program.create_integration(integration_type: type, env: env)
        end

        def prompt_and_update_integration(integration)
          env = prompt_for_env(integration.integration_type)
          integration.update(env: env)
        end

        def prompt_for_env(type)
          env = {}
          env_vars_by_prompt(type).each do |human, key|
            env[key] = ask("#{human}:", echo: false)
            puts
          end

          env
        end

        def env_vars_by_prompt(type)
          case type
          when 'gsuite'
            {
              'Client ID' => 'GOOGLE_CLIENT_ID',
              'Client Secret' => 'GOOGLE_CLIENT_SECRET',
              'Access Token' => 'GOOGLE_ACCESS_TOKEN',
              'Refresh Token' => 'GOOGLE_REFRESH_TOKEN'
            }
          when 'okta'
            {
              'Org Name' => 'OKTA_ORG_NAME',
              'API Key' => 'OKTA_API_KEY'
            }
          end
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
comply-cli-0.0.1 lib/comply/cli/helpers/integration.rb