Fixed cleanip ami bug

parent 23e9aa89
Pipeline #1988 failed with stages
in 15 seconds
......@@ -9,7 +9,7 @@ helpers.set_logger()
@click.option("--role-arns", required=True, help="Role ARNs with assumable permissions, to do the cleanup for")
@click.option("--not-dry-run", is_flag=True, help="Will do nothing unless supplied")
@click.pass_context
def cleanup(ctx, region, role_arns, not_dry_run):
def cleanup(ctx, region, role_arns, not_dry_run=False):
ctx.obj = {'region': region, 'role_arns': role_arns, 'not_dry_run': not_dry_run}
pass
......@@ -19,7 +19,7 @@ def cleanup(ctx, region, role_arns, not_dry_run):
@click.option("--retention", type=int, required=True, help="How long to hold AMIs for")
@click.option("--exceptional-amis", help="List of AMI names to always keep just the latest version of (useful for base images)")
@click.option("--launch-templates", help="List of Launch Templates to check AMI usage against. If AMI appears in latest version, it will be spared")
def ami(ctx, retention, not_dry_run, exceptional_amis, launch_templates):
def ami(ctx, retention, exceptional_amis, launch_templates):
from .ami import cleanup_amis
region = ctx.obj.get('region')
not_dry_run = ctx.obj.get('not_dry_run')
......@@ -60,6 +60,3 @@ def ebs(ctx):
except Exception as e:
logging.error(e)
exit(1)
#!/bin/bash
# Ta very much: https://github.com/fmahnke/shell-semver/blob/master/increment_version.sh
# Parse command line options.
while getopts ":Mmp" Option
do
case $Option in
M ) major=true;;
m ) minor=true;;
p ) patch=true;;
esac
done
shift $(($OPTIND - 1))
version=$(git describe --tags `git rev-list --tags --max-count=1`)
# Build array from version string.
a=( ${version//./ } )
# If version string is missing or has the wrong number of members, show usage message.
if [ ${#a[@]} -ne 3 ]
then
echo "usage: $(basename $0) [-Mmp] major.minor.patch"
exit 1
fi
# Increment version numbers as requested.
if [ ! -z $major ]
then
((a[0]++))
a[1]=0
a[2]=0
fi
if [ ! -z $minor ]
then
((a[1]++))
a[2]=0
fi
if [ ! -z $patch ]
then
((a[2]++))
fi
new_version="${a[0]}.${a[1]}.${a[2]}"
git tag -s $new_version
git push origin $new_version
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment