Compare commits
1 Commits
ec97dae46b
...
lotr
Author | SHA1 | Date | |
---|---|---|---|
7fc09053a4 |
1
.gitignore
vendored
1
.gitignore
vendored
@ -35,4 +35,3 @@
|
|||||||
|
|
||||||
# Go workspace file
|
# Go workspace file
|
||||||
go.work
|
go.work
|
||||||
|
|
||||||
|
6
.gitmodules
vendored
6
.gitmodules
vendored
@ -4,3 +4,9 @@
|
|||||||
[submodule "submodule/src/remote"]
|
[submodule "submodule/src/remote"]
|
||||||
path = submodule/src/remote
|
path = submodule/src/remote
|
||||||
url = git://github.com/laramiel/bazel-example-golang-remote
|
url = git://github.com/laramiel/bazel-example-golang-remote
|
||||||
|
[submodule "vendor/github.com/laramiel/bazel-example-golang-remote"]
|
||||||
|
path = vendor/github.com/laramiel/bazel-example-golang-remote
|
||||||
|
url = git://github.com/laramiel/bazel-example-golang-remote
|
||||||
|
[submodule "vendor/github.com/laramiel/bazel-example-golang-bare"]
|
||||||
|
path = vendor/github.com/laramiel/bazel-example-golang-bare
|
||||||
|
url = git://github.com/laramiel/bazel-example-golang-bare
|
||||||
|
23
BUILD
23
BUILD
@ -1,20 +1,13 @@
|
|||||||
|
load("@io_bazel_rules_go//go:def.bzl", "go_binary")
|
||||||
|
|
||||||
package(
|
package(
|
||||||
default_visibility = ["//visibility:public"],
|
default_visibility = ["//visibility:public"],
|
||||||
)
|
)
|
||||||
|
|
||||||
load("@bazel_gazelle//:def.bzl", "gazelle")
|
go_binary(
|
||||||
|
name = "hello",
|
||||||
# gazelle:prefix github.com/squk/lotr
|
srcs = ["hello.go"],
|
||||||
# gazelle:build_file_name BUILD
|
deps = [
|
||||||
gazelle(name = "gazelle")
|
"//cmd",
|
||||||
|
]
|
||||||
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",
|
|
||||||
)
|
)
|
||||||
|
38
WORKSPACE
38
WORKSPACE
@ -1,39 +1,23 @@
|
|||||||
|
load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository")
|
||||||
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
|
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
|
||||||
|
|
||||||
|
# git_repository(
|
||||||
|
# name = "io_bazel_rules_go",
|
||||||
|
# remote = "https://github.com/bazelbuild/rules_go.git",
|
||||||
|
# branch = "master",
|
||||||
|
# )
|
||||||
|
|
||||||
http_archive(
|
http_archive(
|
||||||
name = "io_bazel_rules_go",
|
name = "io_bazel_rules_go",
|
||||||
sha256 = "6dc2da7ab4cf5d7bfc7c949776b1b7c733f05e56edc4bcd9022bb249d2e2a996",
|
sha256 = "6b65cb7917b4d1709f9410ffe00ecf3e160edf674b78c54a894471320862184f",
|
||||||
urls = [
|
urls = [
|
||||||
"https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v0.39.1/rules_go-v0.39.1.zip",
|
"https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v0.39.0/rules_go-v0.39.0.zip",
|
||||||
"https://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.0/rules_go-v0.39.0.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("@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_rules_dependencies()
|
||||||
|
|
||||||
go_register_toolchains(version = "1.20.4")
|
go_register_toolchains(version = "1.19.3")
|
||||||
|
|
||||||
gazelle_dependencies()
|
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
load("@io_bazel_rules_go//go:def.bzl", "go_library")
|
load("@io_bazel_rules_go//go:def.bzl", "go_library")
|
||||||
|
|
||||||
go_library(
|
go_library(
|
||||||
name = "types",
|
name ="cmd",
|
||||||
srcs = ["card.go"],
|
srcs = [ "cmd.go" ],
|
||||||
importpath = "github.com/squk/lotr/cmd/beornextract/types",
|
|
||||||
visibility = ["//visibility:public"],
|
visibility = ["//visibility:public"],
|
||||||
|
importpath= "github.com/squk/lotr/cmd"
|
||||||
)
|
)
|
@ -1,17 +0,0 @@
|
|||||||
load("@io_bazel_rules_go//go:def.bzl", "go_library")
|
|
||||||
|
|
||||||
package(
|
|
||||||
default_visibility = ["//visibility:public"],
|
|
||||||
)
|
|
||||||
|
|
||||||
alias(
|
|
||||||
name = "beornextract",
|
|
||||||
actual = "//beornextract/",
|
|
||||||
)
|
|
||||||
|
|
||||||
go_library(
|
|
||||||
name = "beornextract_lib",
|
|
||||||
srcs = ["main.go"],
|
|
||||||
importpath = "github.com/squk/lotr/cmd/beornextract",
|
|
||||||
deps = ["@com_github_davecgh_go_spew//spew"],
|
|
||||||
)
|
|
@ -1,2 +0,0 @@
|
|||||||
exports_files(glob(["*.json"]))
|
|
||||||
# exports_files(["Export.Cards.json"])
|
|
File diff suppressed because one or more lines are too long
@ -1,31 +0,0 @@
|
|||||||
package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
"encoding/json"
|
|
||||||
"fmt"
|
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
|
||||||
"github.com/squk/lotr/extract/types"
|
|
||||||
"github.com/davecgh/go-spew/spew"
|
|
||||||
)
|
|
||||||
|
|
||||||
func main() {
|
|
||||||
fmt.Println("LOTR CARD PARSE")
|
|
||||||
|
|
||||||
|
|
||||||
// Open our jsonFile
|
|
||||||
jsonFile, err := os.Open("./data/Bot.Cards.json")
|
|
||||||
// if we os.Open returns an error then handle it
|
|
||||||
if err != nil {
|
|
||||||
fmt.Println(err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
fmt.Println("Successfully Opened users.json")
|
|
||||||
// defer the closing of our jsonFile so that we can parse it later on
|
|
||||||
defer jsonFile.Close()
|
|
||||||
|
|
||||||
byteValue, _ := ioutil.ReadAll(jsonFile)
|
|
||||||
c := []types.HallOfBeornCard{}
|
|
||||||
json.Unmarshal(byteValue, &c)
|
|
||||||
spew.Dump(c)
|
|
||||||
}
|
|
@ -1,33 +0,0 @@
|
|||||||
package types
|
|
||||||
|
|
||||||
type HallOfBeornCard struct {
|
|
||||||
PackCode string `json:"pack_code"`
|
|
||||||
PackName string `json:"pack_name"`
|
|
||||||
IsOfficial bool `json:"is_official"`
|
|
||||||
TypeCode string `json:"type_code"`
|
|
||||||
TypeName string `json:"type_name"`
|
|
||||||
SphereCode string `json:"sphere_code"`
|
|
||||||
SphereName string `json:"sphere_name"`
|
|
||||||
Position int `json:"position"`
|
|
||||||
Code string `json:"code"`
|
|
||||||
Name string `json:"name"`
|
|
||||||
Traits string `json:"traits"`
|
|
||||||
Text string `json:"text"`
|
|
||||||
Flavor string `json:"flavor"`
|
|
||||||
IsUnique bool `json:"is_unique"`
|
|
||||||
Threat int `json:"threat"`
|
|
||||||
Willpower int `json:"willpower"`
|
|
||||||
Attack int `json:"attack"`
|
|
||||||
Defense int `json:"defense"`
|
|
||||||
Health int `json:"health"`
|
|
||||||
Quantity int `json:"quantity"`
|
|
||||||
DeckLimit int `json:"deck_limit"`
|
|
||||||
Illustrator string `json:"illustrator"`
|
|
||||||
Octgnid string `json:"octgnid"`
|
|
||||||
HasErrata bool `json:"has_errata"`
|
|
||||||
URL string `json:"url"`
|
|
||||||
Imagesrc string `json:"imagesrc"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type NormalizedCard struct {
|
|
||||||
}
|
|
9
cmd/cmd.go
Normal file
9
cmd/cmd.go
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
)
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
fmt.Println("Hello World. Cmd")
|
||||||
|
}
|
@ -1,18 +0,0 @@
|
|||||||
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
113
cmd/test/main.go
@ -1,113 +0,0 @@
|
|||||||
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)
|
|
||||||
}
|
|
||||||
}
|
|
18
deps.bzl
18
deps.bzl
@ -1,18 +0,0 @@
|
|||||||
load("@bazel_gazelle//:deps.bzl", "go_repository")
|
|
||||||
|
|
||||||
def go_dependencies():
|
|
||||||
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_mattn_go_sqlite3",
|
|
||||||
build_file_proto_mode = "disable_global",
|
|
||||||
importpath = "github.com/mattn/go-sqlite3",
|
|
||||||
sum = "h1:mCRHCLDUBXgpKAqIKsaAaAsrAlbkeomtRFKXh2L6YIM=",
|
|
||||||
version = "v1.14.17",
|
|
||||||
)
|
|
7
go.mod
7
go.mod
@ -1,7 +0,0 @@
|
|||||||
module github.com/squk/lotr
|
|
||||||
|
|
||||||
go 1.19
|
|
||||||
|
|
||||||
require github.com/davecgh/go-spew v1.1.1
|
|
||||||
|
|
||||||
require github.com/mattn/go-sqlite3 v1.14.17 // indirect
|
|
4
go.sum
4
go.sum
@ -1,4 +0,0 @@
|
|||||||
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/mattn/go-sqlite3 v1.14.17 h1:mCRHCLDUBXgpKAqIKsaAaAsrAlbkeomtRFKXh2L6YIM=
|
|
||||||
github.com/mattn/go-sqlite3 v1.14.17/go.mod h1:2eHXhiwb8IkHr+BDWZGa96P6+rkvnG63S2DGjv9HUNg=
|
|
9
hello.go
Normal file
9
hello.go
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
)
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
fmt.Println("Hello World")
|
||||||
|
}
|
@ -1,50 +0,0 @@
|
|||||||
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:
|
|
7
vendor/github.com/laramiel/BUILD
generated
vendored
Normal file
7
vendor/github.com/laramiel/BUILD
generated
vendored
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
load("@io_bazel_rules_go//go:def.bzl", "go_library")
|
||||||
|
|
||||||
|
go_library(
|
||||||
|
name = "bare",
|
||||||
|
srcs = ["bazel-example-golang-bare/bare.go"],
|
||||||
|
visibility = ["//visibility:public"],
|
||||||
|
)
|
1
vendor/github.com/laramiel/bazel-example-golang-bare
generated
vendored
Submodule
1
vendor/github.com/laramiel/bazel-example-golang-bare
generated
vendored
Submodule
Submodule vendor/github.com/laramiel/bazel-example-golang-bare added at 3bd848fc12
1
vendor/github.com/laramiel/bazel-example-golang-remote
generated
vendored
Submodule
1
vendor/github.com/laramiel/bazel-example-golang-remote
generated
vendored
Submodule
Submodule vendor/github.com/laramiel/bazel-example-golang-remote added at 4a9199be6e
Reference in New Issue
Block a user