Giter Club home page Giter Club logo

inventory-service's Introduction

inventory-service

A demo API that implements a very simple inventory service.

This directory contains an example server using the OpenAPI code generator which implements the OpenAPI inventory example. This is hard forked and heavily inspired by the example pet store code from deepmap/oapi-codegen.

Among other things, we use this to provide an example backend for a simple custom Terraform provider.

Usage

$ docker compose up -d

$ curl -X GET 127.0.0.1:8080/items
[]

$ curl -H 'Content-Type: application/json' -X POST -d '{"name":"car", "tag":"mustang"}' 127.0.0.1:8080/items
{"id":1000,"name":"car","tag":"mustang"}

$ curl -X GET 127.0.0.1:8080/items/1000
{"id":1000,"name":"car","tag":"mustang"}

$ curl -X GET 127.0.0.1:8080/items
[{"id":1000,"name":"car","tag":"mustang"}]

$ curl -H 'Content-Type: application/json' -X PUT -d '{"name":"car", "tag":"shelby"}' 127.0.0.1:8080/items/1000
[{"id":1000,"name":"car","tag":"shelby"}]

$ curl -H 'Content-Type: application/json' -X DELETE 127.0.0.1:8080/items/1000

$ curl -X GET 127.0.0.1:8080/items
[]

$ docker compose down

Releasing

$ go install github.com/mitchellh/gox@latest
$ gox -osarch='darwin/amd64 darwin/arm64 freebsd/386 freebsd/amd64 freebsd/arm linux/386 linux/amd64 linux/arm linux/arm64 linux/mips linux/mips64 linux/mips64le linux/mipsle linux/s390x netbsd/386 netbsd/amd64 netbsd/arm openbsd/386 openbsd/amd64 windows/386 windows/amd64' -output './bin/builds/inventory-service_{{.OS}}_{{.Arch}}'
  • Create a release in Github with the resulting binaries.
  • The container image will be built, tagged latest, and pushed to Docker Hub with eadch merge to main.

Pre-Commit Hooks

Install

Local Install (macOS)

  • IMPORTANT: All developers committing any code to this repo, should have these pre-commit hooks installed locally. Github actions may also run these at some point, but it is generally faster and easier to run them locally, in most cases.
brew install pre-commit jq shellcheck shfmt git-secrets go-critic golangci-lint
curl -sfL https://raw.githubusercontent.com/securego/gosec/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v2.15.0
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin
go install github.com/BurntSushi/toml/cmd/tomlv@master
go install github.com/fzipp/gocyclo/cmd/gocyclo@latest
go install github.com/orijtech/structslop/cmd/structslop
go install github.com/sqs/goreturns@latest
go install golang.org/x/lint/golint@latest
go install golang.org/x/tools/cmd/goimports@latest
go install honnef.co/go/tools/cmd/staticcheck@latest
go install mvdan.cc/gofumpt@latest

mkdir -p ${HOME}/.git-template/hooks
git config --global init.templateDir ${HOME}/.git-template
  • Close and reopen your terminal
  • Make sure that you run these commands from the root of this git repo!
cd inventory-service
pre-commit init-templatedir -t pre-commit ${HOME}/.git-template
pre-commit install
  • Test it
pre-commit run -a
git diff

Checks

See:

Configuring Hooks

inventory-service's People

Contributors

spkane avatar superorbitalrobot avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.