Skip to content

Commit

Permalink
Merge pull request #19 from cisagov/lineage/skeleton
Browse files Browse the repository at this point in the history
Lineage pull request for: skeleton
  • Loading branch information
jsf9k authored Feb 18, 2021
2 parents 7ae4abd + 13e73d3 commit f0c07b2
Show file tree
Hide file tree
Showing 6 changed files with 60 additions and 49 deletions.
15 changes: 12 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,20 @@ repos:
hooks:
- id: prettier
- repo: https://github.com/adrienverge/yamllint
rev: v1.25.0
rev: v1.26.0
hooks:
- id: yamllint
args:
- --strict

# Shell script hooks
- repo: https://github.com/lovesegfault/beautysh
rev: 6.0.1
hooks:
- id: beautysh
args:
- --indent-size
- '2'
- repo: https://github.com/detailyang/pre-commit-shell
rev: 1.0.5
hooks:
Expand Down Expand Up @@ -85,16 +92,18 @@ repos:
hooks:
- id: isort
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v0.790
rev: v0.800
hooks:
- id: mypy
- repo: https://github.com/asottile/pyupgrade
rev: v2.7.4
rev: v2.10.0
hooks:
- id: pyupgrade

# Ansible hooks
- repo: https://github.com/ansible-community/ansible-lint
# This is intentionally being held back because of issues in v5 per
# https://github.com/cisagov/skeleton-ansible-role/issues/69
rev: v4.3.7
hooks:
- id: ansible-lint
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ ARG VERSION
# https://github.com/opencontainers/image-spec/blob/master/annotations.md
# Note: Additional labels are added by the build workflow.
LABEL org.opencontainers.image.authors="[email protected]"
LABEL org.opencontainers.image.vendor="Cyber and Infrastructure Security Agency"
LABEL org.opencontainers.image.vendor="Cybersecurity and Infrastructure Security Agency"

RUN apk add python3
RUN pip3 install --upgrade pip && pip3 install --upgrade awscli boto3 docopt
Expand Down
58 changes: 29 additions & 29 deletions bump_version.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,34 +14,34 @@ old_version=$(sed -n "s/^__version__ = \"\(.*\)\"$/\1/p" $VERSION_FILE)

if [ $# -ne 1 ]
then
echo "$HELP_INFORMATION"
echo "$HELP_INFORMATION"
else
case $1 in
major|minor|patch|prerelease|build)
new_version=$(python -c "import semver; print(semver.bump_$1('$old_version'))")
echo Changing version from "$old_version" to "$new_version"
tmp_file=/tmp/version.$$
sed "s/$old_version/$new_version/" $VERSION_FILE > $tmp_file
mv $tmp_file $VERSION_FILE
git add $VERSION_FILE
git commit -m"Bumping version from $old_version to $new_version"
git push
;;
finalize)
new_version=$(python -c "import semver; print(semver.finalize_version('$old_version'))")
echo Changing version from "$old_version" to "$new_version"
tmp_file=/tmp/version.$$
sed "s/$old_version/$new_version/" $VERSION_FILE > $tmp_file
mv $tmp_file $VERSION_FILE
git add $VERSION_FILE
git commit -m"Bumping version from $old_version to $new_version"
git push
;;
show)
echo "$old_version"
;;
*)
echo "$HELP_INFORMATION"
;;
esac
case $1 in
major|minor|patch|prerelease|build)
new_version=$(python -c "import semver; print(semver.bump_$1('$old_version'))")
echo Changing version from "$old_version" to "$new_version"
tmp_file=/tmp/version.$$
sed "s/$old_version/$new_version/" $VERSION_FILE > $tmp_file
mv $tmp_file $VERSION_FILE
git add $VERSION_FILE
git commit -m"Bumping version from $old_version to $new_version"
git push
;;
finalize)
new_version=$(python -c "import semver; print(semver.finalize_version('$old_version'))")
echo Changing version from "$old_version" to "$new_version"
tmp_file=/tmp/version.$$
sed "s/$old_version/$new_version/" $VERSION_FILE > $tmp_file
mv $tmp_file $VERSION_FILE
git add $VERSION_FILE
git commit -m"Bumping version from $old_version to $new_version"
git push
;;
show)
echo "$old_version"
;;
*)
echo "$HELP_INFORMATION"
;;
esac
fi
18 changes: 9 additions & 9 deletions push_readme.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,19 @@ set -o pipefail

echo "Logging in and requesting JWT..."
token=$(curl --silent --request POST \
--header "Content-Type: application/json" \
--data \
'{"username": "'"$DOCKER_USERNAME"'", "password": "'"$DOCKER_PASSWORD"'"}' \
--header "Content-Type: application/json" \
--data \
'{"username": "'"$DOCKER_USERNAME"'", "password": "'"$DOCKER_PASSWORD"'"}' \
https://hub.docker.com/v2/users/login/ | jq --raw-output .token)

echo "Pushing README file..."
code=$(jq --null-input --arg msg "$(<README.md)" \
'{"registry":"registry-1.docker.io","full_description": $msg }' | \
curl --silent --output /dev/null --location --write-out "%{http_code}" \
https://hub.docker.com/v2/repositories/"${IMAGE_NAME}"/ \
--data @- --request PATCH \
--header "Content-Type: application/json" \
--header "Authorization: JWT ${token}")
'{"registry":"registry-1.docker.io","full_description": $msg }' | \
curl --silent --output /dev/null --location --write-out "%{http_code}" \
https://hub.docker.com/v2/repositories/"${IMAGE_NAME}"/ \
--data @- --request PATCH \
--header "Content-Type: application/json" \
--header "Authorization: JWT ${token}")

if [[ "${code}" = "200" ]]; then
printf "Successfully pushed README to Docker Hub"
Expand Down
2 changes: 2 additions & 0 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
--requirement requirements-test.txt
ipython
14 changes: 7 additions & 7 deletions setup-env
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,14 @@ while (( "$#" )); do
shift
;;
-*) # unsupported flags
echo "Error: Unsupported flag $1" >&2
exit 1
;;
echo "Error: Unsupported flag $1" >&2
exit 1
;;
*) # preserve positional arguments
PARAMS="$PARAMS $1"
shift
;;
esac
PARAMS="$PARAMS $1"
shift
;;
esac
done

# set positional arguments in their proper place
Expand Down

0 comments on commit f0c07b2

Please sign in to comment.