Skip to content

Commit

Permalink
Merge pull request #116 from wednesday-solutions/fix/test-fix-for-env
Browse files Browse the repository at this point in the history
fix: made fixed to env tests and readme
  • Loading branch information
gang-wednesday committed Feb 16, 2023
2 parents 7d57a98 + 4bac5a9 commit 7bf737c
Show file tree
Hide file tree
Showing 13 changed files with 132 additions and 44 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/go-template-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
- name: Install Go
uses: actions/setup-go@v3
with:
go-version: 1.18
go-version: 1.19
- name: Install pre-commit dependencies
run: |
go install github.com/fzipp/gocyclo/cmd/gocyclo@latest
Expand Down Expand Up @@ -56,5 +56,5 @@ jobs:
- name: Install Go
uses: actions/setup-go@v3
with:
go-version: 1.18
go-version: 1.19
- uses: golangci/golangci-lint-action@v3
6 changes: 5 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,11 @@ RUN go build -o ./output/seeder ./cmd/seeder/exec/seed.go


FROM alpine:latest
ARG ENVIRONMENT_NAME
RUN addgroup -S nonroot \
&& adduser -S nonroot -G nonroot

USER nonroot
ARG ENVIRONMENT_NAME docker
RUN apk add --no-cache libc6-compat
RUN apk add --no-cache --upgrade bash
RUN mkdir -p /app/
Expand Down
1 change: 1 addition & 0 deletions README.MD
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,7 @@ http:
# healthcheck: '/'
```
Also make sure the execution role has an appropriate policy attached to it so it can access our .env file inside the s3 bucket, and inject it as environment variables.
### To deploy

```
Expand Down
Binary file added cmd/seeder/exec/build/1_roles
Binary file not shown.
Binary file added cmd/seeder/exec/build/2_users
Binary file not shown.
1 change: 1 addition & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ services:
restart: always
env_file:
- .env.docker

environment:
- POSTGRES_USER=${PSQL_USER}
- POSTGRES_PASSWORD=${PSQL_PASS}
Expand Down
8 changes: 4 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module go-template
go 1.18

require (
github.com/99designs/gqlgen v0.17.22
github.com/99designs/gqlgen v0.17.24
github.com/DATA-DOG/go-sqlmock v1.5.0
github.com/agiledragon/gomonkey/v2 v2.2.0
github.com/dgrijalva/jwt-go v3.2.0+incompatible
Expand All @@ -17,13 +17,13 @@ require (
github.com/kat-co/vala v0.0.0-20170210184112-42e1d8b61f12
github.com/labstack/echo/v4 v4.7.2
github.com/labstack/gommon v0.3.1
github.com/lib/pq v1.10.0
github.com/lib/pq v1.10.7
github.com/masahiro331/go-commitlinter v0.0.0-20220207112004-c66fa942bad3
github.com/nbutton23/zxcvbn-go v0.0.0-20180912185939-ae427f1e4c1d
github.com/rafaeljusto/redigomock v2.4.0+incompatible
github.com/rafaeljusto/redigomock/v3 v3.0.1
github.com/rs/zerolog v1.18.0
github.com/rubenv/sql-migrate v1.3.0
github.com/rubenv/sql-migrate v1.3.1
github.com/spf13/viper v1.10.0
github.com/stretchr/testify v1.8.0
github.com/uptrace/opentelemetry-go-extra/otelsql v0.1.14
Expand Down Expand Up @@ -54,7 +54,7 @@ require (
github.com/cpuguy83/go-md2man/v2 v2.0.2 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/fsnotify/fsnotify v1.5.1 // indirect
github.com/go-gorp/gorp/v3 v3.0.2 // indirect
github.com/go-gorp/gorp/v3 v3.0.5 // indirect
github.com/go-logr/logr v1.2.3 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/go-playground/locales v0.14.0 // indirect
Expand Down
116 changes: 96 additions & 20 deletions go.sum

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions internal/config/env_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -181,15 +181,15 @@ func TestLoadEnv(t *testing.T) {
name: "Fail to load develop env",
wantErr: true,
args: args{
env: "develop",
env: "production",
tapped: false,
},
},
{
name: "Successfully load develop env",
wantErr: false,
args: args{
env: "develop",
env: "production",
tapped: false,
dbSecret: fmt.Sprintf(`{"username":"%s",`+
`"host":"%s","dbname":"%s","password":"%s",`+
Expand Down
24 changes: 15 additions & 9 deletions resolver/auth_mutations.resolvers.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,11 @@ import (
"go-template/internal/middleware/auth"
"go-template/internal/service"
"go-template/pkg/utl/convert"
resultwrapper "go-template/pkg/utl/resultwrapper"
"go-template/pkg/utl/resultwrapper"

null "github.com/volatiletech/null/v8"
)

func loadConfig() (*config.Configuration, error) {
cfg, err := config.Load()
if err != nil {
return nil, fmt.Errorf("error in loading config")
}
return cfg, nil
}

// Login is the resolver for the login field.
func (r *mutationResolver) Login(ctx context.Context, username string, password string) (*gqlmodels.LoginResponse, error) {
u, err := daos.FindUserByUserName(username, ctx)
Expand Down Expand Up @@ -132,3 +124,17 @@ func (r *mutationResolver) RefreshToken(ctx context.Context, token string) (*gql
func (r *Resolver) Mutation() gqlmodels.MutationResolver { return &mutationResolver{r} }

type mutationResolver struct{ *Resolver }

// !!! WARNING !!!
// The code below was going to be deleted when updating resolvers. It has been copied here so you have
// one last chance to move it out of harms way if you want. There are two reasons this happens:
// - When renaming or deleting a resolver the old code will be put in here. You can safely delete
// it when you're done.
// - You have helper methods in this file. Move them out to keep these resolver files clean.
func loadConfig() (*config.Configuration, error) {
cfg, err := config.Load()
if err != nil {
return nil, fmt.Errorf("error in loading config")
}
return cfg, nil
}
4 changes: 2 additions & 2 deletions resolver/role_mutations.resolvers.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import (
"go-template/internal/middleware/auth"
"go-template/models"
"go-template/pkg/utl/convert"
rediscache "go-template/pkg/utl/rediscache"
resultwrapper "go-template/pkg/utl/resultwrapper"
"go-template/pkg/utl/rediscache"
"go-template/pkg/utl/resultwrapper"
)

// CreateRole is the resolver for the createRole field.
Expand Down
4 changes: 2 additions & 2 deletions resolver/user_mutations.resolvers.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ import (
"go-template/internal/service"
"go-template/models"
"go-template/pkg/utl/cnvrttogql"
resultwrapper "go-template/pkg/utl/resultwrapper"
throttle "go-template/pkg/utl/throttle"
"go-template/pkg/utl/resultwrapper"
"go-template/pkg/utl/throttle"
"strconv"
"time"

Expand Down
4 changes: 2 additions & 2 deletions resolver/user_queries.resolvers.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import (
"go-template/gqlmodels"
"go-template/internal/middleware/auth"
"go-template/pkg/utl/cnvrttogql"
rediscache "go-template/pkg/utl/rediscache"
resultwrapper "go-template/pkg/utl/resultwrapper"
"go-template/pkg/utl/rediscache"
"go-template/pkg/utl/resultwrapper"

"github.com/volatiletech/sqlboiler/v4/queries/qm"
)
Expand Down

0 comments on commit 7bf737c

Please sign in to comment.