From 9e5bc8a0495287fd778a8a664d8b13c0123fe2ff Mon Sep 17 00:00:00 2001 From: beelit94 Date: Tue, 3 Jan 2017 23:46:38 +0800 Subject: [PATCH] python-terraform-3 Refactor readme and how default value being passed refactor options usage illustration --- README.md | 48 +++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 39 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 31fbd21..3f639af 100644 --- a/README.md +++ b/README.md @@ -19,22 +19,52 @@ Therefore I end-up with using `IsFlagged` or `IsNotFlagged` as value of option like `-no-color` and `True/False` value reserved for option like ## Usage -For any terraform command +####For any terraform command from python_terraform import Terraform t = Terraform() return_code, stdout, stderr = t.(*arguments, **options) -For any options +####For any parameter +simply pass as argument in order of method, for example, + + terraform apply target_dir --> .apply('target_dir') + +####For any options - if there's a dash in the option name, use under line instead of dash, +* dash to underscore + + remove first dash, and then use underscore to replace dash symbol as option name + ex. -no-color --> no_color - if it's a simple flag with no value, value should be IsFlagged - ex. cmd('taint', allow_missing=IsFlagged) - if it's a boolean value flag like "-refresh=true", assign True or False - if it's a flag could be used multiple times, assign list to it's value - if it's a "var" variable flag, assign dictionary to it - if a value is None, will skip this option + +* for a simple flag option + + use ```IsFlagged/None``` as value for raising/not raising flag, for example, + + terraform taint -allow-missing + --> .taint(allow_missing=IsFlagged) + terraform taint + --> .taint(allow_missing=None) or .taint() + terraform apply -no-color + --> .apply(no_color=IsFlagged) + +* for a boolean value option + + assign True or False, for example, + + terraform apply -refresh=true --> .apply(refresh=True) + +* if a flag could be used multiple times, assign a list to it's value + + terraform apply -target=aws_instance.foo[1] -target=aws_instance.foo[2] + ---> + .apply(target=['aws_instance.foo[1]', 'aws_instance.foo[2]']) +* for the "var" flag, assign dictionary to it + + terraform apply -var='a=b' -var='c=d' + --> tf.apply(var={'a':'b', 'c':'d'}) +* if an option with None as value, it won't be used ## Examples ### Have a test.tf file under folder "/home/test"