Compare commits
18 Commits
kraken-app
...
ac4aabede4
Author | SHA1 | Date | |
---|---|---|---|
ac4aabede4
|
|||
a503204e8a
|
|||
97d362e5be
|
|||
15a764a3ef
|
|||
c0f6d6b4c6
|
|||
532638f2f8
|
|||
8cf06c8117
|
|||
f96ec96786
|
|||
b12d7f8a00
|
|||
f3adcfc1ce
|
|||
a3f40c6503
|
|||
9593a95ebd
|
|||
4f35d3ac81
|
|||
5855624157
|
|||
62c9e15247
|
|||
f6001f4e3d | |||
38a657e745
|
|||
3ce59769d3
|
1
CONFIGURATION_SERVER.md
Normal file
1
CONFIGURATION_SERVER.md
Normal file
@@ -0,0 +1 @@
|
||||
# Configuration server
|
249
README.md
Normal file
249
README.md
Normal file
@@ -0,0 +1,249 @@
|
||||
<p align="center">
|
||||
<image src="https://git.front.kjuulh.io/kjuulh/octopush/raw/branch/v0.2/assets/octopush.svg" width="300" height="300"/>
|
||||
</p>
|
||||
<h1 align="center">Octopush - Your cute action executor</h1>
|
||||
|
||||
## Purpose
|
||||
|
||||
The goal of this project is to easily do batch changes or queries on a host of
|
||||
repositories. In large organisations using multi-repository strategies, it may
|
||||
be painful to change even small things across many repositories, because there
|
||||
are so many of them. Octopush aims to change that.
|
||||
|
||||
**DISCLAIMER:** It is still early days, and the api is subject to change.
|
||||
|
||||
## Features
|
||||
|
||||
- Uses an actions repository, where you store all your pending commands or
|
||||
queries to be performed across your fleet of repositories. (See \_examples)
|
||||
- Actions can both execute changes, open pull-requests or in some cases commit
|
||||
directly to your preferred branch
|
||||
- Actions natively use either shell, go or docker files to execute changes
|
||||
(see \_examples/actions)
|
||||
- Actions can also be analytical, so you can query your fleet for whatever you
|
||||
would like
|
||||
- Works both as a client, or as a server
|
||||
- Supports SSH/https for fetching repos
|
||||
- Supports GPG signing
|
||||
- Supports dry-run mode for easy testing when developing your actions (enabled
|
||||
by default on the cli)
|
||||
|
||||
## Roadmap
|
||||
|
||||
Refer to [roadmap.md](roadmap.md)
|
||||
|
||||
## Installation
|
||||
|
||||
Octopush comes in two modes. Client or Client -> Server. Octopush can stand alone as
|
||||
a client, for smaller and less secure changes. However, for organisations, it
|
||||
may be useful to use Octopush in server mode, which supports more features, and
|
||||
has extra security built in.
|
||||
|
||||
### Client (CLI)
|
||||
|
||||
Download executable from [releases](https://github.com/kjuulh/octopush/releases)
|
||||
|
||||
#### Or Use docker image
|
||||
|
||||
```bash
|
||||
docker run --rm kasperhermansen/octopushcli:latest version
|
||||
```
|
||||
|
||||
#### Or Build from source
|
||||
|
||||
```bash
|
||||
git clone https://github.com/kjuulh/octopush.git
|
||||
cd octopush
|
||||
|
||||
go build cmd/octopush/octopush.go
|
||||
./octopush version
|
||||
```
|
||||
|
||||
#### Or Build with cuddle
|
||||
|
||||
```bash
|
||||
git clone https://github.com/kjuulh/octopush.git
|
||||
cd octopush
|
||||
|
||||
cuddle_cli x build_cli
|
||||
```
|
||||
|
||||
### Server
|
||||
|
||||
We prefer to run the server directly as a docker image.
|
||||
|
||||
```bash
|
||||
docker pull kasperhermansen/octopushserver:latest
|
||||
docker run -p 9090:80 --rm kasperhermansen/octopushserver:latest
|
||||
```
|
||||
|
||||
#### Or Build from source
|
||||
|
||||
```bash
|
||||
git clone https://github.com/kjuulh/octopush.git
|
||||
cd octopush
|
||||
|
||||
go build cmd/server/server.go
|
||||
./server version
|
||||
```
|
||||
|
||||
#### Or Build with cuddle
|
||||
|
||||
```bash
|
||||
git clone https://github.com/kjuulh/octopush.git
|
||||
cd octopush
|
||||
|
||||
cuddle_cli x build_server
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
**DISCLAIMER:** It is still early days, and the api of the CLI is subject to
|
||||
change, this provides the aim of the project, but as it is currently in flux,
|
||||
there may not be as much handholding in the actual usage.
|
||||
|
||||
I will focus on the client here, as the server provides the same features,
|
||||
though available through the cli, but instead as configuration options (see
|
||||
[CONFIGURATION_SERVER.md](CONFIGURATION_SERVER.md))
|
||||
|
||||
Octopush ships with autocomplete built in (courtesy of spf13/cobra). To add:
|
||||
|
||||
- Bash: `echo 'source <(octopush completion bash)' >> ~/.bashrc`
|
||||
- Zsh: `echo 'source <(octopush completion zsh)' >> ~/.zshrc`
|
||||
|
||||
### Creating a new action
|
||||
|
||||
Creating a new action
|
||||
|
||||
```bash
|
||||
git init my-actions # should only be done once
|
||||
cd my-actions
|
||||
octopush tmpl init write-a-readme --command
|
||||
cat write-a-readme/octopush.yml
|
||||
|
||||
# Output
|
||||
# apiVersion: git.front.kjuulh.io/kjuulh/octopush/blob/main/schema/v1
|
||||
# name: write-a-readme
|
||||
# select:
|
||||
# repositories: []
|
||||
# actions:
|
||||
# - type: shell
|
||||
# entry: "main.sh"
|
||||
```
|
||||
|
||||
Octopush also ships with yaml schema, which should help write the yaml
|
||||
configuration.
|
||||
|
||||
#### Add upstream repositories (victims)
|
||||
|
||||
Now add a preferred repository
|
||||
|
||||
```
|
||||
cat << EOF > write-a-readme/octopush.yml
|
||||
apiVersion: git.front.kjuulh.io/kjuulh/octopush/blob/main/schema/v1
|
||||
name: write-a-readme
|
||||
select:
|
||||
providers: # new
|
||||
- gitea: https://git.front.kjuulh.io # new
|
||||
organisation: "kjuulh" # new
|
||||
actions:
|
||||
- type: shell
|
||||
entry: "main.sh"
|
||||
EOF
|
||||
```
|
||||
|
||||
This will take all your repositories under an organisation and run the script
|
||||
on.
|
||||
|
||||
Another could be to use
|
||||
|
||||
```bash
|
||||
cat << EOF > write-a-readme/octopush.yml
|
||||
apiVersion: git.front.kjuulh.io/kjuulh/octopush/blob/main/schema/v1
|
||||
name: write-a-readme
|
||||
select:
|
||||
repositories: #new
|
||||
- git@git.front.kjuulh.io:kjuulh/octopush.git #new
|
||||
- git@git.front.kjuulh.io:kjuulh/octopush-test.git #new
|
||||
actions:
|
||||
- type: shell
|
||||
entry: "main.sh"
|
||||
EOF
|
||||
```
|
||||
|
||||
This will just apply to those repositories instead. Both can also be combined
|
||||
for a shared effect.
|
||||
|
||||
### Execute action
|
||||
|
||||
To run the script use
|
||||
|
||||
```bash
|
||||
octopush process --path "write-a-readme"
|
||||
```
|
||||
|
||||
This will cause the octopush process to automatically apply the action on the repo
|
||||
and open a pr.
|
||||
|
||||
### Query repositories
|
||||
|
||||
Octopush can also be used to query.
|
||||
|
||||
```bash
|
||||
cat << EOF > write-a-readme/octopush.yml
|
||||
apiVersion: git.front.kjuulh.io/kjuulh/octopush/blob/main/schema/v1
|
||||
name: write-a-readme
|
||||
select:
|
||||
repositories:
|
||||
- git@git.front.kjuulh.io:kjuulh/octopush.git
|
||||
- git@git.front.kjuulh.io:kjuulh/octopush-test.git
|
||||
queries:
|
||||
- type: grep
|
||||
query: "# README"
|
||||
EOF
|
||||
```
|
||||
|
||||
Using the same command as above, will return the lines on each repo with those
|
||||
criteria. Everything is run in docker, even locally, so no need to install fancy
|
||||
tools.
|
||||
|
||||
Do note: All actions will be run as dry-run unless `--apply` is added. This is
|
||||
to help test locally, as well as not cause serious issues. The server
|
||||
configuration is pretty much the same, except the command would look like so:
|
||||
`octopush server process --path "write-a-readme" --apply`. Octopush will try to
|
||||
infer as much as possible, but it may be needed to apply some extra flags to
|
||||
specify upstream repositories and such. Octopush will also help you setup keys and
|
||||
such on the first run, using `octopush setup` or `octopush server setup`.
|
||||
|
||||
## Contributing
|
||||
|
||||
It is still early days, and as such things are moving fast, I may not be able to
|
||||
implement features, because I am focusing my energy on the API. That said PRs
|
||||
are welcome, though they are at your own risk.
|
||||
|
||||
### Bugs & features requests
|
||||
|
||||
Please use [issues](https://github.com/kjuulh/octopush/issues)
|
||||
|
||||
### Development
|
||||
|
||||
We use [cuddle](https://git.front.kjuulh.io/kjuulh/cuddle) to improve ease of
|
||||
use, it is however, not a requirement, and probably won't need to be used
|
||||
outside core maintainers.
|
||||
|
||||
Simply:
|
||||
|
||||
```bash
|
||||
go run cmd/octopush/octopush.go # CLI
|
||||
go run cmd/server/server.go # Server
|
||||
```
|
||||
|
||||
We follow the `gofmt` formatting, along with optionally but recommend `golines`
|
||||
|
||||
If using cuddle
|
||||
|
||||
```
|
||||
cuddle_cli x run # Run both server and client, will do a quick test sweep on the cli
|
||||
cuddle_cli x watch_run # Automatically refresh both
|
||||
cuddle_cli x fmt # will format the current code
|
||||
```
|
11
_examples/actions/add_releaserc/go.mod
Normal file
11
_examples/actions/add_releaserc/go.mod
Normal file
@@ -0,0 +1,11 @@
|
||||
module write_a_readme
|
||||
|
||||
go 1.19
|
||||
|
||||
require github.com/bitfield/script v0.20.2
|
||||
|
||||
require (
|
||||
bitbucket.org/creachadair/shell v0.0.7 // indirect
|
||||
github.com/itchyny/gojq v0.12.7 // indirect
|
||||
github.com/itchyny/timefmt-go v0.1.3 // indirect
|
||||
)
|
20
_examples/actions/add_releaserc/go.sum
Normal file
20
_examples/actions/add_releaserc/go.sum
Normal file
@@ -0,0 +1,20 @@
|
||||
bitbucket.org/creachadair/shell v0.0.7 h1:Z96pB6DkSb7F3Y3BBnJeOZH2gazyMTWlvecSD4vDqfk=
|
||||
bitbucket.org/creachadair/shell v0.0.7/go.mod h1:oqtXSSvSYr4624lnnabXHaBsYW6RD80caLi2b3hJk0U=
|
||||
github.com/bitfield/script v0.20.2 h1:4DexsRtBILVMEn3EZwHbtJdDqdk43sXI8gM3F04JXgs=
|
||||
github.com/bitfield/script v0.20.2/go.mod h1:l3AZPVAtKQrL03bwh7nlNTUtgrgSWurpJSbtqspYrOA=
|
||||
github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
github.com/google/go-cmp v0.5.7 h1:81/ik6ipDQS2aGcBfIN5dHDB36BwrStyeAQquSYCV4o=
|
||||
github.com/google/go-cmp v0.5.7/go.mod h1:n+brtR0CgQNWTVd5ZUFpTBC8YFBDLK/h/bpaJ8/DtOE=
|
||||
github.com/itchyny/gojq v0.12.7 h1:hYPTpeWfrJ1OT+2j6cvBScbhl0TkdwGM4bc66onUSOQ=
|
||||
github.com/itchyny/gojq v0.12.7/go.mod h1:ZdvNHVlzPgUf8pgjnuDTmGfHA/21KoutQUJ3An/xNuw=
|
||||
github.com/itchyny/timefmt-go v0.1.3 h1:7M3LGVDsqcd0VZH2U+x393obrzZisp7C0uEe921iRkU=
|
||||
github.com/itchyny/timefmt-go v0.1.3/go.mod h1:0osSSCQSASBJMsIZnhAaF1C2fCBTJZXrnj37mG8/c+A=
|
||||
github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94=
|
||||
github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI=
|
||||
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20220227234510-4e6760a101f9/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
12
_examples/actions/add_releaserc/kraken.yml
Normal file
12
_examples/actions/add_releaserc/kraken.yml
Normal file
@@ -0,0 +1,12 @@
|
||||
apiVersion: git.front.kjuulh.io/kjuulh/octopush/blob/main/schema/v1
|
||||
name: write-a-readme
|
||||
select:
|
||||
repositories:
|
||||
- git@git.front.kjuulh.io:kjuulh/octopush-test.git
|
||||
- git@git.front.kjuulh.io:kjuulh/octopush.git
|
||||
# providers:
|
||||
# - gitea: https://git.front.kjuulh.io
|
||||
# organisation: "cibus"
|
||||
actions:
|
||||
- type: go
|
||||
entry: "main.go"
|
25
_examples/actions/add_releaserc/main.go
Normal file
25
_examples/actions/add_releaserc/main.go
Normal file
@@ -0,0 +1,25 @@
|
||||
package main
|
||||
|
||||
import "github.com/bitfield/script"
|
||||
|
||||
func main() {
|
||||
|
||||
releaseRc := `
|
||||
branches:
|
||||
- "main"
|
||||
- "v0.x"
|
||||
|
||||
plugins:
|
||||
- "@semantic-release/commit-analyzer"
|
||||
- "@semantic-release/release-notes-generator"
|
||||
- "@semantic-release/changelog"
|
||||
- "@semantic-release/git"
|
||||
`
|
||||
|
||||
_, err := script.
|
||||
Echo(releaseRc).
|
||||
WriteFile(".releaserc.yml")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
@@ -1,6 +1,6 @@
|
||||
FROM debian:bullseye-slim
|
||||
|
||||
# Kraken relies on this path being the specified path
|
||||
# Octopush relies on this path being the specified path
|
||||
WORKDIR /src/work/
|
||||
|
||||
COPY entry.sh /src/script.sh
|
||||
|
@@ -1,8 +1,8 @@
|
||||
apiVersion: git.front.kjuulh.io/kjuulh/kraken/blob/main/schema/v1
|
||||
apiVersion: git.front.kjuulh.io/kjuulh/octopush/blob/main/schema/v1
|
||||
name: write-a-readme
|
||||
select:
|
||||
repositories:
|
||||
- git@git.front.kjuulh.io:kjuulh/kraken-test.git
|
||||
- git@git.front.kjuulh.io:kjuulh/octopush-test.git
|
||||
# providers:
|
||||
# - gitea: https://git.front.kjuulh.io
|
||||
# organisation: "cibus"
|
||||
|
@@ -1,8 +1,8 @@
|
||||
apiVersion: git.front.kjuulh.io/kjuulh/kraken/blob/main/schema/v1
|
||||
apiVersion: git.front.kjuulh.io/kjuulh/octopush/blob/main/schema/v1
|
||||
name: write-a-readme
|
||||
select:
|
||||
repositories:
|
||||
- git@git.front.kjuulh.io:kjuulh/kraken-test.git
|
||||
- git@git.front.kjuulh.io:kjuulh/octopush-test.git
|
||||
# providers:
|
||||
# - gitea: https://git.front.kjuulh.io
|
||||
# organisation: "cibus"
|
||||
|
9
_examples/queries/find_semantic/kraken.yml
Normal file
9
_examples/queries/find_semantic/kraken.yml
Normal file
@@ -0,0 +1,9 @@
|
||||
apiVersion: git.front.kjuulh.io/kjuulh/octopush/blob/main/schema/v1
|
||||
name: write-a-readme
|
||||
select:
|
||||
providers:
|
||||
- gitea: https://git.front.kjuulh.io
|
||||
organisation: "cibus"
|
||||
queries:
|
||||
- type: grep
|
||||
query: "releaser"
|
@@ -1,8 +1,8 @@
|
||||
apiVersion: git.front.kjuulh.io/kjuulh/kraken/blob/main/schema/v1
|
||||
apiVersion: git.front.kjuulh.io/kjuulh/octopush/blob/main/schema/v1
|
||||
name: write-a-readme
|
||||
select:
|
||||
repositories:
|
||||
- git@git.front.kjuulh.io:kjuulh/kraken-test.git
|
||||
- git@git.front.kjuulh.io:kjuulh/octopush-test.git
|
||||
# providers:
|
||||
# - gitea: https://git.front.kjuulh.io
|
||||
# organisation: "cibus"
|
||||
|
BIN
assets/kraken.png
Normal file
BIN
assets/kraken.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 32 KiB |
10
assets/kraken.svg
Normal file
10
assets/kraken.svg
Normal file
@@ -0,0 +1,10 @@
|
||||
<svg width="1000" height="1000" viewBox="0 0 1000 1000" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M975 568C975 830.335 762.335 497 500 497C237.665 497 25 830.335 25 568C25 305.665 237.665 93 500 93C762.335 93 975 305.665 975 568Z" fill="#52DB78"/>
|
||||
<path d="M237.436 856.185C165.693 827.571 320.875 755.464 377.754 612.854C434.634 470.243 371.672 311.132 443.414 339.746C515.157 368.36 527.205 507.165 470.326 649.776C413.446 792.386 309.178 884.799 237.436 856.185Z" fill="#52DB78"/>
|
||||
<path d="M428.353 849.847C353.918 829.229 500.308 740.627 541.293 592.663C582.278 444.699 502.337 293.405 576.773 314.023C651.208 334.641 678.325 471.303 637.34 619.267C596.355 767.231 502.788 870.465 428.353 849.847Z" fill="#52DB78"/>
|
||||
<path d="M598.707 855.902C523.231 839.498 664.415 742.813 697.024 592.781C729.634 442.748 641.321 296.183 716.797 312.588C792.272 328.992 827.022 463.916 794.413 613.948C761.803 763.98 674.183 872.307 598.707 855.902Z" fill="#52DB78"/>
|
||||
<path d="M47.896 838.855C-19.3259 800.817 144.17 750.323 219.784 616.698C295.397 483.073 254.495 316.918 321.717 354.956C388.938 392.994 382.136 532.155 306.522 665.78C230.909 799.405 115.118 876.893 47.896 838.855Z" fill="#52DB78"/>
|
||||
<ellipse cx="605.35" cy="265.255" rx="57.5" ry="36.5" transform="rotate(-40.9544 605.35 265.255)" fill="white"/>
|
||||
<ellipse cx="359.35" cy="265.255" rx="57.5" ry="36.5" transform="rotate(-40.9544 359.35 265.255)" fill="white"/>
|
||||
<path d="M385.635 374C385.635 374 391.199 435.298 463.528 438.425C535.857 441.553 538.492 380.61 538.492 380.61" stroke="white" stroke-width="8"/>
|
||||
</svg>
|
After Width: | Height: | Size: 1.5 KiB |
@@ -8,7 +8,7 @@ import (
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
func CreateKrakenProcessCmd() *cobra.Command {
|
||||
func CreateOctopushProcessCmd() *cobra.Command {
|
||||
|
||||
var (
|
||||
actionsRepo string
|
||||
|
@@ -2,13 +2,13 @@ package commands
|
||||
|
||||
import "github.com/spf13/cobra"
|
||||
|
||||
func CreateKrakenCmd() *cobra.Command {
|
||||
func CreateOctopushCmd() *cobra.Command {
|
||||
cmd := &cobra.Command{
|
||||
Use: "kraken",
|
||||
Use: "octopush",
|
||||
// Run: func(cmd *cobra.Command, args []string) { },
|
||||
}
|
||||
|
||||
cmd.AddCommand(CreateKrakenProcessCmd())
|
||||
cmd.AddCommand(CreateOctopushProcessCmd())
|
||||
|
||||
return cmd
|
||||
}
|
||||
|
@@ -3,7 +3,7 @@ package main
|
||||
import (
|
||||
"os"
|
||||
|
||||
"git.front.kjuulh.io/kjuulh/kraken/cmd/kraken/commands"
|
||||
"git.front.kjuulh.io/kjuulh/octopush/cmd/octopush/commands"
|
||||
)
|
||||
|
||||
func main() {
|
||||
@@ -11,7 +11,7 @@ func main() {
|
||||
}
|
||||
|
||||
func Execute() {
|
||||
err := commands.CreateKrakenCmd().Execute()
|
||||
err := commands.CreateOctopushCmd().Execute()
|
||||
if err != nil {
|
||||
os.Exit(1)
|
||||
}
|
||||
|
@@ -7,7 +7,7 @@ import (
|
||||
|
||||
func CreateServerCmd(logger *zap.Logger) *cobra.Command {
|
||||
cmd := &cobra.Command{
|
||||
Use: "krakenserver",
|
||||
Use: "octopushserver",
|
||||
}
|
||||
|
||||
cmd.AddCommand(NewStartServerCommand(logger))
|
||||
|
@@ -1,7 +1,7 @@
|
||||
package commands
|
||||
|
||||
import (
|
||||
"git.front.kjuulh.io/kjuulh/kraken/internal/server"
|
||||
"git.front.kjuulh.io/kjuulh/octopush/internal/server"
|
||||
"github.com/spf13/cobra"
|
||||
"go.uber.org/zap"
|
||||
)
|
||||
@@ -9,7 +9,7 @@ import (
|
||||
func NewStartServerCommand(logger *zap.Logger) *cobra.Command {
|
||||
cmd := &cobra.Command{
|
||||
Use: "start",
|
||||
Short: "Start the kraken server",
|
||||
Short: "Start the octopush server",
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
return server.Start(logger)
|
||||
},
|
||||
|
@@ -3,8 +3,8 @@ package main
|
||||
import (
|
||||
"os"
|
||||
|
||||
"git.front.kjuulh.io/kjuulh/kraken/cmd/server/commands"
|
||||
"git.front.kjuulh.io/kjuulh/kraken/internal/logger"
|
||||
"git.front.kjuulh.io/kjuulh/octopush/cmd/server/commands"
|
||||
"git.front.kjuulh.io/kjuulh/octopush/internal/logger"
|
||||
"go.uber.org/zap"
|
||||
)
|
||||
|
||||
|
@@ -3,7 +3,7 @@
|
||||
base: "git@git.front.kjuulh.io:kjuulh/cuddle-go-plan.git"
|
||||
|
||||
vars:
|
||||
service: "kraken"
|
||||
service: "octopush"
|
||||
deployments: "git@git.front.kjuulh.io:kjuulh/deployments.git"
|
||||
|
||||
scripts:
|
||||
|
2
go.mod
2
go.mod
@@ -1,4 +1,4 @@
|
||||
module git.front.kjuulh.io/kjuulh/kraken
|
||||
module git.front.kjuulh.io/kjuulh/octopush
|
||||
|
||||
go 1.19
|
||||
|
||||
|
@@ -7,7 +7,7 @@ import (
|
||||
"os"
|
||||
"testing"
|
||||
|
||||
"git.front.kjuulh.io/kjuulh/kraken/internal/server"
|
||||
"git.front.kjuulh.io/kjuulh/octopush/internal/server"
|
||||
"go.uber.org/zap"
|
||||
)
|
||||
|
||||
|
@@ -9,7 +9,7 @@ import (
|
||||
"path"
|
||||
"testing"
|
||||
|
||||
"git.front.kjuulh.io/kjuulh/kraken/internal/services/storage"
|
||||
"git.front.kjuulh.io/kjuulh/octopush/internal/services/storage"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
|
@@ -4,15 +4,15 @@ import (
|
||||
"context"
|
||||
"errors"
|
||||
|
||||
"git.front.kjuulh.io/kjuulh/kraken/internal/actions/builders"
|
||||
"git.front.kjuulh.io/kjuulh/kraken/internal/actions/querier"
|
||||
"git.front.kjuulh.io/kjuulh/kraken/internal/schema"
|
||||
"git.front.kjuulh.io/kjuulh/kraken/internal/services/storage"
|
||||
"git.front.kjuulh.io/kjuulh/octopush/internal/actions/builders"
|
||||
"git.front.kjuulh.io/kjuulh/octopush/internal/actions/querier"
|
||||
"git.front.kjuulh.io/kjuulh/octopush/internal/schema"
|
||||
"git.front.kjuulh.io/kjuulh/octopush/internal/services/storage"
|
||||
"go.uber.org/zap"
|
||||
)
|
||||
|
||||
type Action struct {
|
||||
Schema *schema.KrakenSchema
|
||||
Schema *schema.OctopushSchema
|
||||
SchemaPath string
|
||||
}
|
||||
|
||||
|
@@ -7,9 +7,9 @@ import (
|
||||
"path"
|
||||
"time"
|
||||
|
||||
"git.front.kjuulh.io/kjuulh/kraken/internal/schema"
|
||||
"git.front.kjuulh.io/kjuulh/kraken/internal/services/providers"
|
||||
"git.front.kjuulh.io/kjuulh/kraken/internal/services/storage"
|
||||
"git.front.kjuulh.io/kjuulh/octopush/internal/schema"
|
||||
"git.front.kjuulh.io/kjuulh/octopush/internal/services/providers"
|
||||
"git.front.kjuulh.io/kjuulh/octopush/internal/services/storage"
|
||||
"go.uber.org/zap"
|
||||
)
|
||||
|
||||
@@ -59,19 +59,19 @@ func (ac *ActionCreator) Prepare(ctx context.Context, ops *ActionCreatorOps) (*A
|
||||
return nil, fmt.Errorf("path is invalid: %s", ops.Path)
|
||||
}
|
||||
|
||||
contents, err := os.ReadFile(path.Join(executorUrl, "kraken.yml"))
|
||||
contents, err := os.ReadFile(path.Join(executorUrl, "octopush.yml"))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
krakenSchema, err := schema.Unmarshal(string(contents))
|
||||
octopushSchema, err := schema.Unmarshal(string(contents))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
ac.logger.Debug("Action creator done")
|
||||
return &Action{
|
||||
Schema: krakenSchema,
|
||||
Schema: octopushSchema,
|
||||
SchemaPath: executorUrl,
|
||||
}, nil
|
||||
}
|
||||
|
@@ -36,7 +36,7 @@ func (g *DockerBuild) Build(ctx context.Context, modulePath, entryPath string) (
|
||||
return nil, err
|
||||
}
|
||||
tag := hex.EncodeToString(b)
|
||||
buildDockerCmd := fmt.Sprintf("(cd %s; docker build -f %s --tag kraken/%s .)", modulePath, entryPath, tag)
|
||||
buildDockerCmd := fmt.Sprintf("(cd %s; docker build -f %s --tag octopush/%s .)", modulePath, entryPath, tag)
|
||||
g.logger.Debug("Running command", zap.String("command", buildDockerCmd))
|
||||
|
||||
cmd := exec.CommandContext(
|
||||
@@ -73,7 +73,7 @@ func (g *DockerBuild) Build(ctx context.Context, modulePath, entryPath string) (
|
||||
ctx,
|
||||
"/bin/bash",
|
||||
"-c",
|
||||
fmt.Sprintf("docker run --rm -v %s/:/src/work/ kraken/%s", victimPath, tag),
|
||||
fmt.Sprintf("docker run --rm -v %s/:/src/work/ octopush/%s", victimPath, tag),
|
||||
)
|
||||
|
||||
runDockerWriter := &zapio.Writer{
|
||||
|
@@ -4,9 +4,9 @@ import (
|
||||
"context"
|
||||
"net/http"
|
||||
|
||||
"git.front.kjuulh.io/kjuulh/kraken/internal/commands"
|
||||
"git.front.kjuulh.io/kjuulh/kraken/internal/serverdeps"
|
||||
"git.front.kjuulh.io/kjuulh/kraken/internal/services/jobs"
|
||||
"git.front.kjuulh.io/kjuulh/octopush/internal/commands"
|
||||
"git.front.kjuulh.io/kjuulh/octopush/internal/serverdeps"
|
||||
"git.front.kjuulh.io/kjuulh/octopush/internal/services/jobs"
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/google/uuid"
|
||||
"go.uber.org/zap"
|
||||
|
@@ -1,7 +1,7 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
"git.front.kjuulh.io/kjuulh/kraken/internal/serverdeps"
|
||||
"git.front.kjuulh.io/kjuulh/octopush/internal/serverdeps"
|
||||
"github.com/gin-gonic/gin"
|
||||
"go.uber.org/zap"
|
||||
)
|
||||
|
@@ -7,11 +7,11 @@ import (
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"git.front.kjuulh.io/kjuulh/kraken/internal/actions"
|
||||
"git.front.kjuulh.io/kjuulh/kraken/internal/gitproviders"
|
||||
"git.front.kjuulh.io/kjuulh/kraken/internal/schema"
|
||||
"git.front.kjuulh.io/kjuulh/kraken/internal/services/providers"
|
||||
"git.front.kjuulh.io/kjuulh/kraken/internal/services/storage"
|
||||
"git.front.kjuulh.io/kjuulh/octopush/internal/actions"
|
||||
"git.front.kjuulh.io/kjuulh/octopush/internal/gitproviders"
|
||||
"git.front.kjuulh.io/kjuulh/octopush/internal/schema"
|
||||
"git.front.kjuulh.io/kjuulh/octopush/internal/services/providers"
|
||||
"git.front.kjuulh.io/kjuulh/octopush/internal/services/storage"
|
||||
giturls "github.com/whilp/git-urls"
|
||||
"go.uber.org/zap"
|
||||
)
|
||||
@@ -79,7 +79,7 @@ func (pr *ProcessRepos) Process(ctx context.Context, repository string, branch s
|
||||
return nil
|
||||
}
|
||||
|
||||
func (pr *ProcessRepos) getRepoUrls(ctx context.Context, schema *schema.KrakenSchema) ([]string, error) {
|
||||
func (pr *ProcessRepos) getRepoUrls(ctx context.Context, schema *schema.OctopushSchema) ([]string, error) {
|
||||
repoUrls := make([]string, 0)
|
||||
|
||||
repoUrls = append(repoUrls, schema.Select.Repositories...)
|
||||
@@ -231,7 +231,7 @@ func (pr *ProcessRepos) commit(ctx context.Context, area *storage.Area, repo *pr
|
||||
return err
|
||||
}
|
||||
|
||||
err = pr.gitea.CreatePr(ctx, fmt.Sprintf("%s://%s", "https", url.Host), org, semanticName, head, originHead, "kraken-apply")
|
||||
err = pr.gitea.CreatePr(ctx, fmt.Sprintf("%s://%s", "https", url.Host), org, semanticName, head, originHead, "octopush-apply")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@@ -12,7 +12,7 @@ func New() (*zap.Logger, error) {
|
||||
return lvl >= zapcore.ErrorLevel
|
||||
})
|
||||
lowPriority := zap.LevelEnablerFunc(func(lvl zapcore.Level) bool {
|
||||
return lvl < zapcore.ErrorLevel
|
||||
return lvl < zapcore.ErrorLevel && lvl > zapcore.DebugLevel
|
||||
})
|
||||
|
||||
config := zap.NewDevelopmentEncoderConfig()
|
||||
@@ -28,5 +28,6 @@ func New() (*zap.Logger, error) {
|
||||
)
|
||||
|
||||
logger := zap.New(core)
|
||||
|
||||
return logger, nil
|
||||
}
|
||||
|
@@ -2,7 +2,7 @@ package schema
|
||||
|
||||
import "gopkg.in/yaml.v3"
|
||||
|
||||
type KrakenSchema struct {
|
||||
type OctopushSchema struct {
|
||||
ApiVersion string `yaml:"apiVersion"`
|
||||
Name string `yaml:"name"`
|
||||
Select struct {
|
||||
@@ -22,8 +22,8 @@ type KrakenSchema struct {
|
||||
} `yaml:"queries"`
|
||||
}
|
||||
|
||||
func Unmarshal(raw string) (*KrakenSchema, error) {
|
||||
k := &KrakenSchema{}
|
||||
func Unmarshal(raw string) (*OctopushSchema, error) {
|
||||
k := &OctopushSchema{}
|
||||
err := yaml.Unmarshal([]byte(raw), k)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
@@ -7,8 +7,8 @@ import (
|
||||
"time"
|
||||
|
||||
"git.front.kjuulh.io/kjuulh/curre"
|
||||
"git.front.kjuulh.io/kjuulh/kraken/internal/api"
|
||||
"git.front.kjuulh.io/kjuulh/kraken/internal/serverdeps"
|
||||
"git.front.kjuulh.io/kjuulh/octopush/internal/api"
|
||||
"git.front.kjuulh.io/kjuulh/octopush/internal/serverdeps"
|
||||
ginzap "github.com/gin-contrib/zap"
|
||||
"github.com/gin-gonic/gin"
|
||||
"go.uber.org/zap"
|
||||
|
@@ -4,8 +4,8 @@ import (
|
||||
"context"
|
||||
|
||||
"git.front.kjuulh.io/kjuulh/curre"
|
||||
"git.front.kjuulh.io/kjuulh/kraken/internal/serverdeps"
|
||||
"git.front.kjuulh.io/kjuulh/kraken/internal/services/signer"
|
||||
"git.front.kjuulh.io/kjuulh/octopush/internal/serverdeps"
|
||||
"git.front.kjuulh.io/kjuulh/octopush/internal/services/signer"
|
||||
"go.uber.org/zap"
|
||||
)
|
||||
|
||||
|
@@ -5,7 +5,7 @@ import (
|
||||
"time"
|
||||
|
||||
"git.front.kjuulh.io/kjuulh/curre"
|
||||
"git.front.kjuulh.io/kjuulh/kraken/internal/serverdeps"
|
||||
"git.front.kjuulh.io/kjuulh/octopush/internal/serverdeps"
|
||||
"go.uber.org/zap"
|
||||
)
|
||||
|
||||
|
@@ -1,12 +1,12 @@
|
||||
package serverdeps
|
||||
|
||||
import (
|
||||
actionc "git.front.kjuulh.io/kjuulh/kraken/internal/actions"
|
||||
"git.front.kjuulh.io/kjuulh/kraken/internal/gitproviders"
|
||||
"git.front.kjuulh.io/kjuulh/kraken/internal/services/actions"
|
||||
"git.front.kjuulh.io/kjuulh/kraken/internal/services/providers"
|
||||
"git.front.kjuulh.io/kjuulh/kraken/internal/services/signer"
|
||||
"git.front.kjuulh.io/kjuulh/kraken/internal/services/storage"
|
||||
actionc "git.front.kjuulh.io/kjuulh/octopush/internal/actions"
|
||||
"git.front.kjuulh.io/kjuulh/octopush/internal/gitproviders"
|
||||
"git.front.kjuulh.io/kjuulh/octopush/internal/services/actions"
|
||||
"git.front.kjuulh.io/kjuulh/octopush/internal/services/providers"
|
||||
"git.front.kjuulh.io/kjuulh/octopush/internal/services/signer"
|
||||
"git.front.kjuulh.io/kjuulh/octopush/internal/services/storage"
|
||||
"go.uber.org/zap"
|
||||
)
|
||||
|
||||
@@ -42,7 +42,7 @@ func NewServerDeps(logger *zap.Logger) *ServerDeps {
|
||||
openPGPConfig := &signer.OpenPgpConfig{
|
||||
PrivateKeyFilePath: "./example/testkey.private.pgp",
|
||||
PrivateKeyPassword: "somepassword",
|
||||
PrivateKeyIdentity: "kraken@kasperhermansen.com",
|
||||
PrivateKeyIdentity: "octopush@kasperhermansen.com",
|
||||
}
|
||||
deps.openPGP = signer.NewOpenPGP(logger.With(zap.Namespace("openpgp")), openPGPConfig)
|
||||
|
||||
|
@@ -3,7 +3,7 @@ package actions
|
||||
import (
|
||||
"context"
|
||||
|
||||
"git.front.kjuulh.io/kjuulh/kraken/internal/services/storage"
|
||||
"git.front.kjuulh.io/kjuulh/octopush/internal/services/storage"
|
||||
"go.uber.org/zap"
|
||||
)
|
||||
|
||||
|
@@ -6,8 +6,8 @@ import (
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"git.front.kjuulh.io/kjuulh/kraken/internal/services/signer"
|
||||
"git.front.kjuulh.io/kjuulh/kraken/internal/services/storage"
|
||||
"git.front.kjuulh.io/kjuulh/octopush/internal/services/signer"
|
||||
"git.front.kjuulh.io/kjuulh/octopush/internal/services/storage"
|
||||
"github.com/go-git/go-git/v5"
|
||||
"github.com/go-git/go-git/v5/config"
|
||||
"github.com/go-git/go-git/v5/plumbing"
|
||||
@@ -206,9 +206,9 @@ func (g *Git) CreateBranch(ctx context.Context, gitRepo *GitRepo) error {
|
||||
return err
|
||||
}
|
||||
|
||||
refSpec := plumbing.NewBranchReferenceName("kraken-apply")
|
||||
refSpec := plumbing.NewBranchReferenceName("octopush-apply")
|
||||
err = gitRepo.repo.CreateBranch(&config.Branch{
|
||||
Name: "kraken-apply",
|
||||
Name: "octopush-apply",
|
||||
Remote: "origin",
|
||||
Merge: refSpec,
|
||||
Rebase: "",
|
||||
@@ -227,7 +227,7 @@ func (g *Git) CreateBranch(ctx context.Context, gitRepo *GitRepo) error {
|
||||
return fmt.Errorf("could not checkout branch: %w", err)
|
||||
}
|
||||
|
||||
remoteRef := plumbing.NewRemoteReferenceName("origin", "kraken-apply")
|
||||
remoteRef := plumbing.NewRemoteReferenceName("origin", "octopush-apply")
|
||||
ref := plumbing.NewSymbolicReference(refSpec, remoteRef)
|
||||
err = gitRepo.repo.Storer.SetReference(ref)
|
||||
if err != nil {
|
||||
@@ -268,8 +268,8 @@ func (g *Git) Commit(ctx context.Context, gitRepo *GitRepo) error {
|
||||
|
||||
_, err = worktree.Commit("some-commit", &git.CommitOptions{
|
||||
All: true,
|
||||
Author: &object.Signature{Name: "kraken", Email: "kraken@kasperhermansen.com", When: time.Now()},
|
||||
Committer: &object.Signature{Name: "kraken", Email: "kraken@kasperhermansen.com", When: time.Now()},
|
||||
Author: &object.Signature{Name: "octopush", Email: "octopush@kasperhermansen.com", When: time.Now()},
|
||||
Committer: &object.Signature{Name: "octopush", Email: "octopush@kasperhermansen.com", When: time.Now()},
|
||||
SignKey: g.openPGP.SigningKey,
|
||||
})
|
||||
if err != nil {
|
||||
|
@@ -22,7 +22,7 @@ func NewDefaultStorageConfig() (*StorageConfig, error) {
|
||||
return nil, err
|
||||
}
|
||||
return &StorageConfig{
|
||||
Path: path.Join(tempDir, "kraken"),
|
||||
Path: path.Join(tempDir, "octopush"),
|
||||
}, nil
|
||||
}
|
||||
|
||||
|
32
roadmap.md
32
roadmap.md
@@ -19,26 +19,38 @@
|
||||
## Version 0.1
|
||||
|
||||
- [x] Setup a way to choose actions and predicates
|
||||
- [x] Allow instantiation of actions, kraken template repo etc.
|
||||
- [x] Allow instantiation of actions, octopush template repo etc.
|
||||
- [x] Implement docker action
|
||||
- [x] Create pr for gitea provider
|
||||
- [x] Providing query results
|
||||
- [ ] Create CLI to trigger action
|
||||
- [x] Create CLI to trigger action
|
||||
|
||||
### Not in scope
|
||||
## Version 0.2
|
||||
|
||||
## Version 1.0
|
||||
|
||||
- [ ] Write README
|
||||
- [x] Write README
|
||||
- [ ] Make select depend on query
|
||||
- [ ] Make configurable ssh user
|
||||
- [ ] Make configurable gpg keyset
|
||||
- [ ] Make configurable git provider
|
||||
- [ ] Create templating function
|
||||
- [ ] Add github
|
||||
- [ ] Create templating function for easily creating new actions
|
||||
- [ ] Add way to see progress of runners
|
||||
- [ ] Implement global .kraken store for easy access
|
||||
- [ ] Move builders to start instead of every time
|
||||
- [ ] Implement global .octopush store for easy access to settings
|
||||
- [ ] Move builders to start instead of every building on every action
|
||||
- [ ] Setup releases on github
|
||||
- [ ] Setup CI
|
||||
- [ ] Setup static analysis
|
||||
- [ ] Setup releases on gitea using drone
|
||||
- [ ] Figure out a license (probably MIT)
|
||||
|
||||
## Version 1.x
|
||||
## Version 0.3
|
||||
|
||||
- [ ] Create setup version for local actions
|
||||
- [ ] Create setup version for server actions
|
||||
- [ ] Create json schema
|
||||
- [ ] Move roadmap to release / changelog
|
||||
|
||||
## Version 0.x
|
||||
|
||||
- Think about some sort of isolation
|
||||
- Run authenticated on servers
|
||||
|
@@ -2,6 +2,6 @@
|
||||
|
||||
set -e
|
||||
|
||||
git remote add github git@github.com:kjuulh/kraken.git || true
|
||||
git remote add github git@github.com:kjuulh/octopush.git || true
|
||||
|
||||
git push -f github main
|
||||
|
@@ -4,5 +4,8 @@ set -e
|
||||
|
||||
current_branch=$(git branch --show-current)
|
||||
|
||||
go run cmd/kraken/kraken.go process --actions-repo "git@git.front.kjuulh.io:kjuulh/kraken.git" --branch "$current_branch" --path "_examples/actions/write_a_readme"
|
||||
go run cmd/kraken/kraken.go process --actions-repo "git@git.front.kjuulh.io:kjuulh/kraken.git" --branch "$current_branch" --path "_examples/queries/scrape_readme"
|
||||
#go run cmd/octopush/octopush.go process --actions-repo "git@git.front.kjuulh.io:kjuulh/octopush.git" --branch "$current_branch" --path "_examples/actions/write_a_readme"
|
||||
go run cmd/octopush/octopush.go process \
|
||||
--actions-repo "git@git.front.kjuulh.io:kjuulh/octopush.git"\
|
||||
--branch "$current_branch" \
|
||||
--path "_examples/actions/add_releaserc"
|
||||
|
Reference in New Issue
Block a user