Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Repository maintenance #19

Merged
merged 3 commits into from
Jan 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 15 additions & 3 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,27 @@ version: 2.1
# Define a job to be invoked later in a workflow.
# See: https://circleci.com/docs/2.0/configuration-reference/#jobs
jobs:
shellcheck:
docker:
- image: public.ecr.aws/debian/debian:11
steps:
- run:
name: "Install dependencies"
command: "apt-get update && DEBIAN_FRONTEND=noninteractive apt-get -y install shellcheck git ssh-client"
- checkout
- run:
name: "shellcheck"
command: "shellcheck -s bash -S warning ec2-metadata ec2nvme-nsid ec2udev-vbd ec2udev-vcpu"
code-checks-al2:
docker:
- image: public.ecr.aws/amazonlinux/amazonlinux:2
steps:
- checkout
- run:
name: "Install dependencies"
command: |
yum -y install python-pip git
pip install flake8
- checkout
- run:
name: "flake8"
command: "git grep -l '^#!/usr/bin/env python' | xargs flake8 ebsnvme-id"
Expand All @@ -23,11 +34,11 @@ jobs:
docker:
- image: public.ecr.aws/amazonlinux/amazonlinux:2
steps:
- checkout
- run:
name: "Install dependencies"
command: |
yum -y install rpm-build python
yum -y install rpm-build python git
- checkout
- run:
name: "rpmbuild"
command: "rpmbuild --define \"_sourcedir $PWD\" -bb amazon-ec2-utils.spec"
Expand All @@ -37,5 +48,6 @@ jobs:
workflows:
ci-workflow:
jobs:
- shellcheck
- code-checks-al2
- build-al2-rpm
11 changes: 6 additions & 5 deletions ec2-metadata
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ function set_imds_token()
# param1 = query
function get_meta()
{
local imds_out=$(curl -s -q -H "X-aws-ec2-metadata-token:${IMDS_TOKEN}" -f ${METADATA_BASEURL}/latest/${1})
local imds_out
imds_out=$(curl -s -q -H "X-aws-ec2-metadata-token:${IMDS_TOKEN}" -f ${METADATA_BASEURL}/latest/${1})
echo -n "${imds_out}"
}

Expand All @@ -81,7 +82,7 @@ function print_block-device-mapping()
x=$(get_meta meta-data/block-device-mapping/)
if [ -n "${x}" ]; then
for i in $x; do
echo -e '\t' $i: $(get_meta meta-data/block-device-mapping/$i)
echo -e '\t' $i: "$(get_meta meta-data/block-device-mapping/$i)"
done
else
echo not available
Expand All @@ -102,7 +103,7 @@ function print_public-keys()
format=$(get_meta meta-data/public-keys/$index/)
echo format:$format
echo 'key:(begins from next line)'
echo $(get_meta meta-data/public-keys/$index/$format)
echo "$(get_meta meta-data/public-keys/$index/$format)"
done
else
echo not available
Expand All @@ -116,7 +117,7 @@ function print_tags()
x=$(get_meta meta-data/tags/instance/)
if [ -n "${x}" ]; then
for i in $x; do
echo -e '\t' $i: $(get_meta meta-data/tags/instance/$i)
echo -e '\t' $i: "$(get_meta meta-data/tags/instance/$i)"
done
else
echo not available
Expand Down Expand Up @@ -198,7 +199,7 @@ while [ "$1" != "" ]; do
;;
-g | --tags ) print_tags
;;
-h | --help ) print_help
--help ) print_help

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see a reason for removing -h functionality here for help.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because -h is already used for --local-hostname

exit
;;
--all ) print_all
Expand Down