Sha256: de56c9b4621d4db98435fe0f49ff7ed15aa2114c513368215c0ad5f8765191c9

Contents?: true

Size: 1.56 KB

Versions: 16

Compression:

Stored size: 1.56 KB

Contents

# frozen_string_literal: true

module RailsTemplate18f
  module Generators
    module CloudGovOptions
      extend ActiveSupport::Concern

      included do
        class_option :cg_org, desc: "cloud.gov organization name"
        class_option :cg_staging, desc: "cloud.gov space name for staging"
        class_option :cg_prod, desc: "cloud.gov space name for production"
      end

      private

      def cloud_gov_organization
        if options[:cg_org].present?
          return options[:cg_org]
        elsif terraform_dir_exists?
          staging_main = file_content("terraform/staging/main.tf")
          if (matches = staging_main.match(/cf_org_name\s+= "(?<org_name>.*)"/))
            return matches[:org_name]
          end
        end
        "TKTK-cloud.gov-org-name"
      end

      def cloud_gov_staging_space
        if options[:cg_staging].present?
          return options[:cg_staging]
        elsif terraform_dir_exists?
          staging_main = file_content("terraform/staging/main.tf")
          if (matches = staging_main.match(/cf_space_name\s+= "(?<space_name>.*)"/))
            return matches[:space_name]
          end
        end
        "staging"
      end

      def cloud_gov_production_space
        if options[:cg_prod].present?
          return options[:cg_prod]
        elsif terraform_dir_exists?
          prod_main = file_content("terraform/production/main.tf")
          if (matches = prod_main.match(/cf_space_name\s+= "(?<space_name>.*)"/))
            return matches[:space_name]
          end
        end
        "prod"
      end
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
rails_template_18f-1.2.0 lib/rails_template18f/generators/cloud_gov_options.rb
rails_template_18f-1.1.0 lib/rails_template18f/generators/cloud_gov_options.rb
rails_template_18f-1.0.0 lib/rails_template18f/generators/cloud_gov_options.rb
rails_template_18f-0.8.2 lib/rails_template18f/generators/cloud_gov_options.rb
rails_template_18f-0.8.1 lib/rails_template18f/generators/cloud_gov_options.rb
rails_template_18f-0.8.0 lib/rails_template18f/generators/cloud_gov_options.rb
rails_template_18f-0.7.2 lib/rails_template18f/generators/cloud_gov_options.rb
rails_template_18f-0.7.1 lib/rails_template18f/generators/cloud_gov_options.rb
rails_template_18f-0.7.0 lib/rails_template18f/generators/cloud_gov_options.rb
rails_template_18f-0.6.0 lib/rails_template18f/generators/cloud_gov_options.rb
rails_template_18f-0.5.3 lib/rails_template18f/generators/cloud_gov_options.rb
rails_template_18f-0.5.2 lib/rails_template18f/generators/cloud_gov_options.rb
rails_template_18f-0.5.1 lib/rails_template18f/generators/cloud_gov_options.rb
rails_template_18f-0.5.0 lib/rails_template18f/generators/cloud_gov_options.rb
rails_template_18f-0.4.1 lib/rails_template18f/generators/cloud_gov_options.rb
rails_template_18f-0.4.0 lib/rails_template18f/generators/cloud_gov_options.rb