From f98f22d9ccd27f7a41beec121fb10cad9a44d5d2 Mon Sep 17 00:00:00 2001 From: Jeffrey Paul Date: Mon, 4 Nov 2019 18:57:48 -0800 Subject: [PATCH] packageized --- Makefile | 8 +++++--- api.go | 4 ++++ cmd/feta/main.go | 8 +++++--- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index 1863756..fd58283 100644 --- a/Makefile +++ b/Makefile @@ -38,8 +38,8 @@ clean: build: ./$(FN) -./$(FN): *.go - go build -o $@ $(GOFLAGS) . +./$(FN): *.go cmd/*/*.go + cd cmd/$(FN) && go build -o ../../$(FN) $(GOFLAGS) . fmt: go fmt *.go @@ -49,7 +49,7 @@ test: build-docker-image is_uncommitted: git diff --exit-code >/dev/null 2>&1 -build-docker-image: is_uncommitted +build-docker-image: is_uncommitted clean docker build -t $(IMAGENAME):$(VERSION) -t $(IMAGENAME):latest -t $(IMAGENAME):$(BUILDTIMETAG) . dist: build-docker-image @@ -63,3 +63,5 @@ upload-docker-image: build-docker-image docker push $(IMAGENAME):$(VERSION) docker push $(IMAGENAME):$(BUILDTIMETAG) docker push $(IMAGENAME):latest + +.PHONY: build fmt test is_uncommitted build-docker-image dist hub upload-docker-image clean run rundebug default diff --git a/api.go b/api.go index b2d634a..c31cb11 100644 --- a/api.go +++ b/api.go @@ -13,6 +13,10 @@ type TootArchiverAPIServer struct { archiver *TootArchiver } +func (self *TootArchiverAPIServer) SetArchiver(archiver *TootArchiver) { + self.archiver = archiver +} + func (a *TootArchiverAPIServer) Serve() { if a.archiver == nil { panic("must have archiver from which to serve stats") diff --git a/cmd/feta/main.go b/cmd/feta/main.go index 96a7c82..69873a9 100644 --- a/cmd/feta/main.go +++ b/cmd/feta/main.go @@ -8,6 +8,8 @@ import "github.com/rs/zerolog" import "github.com/rs/zerolog/log" import "golang.org/x/crypto/ssh/terminal" +import "github.com/sneak/feta" + func main() { os.Exit(app()) } @@ -30,10 +32,10 @@ func app() int { zerolog.SetGlobalLevel(zerolog.DebugLevel) } - archiver := NewTootArchiver() + archiver := feta.NewTootArchiver() - api := new(TootArchiverAPIServer) - api.archiver = archiver + api := new(feta.TootArchiverAPIServer) + api.SetArchiver(archiver) var wg sync.WaitGroup