Skip to content

Commit

Permalink
Modifying Raketask to support GOV cloud
Browse files Browse the repository at this point in the history
Signed-off-by: NimishaS <nimisha.sharad@clogeny.com>
  • Loading branch information
NimishaS committed Sep 12, 2017
1 parent f4ff0f6 commit ce117e4
Showing 1 changed file with 47 additions and 12 deletions.
59 changes: 47 additions & 12 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,33 @@ def assert_publish_env_vars
end
end

def assert_gov_environment_vars
env_vars = {
"azure_extension_cli" => "Path of azure-extension-cli binary. Download it from https://github.com/Azure/azure-extensions-cli/releases",
"SUBSCRIPTION_ID" => "Subscription ID of the GOV Account from where extension is to be published.",
"SUBSCRIPTION_CERT" => "Path to the Management Certificate",
"MANAGEMENT_URL" => "Management URL for Gov Cloud (https://management.core.usgovcloudapi.net)",
"EXTENSION_NAMESPACE" => "Publisher namespace (Chef.Bootstrap.WindowsAzure)"
}

env_vars.each do |var, desc|
error_and_exit! "Please set the environment variable - \"#{var}\" for [#{desc}]" unless ENV[var]
end
end

# sets the common environment varaibles for Chef Extension
def set_gov_env_vars(subscription_id)
env_vars = {
"SUBSCRIPTION_ID" => subscription_id,
"MANAGEMENT_URL" => "https://management.core.usgovcloudapi.net",
"EXTENSION_NAMESPACE" => "Chef.Bootstrap.WindowsAzure"
}

env_vars.each do |var, value|
ENV[var] = value
end
end

def assert_deploy_params(deploy_type, internal_or_public)
assert_publish_env_vars

Expand Down Expand Up @@ -166,18 +193,21 @@ def get_definition_xml(args, date_tag = nil)

extensionZipPackage = get_extension_pkg_name(args, date_tag)

# Process the erb
definitionXml = ERBHelpers::ERBCompiler.run(
File.read("build/templates/definition.xml.erb"),
{:chef_namespace => args.chef_deploy_namespace,
:extension_name => extensionName,
:extension_version => args.extension_version,
:target_type => args.target_type,
:package_storage_account => storageAccount,
:package_container => storageContainer,
:package_name => extensionZipPackage,
:is_internal => is_internal?(args)
})
if args.deploy_type == GOV
else
# Process the erb
definitionXml = ERBHelpers::ERBCompiler.run(
File.read("build/templates/definition.xml.erb"),
{:chef_namespace => args.chef_deploy_namespace,
:extension_name => extensionName,
:extension_version => args.extension_version,
:target_type => args.target_type,
:package_storage_account => storageAccount,
:package_container => storageContainer,
:package_name => extensionZipPackage,
:is_internal => is_internal?(args)
})
end

definitionXml
end
Expand Down Expand Up @@ -281,6 +311,11 @@ task :publish, [:deploy_type, :target_type, :extension_version, :chef_deploy_nam

subscription_id, subscription_name = load_publish_settings

if args.deploy_type == GOV
set_gov_env_vars(subscription_id)
assert_gov_environment_vars
end

publish_uri = get_publish_uri(args.deploy_type, subscription_id, args.operation)

definitionXml = get_definition_xml(args)
Expand Down

0 comments on commit ce117e4

Please sign in to comment.