From 9cfeb856760a84beec07019b1f734ae137b25645 Mon Sep 17 00:00:00 2001 From: Douglas Thrift Date: Fri, 28 Feb 2020 13:13:41 -0800 Subject: [PATCH 1/6] Add short flag ("-C") for credentials to along with --credentials --- cmd/fpt/ChangeLog.md | 8 ++++++-- cmd/fpt/README.md | 10 +++++++--- cmd/fpt/main.go | 4 ++-- 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/cmd/fpt/ChangeLog.md b/cmd/fpt/ChangeLog.md index 96404fd..651203d 100644 --- a/cmd/fpt/ChangeLog.md +++ b/cmd/fpt/ChangeLog.md @@ -1,8 +1,12 @@ -v1.0.7 / 2020-02-10 +v1.0.8 / 2020-02-28 +------------------- +* Add short flag (`-C`) for credentials to go along with `--credentials`. + +v1.0.7 / 2020-02-28 ------------------- * Fix errors with incident index. -v1.0.6 / 2020-02-10 +v1.0.6 / 2020-02-27 ------------------- * Add credential support on `fpt run` or `fpt retrieve_data`. diff --git a/cmd/fpt/README.md b/cmd/fpt/README.md index 33a48d6..d2d8268 100644 --- a/cmd/fpt/README.md +++ b/cmd/fpt/README.md @@ -2,7 +2,7 @@ `fpt` is a command line tool to aid in the development and testing of [RightScale Policies](https://docs.rightscale.com/policies/). The tool is able to syntax check, upload, and run Policies. -[![Travis CI Build Status](https://travis-ci.com/rightscale/fpt.svg?token=6Udhsz2ZbD68aBb7ApTx&branch=master)](https://travis-ci.com/rightscale/fpt) +[![Travis CI Build Status](https://travis-ci.com/rightscale/policy_sdk.svg?branch=master)](https://travis-ci.com/rightscale/policy_sdk) See [ChangeLog.md](https://github.com/rightscale/policy_sdk/tree/master/cmd/fpt/ChangeLog.md) for changes. @@ -55,6 +55,8 @@ fpt run [] [...] Example: fpt run max_snapshots.pt regions=us-east-1,us-west-2 max_snapshot_count=100 + -C, --credentials=CREDENTIALS ... + Credentials is the map of name and credential used to launch the policy. Credentials must be of the form "--credentials = --credentials =". -n, --no-log Do not print policy execution log. -k, --keep Keep applied policy running at end, for inspection in UI. Normally policy is terminated at the end. -r, --run-escalations If set, escalations will be run. Normally dry_run is set to avoid running any escalations. @@ -66,8 +68,10 @@ fpt retrieve_data [] [...] Example: fpt retrieve_data my_policy.pt --names instances - -n, --names=NAMES ... Names of resources/datasources to retrieve. By default, all datasources will be retrieved. - -o, --output-dir=OUTPUTDIR Directory to store retrieved datasources. + -C, --credentials=CREDENTIALS ... + Credentials is the map of name and credential used to launch the policy. Credentials must be of the form "--credentials = --credentials =". + -n, --names=NAMES ... Names of resources/datasources to retrieve. By default, all datasources will be retrieved. + -o, --output-dir=OUTPUT-DIR Directory to store retrieved datasources. fpt script [] [...] Run the body of a script locally. diff --git a/cmd/fpt/main.go b/cmd/fpt/main.go index 6e0b290..9f4a149 100644 --- a/cmd/fpt/main.go +++ b/cmd/fpt/main.go @@ -40,7 +40,7 @@ followed and incident printed out. Example: fpt run max_snapshots.pt regions=us-east-1,us-west-2 max_snapshot_count=100`) runFile = runCmd.Arg("file", "Policy Template file name.").Required().ExistingFile() runOptions = runCmd.Arg("options", `Options are user-supplied values for "parameters" defined in the PolicyTemplate language. Options must be in the form of "=". For list parameters, a JSON encoded array or comma separated list may be passed as the value.`).Strings() - runCredentials = runCmd.Flag("credentials", `Credentials is the map of name and credential used to launch the policy. Credentials must be of the form "--credentials = --credentials =.`).Strings() + runCredentials = runCmd.Flag("credentials", `Credentials is the map of name and credential used to launch the policy. Credentials must be of the form "--credentials = --credentials =".`).Short('C').Strings() runNoLog = runCmd.Flag("no-log", "Do not print policy execution log.").Short('n').Bool() runKeep = runCmd.Flag("keep", "Keep applied policy running at end, for inspection in UI. Normally policy is terminated at the end.").Short('k').Bool() runEscalations = runCmd.Flag("run-escalations", "If set, escalations will be run. Normally dry_run is set to avoid running any escalations.").Short('r').Bool() @@ -53,7 +53,7 @@ Example: fpt retrieve_data my_policy.pt --names instances `) rdFile = rdCmd.Arg("file", "Policy Template file name.").Required().ExistingFile() rdOptions = rdCmd.Arg("options", `Options are user-supplied values for "parameters" defined in the PolicyTemplate language. Options must be in the form of "=". For list parameters, a JSON encoded array or comma separated list may be passed as the value.`).Strings() - rdCredentials = rdCmd.Flag("credentials", `Credentials is the map of name and credential used to launch the policy. Credentials must be of the form "--credentials = --credentials =.`).Strings() + rdCredentials = rdCmd.Flag("credentials", `Credentials is the map of name and credential used to launch the policy. Credentials must be of the form "--credentials = --credentials =".`).Short('C').Strings() rdNames = rdCmd.Flag("names", "Names of resources/datasources to retrieve. By default, all datasources will be retrieved.").Short('n').Strings() rdOD = rdCmd.Flag("output-dir", "Directory to store retrieved datasources.").Short('o').String() From 7151a87146510ce9d323fe333f5921ffe4f9ada2 Mon Sep 17 00:00:00 2001 From: Douglas Thrift Date: Fri, 28 Feb 2020 13:22:14 -0800 Subject: [PATCH 2/6] Revert "PHX-1467 Try again. Cross compile everything from linux" This reverts commit a1f9a47623910f77a52c31fa8614db6819ac04cb. --- .travis.yml | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index cbafa04..edb5c90 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,8 +5,10 @@ matrix: include: - os: linux env: MAKE=make - # Windows builds broken on travis: https://travis-ci.community/t/choco-install-hangs-forever/307/23. - # git revert a1f9a47623910f77a52c31fa8614db6819ac04cb to build/test/deploy from each os (windows/darwin/linux) when this is fixed + - os: osx + env: MAKE=make + - os: windows + env: MAKE=mingw32-make cache: directories: - $HOME/.cache/go-build @@ -16,6 +18,11 @@ addons: packages: # install 7z on Linux so both the Linux and Windows build can make the zip file the same way - p7zip-full + homebrew: + packages: + # install modern bash and coreutils on macOS so that version.sh script works correctly + - bash + - coreutils before_install: # install latest mercurial client on Linux. Older clients have issues https://bitbucket.org/blog/deprecating-tlsv1-tlsv1-1-2018-12-01 - if [[ $TRAVIS_OS_NAME == linux ]]; then pyenv install --skip-existing 2.7.14 && pyenv rehash && pyenv local 2.7.14; fi @@ -29,9 +36,7 @@ install: - $MAKE depend script: - $MAKE test - - GOOS=linux $MAKE build - - GOOS=darwin $MAKE build - - GOOS=windows $MAKE build + - $MAKE build # QnB upload user (rightscale-binaries-upload-governance) - export AWS_ACCESS_KEY_ID=AKIAIX27XNPUMQ25GSEQ - export AWS_SECRET_ACCESS_KEY=${RSBIN_KEY} From ff7a4117fe6d2ddfd07a15685c0e8c7b19580b46 Mon Sep 17 00:00:00 2001 From: Douglas Thrift Date: Fri, 28 Feb 2020 13:23:46 -0800 Subject: [PATCH 3/6] Remove Mercurial fix install as it was fixed on Travis CI a while ago --- .travis.yml | 6 ------ 1 file changed, 6 deletions(-) diff --git a/.travis.yml b/.travis.yml index edb5c90..9c19578 100644 --- a/.travis.yml +++ b/.travis.yml @@ -24,12 +24,6 @@ addons: - bash - coreutils before_install: - # install latest mercurial client on Linux. Older clients have issues https://bitbucket.org/blog/deprecating-tlsv1-tlsv1-1-2018-12-01 - - if [[ $TRAVIS_OS_NAME == linux ]]; then pyenv install --skip-existing 2.7.14 && pyenv rehash && pyenv local 2.7.14; fi - - if [[ $TRAVIS_OS_NAME == linux ]]; then virtualenv -p python2.7 python_env; fi - - if [[ $TRAVIS_OS_NAME == linux ]]; then source python_env/bin/activate; fi - - if [[ $TRAVIS_OS_NAME == linux ]]; then pip install --upgrade pip; fi - - if [[ $TRAVIS_OS_NAME == linux ]]; then pip install mercurial --upgrade; fi # install mercurial on Windows as some Go dependencies need it - if [[ $TRAVIS_OS_NAME == windows ]]; then choco install -y hg; fi install: From b77ee405551c7e33f92c7755a4e84dbc28b7671e Mon Sep 17 00:00:00 2001 From: Douglas Thrift Date: Fri, 28 Feb 2020 13:30:19 -0800 Subject: [PATCH 4/6] Fix Windows to $MAKE upload --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 9c19578..b1ea3e1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -34,4 +34,4 @@ script: # QnB upload user (rightscale-binaries-upload-governance) - export AWS_ACCESS_KEY_ID=AKIAIX27XNPUMQ25GSEQ - export AWS_SECRET_ACCESS_KEY=${RSBIN_KEY} - - "[[ -z $AWS_SECRET_ACCESS_KEY ]] || make upload" + - "[[ -z $AWS_SECRET_ACCESS_KEY ]] || $MAKE upload" From e8f4ff375ce5e128d2e8af9074261074318e58f3 Mon Sep 17 00:00:00 2001 From: Douglas Thrift Date: Fri, 28 Feb 2020 13:46:39 -0800 Subject: [PATCH 5/6] Use a newer macOS image for Homebrew to work --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index b1ea3e1..5456fc9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,6 +6,7 @@ matrix: - os: linux env: MAKE=make - os: osx + osx_image: xcode11.2 env: MAKE=make - os: windows env: MAKE=mingw32-make From e037b19a534020fac2d1452b7c3f0edabd01b4f8 Mon Sep 17 00:00:00 2001 From: Douglas Thrift Date: Fri, 28 Feb 2020 13:55:48 -0800 Subject: [PATCH 6/6] Maybe this will get Homebrew to work correctly --- .travis.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 5456fc9..bed174a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,7 +6,7 @@ matrix: - os: linux env: MAKE=make - os: osx - osx_image: xcode11.2 + osx_image: xcode11.3 env: MAKE=make - os: windows env: MAKE=mingw32-make @@ -24,6 +24,7 @@ addons: # install modern bash and coreutils on macOS so that version.sh script works correctly - bash - coreutils + update: true before_install: # install mercurial on Windows as some Go dependencies need it - if [[ $TRAVIS_OS_NAME == windows ]]; then choco install -y hg; fi