Bazel structure and bin to convert HallOfBeorn dump to CSV for ALEP pipeline
This commit is contained in:
38
.gitignore
vendored
Normal file
38
.gitignore
vendored
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
# ---> Bazel
|
||||||
|
# gitignore template for Bazel build system
|
||||||
|
# website: https://bazel.build/
|
||||||
|
|
||||||
|
# Ignore all bazel-* symlinks. There is no full list since this can change
|
||||||
|
# based on the name of the directory bazel is cloned into.
|
||||||
|
/bazel-*
|
||||||
|
|
||||||
|
# Directories for the Bazel IntelliJ plugin containing the generated
|
||||||
|
# IntelliJ project files and plugin configuration. Seperate directories are
|
||||||
|
# for the IntelliJ, Android Studio and CLion versions of the plugin.
|
||||||
|
/.ijwb/
|
||||||
|
/.aswb/
|
||||||
|
/.clwb/
|
||||||
|
|
||||||
|
# ---> Go
|
||||||
|
# If you prefer the allow list template instead of the deny list, see community template:
|
||||||
|
# https://github.com/github/gitignore/blob/main/community/Golang/Go.AllowList.gitignore
|
||||||
|
#
|
||||||
|
# Binaries for programs and plugins
|
||||||
|
*.exe
|
||||||
|
*.exe~
|
||||||
|
*.dll
|
||||||
|
*.so
|
||||||
|
*.dylib
|
||||||
|
|
||||||
|
# Test binary, built with `go test -c`
|
||||||
|
*.test
|
||||||
|
|
||||||
|
# Output of the go coverage tool, specifically when used with LiteIDE
|
||||||
|
*.out
|
||||||
|
|
||||||
|
# Dependency directories (remove the comment below to include it)
|
||||||
|
# vendor/
|
||||||
|
|
||||||
|
# Go workspace file
|
||||||
|
go.work
|
||||||
|
|
6
.gitmodules
vendored
Normal file
6
.gitmodules
vendored
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
[submodule "submodule/src/bare"]
|
||||||
|
path = submodule/src/bare
|
||||||
|
url = git://github.com/laramiel/bazel-example-golang-bare
|
||||||
|
[submodule "submodule/src/remote"]
|
||||||
|
path = submodule/src/remote
|
||||||
|
url = git://github.com/laramiel/bazel-example-golang-remote
|
25
BUILD
Normal file
25
BUILD
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
package(
|
||||||
|
default_visibility = ["//visibility:public"],
|
||||||
|
)
|
||||||
|
|
||||||
|
load("@bazel_gazelle//:def.bzl", "gazelle")
|
||||||
|
|
||||||
|
# gazelle:prefix github.com/squk/lotr
|
||||||
|
# gazelle:build_file_name BUILD
|
||||||
|
gazelle(name = "gazelle")
|
||||||
|
|
||||||
|
gazelle(
|
||||||
|
name = "gazelle-update-repos",
|
||||||
|
args = [
|
||||||
|
"-from_file=go.mod",
|
||||||
|
"-to_macro=deps.bzl%go_dependencies",
|
||||||
|
"-prune",
|
||||||
|
"-build_file_proto_mode=disable_global",
|
||||||
|
],
|
||||||
|
command = "update-repos",
|
||||||
|
)
|
||||||
|
|
||||||
|
alias(
|
||||||
|
name = "beornextract",
|
||||||
|
actual = "//cmd/beornextract:beornextract",
|
||||||
|
)
|
39
WORKSPACE
Normal file
39
WORKSPACE
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
|
||||||
|
|
||||||
|
http_archive(
|
||||||
|
name = "io_bazel_rules_go",
|
||||||
|
sha256 = "6dc2da7ab4cf5d7bfc7c949776b1b7c733f05e56edc4bcd9022bb249d2e2a996",
|
||||||
|
urls = [
|
||||||
|
"https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v0.39.1/rules_go-v0.39.1.zip",
|
||||||
|
"https://github.com/bazelbuild/rules_go/releases/download/v0.39.1/rules_go-v0.39.1.zip",
|
||||||
|
],
|
||||||
|
)
|
||||||
|
|
||||||
|
http_archive(
|
||||||
|
name = "bazel_gazelle",
|
||||||
|
sha256 = "727f3e4edd96ea20c29e8c2ca9e8d2af724d8c7778e7923a854b2c80952bc405",
|
||||||
|
urls = [
|
||||||
|
"https://mirror.bazel.build/github.com/bazelbuild/bazel-gazelle/releases/download/v0.30.0/bazel-gazelle-v0.30.0.tar.gz",
|
||||||
|
"https://github.com/bazelbuild/bazel-gazelle/releases/download/v0.30.0/bazel-gazelle-v0.30.0.tar.gz",
|
||||||
|
],
|
||||||
|
)
|
||||||
|
|
||||||
|
load("@io_bazel_rules_go//go:deps.bzl", "go_register_toolchains", "go_rules_dependencies")
|
||||||
|
load("@bazel_gazelle//:deps.bzl", "gazelle_dependencies", "go_repository")
|
||||||
|
|
||||||
|
############################################################
|
||||||
|
# Define your own dependencies here using go_repository.
|
||||||
|
# Else, dependencies declared by rules_go/gazelle will be used.
|
||||||
|
# The first declaration of an external repository "wins".
|
||||||
|
############################################################
|
||||||
|
|
||||||
|
load("//:deps.bzl", "go_dependencies")
|
||||||
|
|
||||||
|
# gazelle:repository_macro deps.bzl%go_dependencies
|
||||||
|
go_dependencies()
|
||||||
|
|
||||||
|
go_rules_dependencies()
|
||||||
|
|
||||||
|
go_register_toolchains(version = "1.20.4")
|
||||||
|
|
||||||
|
gazelle_dependencies()
|
26
cmd/beornextract/BUILD
Normal file
26
cmd/beornextract/BUILD
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library")
|
||||||
|
|
||||||
|
package(
|
||||||
|
default_visibility = ["//visibility:public"],
|
||||||
|
)
|
||||||
|
|
||||||
|
go_library(
|
||||||
|
name = "beornextract_lib",
|
||||||
|
srcs = ["main.go"],
|
||||||
|
data = [
|
||||||
|
"//cmd/beornextract/data:Bot.Cards.json",
|
||||||
|
"//cmd/beornextract/data:Export.Cards.json",
|
||||||
|
],
|
||||||
|
importpath = "github.com/squk/lotr/cmd/beornextract",
|
||||||
|
deps = [
|
||||||
|
"//cmd/beornextract/types",
|
||||||
|
"@com_github_grokify_html_strip_tags_go//:html-strip-tags-go",
|
||||||
|
"@com_github_jessevdk_go_flags//:go_default_library",
|
||||||
|
"@io_bazel_rules_go//go/tools/bazel:go_default_library",
|
||||||
|
],
|
||||||
|
)
|
||||||
|
|
||||||
|
go_binary(
|
||||||
|
name = "beornextract",
|
||||||
|
embed = [":beornextract_lib"],
|
||||||
|
)
|
2
cmd/beornextract/data/BUILD
Normal file
2
cmd/beornextract/data/BUILD
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
exports_files(glob(["*.json"]))
|
||||||
|
# exports_files(["Export.Cards.json"])
|
1
cmd/beornextract/data/Bot.Cards.json
Normal file
1
cmd/beornextract/data/Bot.Cards.json
Normal file
File diff suppressed because one or more lines are too long
1
cmd/beornextract/data/Export.Cards.json
Normal file
1
cmd/beornextract/data/Export.Cards.json
Normal file
File diff suppressed because one or more lines are too long
1
cmd/beornextract/data/ringsdb.json
Normal file
1
cmd/beornextract/data/ringsdb.json
Normal file
File diff suppressed because one or more lines are too long
136
cmd/beornextract/main.go
Normal file
136
cmd/beornextract/main.go
Normal file
@ -0,0 +1,136 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"encoding/csv"
|
||||||
|
"encoding/json"
|
||||||
|
"fmt"
|
||||||
|
"io/ioutil"
|
||||||
|
"log"
|
||||||
|
"os"
|
||||||
|
"path/filepath"
|
||||||
|
"regexp"
|
||||||
|
"strconv"
|
||||||
|
"strings"
|
||||||
|
|
||||||
|
"github.com/bazelbuild/rules_go/go/tools/bazel"
|
||||||
|
strip "github.com/grokify/html-strip-tags-go"
|
||||||
|
"github.com/jessevdk/go-flags"
|
||||||
|
"github.com/squk/lotr/cmd/beornextract/types"
|
||||||
|
)
|
||||||
|
|
||||||
|
type Options struct {
|
||||||
|
RawConversion bool `short:"r" long:"raw" description:"Enable to keep the original text from HallOfBeorn dump. Enable to prep for ALEP pipeline."`
|
||||||
|
}
|
||||||
|
|
||||||
|
var opts = Options{
|
||||||
|
RawConversion: false,
|
||||||
|
}
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
_, err := flags.ParseArgs(&opts, os.Args)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
fmt.Println("LOTR CARD PARSE")
|
||||||
|
f, err := bazel.Runfile(".")
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
err = filepath.Walk(f,
|
||||||
|
func(path string, info os.FileInfo, err error) error {
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
fmt.Println(path, info.Size())
|
||||||
|
return nil
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
log.Println(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Open our jsonFile
|
||||||
|
// jsonFile, err := os.Open("cmd/beornextract/data/Bot.Cards.json")
|
||||||
|
jsonFile, err := os.Open("cmd/beornextract/data/Export.Cards.json")
|
||||||
|
// if we os.Open returns an error then handle it
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
// defer the closing of our jsonFile so that we can parse it later on
|
||||||
|
defer jsonFile.Close()
|
||||||
|
|
||||||
|
byteValue, _ := ioutil.ReadAll(jsonFile)
|
||||||
|
cards := []types.HallOfBeornCard{}
|
||||||
|
json.Unmarshal(byteValue, &cards)
|
||||||
|
|
||||||
|
// Open a file for writing
|
||||||
|
csvFile, err := os.Create("/Users/christian/Downloads/lotr-lcg-set-generator.csv")
|
||||||
|
defer csvFile.Close()
|
||||||
|
if err != nil {
|
||||||
|
// Handle error
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create a writer
|
||||||
|
w := csv.NewWriter(csvFile)
|
||||||
|
|
||||||
|
// Write some rows
|
||||||
|
for _, card := range cards {
|
||||||
|
if card.EncounterSet != "" {
|
||||||
|
continue // skip non=player cards
|
||||||
|
}
|
||||||
|
|
||||||
|
w.Write(
|
||||||
|
[]string{
|
||||||
|
card.Octgnid,
|
||||||
|
"", // hidden
|
||||||
|
"", // hidden
|
||||||
|
card.EncounterSet,
|
||||||
|
strconv.Itoa(card.Position),
|
||||||
|
strconv.Itoa(card.Quantity),
|
||||||
|
card.Name,
|
||||||
|
fmt.Sprintf(
|
||||||
|
"%t",
|
||||||
|
card.IsUnique,
|
||||||
|
),
|
||||||
|
card.TypeName,
|
||||||
|
card.SphereName,
|
||||||
|
card.Traits,
|
||||||
|
findKeywords(card.Text),
|
||||||
|
card.Cost,
|
||||||
|
card.EngagementCost,
|
||||||
|
strconv.Itoa(card.Threat),
|
||||||
|
strconv.Itoa(card.Willpower),
|
||||||
|
strconv.Itoa(card.Attack),
|
||||||
|
strconv.Itoa(card.Defense),
|
||||||
|
strconv.Itoa(card.Health),
|
||||||
|
card.QuestPoints,
|
||||||
|
strconv.Itoa(card.VictoryPoints),
|
||||||
|
"", // Special Icon
|
||||||
|
transformText(card.Name, card.Text),
|
||||||
|
card.Flavor,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Close the writer
|
||||||
|
w.Flush()
|
||||||
|
// spew.Dump(c)
|
||||||
|
}
|
||||||
|
|
||||||
|
func transformText(name, text string) string {
|
||||||
|
if opts.RawConversion {
|
||||||
|
return text
|
||||||
|
}
|
||||||
|
|
||||||
|
out := strings.ReplaceAll(text, name, "[name]") // insert name tag
|
||||||
|
out = strip.StripTags(out)
|
||||||
|
out = keywordPattern.ReplaceAllLiteralString(out, "")
|
||||||
|
return strings.TrimSpace(out)
|
||||||
|
}
|
||||||
|
|
||||||
|
var keywordPattern = regexp.MustCompile(`((?:(?:[A-Z][a-z]+(\.|\s[0-9]+\.)\s*)+))`)
|
||||||
|
|
||||||
|
func findKeywords(text string) string {
|
||||||
|
return strings.TrimSpace(keywordPattern.FindString(text))
|
||||||
|
}
|
8
cmd/beornextract/types/BUILD
Normal file
8
cmd/beornextract/types/BUILD
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
load("@io_bazel_rules_go//go:def.bzl", "go_library")
|
||||||
|
|
||||||
|
go_library(
|
||||||
|
name = "types",
|
||||||
|
srcs = ["card.go"],
|
||||||
|
importpath = "github.com/squk/lotr/cmd/beornextract/types",
|
||||||
|
visibility = ["//visibility:public"],
|
||||||
|
)
|
27
cmd/beornextract/types/card.go
Normal file
27
cmd/beornextract/types/card.go
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
package types
|
||||||
|
|
||||||
|
type HallOfBeornCard struct {
|
||||||
|
PackCode string `json:"pack_code,omitempty"`
|
||||||
|
PackName string `json:"pack_name,omitempty"`
|
||||||
|
IsOfficial bool `json:"is_official,omitempty"`
|
||||||
|
TypeCode string `json:"type_code,omitempty"`
|
||||||
|
TypeName string `json:"type_name,omitempty"`
|
||||||
|
SphereCode string `json:"sphere_code,omitempty"`
|
||||||
|
SphereName string `json:"sphere_name,omitempty"`
|
||||||
|
Position int `json:"position,omitempty"`
|
||||||
|
Threat int `json:"threat,omitempty"`
|
||||||
|
Willpower int `json:"willpower,omitempty"`
|
||||||
|
Attack int `json:"attack,omitempty"`
|
||||||
|
Defense int `json:"defense,omitempty"`
|
||||||
|
Health int `json:"health,omitempty"`
|
||||||
|
Octgnid string `json:"octgnid,omitempty"`
|
||||||
|
HasErrata bool `json:"has_errata,omitempty"`
|
||||||
|
URL string `json:"url,omitempty"`
|
||||||
|
QuestPoints string `json:"quest,omitempty"`
|
||||||
|
VictoryPoints int `json:"victory,omitempty"`
|
||||||
|
Imagesrc string `json:"imagesrc,omitempty"`
|
||||||
|
|
||||||
|
EncounterSet string `json:"encounter_set,omitempty"`
|
||||||
|
EngagementCost string `json:"engagement_cost,omitempty"`
|
||||||
|
ThreatStrength int `json:"threat_strength,omitempty"`
|
||||||
|
}
|
18
cmd/test/BUILD
Normal file
18
cmd/test/BUILD
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library")
|
||||||
|
|
||||||
|
go_library(
|
||||||
|
name = "test_lib",
|
||||||
|
srcs = ["main.go"],
|
||||||
|
importpath = "github.com/squk/lotr/cmd/test",
|
||||||
|
visibility = ["//visibility:private"],
|
||||||
|
deps = [
|
||||||
|
"@com_github_davecgh_go_spew//spew",
|
||||||
|
"@com_github_mattn_go_sqlite3//:go-sqlite3",
|
||||||
|
],
|
||||||
|
)
|
||||||
|
|
||||||
|
go_binary(
|
||||||
|
name = "test",
|
||||||
|
embed = [":test_lib"],
|
||||||
|
visibility = ["//visibility:public"],
|
||||||
|
)
|
113
cmd/test/main.go
Normal file
113
cmd/test/main.go
Normal file
@ -0,0 +1,113 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"database/sql"
|
||||||
|
"fmt"
|
||||||
|
"log"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"github.com/davecgh/go-spew/spew"
|
||||||
|
_ "github.com/mattn/go-sqlite3"
|
||||||
|
)
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
spew.Dump(os.Getwd())
|
||||||
|
|
||||||
|
os.Remove("./foo.db")
|
||||||
|
|
||||||
|
db, err := sql.Open("sqlite3", "./foo.db")
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal(err)
|
||||||
|
}
|
||||||
|
defer db.Close()
|
||||||
|
|
||||||
|
sqlStmt := `
|
||||||
|
create table foo (id integer not null primary key, name text);
|
||||||
|
delete from foo;
|
||||||
|
`
|
||||||
|
_, err = db.Exec(sqlStmt)
|
||||||
|
if err != nil {
|
||||||
|
log.Printf("%q: %s\n", err, sqlStmt)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
tx, err := db.Begin()
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal(err)
|
||||||
|
}
|
||||||
|
stmt, err := tx.Prepare("insert into foo(id, name) values(?, ?)")
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal(err)
|
||||||
|
}
|
||||||
|
defer stmt.Close()
|
||||||
|
for i := 0; i < 100; i++ {
|
||||||
|
_, err = stmt.Exec(i, fmt.Sprintf("こんにちは世界%03d", i))
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
err = tx.Commit()
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
rows, err := db.Query("select id, name from foo")
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal(err)
|
||||||
|
}
|
||||||
|
defer rows.Close()
|
||||||
|
for rows.Next() {
|
||||||
|
var id int
|
||||||
|
var name string
|
||||||
|
err = rows.Scan(&id, &name)
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal(err)
|
||||||
|
}
|
||||||
|
fmt.Println(id, name)
|
||||||
|
}
|
||||||
|
err = rows.Err()
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
stmt, err = db.Prepare("select name from foo where id = ?")
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal(err)
|
||||||
|
}
|
||||||
|
defer stmt.Close()
|
||||||
|
var name string
|
||||||
|
err = stmt.QueryRow("3").Scan(&name)
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal(err)
|
||||||
|
}
|
||||||
|
fmt.Println(name)
|
||||||
|
|
||||||
|
_, err = db.Exec("delete from foo")
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
_, err = db.Exec("insert into foo(id, name) values(1, 'foo'), (2, 'bar'), (3, 'baz')")
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
rows, err = db.Query("select id, name from foo")
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal(err)
|
||||||
|
}
|
||||||
|
defer rows.Close()
|
||||||
|
for rows.Next() {
|
||||||
|
var id int
|
||||||
|
var name string
|
||||||
|
err = rows.Scan(&id, &name)
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal(err)
|
||||||
|
}
|
||||||
|
fmt.Println(id, name)
|
||||||
|
}
|
||||||
|
err = rows.Err()
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal(err)
|
||||||
|
}
|
||||||
|
}
|
96
deps.bzl
Normal file
96
deps.bzl
Normal file
@ -0,0 +1,96 @@
|
|||||||
|
load("@bazel_gazelle//:deps.bzl", "go_repository")
|
||||||
|
|
||||||
|
def go_dependencies():
|
||||||
|
go_repository(
|
||||||
|
name = "com_github_bazelbuild_rules_go",
|
||||||
|
build_file_proto_mode = "disable_global",
|
||||||
|
importpath = "github.com/bazelbuild/rules_go",
|
||||||
|
sum = "h1:JzlRxsFNhlX+g4drDRPhIaU5H5LnI978wdMJ0vK4I+k=",
|
||||||
|
version = "v0.41.0",
|
||||||
|
)
|
||||||
|
|
||||||
|
go_repository(
|
||||||
|
name = "com_github_davecgh_go_spew",
|
||||||
|
build_file_proto_mode = "disable_global",
|
||||||
|
importpath = "github.com/davecgh/go-spew",
|
||||||
|
sum = "h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=",
|
||||||
|
version = "v1.1.1",
|
||||||
|
)
|
||||||
|
go_repository(
|
||||||
|
name = "com_github_golang_mock",
|
||||||
|
build_file_proto_mode = "disable_global",
|
||||||
|
importpath = "github.com/golang/mock",
|
||||||
|
sum = "h1:ErTB+efbowRARo13NNdxyJji2egdxLGQhRaY+DUumQc=",
|
||||||
|
version = "v1.6.0",
|
||||||
|
)
|
||||||
|
go_repository(
|
||||||
|
name = "com_github_golang_protobuf",
|
||||||
|
build_file_proto_mode = "disable_global",
|
||||||
|
importpath = "github.com/golang/protobuf",
|
||||||
|
sum = "h1:ROPKBNFfQgOUMifHyP+KYbvpjbdoFNs+aK7DXlji0Tw=",
|
||||||
|
version = "v1.5.2",
|
||||||
|
)
|
||||||
|
go_repository(
|
||||||
|
name = "com_github_grokify_html_strip_tags_go",
|
||||||
|
build_file_proto_mode = "disable_global",
|
||||||
|
importpath = "github.com/grokify/html-strip-tags-go",
|
||||||
|
sum = "h1:0fThFwLbW7P/kOiTBs03FsJSV9RM2M/Q/MOnCQxKMo0=",
|
||||||
|
version = "v0.0.1",
|
||||||
|
)
|
||||||
|
go_repository(
|
||||||
|
name = "com_github_jessevdk_go_flags",
|
||||||
|
build_file_proto_mode = "disable_global",
|
||||||
|
importpath = "github.com/jessevdk/go-flags",
|
||||||
|
sum = "h1:1jKYvbxEjfUl0fmqTCOfonvskHHXMjBySTLW4y9LFvc=",
|
||||||
|
version = "v1.5.0",
|
||||||
|
)
|
||||||
|
|
||||||
|
go_repository(
|
||||||
|
name = "com_github_mattn_go_sqlite3",
|
||||||
|
build_file_proto_mode = "disable_global",
|
||||||
|
importpath = "github.com/mattn/go-sqlite3",
|
||||||
|
sum = "h1:mCRHCLDUBXgpKAqIKsaAaAsrAlbkeomtRFKXh2L6YIM=",
|
||||||
|
version = "v1.14.17",
|
||||||
|
)
|
||||||
|
go_repository(
|
||||||
|
name = "org_golang_google_genproto",
|
||||||
|
build_file_proto_mode = "disable_global",
|
||||||
|
importpath = "google.golang.org/genproto",
|
||||||
|
sum = "h1:+kGHl1aib/qcwaRi1CbqBZ1rk19r85MNUf8HaBghugY=",
|
||||||
|
version = "v0.0.0-20200526211855-cb27e3aa2013",
|
||||||
|
)
|
||||||
|
go_repository(
|
||||||
|
name = "org_golang_google_grpc",
|
||||||
|
build_file_proto_mode = "disable_global",
|
||||||
|
importpath = "google.golang.org/grpc",
|
||||||
|
sum = "h1:fPVVDxY9w++VjTZsYvXWqEf9Rqar/e+9zYfxKK+W+YU=",
|
||||||
|
version = "v1.50.0",
|
||||||
|
)
|
||||||
|
go_repository(
|
||||||
|
name = "org_golang_google_protobuf",
|
||||||
|
build_file_proto_mode = "disable_global",
|
||||||
|
importpath = "google.golang.org/protobuf",
|
||||||
|
sum = "h1:w43yiav+6bVFTBQFZX0r7ipe9JQ1QsbMgHwbBziscLw=",
|
||||||
|
version = "v1.28.0",
|
||||||
|
)
|
||||||
|
go_repository(
|
||||||
|
name = "org_golang_x_net",
|
||||||
|
build_file_proto_mode = "disable_global",
|
||||||
|
importpath = "golang.org/x/net",
|
||||||
|
sum = "h1:4nGaVu0QrbjT/AK2PRLuQfQuh6DJve+pELhqTdAj3x0=",
|
||||||
|
version = "v0.0.0-20210405180319-a5a99cb37ef4",
|
||||||
|
)
|
||||||
|
go_repository(
|
||||||
|
name = "org_golang_x_sys",
|
||||||
|
build_file_proto_mode = "disable_global",
|
||||||
|
importpath = "golang.org/x/sys",
|
||||||
|
sum = "h1:gG67DSER+11cZvqIMb8S8bt0vZtiN6xWYARwirrOSfE=",
|
||||||
|
version = "v0.0.0-20210510120138-977fb7262007",
|
||||||
|
)
|
||||||
|
go_repository(
|
||||||
|
name = "org_golang_x_text",
|
||||||
|
build_file_proto_mode = "disable_global",
|
||||||
|
importpath = "golang.org/x/text",
|
||||||
|
sum = "h1:cokOdA+Jmi5PJGXLlLllQSgYigAEfHXJAERHVMaCc2k=",
|
||||||
|
version = "v0.3.3",
|
||||||
|
)
|
13
go.mod
Normal file
13
go.mod
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
module github.com/squk/lotr
|
||||||
|
|
||||||
|
go 1.19
|
||||||
|
|
||||||
|
require github.com/davecgh/go-spew v1.1.1
|
||||||
|
|
||||||
|
require (
|
||||||
|
github.com/bazelbuild/rules_go v0.41.0 // indirect
|
||||||
|
github.com/grokify/html-strip-tags-go v0.0.1 // indirect
|
||||||
|
github.com/jessevdk/go-flags v1.5.0 // indirect
|
||||||
|
github.com/mattn/go-sqlite3 v1.14.17 // indirect
|
||||||
|
golang.org/x/sys v0.0.0-20210510120138-977fb7262007 // indirect
|
||||||
|
)
|
13
go.sum
Normal file
13
go.sum
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
github.com/bazelbuild/rules_go v0.41.0 h1:JzlRxsFNhlX+g4drDRPhIaU5H5LnI978wdMJ0vK4I+k=
|
||||||
|
github.com/bazelbuild/rules_go v0.41.0/go.mod h1:TMHmtfpvyfsxaqfL9WnahCsXMWDMICTw7XeK9yVb+YU=
|
||||||
|
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||||
|
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
|
github.com/grokify/html-strip-tags-go v0.0.1 h1:0fThFwLbW7P/kOiTBs03FsJSV9RM2M/Q/MOnCQxKMo0=
|
||||||
|
github.com/grokify/html-strip-tags-go v0.0.1/go.mod h1:2Su6romC5/1VXOQMaWL2yb618ARB8iVo6/DR99A6d78=
|
||||||
|
github.com/jessevdk/go-flags v1.5.0 h1:1jKYvbxEjfUl0fmqTCOfonvskHHXMjBySTLW4y9LFvc=
|
||||||
|
github.com/jessevdk/go-flags v1.5.0/go.mod h1:Fw0T6WPc1dYxT4mKEZRfG5kJhaTDP9pj1c2EWnYs/m4=
|
||||||
|
github.com/mattn/go-sqlite3 v1.14.17 h1:mCRHCLDUBXgpKAqIKsaAaAsrAlbkeomtRFKXh2L6YIM=
|
||||||
|
github.com/mattn/go-sqlite3 v1.14.17/go.mod h1:2eHXhiwb8IkHr+BDWZGa96P6+rkvnG63S2DGjv9HUNg=
|
||||||
|
golang.org/x/sys v0.0.0-20210320140829-1e4c9ba3b0c4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
|
golang.org/x/sys v0.0.0-20210510120138-977fb7262007 h1:gG67DSER+11cZvqIMb8S8bt0vZtiN6xWYARwirrOSfE=
|
||||||
|
golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
50
server/docker-compose.yaml
Normal file
50
server/docker-compose.yaml
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
version: "3.6"
|
||||||
|
services:
|
||||||
|
postgres:
|
||||||
|
image: postgres:15
|
||||||
|
restart: always
|
||||||
|
volumes:
|
||||||
|
- db_data:/var/lib/postgresql/data
|
||||||
|
environment:
|
||||||
|
POSTGRES_PASSWORD: lotrlcgpassword
|
||||||
|
graphql-engine:
|
||||||
|
image: hasura/graphql-engine:v2.28.0
|
||||||
|
ports:
|
||||||
|
- "8080:8080"
|
||||||
|
restart: always
|
||||||
|
environment:
|
||||||
|
## postgres database to store Hasura metadata
|
||||||
|
HASURA_GRAPHQL_METADATA_DATABASE_URL: postgres://postgres:lotrlcgpassword@postgres:5432/postgres
|
||||||
|
## this env var can be used to add the above postgres database to Hasura as a data source. this can be removed/updated based on your needs
|
||||||
|
PG_DATABASE_URL: postgres://postgres:lotrlcgpassword@postgres:5432/postgres
|
||||||
|
## enable the console served by server
|
||||||
|
HASURA_GRAPHQL_ENABLE_CONSOLE: "true" # set to "false" to disable console
|
||||||
|
## enable debugging mode. It is recommended to disable this in production
|
||||||
|
HASURA_GRAPHQL_DEV_MODE: "true"
|
||||||
|
HASURA_GRAPHQL_ENABLED_LOG_TYPES: startup, http-log, webhook-log, websocket-log, query-log
|
||||||
|
## uncomment next line to run console offline (i.e load console assets from server instead of CDN)
|
||||||
|
# HASURA_GRAPHQL_CONSOLE_ASSETS_DIR: /srv/console-assets
|
||||||
|
## uncomment next line to set an admin secret
|
||||||
|
# HASURA_GRAPHQL_ADMIN_SECRET: myadminsecretkey
|
||||||
|
HASURA_GRAPHQL_METADATA_DEFAULTS: '{"backend_configs":{"dataconnector":{"athena":{"uri":"http://data-connector-agent:8081/api/v1/athena"},"mariadb":{"uri":"http://data-connector-agent:8081/api/v1/mariadb"},"mysql8":{"uri":"http://data-connector-agent:8081/api/v1/mysql"},"oracle":{"uri":"http://data-connector-agent:8081/api/v1/oracle"},"snowflake":{"uri":"http://data-connector-agent:8081/api/v1/snowflake"}}}}'
|
||||||
|
depends_on:
|
||||||
|
data-connector-agent:
|
||||||
|
condition: service_healthy
|
||||||
|
data-connector-agent:
|
||||||
|
image: hasura/graphql-data-connector:v2.28.0
|
||||||
|
restart: always
|
||||||
|
ports:
|
||||||
|
- 8081:8081
|
||||||
|
environment:
|
||||||
|
QUARKUS_LOG_LEVEL: ERROR # FATAL, ERROR, WARN, INFO, DEBUG, TRACE
|
||||||
|
## https://quarkus.io/guides/opentelemetry#configuration-reference
|
||||||
|
QUARKUS_OPENTELEMETRY_ENABLED: "false"
|
||||||
|
## QUARKUS_OPENTELEMETRY_TRACER_EXPORTER_OTLP_ENDPOINT: http://jaeger:4317
|
||||||
|
healthcheck:
|
||||||
|
test: ["CMD", "curl", "-f", "http://localhost:8081/api/v1/athena/health"]
|
||||||
|
interval: 5s
|
||||||
|
timeout: 10s
|
||||||
|
retries: 5
|
||||||
|
start_period: 5s
|
||||||
|
volumes:
|
||||||
|
db_data:
|
0
sqlgen/cmd/BUILD
Normal file
0
sqlgen/cmd/BUILD
Normal file
Reference in New Issue
Block a user