Skip to content
Permalink
Browse files

Refactor environment -> project map out of build (#300)

Move the project mapping into its own file so that it can be more easily
overriden.
  • Loading branch information...
mindhog committed Oct 7, 2019
1 parent 8bcfb18 commit 8ca8fff387f3e99c1ed425ee75fc9f4709db60fd
Showing with 25 additions and 7 deletions.
  1. +4 −7 build.gradle
  2. +21 −0 projects.gradle
@@ -119,14 +119,10 @@ task stage {

def environments = ['production', 'sandbox', 'alpha', 'crash']

// TODO(mmuller): Move this into internal specialization code.
def projects = ['production': 'domain-registry',
'sandbox' : 'domain-registry-sandbox',
'alpha' : 'domain-registry-alpha',
'crash' : 'domain-registry-crash']

def gcpProject = null

apply from: "${rootDir.path}/projects.gradle"

if (environment == '') {
// Keep the project null, this will prevent deployment. Set the
// environment to "alpha" because other code needs this property to
@@ -135,7 +131,8 @@ if (environment == '') {
} else if (environment != 'production' && environment != 'sandbox') {
gcpProject = projects[environment]
if (gcpProject == null) {
throw new GradleException("-Penvironment must be one of ${environments}.")
throw new GradleException("-Penvironment must be one of " +
"${projects.keySet()}.")
}
}

@@ -0,0 +1,21 @@
// Copyright 2019 The Nomulus Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

// Mapping from environment names to GCP projects.
// Replace the values with the names of your deployment environments.

rootProject.ext.projects = ['production': 'your-production-project',
'sandbox' : 'your-sandbox-project',
'alpha' : 'your-alpha-project',
'crash' : 'your-crash-project']

0 comments on commit 8ca8fff

Please sign in to comment.
You can’t perform that action at this time.