Skip to content

Commit

Permalink
feat: Initial alpha release
Browse files Browse the repository at this point in the history
### Added

- Adds the APIClient class for simplying creation of sessions, connections, and
  making API calls
- Adds the ModelBase dataclass for data models to inherit from
- Adds dataclasses for Organizations data models: Organization, Account,
  OrganizationalUnit, etc
- Adds the OrganizationsDataBuilder class for querying the Organizations APIs to build
  up the data model
- Adds a CLI tool as an extra that can be installed. Supports dumping an organization
  data model
- Adds configuration for packaging and publishing to PyPI
- Adds Git pre-commit config w/ linting
  • Loading branch information
timoguin authored and Tim O'Guin committed Jun 10, 2021
1 parent c14565a commit fbce41d
Show file tree
Hide file tree
Showing 18 changed files with 3,260 additions and 83 deletions.
Empty file added .editorconfig
Empty file.
2 changes: 1 addition & 1 deletion .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ until they're ready to be submitted upstream via a PR.


<!-- Markdown anchors -->
[GitHub Issues]: https://github.com/timoguin/repo-template/issues).
[GitHub Issues]: https://github.com/timoguin/aws-org-tools-py/issues).
[README]: README.md
[Readme Driven Development]: https://tom.preston-werner.com/2010/08/23/readme-driven-development.html
[CHANGELOG]: CHANGELOG.md
Expand Down
2 changes: 1 addition & 1 deletion .github/SECURITY.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ Maintainers:
- Tim O'Guin <[email protected]>

<!-- Markdown anchors -->
[open an issue]: https://github.com/timoguin/repo-template/issues
[open an issue]: https://github.com/timoguin/aws-org-tools-py/issues
17 changes: 17 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# pre-commit run --all-files
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v3.4.0
hooks:
- id: end-of-file-fixer
- id: trailing-whitespace
- id: mixed-line-ending
- repo: https://github.com/psf/black
rev: 20.8b1
hooks:
- id: black
- repo: https://github.com/asottile/blacken-docs
rev: v1.9.1
hooks:
- id: blacken-docs
additional_dependencies: [black==20.8b1]
20 changes: 14 additions & 6 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,26 @@ Upcoming changes.

### Removed

## [0.0.1] - YYYY-MM-DD
## [0.1.0-alpha4] - 2020-06-09

Initial Release.
Initial alpha release

### Added

- What was added.

- Adds the APIClient class for simplying creation of sessions, connections, and
making API calls
- Adds the ModelBase dataclass for data models to inherit from
- Adds dataclasses for Organizations data models: Organization, Account,
OrganizationalUnit, etc
- Adds the OrganizationsDataBuilder class for querying the Organizations APIs to build
up the data model
- Adds a CLI tool as an extra that can be installed
- Adds configuration for packaging and publishing to PyPI
- Adds Git pre-commit config w/ linting

<!--
These Markdown anchors provide a link to the diff for each release. They should be
updated any time a new release is cut.
-->
[Unreleased]: https://github.com/timoguin/repo-template/compare/v0.0.1...HEAD
[0.0.1]: https://github.com/timoguin/repo-template/releases/tag/v0.0.1
[Unreleased]: https://github.com/timoguin/aws-org-tools-py/compare/v0.1.0-alpha4...HEAD
[0.1.0-alpha4]: https://github.com/timoguin/aws-org-tools-py/releases/tag/v0.1.0-alpha4
115 changes: 115 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
DEPS ?=awk docker docker-compose grep poetry realpath sed
AWS_OKTA_PROFILE ?=
PY_INSTALL_ARGS ?=--extras="cli devtools docs"
VENV_DIR ?=.venv
CMD ?=/bin/bash
DEBUG ?=false

ifeq (${DEBUG},true)
export PYTHONBREAKPOINT=ipdb.set_trace
else
export PYTHONBREAKPOINT=0
endif

ifneq (${AWS_OKTA_PROFILE},)
SHELL_CMD_PREFIX =aws-okta exec ${AWS_OKTA_PROFILE} --
endif

.PHONY: default
default: help

.PHONY: shell ## Activate the Python virtual environment in a subshell
shell: ${VENV_DIR}
@${SHELL_CMD_PREFIX} poetry shell --quiet --no-interaction

.PHONY: shellcmd ## Run a command (CMD arg)in the activated Python venv
shellcmd: ${VENV_DIR}
@${SHELL_CMD_PREFIX} /bin/bash -c "poetry run ${CMD}"

.PHONY: test-integration ## Run the integration test suite
test-integration: run-test-server
@printf "${OK}%s...\n${CCEND}" "Starting motoserver"
@docker-compose --log-level ERROR up --detach >/dev/null
@pushd tests >/dev/null && ./test.sh && popd >/dev/null || popd >/dev/null

.PHONY: run-test-server ## Start motoserver with docker-compose if it's not running
run-test-server:
@CONTAINER_ID=$$(docker-compose ps --quiet motoserver 2>/dev/null); \
CONTAINER_START=0; \
if [ "$$CONTAINER_ID" != "" ]; then \
if ! $$(docker ps --quiet --no-trunc | grep --quiet "$$CONTAINER_ID"); then \
CONTAINER_START=1; \
fi; \
else \
CONTAINER_START=1; \
fi; \
if [ $$CONTAINER_START -eq 1 ]; then \
docker-compose up --detach --no-recreate --remove-orphans; \
fi

.PHONY: stop-test-server ## Stop motoserver container(s)
stop-test-server:
@docker-compose down --remove-orphans --volumes

.PHONY: build ## Build the Python package for distribution
build: ${VENV_DIR}
@poetry build --quiet --no-interaction

# Ensures the Python venv exists and has dependencies installed
${VENV_DIR}:
@python -m venv ${VENV_DIR} >/dev/null
@${VENV_DIR}/bin/pip install --quiet --upgrade pip
@make python-install-deps

.PHONY: python-install-deps ## Install Python dependencies in the venv
python-install-deps: ${VENV_DIR}
@poetry install --quiet --no-interaction ${PY_INSTALL_ARGS}

.PHONY: python-update-deps ## Update Python dependencies in the venv
python-update-deps: ${VENV_DIR}
@poetry update --quiet --no-interaction

.PHONY: python-update-lock ## Update Python dependency lock file
python-update-lock:
@poetry update --quiet --no-interaction --lock

.PHONY: clean ## Remove temp files and build artifacts
clean:
@find . -path ./${VENV_DIR} -prune -false -o -type f -iname '*.pyc' -delete
@find . -path ./${VENV_DIR} -prune -false -o \
-type d \( -name 'dist' -o -name '__pycache__' \) \
-exec rm -rf "{}" +
@poetry install --remove-untracked --quiet

.PHONY: clean-all ## Run clean, remove the Python venv and untracked / ignored Git files
clean-all: clean
@git clean --quiet --force -d -f -x
@docker-compose down --rmi 'all' --volumes --remove-orphans

.PHONY: help
help:
@echo "Available commands:"
@echo
@cat Makefile \
| grep -E '^\.PHONY: [a-zA-Z_-]+ ## .*$$' \
| sed 's/^\.PHONY: //' \
| awk 'BEGIN {FS = " ## "}; {printf "\033[36mmake %-30s\033[0m %s\n", $$1, $$2}'
@echo

.PHONY: deps ## Check that dependencies are installed
deps:
@deps_not_found=; \
for dep in ${DEPS}; do \
if ! command -v $$dep &> /dev/null; then deps_not_found+="$$dep "; fi; \
done; \
if [ "$$deps_not_found" != "" ]; then \
printf "${ERROR}%s${CCEND}\n" \
"This script has unmet dependencies: $$deps_not_found"; \
exit 1; \
fi

# Colors
OK ="\\033[32m"
WARN ="\\033[33m"
ERROR ="\\033[31m"
CCEND ="\\033[0m"
Loading

0 comments on commit fbce41d

Please sign in to comment.