Skip to content

Commit

Permalink
fix: resolve pkger issues
Browse files Browse the repository at this point in the history
  • Loading branch information
aeneasr committed Sep 3, 2020
1 parent 1ed9c70 commit 294066c
Show file tree
Hide file tree
Showing 16 changed files with 30 additions and 47 deletions.
2 changes: 1 addition & 1 deletion .docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM alpine:3.11
FROM alpine:3.12

RUN addgroup -S ory; \
adduser -S ory -G ory -D -h /home/ory -s /bin/nologin; \
Expand Down
7 changes: 3 additions & 4 deletions .docker/Dockerfile-build
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.14-alpine AS builder
FROM golang:1.15-alpine AS builder

RUN apk -U --no-cache add build-base git gcc bash

Expand All @@ -14,10 +14,9 @@ RUN go mod download

ADD . .

RUN make pack
RUN go build -tags sqlite -a -o /usr/bin/kratos
RUN make pack && go build -tags sqlite -o /usr/bin/kratos

FROM alpine:3.11
FROM alpine:3.12

RUN addgroup -S ory; \
adduser -S ory -G ory -D -h /home/ory -s /bin/nologin; \
Expand Down
2 changes: 1 addition & 1 deletion .docker/Dockerfile-sqlite
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM alpine:3.11
FROM alpine:3.12

# Because this image is built for SQLite, we create /home/ory and /home/ory/sqlite which is owned by the ory user
# and declare /home/ory/sqlite a volume.
Expand Down
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@ node_modules/
./quickstart-*.yml
.bin/
test/
pgked.go
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -136,4 +136,4 @@ migratest-refresh:

.PHONY: pack
pack: .bin/pkger
pkger -exclude node_modules -exclude docs -exclude .bin -exclude test -exclude script -exclude contrib
pkger -exclude node_modules -exclude docs -exclude .git -exclude .github -exclude .bin -exclude test -exclude script -exclude contrib
4 changes: 0 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -352,8 +352,6 @@ github.com/gobuffalo/events v1.4.1/go.mod h1:SjXgWKpeSuvQDvGhgMz5IXx3Czu+IbL+XPL
github.com/gobuffalo/fizz v1.0.12/go.mod h1:C0sltPxpYK8Ftvf64kbsQa2yiCZY4RZviurNxXdAKwc=
github.com/gobuffalo/fizz v1.9.8/go.mod h1:w1FEn1yKNVCc49KnADGyYGRPH7jFON3ak4Bj1yUudHo=
github.com/gobuffalo/fizz v1.10.0/go.mod h1:J2XGPO0AfJ1zKw7+2BA+6FEGAkyEsdCOLvN93WCT2WI=
github.com/gobuffalo/fizz v1.13.0 h1:XzcBh8DLZH2BgEH77p6q+EKbd8FZyyUXgokUmKXk5ow=
github.com/gobuffalo/fizz v1.13.0/go.mod h1:cXLjhE5p3iuIes6AGZ/9+dfyOkehlB2Vldj0Iw2Uu38=
github.com/gobuffalo/fizz v1.13.1-0.20200903094245-046abeb7de46 h1:lkv+5YiQOlOhXaYyD2PtN/E0BT87G/I0iCL7gqxTKBg=
github.com/gobuffalo/fizz v1.13.1-0.20200903094245-046abeb7de46/go.mod h1:cXLjhE5p3iuIes6AGZ/9+dfyOkehlB2Vldj0Iw2Uu38=
github.com/gobuffalo/flect v0.0.0-20180907193754-dc14d8acaf9f/go.mod h1:rCiQgmAE4axgBNl3jZWzS5rETRYTGOsrixTRaCPzNdA=
Expand Down Expand Up @@ -1046,8 +1044,6 @@ github.com/openzipkin/zipkin-go v0.2.2 h1:nY8Hti+WKaP0cRsSeQ026wU03QsM762XBeCXBb
github.com/openzipkin/zipkin-go v0.2.2/go.mod h1:NaW6tEwdmWMaCDZzg8sh+IBNOxHMPnhQw8ySjnjRyN4=
github.com/ory/analytics-go/v4 v4.0.0 h1:KQ2P00j9dbj4lDC/Albw/zn/scK67041RhqeW5ptsbw=
github.com/ory/analytics-go/v4 v4.0.0/go.mod h1:FMx9cLRD9xN+XevPvZ5FDMfignpmcqPP6FUKnJ9/MmE=
github.com/ory/cli v0.0.27 h1:4dfDDqSzIGUcR/LXzmqI6bnMa/c0Ao0S4Uw3PI2ACWw=
github.com/ory/cli v0.0.27/go.mod h1:DrhqIZ67p55fetGyczTpU+amx3WGIMKOj75mSSbYJ+U=
github.com/ory/cli v0.0.28-0.20200903094455-e203529bf12b h1:YY/QfVyxo4RB1/J5BTC+XJ/LPI70+246XnGlH930fE8=
github.com/ory/cli v0.0.28-0.20200903094455-e203529bf12b/go.mod h1:PqijULTsktU0v2STwzZRXTEYRK5ZEJb0NGkdXLFy/BE=
github.com/ory/dockertest v3.3.5+incompatible h1:iLLK6SQwIhcbrG783Dghaaa3WPzGc+4Emza6EbVUUGA=
Expand Down
8 changes: 0 additions & 8 deletions selfservice/strategy/link/schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,6 @@ package link

import (
"github.com/markbates/pkger"

"github.com/ory/kratos/x"
)

var _ = pkger.Dir("/selfservice/strategy/link/.schema")

var emailSchema []byte

func init() {
emailSchema = x.MustPkgerRead(pkger.Open("/selfservice/strategy/link/.schema/email.schema.json"))
}
5 changes: 4 additions & 1 deletion selfservice/strategy/link/strategy_recovery.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (

"github.com/gofrs/uuid"
"github.com/julienschmidt/httprouter"
"github.com/markbates/pkger"
"github.com/pkg/errors"

"github.com/ory/x/decoderx"
Expand Down Expand Up @@ -484,7 +485,9 @@ func (s *Strategy) decodeRecovery(r *http.Request, decodeBody bool) (*completeSe

if decodeBody {
if err := s.dx.Decode(r, &body,
decoderx.MustHTTPRawJSONSchemaCompiler(emailSchema),
decoderx.MustHTTPRawJSONSchemaCompiler(
x.MustPkgerRead(pkger.Open("/selfservice/strategy/link/.schema/email.schema.json")),
),
decoderx.HTTPDecoderSetValidatePayloads(false),
decoderx.HTTPDecoderJSONFollowsFormFormat()); err != nil {
return nil, err
Expand Down
5 changes: 4 additions & 1 deletion selfservice/strategy/link/strategy_verification.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (

"github.com/gofrs/uuid"
"github.com/julienschmidt/httprouter"
"github.com/markbates/pkger"
"github.com/pkg/errors"

"github.com/ory/x/decoderx"
Expand Down Expand Up @@ -57,7 +58,9 @@ func (s *Strategy) decodeVerification(r *http.Request, decodeBody bool) (*comple

if decodeBody {
if err := s.dx.Decode(r, &body,
decoderx.MustHTTPRawJSONSchemaCompiler(emailSchema),
decoderx.MustHTTPRawJSONSchemaCompiler(
x.MustPkgerRead(pkger.Open("/selfservice/strategy/link/.schema/email.schema.json")),
),
decoderx.HTTPDecoderSetValidatePayloads(false),
decoderx.HTTPDecoderJSONFollowsFormFormat()); err != nil {
return nil, err
Expand Down
4 changes: 3 additions & 1 deletion selfservice/strategy/password/login.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"net/http"

"github.com/julienschmidt/httprouter"
"github.com/markbates/pkger"
"github.com/pkg/errors"

"github.com/ory/x/decoderx"
Expand Down Expand Up @@ -105,7 +106,8 @@ func (s *Strategy) handleLogin(w http.ResponseWriter, r *http.Request, _ httprou
}

var p CompleteSelfServiceLoginFlowWithPasswordMethod
if err := s.hd.Decode(r, &p, decoderx.MustHTTPRawJSONSchemaCompiler(loginSchema)); err != nil {
if err := s.hd.Decode(r, &p, decoderx.MustHTTPRawJSONSchemaCompiler(x.MustPkgerRead(
pkger.Open("/selfservice/strategy/password/.schema/login.schema.json")))); err != nil {
s.handleLoginError(w, r, ar, &p, err)
return
}
Expand Down
4 changes: 3 additions & 1 deletion selfservice/strategy/password/registration.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"net/http"

"github.com/julienschmidt/httprouter"
"github.com/markbates/pkger"
"github.com/pkg/errors"
"github.com/tidwall/sjson"

Expand Down Expand Up @@ -74,7 +75,8 @@ func (s *Strategy) handleRegistrationError(w http.ResponseWriter, r *http.Reques
}

func (s *Strategy) decode(p *RegistrationFormPayload, r *http.Request) error {
raw, err := sjson.SetBytes(registrationSchema, "properties.traits.$ref", s.c.DefaultIdentityTraitsSchemaURL().String()+"#/properties/traits")
raw, err := sjson.SetBytes(x.MustPkgerRead(pkger.Open("/selfservice/strategy/password/.schema/registration.schema.json")),
"properties.traits.$ref", s.c.DefaultIdentityTraitsSchemaURL().String()+"#/properties/traits")
if err != nil {
return errors.WithStack(err)
}
Expand Down
10 changes: 0 additions & 10 deletions selfservice/strategy/password/schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,6 @@ package password

import (
"github.com/markbates/pkger"

"github.com/ory/kratos/x"
)

var _ = pkger.Dir("/selfservice/strategy/password/.schema")

var loginSchema, registrationSchema, settingsSchema []byte

func init() {
loginSchema = x.MustPkgerRead(pkger.Open("/selfservice/strategy/password/.schema/login.schema.json"))
registrationSchema = x.MustPkgerRead(pkger.Open("/selfservice/strategy/password/.schema/registration.schema.json"))
settingsSchema = x.MustPkgerRead(pkger.Open("/selfservice/strategy/password/.schema/settings.schema.json"))
}
3 changes: 2 additions & 1 deletion selfservice/strategy/password/settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (

"github.com/gofrs/uuid"
"github.com/julienschmidt/httprouter"
"github.com/markbates/pkger"
"github.com/pkg/errors"

"github.com/ory/herodot"
Expand Down Expand Up @@ -137,7 +138,7 @@ func (s *Strategy) submitSettingsFlow(w http.ResponseWriter, r *http.Request, ps
}

func (s *Strategy) decodeSettingsFlow(r *http.Request, dest interface{}) error {
compiler, err := decoderx.HTTPRawJSONSchemaCompiler(settingsSchema)
compiler, err := decoderx.HTTPRawJSONSchemaCompiler( x.MustPkgerRead(pkger.Open("/selfservice/strategy/password/.schema/settings.schema.json")))
if err != nil {
return errors.WithStack(err)
}
Expand Down
8 changes: 0 additions & 8 deletions selfservice/strategy/profile/schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,6 @@ package profile

import (
"github.com/markbates/pkger"

"github.com/ory/kratos/x"
)

var _ = pkger.Dir("/selfservice/strategy/profile/.schema")

var settingsSchema []byte

func init() {
settingsSchema = x.MustPkgerRead(pkger.Open("/selfservice/strategy/password/.schema/settings.schema.json"))
}
5 changes: 4 additions & 1 deletion selfservice/strategy/profile/strategy.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (

"github.com/gofrs/uuid"
"github.com/julienschmidt/httprouter"
"github.com/markbates/pkger"
"github.com/pkg/errors"
"github.com/tidwall/sjson"

Expand Down Expand Up @@ -317,7 +318,9 @@ func (s *Strategy) newSettingsProfileDecoder(i *identity.Identity) (decoderx.HTT
if err != nil {
return nil, err
}
raw, err := sjson.SetBytes(settingsSchema, "properties.traits.$ref", ss.URL.String()+"#/properties/traits")
raw, err := sjson.SetBytes(x.MustPkgerRead(pkger.Open(
"/selfservice/strategy/password/.schema/settings.schema.json")),
"properties.traits.$ref", ss.URL.String()+"#/properties/traits")
if err != nil {
return nil, errors.WithStack(err)
}
Expand Down
7 changes: 3 additions & 4 deletions x/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,12 @@ package x

import (
"github.com/markbates/pkger"

"github.com/ory/x/logrusx"
"github.com/ory/x/viperx"
)

var schema = MustPkgerRead(pkger.Open("/.schema/config.schema.json"))

func WatchAndValidateViper(log *logrusx.Logger) {
viperx.WatchAndValidateViper(log, schema, "ORY Kratos", []string{"serve", "profiling", "log"}, "")
schema := MustPkgerRead(pkger.Open("/.schema/config.schema.json"))
viperx.WatchAndValidateViper(log, schema,
"ORY Kratos", []string{"serve", "profiling", "log"}, "")
}

0 comments on commit 294066c

Please sign in to comment.