Compare commits

...

15 Commits

Author SHA1 Message Date
e76d996943 Merge branch 'main' into main 2021-07-16 09:26:38 +02:00
c65ae974dd Add experimental staticcheck into linting CI
See https://staticcheck.io for more. This is set to be ignored
on failure so that it doesn't disrupt current work flows but maybe
it is nice to add. Just drop the `ignore: ...` line and it will fail
builds.
2021-07-15 23:57:08 +02:00
9b8f16345c Add a Go report card badge 2021-07-15 23:35:43 +02:00
4884c14ab3 Can't sort this as VERSION is not defined then 2021-07-15 23:26:47 +02:00
a9d9d9de2f Silence command echoing to focus output on errors 2021-07-15 23:01:31 +02:00
980f2f7684 Add format and check targets + integrate into CI 2021-07-15 23:00:33 +02:00
3b1dfb7562 Wire up notifications for failures 2021-07-15 22:29:31 +02:00
0a6ffd48cb Sort vars 2021-07-15 22:27:30 +02:00
567dae83cf Parametrize the abra path 2021-07-15 22:26:40 +02:00
2e7da361a6 Add proof of concept server ls comand 2021-07-15 17:04:40 +02:00
462a4d296f Add CI badge and link to OG abra repo 2021-07-15 15:40:29 +02:00
8373dea7fb Take a stab at a Drone CI/CD build 2021-07-15 15:37:54 +02:00
b13081d1a6 Add build, parametrize LDFLAGS and list all targets 2021-07-15 15:26:02 +02:00
8b38b89647 Ignore built binaries 2021-07-15 15:25:54 +02:00
3a96f48ec5 Merge pull request 'Add install and clean rules to Makefile' (#1) from knoflook/go-abra:main into main
Reviewed-on: coop-cloud/go-abra#1
2021-07-15 15:07:47 +02:00
5 changed files with 92 additions and 8 deletions

41
.drone.yml Normal file
View 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
View File

@ -0,0 +1 @@
abra

View File

@ -1,14 +1,28 @@
ABRA := ./cmd/abra
COMMIT := $(shell git rev-list -1 HEAD)
VERSION := $(shell cat ./version)
GOPATH := $(shell go env GOPATH)
VERSION := $(shell cat ./version)
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)

View File

@ -1,3 +1,6 @@
# go-abra
WIP port of abra to Golang.
[![Build Status](https://drone.autonomic.zone/api/badges/coop-cloud/go-abra/status.svg?ref=refs/heads/main)](https://drone.autonomic.zone/coop-cloud/go-abra)
[![Go Report Card](https://goreportcard.com/badge/git.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.

View File

@ -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{