Skip to content

Commit

Permalink
Merge bc06a0e into 79671e4
Browse files Browse the repository at this point in the history
  • Loading branch information
sio4 committed Jul 16, 2022
2 parents 79671e4 + bc06a0e commit fcfafd0
Show file tree
Hide file tree
Showing 17 changed files with 1,393 additions and 2,764 deletions.
13 changes: 8 additions & 5 deletions .buffalo.dev.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
app_root: .
binary_name: uart-build
build_delay: 200ns
build_flags: []
build_path: tmp
build_target_path: ./cmd/app
command_env: []
command_flags: []
enable_colors: true
ignored_folders:
- vendor
- log
Expand All @@ -12,9 +20,4 @@ ignored_folders:
- .sass-cache
included_extensions:
- .go
build_path: tmp
build_delay: 200ns
binary_name: uart-build
command_flags: []
enable_colors: true
log_name: buffalo
16 changes: 16 additions & 0 deletions .deepsource.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
version = 1

[[analyzers]]
name = "test-coverage"
enabled = true

[[analyzers]]
name = "go"
enabled = true

[analyzers.meta]
import_root = "github.com/hyeoncheon/uart"

[[analyzers]]
name = "docker"
enabled = true
1 change: 0 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,4 @@ dev.sh
docs/
examples/
node_modules/
public/
tmp/
18 changes: 9 additions & 9 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ language: go
dist: bionic

go:
- 1.16.x
- 1.17.x
- 1.18.x

# sudo enabled, fully virtualized virtual machine required for mysql 5.7.
# https://docs.travis-ci.com/user/database-setup/#mysql
Expand All @@ -18,7 +19,7 @@ env:

before_install:
- nvm --version
- nvm install 14.17.4
- nvm install lts/fermium
- node --version
- env
- mysql --version
Expand All @@ -42,15 +43,14 @@ before_script:
go_import_path: github.com/hyeoncheon/uart

script:
- buffalo plugins install
- buffalo plugins list
- buffalo build
- cp database.yml.travis database.yml
- >
go mod tidy &&
cat go.mod go.sum
- >
buffalo build --skip-assets &&
ls -l bin/uart &&
cp database.yml.travis database.yml &&
UART_HOME=`pwd` buffalo test -coverprofile=c.out -covermode=count ./... &&
./cc-test-reporter after-build --exit-code 0 &&
./cc-test-reporter after-build --exit-code 0
- >
buffalo pop drop -e test &&
buffalo pop create -e test &&
buffalo pop migrate -e test &&
Expand Down
20 changes: 11 additions & 9 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
# This is a multi-stage Dockerfile and requires >= Docker 17.05
# https://docs.docker.com/engine/userguide/eng-image/multistage-build/
FROM gobuffalo/buffalo:v0.18.3 as builder
FROM gobuffalo/buffalo:v0.18.7 as builder

ENV GOPROXY http://proxy.golang.org

RUN mkdir -p /src/github.com/hyeoncheon/uart
WORKDIR /src/github.com/hyeoncheon/uart

# this will cache the npm install step, unless package.json changes
ADD package.json .
ADD yarn.lock .
COPY package.json .
COPY yarn.lock .
COPY .yarn* .
RUN yarn install
# Copy the Go Modules manifests
COPY go.mod go.mod
Expand All @@ -18,14 +19,15 @@ COPY go.sum go.sum
# and so that source changes don't invalidate our downloaded layer
RUN go mod download

ADD . .
COPY . .
#RUN buffalo build --static -o /bin/app
RUN HC_ROOT=/ scripts/setup.sh

FROM alpine
RUN apk add --no-cache bash
RUN apk add --no-cache ca-certificates
### check and update package version here: https://pkgs.alpinelinux.org/packages
FROM alpine:latest
RUN apk add --no-cache 'bash=~5.1' 'ca-certificates>=20211220-r0'

WORKDIR /uart
WORKDIR /uart/

COPY --from=builder /uart /uart

Expand All @@ -39,4 +41,4 @@ EXPOSE 3000

# Uncomment to run the migrations before running the binary:
# CMD /bin/app migrate; /bin/app
CMD exec /bin/app
CMD ["/uart/bin/uart"]
6 changes: 3 additions & 3 deletions actions/docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func (v DocsResource) List(c buffalo.Context) error {
tx := c.Value("tx").(*pop.Connection)
docs := &models.Docs{}
q := tx.Q()
if false == c.Value("member_is_admin").(bool) {
if !c.Value("member_is_admin").(bool) {
q = q.Where("is_published = ?", true)
}
err := q.Order("category, subject").All(docs)
Expand Down Expand Up @@ -58,13 +58,13 @@ func (v DocsResource) Show(c buffalo.Context) error {
tx := c.Value("tx").(*pop.Connection)
doc := &models.Doc{}
q := tx.Q()
if false == c.Value("member_is_admin").(bool) {
if !c.Value("member_is_admin").(bool) {
q = q.Where("is_published = ?", true)
}
err := q.Find(doc, c.Param("doc_id"))
if err != nil {
q := tx.Q()
if false == c.Value("member_is_admin").(bool) {
if !c.Value("member_is_admin").(bool) {
q = q.Where("is_published = ?", true)
}
err = q.Where("slug = ?", c.Param("doc_id")).First(doc)
Expand Down
2 changes: 1 addition & 1 deletion actions/memberships.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
)

func membershipHandler(c buffalo.Context) error {
member := &models.Member{}
var member *models.Member
if c.Value("member_is_admin").(bool) && c.Param("member_id") != "" {
member = models.GetMember(c.Param("member_id"))
} else {
Expand Down
1 change: 0 additions & 1 deletion actions/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ func initProvider(l buffalo.Logger) {
svr.AccessTokenGen = utils.NewRS256AccessTokenGen(brandName, keyFile)

logger.Info("oauth2 provider with jwt support initialized!")
return
}

func authorizeHandler(c buffalo.Context) error {
Expand Down
6 changes: 3 additions & 3 deletions actions/render.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,11 @@ func init() {
"trunc": func(t interface{}, args ...int) string {
length := 20
var s string
switch t.(type) {
switch t := t.(type) {
case string:
s = t.(string)
s = t
case uuid.UUID:
s = t.(uuid.UUID).String()
s = t.String()
length = 14
}

Expand Down
4 changes: 2 additions & 2 deletions actions/roles.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ func (v RolesResource) Update(c buffalo.Context) error {
return c.Redirect(http.StatusFound, "/")
}

if role.IsReadonly == true {
if role.IsReadonly {
c.Flash().Add("danger", t(c, "cannot.delete.readonly.role"))
c.Logger().Errorf("access violation: %v tried to delete a readonly role %v", currentMember(c), role)
return c.Redirect(http.StatusFound, "/")
Expand Down Expand Up @@ -107,7 +107,7 @@ func (v RolesResource) Destroy(c buffalo.Context) error {
return c.Redirect(http.StatusFound, "/")
}

if role.IsReadonly == true {
if role.IsReadonly {
c.Flash().Add("danger", t(c, "cannot.delete.readonly.role"))
c.Logger().Errorf("access violation: %v tried to delete a readonly role %v", currentMember(c), role)
return c.Redirect(http.StatusFound, "/")
Expand Down
File renamed without changes.
28 changes: 15 additions & 13 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,29 +7,31 @@ require (
github.com/facebookgo/ensure v0.0.0-20200202191622-63f1cf65ac4c // indirect
github.com/facebookgo/stack v0.0.0-20160209184415-751773369052 // indirect
github.com/facebookgo/subset v0.0.0-20200203212716-c811ad88dec4 // indirect
github.com/gobuffalo/buffalo v0.18.4
github.com/gobuffalo/buffalo-pop/v3 v3.0.2
github.com/gobuffalo/buffalo v0.18.9
github.com/gobuffalo/buffalo-pop/v3 v3.0.6
github.com/gobuffalo/envy v1.10.1
github.com/gobuffalo/flect v0.2.4
github.com/gobuffalo/flect v0.2.5
github.com/gobuffalo/github_flavored_markdown v1.1.1
github.com/gobuffalo/grift v1.5.1
github.com/gobuffalo/httptest v1.5.1
github.com/gobuffalo/logger v1.0.6
github.com/gobuffalo/mw-csrf v1.0.0
github.com/gobuffalo/mw-i18n/v2 v2.0.1
github.com/gobuffalo/mw-paramlogger v1.0.0
github.com/gobuffalo/pop/v6 v6.0.1
github.com/gobuffalo/suite/v4 v4.0.2
github.com/gobuffalo/validate/v3 v3.3.1
github.com/gobuffalo/mw-csrf v1.0.1
github.com/gobuffalo/mw-i18n/v2 v2.0.2
github.com/gobuffalo/mw-paramlogger v1.0.1
github.com/gobuffalo/pop/v6 v6.0.6
github.com/gobuffalo/suite/v4 v4.0.3
github.com/gobuffalo/validate/v3 v3.3.2
github.com/gofrs/uuid v4.2.0+incompatible
github.com/golang-jwt/jwt v3.2.2+incompatible
github.com/gorilla/sessions v1.2.1
github.com/jinzhu/copier v0.3.5
github.com/markbates/goth v1.69.0
github.com/markbates/grift v1.5.0
github.com/markbates/goth v1.73.0
github.com/onsi/ginkgo v1.16.5 // indirect
github.com/onsi/gomega v1.19.0 // indirect
github.com/pborman/uuid v1.2.1 // indirect
github.com/pkg/errors v0.9.1
github.com/russross/blackfriday/v2 v2.1.0
github.com/stretchr/testify v1.7.0
golang.org/x/oauth2 v0.0.0-20220309155454-6242fa91716a
github.com/stretchr/testify v1.8.0
golang.org/x/oauth2 v0.0.0-20220630143837-2104d58473e0
gopkg.in/mailgun/mailgun-go.v1 v1.1.1
)
Loading

0 comments on commit fcfafd0

Please sign in to comment.