Skip to content

Commit

Permalink
fix/rename (#12)
Browse files Browse the repository at this point in the history
* feat: large renaming

* fix: renaming services and README.md

* Commit from GitHub Actions (CI)

* fix: cleanup name of new repository method

* fix: update repository name

* fix: removed duplicate generated api code

---------

Co-authored-by: brittonhayes <[email protected]>
  • Loading branch information
brittonhayes and brittonhayes authored Jul 28, 2023
1 parent da2dd84 commit 38c1419
Show file tree
Hide file tree
Showing 36 changed files with 200 additions and 200 deletions.
8 changes: 4 additions & 4 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@

# Images
IMAGE_VERSION=1.0.0
IMAGE_NAME=ghcr.io/brittonhayes/warhammer
IMAGE_NAME=ghcr.io/brittonhayes/aos

# Platform
ENV_PLATFORM=local

# Service
WARHAMMER_SERVICE_NAME=warhammerd
WARHAMMER_SERVICE_PORT=8080
SERVICE_NAME=aos
SERVICE_PORT=8080

# OpenTelemetry Collector
OTEL_COLLECTOR_HOST=otel_collector
Expand All @@ -19,7 +19,7 @@ OTEL_EXPORTER_OTLP_ENDPOINT=http://${OTEL_COLLECTOR_HOST}:${OTEL_COLLECTOR_PORT_
PUBLIC_OTEL_EXPORTER_OTLP_TRACES_ENDPOINT=http://localhost:8080/oltp-http/v1/traces

# OpenTelemetry Resource Definitions
OTEL_RESOURCE_ATTRIBUTES="service.namespace=warhammerd"
OTEL_RESOURCE_ATTRIBUTES="service.namespace=aos"

# Metrics Temporality
OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE=cumulative
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
go-version: ${{ matrix.go-version }}

- name: Build
run: go build -o bin/warhammerd ./cmd/warhammerd
run: go build -o bin/aos ./cmd/aos

- name: Test
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
IMAGE_NAME: brittonhayes/aos

jobs:
build-and-push-image:
Expand Down
8 changes: 4 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,17 @@ COPY go.mod ./
RUN go mod download

COPY . /src/
RUN CGO_ENABLED=0 go build -o /bin/warhammerd cmd/warhammerd/main.go
RUN CGO_ENABLED=0 go build -o /bin/aos cmd/aos/main.go

# STAGE 2
FROM gcr.io/distroless/static-debian11:nonroot

LABEL maintainer="brittonhayes"

COPY --from=builder --chown=nonroot:nonroot /bin/warhammerd /bin/warhammerd
COPY --from=builder --chown=nonroot:nonroot /bin/aos /bin/aos

EXPOSE 8080

ENTRYPOINT [ "/bin/warhammerd" ]
ENTRYPOINT [ "/bin/aos" ]

CMD ["/bin/warhammerd"]
CMD ["/bin/aos"]
2 changes: 1 addition & 1 deletion Procfile
Original file line number Diff line number Diff line change
@@ -1 +1 @@
process: /bin/warhammerd
process: /bin/aos
22 changes: 11 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# Warhammer
# AoS

[![Go Reference](https://pkg.go.dev/badge/github.com/brittonhayes/warhammer.svg)](https://pkg.go.dev/github.com/brittonhayes/warhammer)
[![Go Report Card](https://goreportcard.com/badge/github.com/brittonhayes/warhammer)](https://goreportcard.com/report/github.com/brittonhayes/warhammer)
[![Go Reference](https://pkg.go.dev/badge/github.com/brittonhayes/aos.svg)](https://pkg.go.dev/github.com/brittonhayes/aos)
[![Go Report Card](https://goreportcard.com/badge/github.com/brittonhayes/aos)](https://goreportcard.com/report/github.com/brittonhayes/aos)

> A Warhammer: Age of Sigmar REST API built with Go and Sqlite.
> An unnoficial AoS REST API built with Go and Sqlite.
## ✨ Try the API (hosted)

Expand All @@ -28,11 +28,11 @@ task up

API documentation is available in YAML format within the repository. The OpenAPI spec is used to generate the transport logic thanks to [goapi-gen](https://github.com/discord-gophers/goapi-gen).

- [View the OpenAPI Spec](https://github.com/brittonhayes/warhammer/blob/main/api/openapi.yaml)
- [View the OpenAPI Spec](https://github.com/brittonhayes/aos/blob/main/api/openapi.yaml)

## 🗄️ Adding or Editing Data

All application data used to seed the database is editable in the [fixtures/](https://github.com/brittonhayes/warhammer/blob/main/fixtures/) directory. The API is built to be self-seeding and read-only, so if there is a need to add more data, simply add it to the fixtures files, rebuild and redeploy the API.
All application data used to seed the database is editable in the [fixtures/](https://github.com/brittonhayes/aos/blob/main/fixtures/) directory. The API is built to be self-seeding and read-only, so if there is a need to add more data, simply add it to the fixtures files, rebuild and redeploy the API.

### Example - Adding a new alliance

Expand All @@ -50,7 +50,7 @@ To add a new entry to the database, just add a new object to the appropriate yam
+ description: The forces of Chaos seek to corrupt and dominate the Mortal Realms. Made up of daemons, monsters, and twisted beings, they spread destruction wherever theygo.
```

- [View the data](https://github.com/brittonhayes/warhammer/blob/main/fixtures/fixtures.yaml)
- [View the data](https://github.com/brittonhayes/aos/blob/main/fixtures/fixtures.yaml)

## API Endpoints

Expand All @@ -76,15 +76,15 @@ Application observability is instrumented with OpenTelemetry. Telemetry is avail

When running with docker-compose, the following services are available:

- API is available at [http://warhammer.localhost:8090](http://warhammer.localhost:8090)
- Documentation is available at [http://warhammer.localhost:8090/docs](http://warhammer.localhost:8090/docs)
- API is available at [http://aos.localhost:8090](http://aos.localhost:8090)
- Documentation is available at [http://aos.localhost:8090/docs](http://aos.localhost:8090/docs)
- Traefik Dashboard is available at [http://localhost:8080](http://localhost:8080)
- Prometheus is available at [http://prometheus.localhost:8090](http://prometheus.localhost:8090)
- Grafana is available at [http://grafana.localhost:8090](http://grafana.localhost:8090)

## 🙋 FAQ

- **Q: Where is X {unit,alliance,etc}?** - A: Waiting for you to add it! See the [fixtures/](https://github.com/brittonhayes/warhammer/blob/main/fixtures/) directory for more information.
- **Q: Where is X {unit,alliance,etc}?** - A: Waiting for you to add it! See the [fixtures/](https://github.com/brittonhayes/aos/blob/main/fixtures/) directory for more information.

## ⚖️ Copyright and Data Ownership

Expand All @@ -99,4 +99,4 @@ through a REST interface rather than the usual PDF.
If you consume the data served through this API, be aware that you are also obligated to respect
[Games Workshop's](https://www.games-workshop.com) [intellectual property guidelines](https://www.games-workshop.com/en-US/Intellectual-Property-Guidelines).

For more information, view our [Contributing Guidelines](https://github.com/brittonhayes/warhammer/blob/main/CONTRIBUTING.md).
For more information, view our [Contributing Guidelines](https://github.com/brittonhayes/aos/blob/main/CONTRIBUTING.md).
2 changes: 1 addition & 1 deletion Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ version: '3'
tasks:
default:
cmds:
- go run ./cmd/warhammerd
- go run ./cmd/aos

up:
desc: "Start the application with docker-compose"
Expand Down
10 changes: 5 additions & 5 deletions warhammer.go → aos.go
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
// Package warhammer provides the WarhammerRepository interface for the Warhammer REST API and services
// Package aos provides the Repository interface for the AoS REST API and services
//
//go:generate goapi-gen -generate types,server,spec -package api --out api/warhammer.gen.go ./api/openapi.yaml
//go:generate goapi-gen -generate types,server,spec -package api --out api/api.gen.go ./api/openapi.yaml
//go:generate npx @redocly/cli build-docs api/openapi.yaml -o web/index.html
package warhammer
package aos

import (
"context"
"io/fs"

"github.com/brittonhayes/warhammer/api"
"github.com/brittonhayes/aos/api"
)

type WarhammerRepository interface {
type Repository interface {
GetArmyByID(ctx context.Context, id string) (*api.Army, error)
GetArmies(ctx context.Context) ([]api.Army, error)

Expand Down
56 changes: 28 additions & 28 deletions api/warhammer.gen.go → api/api.gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions api/openapi.yaml
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
openapi: "3.1.0"
info:
title: Warhammer Age of Sigmar API (Unofficial)
title: AoS API (Unofficial)
version: 1.0.0
description: API specification for a Warhammer Age of Sigmar API (Unofficial)
description: API specification for an AoS REST API (Unofficial)
license:
name: MIT
url: https://opensource.org/licenses/MIT
security: []
servers:
- url: http://warhammer.localhost
- url: http://aos-api.localhost
description: Local server
- url: https://aos-api.com
description: Production server
Expand Down
42 changes: 21 additions & 21 deletions cmd/warhammerd/main.go → cmd/aos/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ import (
"sort"
"time"

"github.com/brittonhayes/warhammer"
"github.com/brittonhayes/warhammer/api"
"github.com/brittonhayes/warhammer/fixtures"
"github.com/brittonhayes/warhammer/internal/logging"
"github.com/brittonhayes/warhammer/internal/tracing"
"github.com/brittonhayes/warhammer/service"
"github.com/brittonhayes/warhammer/sqlite"
"github.com/brittonhayes/aos"
"github.com/brittonhayes/aos/api"
"github.com/brittonhayes/aos/fixtures"
"github.com/brittonhayes/aos/internal/logging"
"github.com/brittonhayes/aos/internal/tracing"
"github.com/brittonhayes/aos/service"
"github.com/brittonhayes/aos/sqlite"

apimw "github.com/discord-gophers/goapi-gen/middleware"
"github.com/go-chi/chi/v5"
Expand All @@ -29,16 +29,16 @@ import (
func main() {

var (
repo warhammer.WarhammerRepository
repo aos.Repository
)

app := &cli.App{
Name: "warhammerd",
Usage: "the warhammer api server",
Name: "aos",
Usage: "AoS api server",
Suggest: true,
Before: func(c *cli.Context) error {
if c.Bool("migrate") {
repo = sqlite.NewWarhammerRepository(c.String("db"))
repo = sqlite.NewRepository(c.String("db"))

err := repo.Init(c.Context)
if err != nil {
Expand All @@ -59,18 +59,18 @@ func main() {
fixtures.WARSCROLLS,
}

err = repo.Seed(c.Context, warhammer.FIXTURES, data...)
err = repo.Seed(c.Context, aos.FIXTURES, data...)
if err != nil {
return err
}
}
return nil
},
Action: func(c *cli.Context) error {
repo = sqlite.NewWarhammerRepository(c.String("db"))
repo = sqlite.NewRepository(c.String("db"))

// Create an instance of our handler which satisfies the generated interface
s := service.NewWarhammerService(repo)
s := service.New(repo)

swagger, err := api.GetSwagger()
if err != nil {
Expand Down Expand Up @@ -158,14 +158,14 @@ func main() {
Name: "port",
Aliases: []string{"p"},
Value: 8080,
EnvVars: []string{"WARHAMMER_SERVICE_PORT", "PORT"},
EnvVars: []string{"PORT"},
Usage: "port to listen on",
},
&cli.StringFlag{
Name: "service",
Aliases: []string{"s"},
Value: "warhammerd",
EnvVars: []string{"WARHAMMER_SERVICE_NAME", "SERVICE_NAME"},
Value: "aos",
EnvVars: []string{"SERVICE_NAME"},
Usage: "customize the service name",
},
&cli.StringFlag{
Expand All @@ -176,14 +176,14 @@ func main() {
},
&cli.StringFlag{
Name: "db",
Value: "file:warhammer.db",
Value: "file:aos.db",
EnvVars: []string{"DATABASE_URL"},
Usage: "database url",
},
&cli.BoolFlag{
Name: "tracing",
Aliases: []string{"t"},
Value: true,
Value: false,
EnvVars: []string{"TRACING"},
Usage: "enable tracing",
},
Expand All @@ -203,7 +203,7 @@ func main() {
return repo.Migrate(c.Context)
},
Before: func(c *cli.Context) error {
repo = sqlite.NewWarhammerRepository(c.String("db"))
repo = sqlite.NewRepository(c.String("db"))
return nil
},
Subcommands: []*cli.Command{
Expand Down Expand Up @@ -258,7 +258,7 @@ func main() {
fixtures.WARSCROLLS,
}

return repo.Seed(c.Context, warhammer.FIXTURES, data...)
return repo.Seed(c.Context, aos.FIXTURES, data...)
},
},
},
Expand Down
4 changes: 2 additions & 2 deletions config/prometheus-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@ scrape_configs:
static_configs:
- targets: ['prometheus:9090']

- job_name: 'warhammer'
- job_name: 'aos'
static_configs:
- targets: ['warhammer:8080']
- targets: ['aos:8080']
Loading

0 comments on commit 38c1419

Please sign in to comment.