forked from toolshed/abra
		
	Compare commits
	
		
			13 Commits
		
	
	
		
			0.1.0-alph
			...
			0.1.2-alph
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 719e24eb80 | |||
| c441a1ab52 | |||
| b0460bd923 | |||
| f1659b3bda | |||
| eb4a2b3339 | |||
| 265bfe92fd | |||
| 1757fabb89 | |||
| abf0ebf41d | |||
| 45f1692c99 | |||
| 48bc03db51 | |||
| f0e966afc3 | |||
| a1d1166308 | |||
| 1438fdf3c2 | 
| @ -22,6 +22,7 @@ archives: | ||||
|       linux: Linux | ||||
|       386: i386 | ||||
|       amd64: x86_64 | ||||
|     format: binary | ||||
| checksum: | ||||
|   name_template: "checksums.txt" | ||||
| snapshot: | ||||
|  | ||||
							
								
								
									
										38
									
								
								README.md
									
									
									
									
									
								
							
							
						
						
									
										38
									
								
								README.md
									
									
									
									
									
								
							| @ -38,6 +38,27 @@ make install | ||||
|  | ||||
| The abra binary will be in `$GOPATH/bin`. | ||||
|  | ||||
| ## Autocompletion | ||||
|  | ||||
| **bash** | ||||
|  | ||||
| Copy `autocomplete/bash_autocomplete` into `/etc/bash_completion.d/` and rename | ||||
| it to abra. | ||||
| ``` | ||||
| sudo cp autocomplete/bash_autocomplete /etc/bash_completion.d/abra | ||||
| source /etc/bash_completion.d/abra | ||||
| ``` | ||||
|  | ||||
| **(fi)zsh** | ||||
|  | ||||
| (fi)zsh doesn't have an autocompletion folder by default but you can create one, then copy `zsh_autocomplete` into it and add a couple lines to your `~/.zshrc` or `~/.fizsh/.fizshrc` | ||||
| ``` | ||||
| sudo mkdir /etc/zsh/completion.d/ | ||||
| sudo cp autocomplete/zsh_autocomplete /etc/zsh/completion.d/abra | ||||
| echo "PROG=abra\n_CLI_ZSH_AUTOCOMPLETE_HACK=1\nsource /etc/zsh/completion.d/abra" >> ~/.zshrc | ||||
| ``` | ||||
| (replace .zshrc with ~/.fizsh/.fizshrc if you use fizsh) | ||||
|  | ||||
| ## Hacking | ||||
|  | ||||
| Install direnv, run `cp .envrc.sample .envrc`, then run `direnv allow` in this directory. This will set coopcloud repos as private due to [this bug.](https://git.coopcloud.tech/coop-cloud/coopcloud.tech/issues/20#issuecomment-8201). Or you can run `go env -w GOPRIVATE=coopcloud.tech` but I'm not sure how persistent this is. | ||||
| @ -54,11 +75,18 @@ Please use the [conventional commit format](https://www.conventionalcommits.org/ | ||||
|  | ||||
| ## Versioning | ||||
|  | ||||
| We use [goreleaser](https://goreleaser.com) to help us automate releases. We | ||||
| use [semver](https://semver.org) for versioning all releases of the tool. While | ||||
| we are still in the public alpha release phase, we will maintain a | ||||
| `0.y.z-alpha` format. Change logs are generated from our commit logs. We are | ||||
| still working this out and aim to refine our release praxis as we go. | ||||
| We use [goreleaser](https://goreleaser.com) to help us automate releases. We use [semver](https://semver.org) for versioning all releases of the tool. While we are still in the public alpha release phase, we will maintain a `0.y.z-alpha` format. Change logs are generated from our commit logs. We are still working this out and aim to refine our release praxis as we go. | ||||
|  | ||||
| For developers, while using this `-alpha` format, the `y` part is the "major" version part. So, if you make breaking changes, you increment that and _not_ the `x` part. So, if you're on `0.1.0-alpha`, then you'd go to `0.1.1-alpha` for a backwards compatible change and `0.2.0-alpha` for a backwards incompatible change. | ||||
|  | ||||
| ## Making a new release | ||||
|  | ||||
| - Change `ABRA_VERSION` to match the new tag in [`scripts`](./scripts/installer/installer) (use [semver](https://semver.org)) | ||||
| - Commit that change (e.g. `git commit -m 'chore: publish next tag 0.3.1-alpha'`) | ||||
| - Make a new tag (e.g. `git tag 0.y.z-alpha`) | ||||
| - Push the new tag (e.g. `git push && git push --tags`) | ||||
| - Wait until the build finishes on [build.coopcloud.tech](https://build.coopcloud.tech/coop-cloud/abra) | ||||
| - Check the release worked, (e.g. `abra upgrade; abra version`) | ||||
|  | ||||
| ## Fork maintenance | ||||
|  | ||||
|  | ||||
							
								
								
									
										2
									
								
								TODO.md
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								TODO.md
									
									
									
									
									
								
							| @ -42,7 +42,7 @@ | ||||
|     - [x] `sync` | ||||
|     - [x] `versions` | ||||
|     - [x] `lint` | ||||
|   - [ ] `upgrade` | ||||
|   - [x] `upgrade` | ||||
|   - [x] `version` | ||||
|  | ||||
| ## Next phase | ||||
|  | ||||
							
								
								
									
										21
									
								
								autocomplete/bash_autocomplete
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										21
									
								
								autocomplete/bash_autocomplete
									
									
									
									
									
										Executable file
									
								
							| @ -0,0 +1,21 @@ | ||||
| #! /bin/bash | ||||
|  | ||||
| : ${PROG:=$(basename ${BASH_SOURCE})} | ||||
|  | ||||
| _cli_bash_autocomplete() { | ||||
|   if [[ "${COMP_WORDS[0]}" != "source" ]]; then | ||||
|     local cur opts base | ||||
|     COMPREPLY=() | ||||
|     cur="${COMP_WORDS[COMP_CWORD]}" | ||||
|     if [[ "$cur" == "-"* ]]; then | ||||
|       opts=$( ${COMP_WORDS[@]:0:$COMP_CWORD} ${cur} --generate-bash-completion ) | ||||
|     else | ||||
|       opts=$( ${COMP_WORDS[@]:0:$COMP_CWORD} --generate-bash-completion ) | ||||
|     fi | ||||
|     COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) ) | ||||
|     return 0 | ||||
|   fi | ||||
| } | ||||
|  | ||||
| complete -o bashdefault -o default -o nospace -F _cli_bash_autocomplete $PROG | ||||
| unset PROG | ||||
							
								
								
									
										9
									
								
								autocomplete/powershell_autocomplete.ps1
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										9
									
								
								autocomplete/powershell_autocomplete.ps1
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,9 @@ | ||||
| $fn = $($MyInvocation.MyCommand.Name) | ||||
| $name = $fn -replace "(.*)\.ps1$", '$1' | ||||
| Register-ArgumentCompleter -Native -CommandName $name -ScriptBlock { | ||||
|      param($commandName, $wordToComplete, $cursorPosition) | ||||
|      $other = "$wordToComplete --generate-bash-completion" | ||||
|          Invoke-Expression $other | ForEach-Object { | ||||
|             [System.Management.Automation.CompletionResult]::new($_, $_, 'ParameterValue', $_) | ||||
|          } | ||||
|  } | ||||
							
								
								
									
										23
									
								
								autocomplete/zsh_autocomplete
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										23
									
								
								autocomplete/zsh_autocomplete
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,23 @@ | ||||
| #compdef $PROG | ||||
|  | ||||
| _cli_zsh_autocomplete() { | ||||
|  | ||||
|   local -a opts | ||||
|   local cur | ||||
|   cur=${words[-1]} | ||||
|   if [[ "$cur" == "-"* ]]; then | ||||
|     opts=("${(@f)$(_CLI_ZSH_AUTOCOMPLETE_HACK=1 ${words[@]:0:#words[@]-1} ${cur} --generate-bash-completion)}") | ||||
|   else | ||||
|     opts=("${(@f)$(_CLI_ZSH_AUTOCOMPLETE_HACK=1 ${words[@]:0:#words[@]-1} --generate-bash-completion)}") | ||||
|   fi | ||||
|  | ||||
|   if [[ "${opts[1]}" != "" ]]; then | ||||
|     _describe 'values' opts | ||||
|   else | ||||
|     _files | ||||
|   fi | ||||
|  | ||||
|   return | ||||
| } | ||||
|  | ||||
| compdef _cli_zsh_autocomplete $PROG | ||||
| @ -55,6 +55,7 @@ func RunApp(version, commit string) { | ||||
| 			server.ServerCommand, | ||||
| 			recipe.RecipeCommand, | ||||
| 			VersionCommand, | ||||
| 			UpgradeCommand, | ||||
| 		}, | ||||
| 		Flags: []cli.Flag{ | ||||
| 			VerboseFlag, | ||||
| @ -67,6 +68,7 @@ func RunApp(version, commit string) { | ||||
| 			}, | ||||
| 		}, | ||||
| 	} | ||||
| 	app.EnableBashCompletion = true | ||||
|  | ||||
| 	if err := app.Run(os.Args); err != nil { | ||||
| 		logrus.Fatal(err) | ||||
|  | ||||
							
								
								
									
										38
									
								
								cli/internal/command.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										38
									
								
								cli/internal/command.go
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,38 @@ | ||||
| package internal | ||||
|  | ||||
| import ( | ||||
| 	"bufio" | ||||
| 	"fmt" | ||||
| 	"os/exec" | ||||
| ) | ||||
|  | ||||
| func RunCmd(cmd *exec.Cmd) error { | ||||
| 	r, err := cmd.StdoutPipe() | ||||
| 	if err != nil { | ||||
| 		return err | ||||
| 	} | ||||
|  | ||||
| 	cmd.Stderr = cmd.Stdout | ||||
| 	done := make(chan struct{}) | ||||
| 	scanner := bufio.NewScanner(r) | ||||
|  | ||||
| 	go func() { | ||||
| 		for scanner.Scan() { | ||||
| 			line := scanner.Text() | ||||
| 			fmt.Println(line) | ||||
| 		} | ||||
| 		done <- struct{}{} | ||||
| 	}() | ||||
|  | ||||
| 	if err := cmd.Start(); err != nil { | ||||
| 		return err | ||||
| 	} | ||||
|  | ||||
| 	<-done | ||||
|  | ||||
| 	if err := cmd.Wait(); err != nil { | ||||
| 		return err | ||||
| 	} | ||||
|  | ||||
| 	return nil | ||||
| } | ||||
							
								
								
									
										22
									
								
								cli/upgrade.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										22
									
								
								cli/upgrade.go
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,22 @@ | ||||
| package cli | ||||
|  | ||||
| import ( | ||||
| 	"os/exec" | ||||
|  | ||||
| 	"coopcloud.tech/abra/cli/internal" | ||||
| 	"github.com/sirupsen/logrus" | ||||
| 	"github.com/urfave/cli/v2" | ||||
| ) | ||||
|  | ||||
| // UpgradeCommand upgrades abra in-place. | ||||
| var UpgradeCommand = &cli.Command{ | ||||
| 	Name:  "upgrade", | ||||
| 	Usage: "Upgrade abra", | ||||
| 	Action: func(c *cli.Context) error { | ||||
| 		cmd := exec.Command("bash", "-c", "curl -s https://install.abra.coopcloud.tech | bash") | ||||
| 		if err := internal.RunCmd(cmd); err != nil { | ||||
| 			logrus.Fatal(err) | ||||
| 		} | ||||
| 		return nil | ||||
| 	}, | ||||
| } | ||||
							
								
								
									
										5
									
								
								scripts/installer/README.md
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										5
									
								
								scripts/installer/README.md
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,5 @@ | ||||
| # install.abra.coopcloud.tech | ||||
|  | ||||
| To deploy, run `make`. | ||||
|  | ||||
| You have to be an [Autonomic](https://autonomic.zone) member to do this. | ||||
							
								
								
									
										38
									
								
								scripts/installer/compose.yml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										38
									
								
								scripts/installer/compose.yml
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,38 @@ | ||||
| --- | ||||
| version: "3.8" | ||||
|  | ||||
| services: | ||||
|   app: | ||||
|     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`,`install.abra.coopcloud.tech`)" | ||||
|         - "traefik.http.routers.abra-installer.entrypoints=web-secure" | ||||
|         - "traefik.http.routers.abra-installer.tls.certresolver=production" | ||||
|  | ||||
| configs: | ||||
|   abra_installer: | ||||
|     file: installer | ||||
|   abra_conf: | ||||
|     file: nginx.conf | ||||
|  | ||||
| networks: | ||||
|   proxy: | ||||
|     external: true | ||||
|  | ||||
| volumes: | ||||
|   public: | ||||
							
								
								
									
										57
									
								
								scripts/installer/installer
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										57
									
								
								scripts/installer/installer
									
									
									
									
									
										Executable file
									
								
							| @ -0,0 +1,57 @@ | ||||
| #!/usr/bin/env bash | ||||
|  | ||||
| ABRA_VERSION="0.1.2-alpha" | ||||
| ABRA_RELEASE_URL="https://git.coopcloud.tech/api/v1/repos/coop-cloud/abra/releases/tags/$ABRA_VERSION" | ||||
|  | ||||
| function show_banner { | ||||
|   echo "" | ||||
|   echo "   ____                           ____ _                 _ " | ||||
|   echo "  / ___|___         ___  _ __    / ___| | ___  _   _  __| |" | ||||
|   echo " | |   / _ \ _____ / _ \| '_ \  | |   | |/ _ \| | | |/ _' |" | ||||
|   echo " | |__| (_) |_____| (_) | |_) | | |___| | (_) | |_| | (_| |" | ||||
|   echo "  \____\___/       \___/| .__/   \____|_|\___/ \__,_|\__,_|" | ||||
|   echo "                        |_|" | ||||
|   echo "" | ||||
|   echo "" | ||||
|   echo "          === Public interest infrastructure ===           " | ||||
|   echo "" | ||||
|   echo "" | ||||
| } | ||||
|  | ||||
| function install_abra_release { | ||||
|   mkdir -p "$HOME/.local/bin" | ||||
|  | ||||
|   if ! type "curl" > /dev/null 2>&1; then | ||||
|     echo "'curl' is not installed, cannot proceed..." | ||||
|     echo "perhaps try installing manually via the releases URL?" | ||||
|     echo "https://git.coopcloud.tech/coop-cloud/abra/releases" | ||||
|     exit 1 | ||||
|   fi | ||||
|  | ||||
|   if ! type "curl" > /dev/null 2>&1; then | ||||
|     error "'python3' is not installed, cannot proceed..." | ||||
|     echo "perhaps try installing manually via the releases URL?" | ||||
|     echo "https://git.coopcloud.tech/coop-cloud/abra/releases" | ||||
|   fi | ||||
|  | ||||
|   # FIXME: support different architectures | ||||
|   release_url=$(curl -s "$ABRA_RELEASE_URL" | | ||||
|     python3 -c "import sys, json; \ | ||||
|                 payload = json.load(sys.stdin); \ | ||||
|                 url = [a['browser_download_url'] for a in payload['assets'] if 'x86_64' in a['name']][0]; \ | ||||
|                 print(url)") | ||||
|  | ||||
|   echo "downloading $ABRA_VERSION x86_64 binary release for abra..." | ||||
|   curl --progress-bar "$release_url" --output "$HOME/.local/bin/abra" | ||||
|   chmod +x "$HOME/.local/bin/abra" | ||||
|  | ||||
|   echo "abra installed to $HOME/.local/bin/abra" | ||||
| } | ||||
|  | ||||
| function run_installation { | ||||
|   show_banner | ||||
|   install_abra_release | ||||
| } | ||||
|  | ||||
| run_installation "$@" | ||||
| exit 0 | ||||
							
								
								
									
										7
									
								
								scripts/installer/makefile
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										7
									
								
								scripts/installer/makefile
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,7 @@ | ||||
| STACK := abra_installer_script | ||||
|  | ||||
| default: deploy | ||||
|  | ||||
| deploy: | ||||
| 	@docker stack rm $(STACK) && \ | ||||
| 		docker stack deploy -c compose.yml $(STACK) | ||||
							
								
								
									
										10
									
								
								scripts/installer/nginx.conf
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										10
									
								
								scripts/installer/nginx.conf
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,10 @@ | ||||
| server { | ||||
|   listen         80 default_server; | ||||
|   server_name    install.abra.autonomic.zone install.abra.coopcloud.tech; | ||||
|  | ||||
|   location / { | ||||
|     root /var/www/abra-installer; | ||||
|     add_header Content-Type text/plain; | ||||
|     index installer; | ||||
|   } | ||||
| } | ||||
		Reference in New Issue
	
	Block a user