Compare commits

...

6 Commits

5 changed files with 47 additions and 7 deletions

8
.drone.yml Normal file
View File

@ -0,0 +1,8 @@
---
kind: pipeline
name: coopcloud.tech/abra
steps:
- name: make build
image: golang:1.16
commands:
- make build

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
abra

View File

@ -1,14 +1,18 @@
COMMIT := $(shell git rev-list -1 HEAD)
COMMIT := $(shell git rev-list -1 HEAD)
VERSION := $(shell cat ./version)
GOPATH := $(shell go env GOPATH)
GOPATH := $(shell go env GOPATH)
LDFLAGS := "-X 'main.Commit=$(COMMIT)' -X 'main.Version=$(VERSION)'"
all: run
all: run install build clean
run:
go run -ldflags="-X 'main.Commit=$(COMMIT)' -X 'main.Version=$(VERSION)'" ./cmd/abra
go run -ldflags=$(LDFLAGS) ./cmd/abra
install:
go install -ldflags="-X 'main.Commit=$(COMMIT)' -X 'main.Version=$(VERSION)'" ./cmd/abra
go install -ldflags=$(LDFLAGS) ./cmd/abra
build:
go build -ldflags=$(LDFLAGS) ./cmd/abra
clean:
rm '$(GOPATH)/bin/abra'

View File

@ -1,3 +1,5 @@
# 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)
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{