Compare commits

...

146 Commits

Author SHA1 Message Date
3wc
63c982c550 Fix custom commands loading
Some checks failed
continuous-integration/drone/push Build is failing
2020-12-17 13:38:30 +02:00
3wc
0d202eedfc Reënable custom per-stack commands
Some checks failed
continuous-integration/drone/push Build is failing
2020-12-14 12:33:22 +02:00
3wc
cb2d563ea0 Fix status header
Some checks failed
continuous-integration/drone/push Build is failing
2020-11-18 01:06:07 +02:00
3wc
059968a8cf Fix abra app ls --status 2020-11-18 00:40:26 +02:00
3wc
c57069e0af Use ABRA_DIR instead of hard-coding .abra 2020-11-18 00:39:41 +02:00
3wc
946a527baa Add app ... ps command, and some comments 2020-11-16 17:29:35 +02:00
89d530a553 Use printf instead of echo like docker docs do
Some checks failed
continuous-integration/drone/push Build is failing
2020-11-08 16:40:45 +01:00
25fe6808ad Use one line and strip newlines on generation
Some checks failed
continuous-integration/drone/push Build is failing
2020-11-08 16:34:26 +01:00
28b2d8ecc7 Strip whitespace 2020-11-08 16:34:21 +01:00
3wc
fd735a1310 Add app <domain> check to sniff out missing vars
Some checks failed
continuous-integration/drone/push Build is failing
Re #36
2020-11-06 23:14:26 +02:00
3wc
e307286db7 Add --status option to app ls
Some checks failed
continuous-integration/drone/push Build is failing
Closes #35
2020-11-06 22:35:48 +02:00
dd570e224b Ignore those build failures
All checks were successful
continuous-integration/drone/push Build is passing
2020-11-05 16:02:21 +01:00
f495ec0d94 Appease shellcheck
Some checks failed
continuous-integration/drone/push Build is failing
2020-11-05 16:00:50 +01:00
b75bce531b Merge pull request 'PASSWORD/KEY distinction+match for secret generation' (#33) from new-pass-keys-generation into main
Some checks failed
continuous-integration/drone/push Build is failing
Reviewed-on: https://git.autonomic.zone/coop-cloud/abra/pulls/33
2020-11-05 15:57:39 +01:00
0d62f01d5a Merge branch 'main' into new-pass-keys-generation
Some checks failed
continuous-integration/drone/pr Build is failing
2020-11-05 15:57:32 +01:00
eec55896a4 Implement password/key handling
Some checks failed
continuous-integration/drone/pr Build is failing
2020-11-05 15:56:31 +01:00
c2a56c6c09 Drop this broken catch-all
Some checks failed
continuous-integration/drone/push Build is failing
Closes https://git.autonomic.zone/coop-cloud/abra/issues/29.
2020-11-01 21:15:06 +01:00
74dfd75fb1 Use same [] style once more
Some checks failed
continuous-integration/drone/push Build is failing
2020-11-01 20:55:47 +01:00
e8c0efa91e Add --auto to app new for generation
Some checks failed
continuous-integration/drone/push Build is failing
Step one of https://git.autonomic.zone/coop-cloud/abra/issues/32.
2020-11-01 20:54:43 +01:00
6bae48431c Use same style as other [] options 2020-11-01 20:41:58 +01:00
3wc
543072ab37 Add zsh completion, remove compat hacks from bash
Some checks failed
continuous-integration/drone/push Build is failing
Ref #5
2020-11-01 21:09:33 +02:00
57e3a34133 Make sure to clone on deploy as well
Some checks failed
continuous-integration/drone/push Build is failing
2020-11-01 17:08:44 +01:00
33a49a8457 Trim whitespace
Some checks failed
continuous-integration/drone/push Build is failing
2020-11-01 17:05:13 +01:00
5806e40c1c Add require_app_clone 2020-11-01 17:05:10 +01:00
3wc
0d24a8e5cc Tryna fix Drone CI
Some checks failed
continuous-integration/drone/push Build is failing
2020-11-01 16:52:36 +02:00
3wc
e01f06423e Whoops! (Actual compopt fix
Some checks failed
continuous-integration/drone/push Build is failing
Ref #5
2020-11-01 15:22:45 +02:00
3wc
80f06ba0e1 Support >2 COMPOSE_FILEs
Some checks failed
continuous-integration/drone/push Build is failing
2020-10-31 17:51:56 +02:00
3wc
f8306b282d Split tests into separate files, add secret tests 2020-10-31 17:06:54 +02:00
3wc
2bdfe8baa8 Handle missing compopt
All checks were successful
continuous-integration/drone/push Build is passing
Ref #5
2020-10-30 21:40:59 +02:00
3wc
b226396764 Consistent y/n confirmation prompts 2020-10-30 20:57:13 +02:00
3wc
a3cd6d2281 Add git and bash to Drone test env
All checks were successful
continuous-integration/drone/push Build is passing
2020-10-30 18:32:01 +02:00
3wc
50651aeea1 Mollify shellcheck
Some checks failed
continuous-integration/drone/push Build is failing
2020-10-30 18:30:53 +02:00
3wc
57e24eaf0a Always run tests on local Docker 2020-10-30 18:30:43 +02:00
3wc
50ca4f8029 Tighten up options for secret commands
Some checks failed
continuous-integration/drone/push Build is failing
2020-10-30 18:24:22 +02:00
3wc
0433da3689 Fix subcommand -> function mapper
Some checks failed
continuous-integration/drone/push Build is failing
2020-10-30 18:17:06 +02:00
3wc
3e0b9e9475 Working completion app and server
Some checks failed
continuous-integration/drone/push Build is failing
2020-10-30 17:52:47 +02:00
3wc
c6b841de6c First stab 2020-10-30 17:52:47 +02:00
3wc
2daffc8694 Use bash select, tweak args 2020-10-30 17:52:46 +02:00
b15a214049 WIP: app secret rm
Some checks failed
continuous-integration/drone/push Build is failing
2020-10-30 02:09:59 +01:00
8d7194fcce Add quotes
Some checks failed
continuous-integration/drone/push Build is failing
2020-10-30 00:39:24 +01:00
188dc56dd1 Also run via sh 2020-10-30 00:34:37 +01:00
dbfe6f8097 Add initial CLI parsing for secret deletion
Some checks failed
continuous-integration/drone/push Build is failing
2020-10-30 00:32:03 +01:00
26b994ab84 Add --pass for new apps command
Some checks failed
continuous-integration/drone/push Build is failing
See https://git.autonomic.zone/coop-cloud/abra/issues/25.
2020-10-30 00:04:53 +01:00
3wc
dba3c391bd Handle missing tput gracefully
Some checks failed
continuous-integration/drone/push Build is failing
2020-10-29 19:40:19 +02:00
3wc
5a72ed0cfb Make config more chill, small gardening 2020-10-29 19:39:51 +02:00
3wc
b5d84d5e0d Test for git, container, and test app new ... 2020-10-29 19:38:42 +02:00
3wc
e3983c2440 Run bats in dind container, add git & bash 2020-10-29 19:38:15 +02:00
3wc
85b8a4f459 Add config command 2020-10-29 19:35:59 +02:00
3wc
6e38dc35e5 Fix run subcommand 2020-10-29 19:35:57 +02:00
841e4fc61a Explode if can't clone the app
Some checks failed
continuous-integration/drone/push Build is failing
2020-10-28 18:24:28 +01:00
c1d12eacc5 Fix typo 2020-10-28 18:24:15 +01:00
3b730d314b Use basename when listing servers for abra new
Some checks failed
continuous-integration/drone/push Build is failing
2020-10-28 18:05:53 +01:00
5df3a9fffb Account for 0 or 1 servers
Some checks failed
continuous-integration/drone/push Build is failing
2020-10-28 17:33:48 +01:00
3e3fe0e349 Create under servers directory
Some checks failed
continuous-integration/drone/push Build is failing
2020-10-28 17:32:38 +01:00
db766f4aec Don't explode if you already have the context 2020-10-28 17:32:30 +01:00
3wc
8909a46d8c Add --force option to app .. delete
Some checks failed
continuous-integration/drone/push Build is failing
2020-10-28 01:52:27 +02:00
3wc
8d139d4d28 Add undeploy/delete commands
Ref #4
2020-10-28 01:40:35 +02:00
3wc
b6b80298c2 Add .. secret auto command
Some checks failed
continuous-integration/drone/push Build is failing
2020-10-28 00:29:40 +02:00
3wc
b1e8ac4498 Local server list, more tidying 2020-10-27 23:46:03 +02:00
3wc
c5785089d6 Tidy up CLI commands, add app list
Some checks failed
continuous-integration/drone/push Build is failing
2020-10-27 21:38:20 +02:00
3wc
bec3272a41 .abra dir, abra new
Some checks failed
continuous-integration/drone/push Build is failing
Closes #24

Ref #21
2020-10-27 17:58:34 +02:00
dc3b772b72 Use server naming
Some checks failed
continuous-integration/drone/push Build is failing
2020-10-26 18:40:04 +01:00
07d4f8cbdf Remove abra.yml / yq stuff for now
Some checks failed
continuous-integration/drone/push Build is failing
2020-10-26 18:36:28 +01:00
37c59a53ef Drop interactive flags
All checks were successful
continuous-integration/drone/push Build is passing
2020-10-26 18:31:03 +01:00
87a54594f6 Fix typo, clean up after 2020-10-26 18:25:40 +01:00
e2e76edaaf Remove old test file
All checks were successful
continuous-integration/drone/push Build is passing
2020-10-26 18:19:41 +01:00
ab7772e8f7 Shuffle that
All checks were successful
continuous-integration/drone/push Build is passing
2020-10-26 18:16:54 +01:00
7304612f5f Use actual plugin
All checks were successful
continuous-integration/drone/push Build is passing
2020-10-26 18:14:41 +01:00
5a07f08ab3 Use new syntax
Some checks failed
continuous-integration/drone/push Build is failing
2020-10-26 18:13:23 +01:00
1e158cce55 Use cwd for coverage
Some checks failed
continuous-integration/drone/push Build is failing
2020-10-26 18:09:39 +01:00
2102193df1 Fix syntax 2020-10-26 18:05:27 +01:00
1b4258f1ea Add shellcheck target, drop default
All checks were successful
continuous-integration/drone/push Build is passing
2020-10-26 18:04:14 +01:00
cc060b8546 Fix error code 2020-10-26 18:02:24 +01:00
dce46603bf Add codecov target too
Some checks failed
continuous-integration/drone/push Build is failing
2020-10-26 18:01:12 +01:00
64d04a29ab Run full kcov 2020-10-26 18:01:00 +01:00
db7eb30447 Drop curl 2020-10-26 17:50:06 +01:00
f648b251bf Remove yq target and newline test target 2020-10-26 17:49:21 +01:00
86a790bbe4 Make tests run locally isolated 2020-10-26 17:48:19 +01:00
b423d61fce Remove install targets 2020-10-26 17:48:12 +01:00
f03c509552 Use shellcheck image 2020-10-26 17:40:02 +01:00
e6458e5e60 Update parser once more 2020-10-26 17:30:37 +01:00
9580199616 Remove extra secrets help 2020-10-26 17:19:32 +01:00
3wc
b59e902d18 Fix logs, cp, `multilogs
All checks were successful
continuous-integration/drone/push Build is passing
Ref #18
2020-10-26 16:55:43 +02:00
3wc
c50b1d8760 Goodbye, parse_subcommand! 👋
All checks were successful
continuous-integration/drone/push Build is passing
Ref #18
2020-10-26 16:08:15 +02:00
3wc
b49b510c43 Load custom commands in a function 2020-10-26 13:46:54 +02:00
3wc
b68bfdfb43 Regnerate Docopt
All checks were successful
continuous-integration/drone/push Build is passing
2020-10-26 13:35:58 +02:00
3wc
983e4af08c Use docopts variables
Some checks failed
continuous-integration/drone/push Build is failing
Ref #18
2020-10-26 13:34:49 +02:00
3wc
6cf7cf843a Update server subcommands 2020-10-26 13:34:30 +02:00
3wc
d37d8a0c66 Add default --tail option to abra logs 2020-10-26 13:33:56 +02:00
da33064a5f Add codecov badge
All checks were successful
continuous-integration/drone/push Build is passing
2020-10-26 11:49:06 +01:00
be2fffd858 Run plain bin
All checks were successful
continuous-integration/drone/push Build is passing
2020-10-26 11:40:41 +01:00
38f0c92bc7 Try avoid error exit code
Some checks failed
continuous-integration/drone/push Build is failing
2020-10-26 11:38:32 +01:00
c1fbb75657 Wait a sec, collect, not just report 2020-10-26 11:37:13 +01:00
33fd0eeb8d Point codecov at report folder 2020-10-26 11:36:12 +01:00
5955505752 Get reports only 2020-10-26 11:36:04 +01:00
e022fe2310 Use kcov image
Some checks failed
continuous-integration/drone/push Build is failing
2020-10-26 11:28:19 +01:00
02fa9025dc Install kcov directly now
Some checks failed
continuous-integration/drone/push Build is failing
2020-10-26 11:26:28 +01:00
2250713c05 Split up codecov steps
Some checks failed
continuous-integration/drone/push Build is failing
2020-10-26 11:25:55 +01:00
2b77cfebf9 Disable failing test for now 2020-10-26 11:25:39 +01:00
aff01e6741 Install kcov holding package
Some checks failed
continuous-integration/drone/push Build is failing
2020-10-26 11:24:05 +01:00
0eb5d14ad8 Drop unit tests temporarily
Some checks failed
continuous-integration/drone/push Build is failing
2020-10-26 11:21:58 +01:00
6d6208a63c Add code coverage CI
Some checks failed
continuous-integration/drone/push Build is failing
2020-10-26 11:20:17 +01:00
1e059ffe7f Add coverage target 2020-10-26 11:20:09 +01:00
eb12f2392c Ignore coverage folder 2020-10-26 11:19:38 +01:00
a13e58c6c0 Finally work out subcommands
Some checks failed
continuous-integration/drone/push Build is failing
2020-10-26 10:05:03 +01:00
44c41830a7 Finalise docopt parser integration
Some checks failed
continuous-integration/drone/push Build is failing
2020-10-26 09:46:14 +01:00
ae6c2c26ae A first stab at docopt-sh integration
Some checks failed
continuous-integration/drone/push Build is failing
2020-10-25 21:41:17 +01:00
dad72c820a Re-jig names and add test target in Makefile
All checks were successful
continuous-integration/drone/push Build is passing
2020-10-25 21:31:41 +01:00
eec9a8ba1a Add link to site
All checks were successful
continuous-integration/drone/push Build is passing
2020-10-25 21:22:29 +01:00
bf44270b3d Make CI zippier with alpine
All checks were successful
continuous-integration/drone/push Build is passing
2020-10-25 21:19:14 +01:00
4bf1dbd7eb Spacing and naming 2020-10-25 21:17:01 +01:00
4ca1026c2c Don't test against dir that doesnt exist 2020-10-25 21:16:42 +01:00
891b2cc6c9 Add place holders for change log
Some checks failed
continuous-integration/drone/push Build is failing
2020-10-25 21:13:33 +01:00
4de7f24d8e Start moving installer scripts over 2020-10-25 21:08:08 +01:00
ad1063a0cc Trim down README for now 2020-10-25 21:08:03 +01:00
3wc
4cfe143326 Install docker using convenience script
All checks were successful
continuous-integration/drone/push Build is passing
2020-10-23 05:13:06 +02:00
3wc
16cc5d9cf7 Fix tests
Some checks failed
continuous-integration/drone/push Build is failing
2020-10-23 05:04:35 +02:00
3wc
9d22797dc8 Attempt to test using bats / drone
Some checks failed
continuous-integration/drone/push Build is failing
2020-10-23 05:03:01 +02:00
3wc
16a09887e6 Rename abra context to abra server 2020-10-23 05:02:39 +02:00
3wc
b7757b51b1 Fix abra run if there are 2 containers up
All checks were successful
continuous-integration/drone/push Build is passing
2020-10-23 03:58:55 +02:00
3c7c7694bf Merge pull request 'Adapt --help output to Click-like format' (#20) from new-help into main
All checks were successful
continuous-integration/drone/push Build is passing
Reviewed-on: https://git.autonomic.zone/autonomic-cooperative/abra/pulls/20
2020-10-23 03:56:50 +02:00
f15dfd9f5f First stab at new help
All checks were successful
continuous-integration/drone/pr Build is passing
2020-10-22 21:16:30 +02:00
3wc
66dcaedfd0 Add stack and volume as shortcuts to docker
All checks were successful
continuous-integration/drone/push Build is passing
2020-10-06 20:27:50 +02:00
3wc
6598aabc37 Work even if a local path contains $SERVICE
All checks were successful
continuous-integration/drone/push Build is passing
2020-10-01 01:08:29 +02:00
3wc
6759e6a175 Show multiple COMPOSE_FILEs better
All checks were successful
continuous-integration/drone/push Build is passing
Fixes #16
2020-09-29 00:17:26 +02:00
3wc
8735362580 Load custom commands from $ABRA_STACK_DIR too
All checks were successful
continuous-integration/drone/push Build is passing
2020-09-28 15:02:18 +02:00
3wc
7223dca951 Re-enable running commands as another user
All checks were successful
continuous-integration/drone/push Build is passing
Fixes #14
2020-09-27 23:45:39 +02:00
3wc
dd9444b036 Add context init command to set up remote swarm
All checks were successful
continuous-integration/drone/push Build is passing
2020-09-27 13:26:27 +02:00
3wc
81e24b6f72 Remove debugging from secret_generate 2020-09-27 13:26:15 +02:00
16292df5f6 Fix installer and mark new patch
All checks were successful
continuous-integration/drone/push Build is passing
2020-09-27 08:20:36 +02:00
92c91ddbb0 Add log entry
All checks were successful
continuous-integration/drone/push Build is passing
2020-09-27 08:17:00 +02:00
cff9b13f60 Remove quote
All checks were successful
continuous-integration/drone/push Build is passing
2020-09-27 08:04:22 +02:00
0444991636 Fix ticks
All checks were successful
continuous-integration/drone/push Build is passing
2020-09-27 08:04:03 +02:00
28ba33b18e Fix indentation
All checks were successful
continuous-integration/drone/push Build is passing
2020-09-27 08:03:39 +02:00
3wc
77eb83b128 Add credit to sub_multilogs
All checks were successful
continuous-integration/drone/push Build is passing
2020-09-25 00:48:46 +02:00
3wc
ff7fcf2201 Combined logging
All checks were successful
continuous-integration/drone/push Build is passing
Closes #8
2020-09-25 00:36:23 +02:00
3wc
b0d525a980 Tweak usage text 2020-09-24 21:19:40 +02:00
3wc
aa1ffd5d8a Add success() method & secret insert subcommand 2020-09-24 21:17:08 +02:00
3wc
5627e67bf7 Bail if we can't load the specified $ABRA_ENV
Some checks failed
continuous-integration/drone/push Build is failing
2020-09-24 14:47:00 +02:00
3wc
29343369f3 Further tidy-up (+ add warning()) 2020-09-24 14:47:00 +02:00
3wc
427ed97678 Update README and tweak default STACK_DIR 2020-09-24 14:47:00 +02:00
3wc
b01fee3c86 Add -e, -c and ABRA_STACK_DIR options..
..and tidy up a little
2020-09-24 14:46:57 +02:00
949246821f Clarify versioning
All checks were successful
continuous-integration/drone/push Build is passing
2020-09-24 09:19:58 +02:00
60f2892acd Fix CI
All checks were successful
continuous-integration/drone/push Build is passing
2020-09-24 09:18:31 +02:00
0268685cfa Declare minor bump
Some checks failed
continuous-integration/drone/push Build is failing
2020-09-24 09:09:46 +02:00
dd4f31d9a1 Switch over to scripts.d
Some checks failed
continuous-integration/drone/push Build is failing
2020-09-24 09:03:25 +02:00
14 changed files with 1359 additions and 279 deletions

View File

@ -3,11 +3,31 @@ kind: pipeline
name: linters
steps:
- name: run shellcheck
image: debian:buster
image: koalaman/shellcheck-alpine:latest
commands:
- apt update
- apt install -y shellcheck
- shellcheck abra installer
- shellcheck abra
- name: run unit tests
image: docker:dind
commands:
- apk add bats git bash
- bats tests
- name: collect code coverage
failure: ignore # until we fix this
image: kcov/kcov:latest
commands:
- apk add bats git bash
- kcov . bats tests || true
- name: send code coverage report to codecov
failure: ignore # until we fix this
image: plugins/codecov
settings:
token:
from_secret: codecov_token
required: true
trigger:
branch:
- main

2
.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
coverage/
/.venv

View File

@ -1,3 +1,20 @@
# abra x.x.x (UNRELEASED)
- ???
# abra 0.3.1 (2020-09-27)
- Fix installer version
# abra 0.3.0 (2020-09-27)
- Add multilogs stack logs implementation ([#8](https://git.autonomic.zone/compose-stacks/abra/issues/8)
- Add beginnings of "monorepo" functionality
# abra 0.2.0 (2020-09-24)
- Prepare for swarm install script using script.d ([#12](https://git.autonomic.zone/compose-stacks/planning/issues/12))
# abra 0.1.2 (2020-09-22)
- Add upgrade command ([#10](https://git.autonomic.zone/autonomic-cooperative/abra/issues/10))

View File

@ -1,14 +1,38 @@
default: install
.PHONY: test shellcheck docopt kcov codecov
dev_install:
ln -sf $(PWD)/abra ~/.local/bin
test:
@DOCKER_CONTEXT=default docker run \
-it \
--rm \
-v $$(pwd):/workdir \
docker:dind \
sh -c "apk add bats git bash && cd /workdir && bats /workdir/test.bats"
install:
install abra /usr/bin/abra
shellcheck:
@docker run \
-it \
--rm \
-v $$(pwd):/workdir \
koalaman/shellcheck-alpine \
shellcheck /workdir/abra
get_yq:
wget https://github.com/mikefarah/yq/releases/download/3.3.2/yq_linux_amd64 && \
chmod +x yq_linux_amd64 && \
mv yq_linux_amd64 yq
docopt:
@if [ ! -d ".venv" ]; then \
python3 -m venv .venv && \
.venv/bin/pip install -U pip setuptools wheel && \
.venv/bin/pip install docopt-sh; \
fi
.venv/bin/docopt.sh abra
.PHONY: dev_install install get_yq
kcov:
@docker run \
-it \
--rm \
-v $$(pwd):/workdir \
kcov/kcov:latest \
sh -c "kcov /workdir/coverage /workdir/abra || true"
codecov: SHELL:=/bin/bash
codecov:
@bash <(curl -s https://codecov.io/bash) \
-s coverage -t $$(pass show hosts/swarm.autonomic.zone/drone/codecov/token)

View File

@ -1,31 +1,14 @@
# abra
[![Build Status](https://drone.autonomic.zone/api/badges/autonomic-cooperative/abra/status.svg)](https://drone.autonomic.zone/autonomic-cooperative/abra)
[![Build Status](https://drone.autonomic.zone/api/badges/coop-cloud/abra/status.svg)](https://drone.autonomic.zone/coop-cloud/abra)
[![codecov](https://codecov.io/gh/Autonomic-Cooperative/abra/branch/main/graph/badge.svg?token=aX3I5NMRsj)](undefined)
Docker stack magic 🎩🐇
> https://cloud.autonomic.zone
The cooperative cloud utility belt 🎩🐇
## Install
```sh
curl -fsSL https://install.abra.autonomic.zone | bash
curl https://install.abra.autonomic.zone | bash
```
Specific releases are available via the project [release page](https://git.autonomic.zone/autonomic-cooperative/abra/releases).
## Changes
See [CHANGELOG.md](./CHANGELOG.md).
## Hacking
```sh
git clone ssh://git@git.autonomic.zone:2222/autonomic-cooperative/abra.git
cd abra
make dev_install
```
See [autonomic-cooperative/installer-scripts](https://git.autonomic.zone/autonomic-cooperative/installer-scripts) for the installer script deployment. To make a release, just add an entry to [CHANGELOG.md](./CHANGELOG.md) and the [installer](./installer) (following [semver](https://semver.org/) please) and then `git tag x.x.x && git push origin main --tags`. If you want the [installer-scripts](https://git.autonomic.zone/autonomic-cooperative/installer-scripts) deployment to pick that up, you'll need to change the version number in the [Makefile](https://git.autonomic.zone/autonomic-cooperative/installer-scripts/src/branch/main/Makefile) and run `make` in that repository and push the changes.
## Examples
- `abra run mariadb mysqldump gitea -p'GdIbMeS09SURRktBnm3jcTufsL5z0MPd' | gzip > ../git.autonomic.zone_mariadb_`date +%F`.sql.gz`

1222
abra

File diff suppressed because it is too large Load Diff

52
completion/_abra Normal file
View File

@ -0,0 +1,52 @@
#compdef abra
_abra () {
local context state line curcontext="$curcontext" ret=1
_arguments -n : \
{-h,--help}'[Help message]' \
'1:commands:(app server)' \
'*::arguments:->arguments' \
&& ret=0
case $state in
(arguments)
curcontext="${curcontext%:*:*}:abra-arguments-$words[1]:"
case $words[1] in
(app)
_arguments \
'1: :_abra_apps' \
&& ret=0
;;
(server)
_arguments \
'1:servers:_abra_servers' \
&& ret=0
;;
esac
;;
esac
return ret
}
_abra_servers() {
_path_files -/W $HOME/.abra/servers
}
_abra_apps()
{
local newapps apps=($HOME/.abra/servers/*/*.env)
typeset -a apps
newapps=()
for app in $apps; do
newapps+=($(_abra_basename "${app}"))
done
_describe -t apps 'app' newapps
}
_abra_basename()
{
printf -- "${1##*/}"
}
_abra "$@"

117
completion/abra.bash Normal file
View File

@ -0,0 +1,117 @@
#!/usr/bin/env bash
_abra_basename()
{
echo "${1##*/}"
}
_abra_servers()
{
# FIXME 3wc: copied from abra/get_servers()
shopt -s nullglob dotglob
local SERVERS=(~/.abra/servers/*)
shopt -u nullglob dotglob
for SERVER in "${SERVERS[@]}"; do
_abra_basename "${SERVER}"
done
}
_abra_complete_servers()
{
mapfile -t COMPREPLY < <(compgen -W "$(_abra_servers)" -- "$1")
}
_abra_apps()
{
shopt -s nullglob dotglob
local APPS=(~/.abra/servers/*/*.env)
shopt -u nullglob dotglob
for APP in "${APPS[@]}"; do
_abra_basename "${APP%.env}"
done
}
_abra_complete_apps()
{
mapfile -t COMPREPLY < <(compgen -W "$(_abra_apps)" -- "$1")
}
_abra_complete()
{
compopt +o default +o nospace
COMPREPLY=()
local -r cmds='
app
server
'
local -r short_opts='-e -h -s -v'
local -r long_opts='--env --help --stack --version'
# Scan through the command line and find the abra command
# (if present), as well as its expected position.
local cmd
local cmd_index=1 # Expected index of the command token.
local i
for (( i = 1; i < ${#COMP_WORDS[@]}; i++ )); do
local word="${COMP_WORDS[i]}"
case "$word" in
-*)
((cmd_index++))
;;
*)
cmd="$word"
break
;;
esac
done
local cur="${COMP_WORDS[COMP_CWORD]}"
if (( COMP_CWORD < cmd_index )); then
# Offer option completions.
case "$cur" in
--*)
mapfile -t COMPREPLY < <(compgen -W "$long_opts" -- "$cur")
;;
-*)
mapfile -t COMPREPLY < <(compgen -W "$short_opts" -- "$cur")
;;
*)
# Skip completion; we should never get here.
;;
esac
elif (( COMP_CWORD == cmd_index )); then
# Offer command name completions.
mapfile -t COMPREPLY < <(compgen -W "$cmds" -- "$cur")
else
# Offer command argument completions.
case "$cmd" in
server)
# Offer exactly one server name completion.
if (( COMP_CWORD == cmd_index + 2 )); then
_abra_complete_servers "$cur"
fi
;;
app)
# Offer exactly one app completion.
if (( COMP_CWORD == cmd_index + 1 )); then
_abra_complete_apps "$cur"
fi
;;
#help)
# # Offer exactly one command name completion.
# if (( COMP_CWORD == cmd_index + 1 )); then
# COMPREPLY=($(compgen -W "$cmds" -- "$cur"))
# fi
# ;;
*)
# Unknown command or unknowable argument.
;;
esac
fi
}
complete -o default -F _abra_complete abra

40
installer/compose.yml Normal file
View File

@ -0,0 +1,40 @@
---
version: "3.8"
services:
abra_installer:
image: "nginx:stable"
configs:
- source: abra_conf
target: /etc/nginx/conf.d/abra.conf
- source: abra_installer
target: /var/www/abra-installer/installer
volumes:
- "public:/var/www/abra-installer"
networks:
- proxy
deploy:
update_config:
failure_action: rollback
order: start-first
labels:
- "traefik.enable=true"
- "traefik.http.services.abra-installer.loadbalancer.server.port=80"
- "traefik.http.routers.abra-installer.rule=Host(`install.abra.autonomic.zone`)"
- "traefik.http.routers.abra-installer.entrypoints=web-secure"
- "traefik.http.routers.abra-installer.tls.certresolver=production"
configs:
abra_installer:
name: abra_installer_v1
file: installer
abra_conf:
name: abra_conf_v1
file: nginx.conf
networks:
proxy:
external: true
volumes:
public:

View File

@ -1,7 +1,7 @@
#!/bin/bash
ABRA_VERSION="0.1.2"
ABRA_SRC="https://git.autonomic.zone/autonomic-cooperative/abra/raw/tag/$ABRA_VERSION/abra"
ABRA_VERSION="0.3.1"
ABRA_SRC="https://git.autonomic.zone/coop-cloud/abra/raw/tag/$ABRA_VERSION/abra"
function install_abra {
mkdir -p "$HOME/.local/bin"

10
installer/nginx.conf Normal file
View File

@ -0,0 +1,10 @@
server {
listen 80 default_server;
server_name install.abra.autonomic.zone;
location / {
root /var/www/abra-installer;
add_header Content-Type text/plain;
index installer;
}
}

View File

@ -1,7 +0,0 @@
---
name: mystack
secrets:
foo:
bar:
baz:
length: 128

17
tests/01_environment.bats Normal file
View File

@ -0,0 +1,17 @@
#!/usr/bin/env bats
@test "docker is available" {
command -v docker
}
@test "abra is executable" {
./abra --help
}
@test "git is available" {
command -v git
}
@test "running in a container" {
ls /etc/alpine-release
}

49
tests/02_abra.bats Normal file
View File

@ -0,0 +1,49 @@
#!/usr/bin/env bats
setup() {
mkdir -p ~/.abra/servers/default
}
teardown() {
rm -rf ~/.abra/servers/default
rm -rf ~/.abra/servers/swarm.test.com
}
@test "abra server add/rm works" {
./abra server add swarm.test.com
docker context ls | grep swarm.test.com
[ -d ~/.abra/servers/swarm.test.com ]
./abra server rm swarm.test.com
./abra server add swarm.test.com foobar 12345
[ -d ~/.abra/servers/swarm.test.com ]
./abra server rm swarm.test.com
}
@test "abra app new/rm works" {
./abra app new --server default --domain traefik.test.com traefik
[ -f ~/.abra/servers/default/traefik.test.com.env ]
# interactive prompt
echo "y" | ./abra app traefik.test.com delete
[ ! -f ~/.abra/servers/default/traefik.test.com.env ]
# --force
./abra app new --server default --domain traefik.test.com traefik
./abra app traefik.test.com delete --force
[ ! -f ~/.abra/servers/default/traefik.test.com.env ]
}
@test "abra app <domain> secret (insert|generate|rm)" {
# TODO 3wc: mock `server new` so we don't endlessly re-test it
./abra app new --server default --domain traefik.test.com traefik
./abra app traefik.test.com secret insert foobar v1 "foobar"
# interactive prompt
echo "y" | ./abra app traefik.test.com secret rm foobar
./abra app traefik.test.com secret insert foobar v1 "foobar"
# prompt
./abra app traefik.test.com secret rm foobar --force
}