本文整理匯總了Python中webhook2lambda2sqs.terraform_runner.TerraformRunner.plan方法的典型用法代碼示例。如果您正苦於以下問題:Python TerraformRunner.plan方法的具體用法?Python TerraformRunner.plan怎麽用?Python TerraformRunner.plan使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類webhook2lambda2sqs.terraform_runner.TerraformRunner
的用法示例。
在下文中一共展示了TerraformRunner.plan方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: main
# 需要導入模塊: from webhook2lambda2sqs.terraform_runner import TerraformRunner [as 別名]
# 或者: from webhook2lambda2sqs.terraform_runner.TerraformRunner import plan [as 別名]
def main(args=None):
"""
Main entry point
"""
# parse args
if args is None:
args = parse_args(sys.argv[1:])
# dump example config if that action
if args.action == 'example-config':
conf, doc = Config.example_config()
print(conf)
sys.stderr.write(doc + "\n")
return
# set logging level
if args.verbose > 1:
set_log_debug()
elif args.verbose == 1:
set_log_info()
# get our config
config = Config(args.config)
if args.action == 'logs':
aws = AWSInfo(config)
aws.show_cloudwatch_logs(count=args.log_count)
return
if args.action == 'queuepeek':
aws = AWSInfo(config)
aws.show_queue(name=args.queue_name, delete=args.queue_delete,
count=args.msg_count)
return
if args.action == 'test':
run_test(config, args)
return
# if generate or genapply, generate the configs
if args.action == 'generate' or args.action == 'genapply':
func_gen = LambdaFuncGenerator(config)
func_src = func_gen.generate()
# @TODO: also write func_source to disk
tf_gen = TerraformGenerator(config)
tf_gen.generate(func_src)
# if only generate, exit now
if args.action == 'generate':
return
# else setup a Terraform action
runner = TerraformRunner(config, args.tf_path)
# run the terraform action
if args.action == 'apply' or args.action == 'genapply':
runner.apply(args.stream_tf)
elif args.action == 'plan':
runner.plan(args.stream_tf)
else: # destroy
runner.destroy(args.stream_tf)
示例2: test_plan_stream
# 需要導入模塊: from webhook2lambda2sqs.terraform_runner import TerraformRunner [as 別名]
# 或者: from webhook2lambda2sqs.terraform_runner.TerraformRunner import plan [as 別名]
def test_plan_stream(self):
with patch('%s._validate' % pb):
cls = TerraformRunner(self.mock_config(), 'terraform-bin')
with patch('%s.logger' % pbm, autospec=True) as mock_logger:
with patch('%s._set_remote' % pb, autospec=True) as mock_set:
with patch('%s._run_tf' % pb, autospec=True) as mock_run:
mock_run.return_value = 'output'
cls.plan(stream=True)
assert mock_set.mock_calls == [call(cls, stream=True)]
assert mock_run.mock_calls == [
call(cls, 'plan', cmd_args=['-input=false', '-refresh=true', '.'],
stream=True)
]
assert mock_logger.mock_calls == [
call.warning('Running terraform plan: %s',
'-input=false -refresh=true .'),
call.warning("Terraform plan finished successfully.")
]
示例3: main
# 需要導入模塊: from webhook2lambda2sqs.terraform_runner import TerraformRunner [as 別名]
# 或者: from webhook2lambda2sqs.terraform_runner.TerraformRunner import plan [as 別名]
def main(args=None):
"""
Main entry point
"""
# parse args
if args is None:
args = parse_args(sys.argv[1:])
# dump example config if that action
if args.action == 'example-config':
conf, doc = Config.example_config()
print(conf)
sys.stderr.write(doc + "\n")
return
# set logging level
if args.verbose > 1:
set_log_debug()
elif args.verbose == 1:
set_log_info()
# get our config
config = Config(args.config)
if args.action == 'logs':
aws = AWSInfo(config)
aws.show_cloudwatch_logs(count=args.log_count)
return
if args.action == 'apilogs':
api_id = get_api_id(config, args)
aws = AWSInfo(config)
aws.show_cloudwatch_logs(
count=args.log_count,
grp_name='API-Gateway-Execution-Logs_%s/%s' % (
api_id, config.stage_name
)
)
return
if args.action == 'queuepeek':
aws = AWSInfo(config)
aws.show_queue(name=args.queue_name, delete=args.queue_delete,
count=args.msg_count)
return
if args.action == 'test':
run_test(config, args)
return
if args.action in ['apply', 'genapply', 'plan', 'destroy']:
runner = TerraformRunner(config, args.tf_path)
tf_ver = runner.tf_version
else:
tf_ver = tuple(
[int(x) for x in args.tf_ver.split('.')]
)
# if generate or genapply, generate the configs
if args.action == 'generate' or args.action == 'genapply':
func_gen = LambdaFuncGenerator(config)
func_src = func_gen.generate()
# @TODO: also write func_source to disk
tf_gen = TerraformGenerator(config, tf_ver=tf_ver)
tf_gen.generate(func_src)
# if only generate, exit now
if args.action == 'generate':
return
# run the terraform action
if args.action == 'apply' or args.action == 'genapply':
runner.apply(args.stream_tf)
# conditionally set API Gateway Method settings
if config.get('api_gateway_method_settings') is not None:
aws = AWSInfo(config)
aws.set_method_settings()
elif args.action == 'plan':
runner.plan(args.stream_tf)
else: # destroy
runner.destroy(args.stream_tf)