Compare commits
15 Commits
aa8db280e5
...
main
Author | SHA1 | Date | |
---|---|---|---|
e76d996943 | |||
c65ae974dd | |||
9b8f16345c | |||
4884c14ab3 | |||
a9d9d9de2f | |||
980f2f7684 | |||
3b1dfb7562 | |||
0a6ffd48cb | |||
567dae83cf | |||
2e7da361a6
|
|||
462a4d296f | |||
8373dea7fb | |||
b13081d1a6 | |||
8b38b89647 | |||
3a96f48ec5 |
41
.drone.yml
Normal file
41
.drone.yml
Normal file
@ -0,0 +1,41 @@
|
||||
---
|
||||
kind: pipeline
|
||||
name: coopcloud.tech/abra
|
||||
steps:
|
||||
- name: make check
|
||||
image: golang:1.16
|
||||
commands:
|
||||
- make check
|
||||
|
||||
- name: make static
|
||||
image: golang:1.16
|
||||
ignore: true # until we decide we all want this check
|
||||
environment:
|
||||
STATIC_CHECK_URL: honnef.co/go/tools/cmd/staticcheck
|
||||
STATIC_CHECK_VERSION: v0.2.0
|
||||
commands:
|
||||
- go install $STATIC_CHECK_URL@$STATIC_CHECK_VERSION
|
||||
- make static
|
||||
|
||||
- name: make build
|
||||
image: golang:1.16
|
||||
commands:
|
||||
- make build
|
||||
|
||||
- name: notify on failure
|
||||
image: plugins/matrix
|
||||
settings:
|
||||
homeserver: https://matrix.autonomic.zone
|
||||
roomid: "IFazIpLtxiScqbHqoa:autonomic.zone"
|
||||
userid: "@autono-bot:autonomic.zone"
|
||||
accesstoken:
|
||||
from_secret: autono_bot_access_token
|
||||
depends_on:
|
||||
- make check
|
||||
- make build
|
||||
when:
|
||||
status:
|
||||
- failure
|
||||
trigger:
|
||||
branch:
|
||||
- main
|
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
abra
|
26
Makefile
26
Makefile
@ -1,14 +1,28 @@
|
||||
COMMIT := $(shell git rev-list -1 HEAD)
|
||||
ABRA := ./cmd/abra
|
||||
COMMIT := $(shell git rev-list -1 HEAD)
|
||||
GOPATH := $(shell go env GOPATH)
|
||||
VERSION := $(shell cat ./version)
|
||||
GOPATH := $(shell go env GOPATH)
|
||||
LDFLAGS := "-X 'main.Commit=$(COMMIT)' -X 'main.Version=$(VERSION)'"
|
||||
|
||||
all: run
|
||||
all: run install build clean format check static
|
||||
|
||||
run:
|
||||
go run -ldflags="-X 'main.Commit=$(COMMIT)' -X 'main.Version=$(VERSION)'" ./cmd/abra
|
||||
@go run -ldflags=$(LDFLAGS) $(ABRA)
|
||||
|
||||
install:
|
||||
go install -ldflags="-X 'main.Commit=$(COMMIT)' -X 'main.Version=$(VERSION)'" ./cmd/abra
|
||||
@go install -ldflags=$(LDFLAGS) $(ABRA)
|
||||
|
||||
build:
|
||||
@go build -ldflags=$(LDFLAGS) $(ABRA)
|
||||
|
||||
clean:
|
||||
rm '$(GOPATH)/bin/abra'
|
||||
@rm '$(GOPATH)/bin/abra'
|
||||
|
||||
format:
|
||||
@gofmt -s -w .
|
||||
|
||||
check:
|
||||
@test -z $$(gofmt -l .) || (echo "gofmt: formatting issue - run 'make format' to resolve" && exit 1)
|
||||
|
||||
static:
|
||||
@staticcheck $(ABRA)
|
||||
|
@ -1,3 +1,6 @@
|
||||
# go-abra
|
||||
|
||||
WIP port of abra to Golang.
|
||||
[](https://drone.autonomic.zone/coop-cloud/go-abra)
|
||||
[](https://goreportcard.com/report/git.autonomic.zone/coop-cloud/go-abra)
|
||||
|
||||
WIP port of [abra](https://git.autonomic.zone/coop-cloud/abra) to Golang.
|
||||
|
@ -2,6 +2,10 @@ package cli
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"os/exec"
|
||||
"log"
|
||||
|
||||
"github.com/urfave/cli/v2"
|
||||
)
|
||||
@ -12,6 +16,27 @@ var serverListCommand = &cli.Command{
|
||||
Usage: "List locally-defined servers.",
|
||||
ArgsUsage: emptyArgsUsage,
|
||||
HideHelp: true,
|
||||
Action: func(c *cli.Context) error {
|
||||
abradir := os.Getenv("HOME") + "/.abra"
|
||||
|
||||
servers, err := ioutil.ReadDir(abradir + "/servers")
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
fmt.Println("\033[33mLoading status from", len(servers), "server(s), patience advised...\033[0m")
|
||||
fmt.Println(len(servers), "servers:\n")
|
||||
fmt.Println(" NAME\tCONNECTION")
|
||||
fmt.Println(" --\t--")
|
||||
for _, s := range servers {
|
||||
conn, err := exec.Command("docker", "context", "inspect", s.Name(), "-f", "{{.Endpoints.docker.Host}}").Output()
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
fmt.Printf(" %s\t%s\n", s.Name(), string(conn))
|
||||
}
|
||||
|
||||
return nil
|
||||
},
|
||||
}
|
||||
|
||||
var serverAddCommand = &cli.Command{
|
||||
|
Reference in New Issue
Block a user