Skip to content

Commit

Permalink
Add build tag for sqlite + stubbed sqlite db (warrant-dev#76)
Browse files Browse the repository at this point in the history
  • Loading branch information
akajla09 authored Apr 12, 2023
1 parent 246342a commit 364efc6
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 7 deletions.
13 changes: 6 additions & 7 deletions cmd/warrant/Makefile
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
NAME = warrant
NAME = warrant
BUILD_PATH = bin/$(NAME)
GOENV = GOARCH=amd64 GOOS=linux CGO_ENABLED=0
GOCMD = go
GOBUILD = $(GOCMD) build -o
VERSION = $(shell cat VERSION)
GOENV = GOARCH=amd64 GOOS=linux CGO_ENABLED=0
GOCMD = go
GOBUILD = $(GOCMD) build -v -o $(BUILD_PATH)

.PHONY: clean
clean:
Expand All @@ -12,9 +11,9 @@ clean:
.PHONY: dev
dev: clean
$(GOCMD) get
$(GOBUILD) $(BUILD_PATH) main.go
$(GOBUILD) -tags="sqlite" main.go

.PHONY: build
build: clean
$(GOCMD) get
$(GOENV) $(GOBUILD) $(BUILD_PATH) -ldflags="-s -w" main.go
$(GOENV) $(GOBUILD) -ldflags="-s -w" main.go
36 changes: 36 additions & 0 deletions pkg/database/sqlite-stub.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
//go:build !sqlite
// +build !sqlite

package database

import (
"context"
"fmt"

"github.com/warrant-dev/warrant/pkg/config"
)

type SQLite struct {
SQL
Config config.SQLiteConfig
}

func NewSQLite(config config.SQLiteConfig) *SQLite {
return nil
}

func (ds SQLite) Type() string {
return TypeSQLite
}

func (ds *SQLite) Connect(ctx context.Context) error {
return fmt.Errorf("sqlite not supported")
}

func (ds SQLite) Migrate(ctx context.Context, toVersion uint) error {
return fmt.Errorf("sqlite not supported")
}

func (ds SQLite) Ping(ctx context.Context) error {
return fmt.Errorf("sqlite not supported")
}
3 changes: 3 additions & 0 deletions pkg/database/sqlite.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
//go:build sqlite
// +build sqlite

package database

import (
Expand Down

0 comments on commit 364efc6

Please sign in to comment.