Skip to content

Commit

Permalink
refactor: rename config structs and interfaces
Browse files Browse the repository at this point in the history
  • Loading branch information
aeneasr committed Jan 13, 2021
1 parent cd0e0eb commit 4a2f419
Show file tree
Hide file tree
Showing 86 changed files with 385 additions and 385 deletions.
2 changes: 1 addition & 1 deletion cmd/cliclient/migrate.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func (h *MigrateHandler) MigrateSQL(cmd *cobra.Command, args []string) {
cmd.Context(),
configx.WithFlags(cmd.Flags()),
configx.SkipValidation())
if len(d.Configuration(cmd.Context()).DSN()) == 0 {
if len(d.Config(cmd.Context()).DSN()) == 0 {
fmt.Println(cmd.UsageString())
fmt.Println("")
fmt.Println("When using flag -e, environment variable DSN must be set")
Expand Down
16 changes: 8 additions & 8 deletions cmd/daemon/serve.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ func ServePublic(r driver.Registry, wg *sync.WaitGroup, cmd *cobra.Command, args
defer wg.Done()
modifiers := newOptions(opts)

c := r.Configuration(cmd.Context())
c := r.Config(cmd.Context())
l := r.Logger()
n := negroni.New()
for _, mw := range modifiers.mwf {
Expand Down Expand Up @@ -97,7 +97,7 @@ func ServePublic(r driver.Registry, wg *sync.WaitGroup, cmd *cobra.Command, args
}

var handler http.Handler = n
options, enabled := r.Configuration(cmd.Context()).CORS("public")
options, enabled := r.Config(cmd.Context()).CORS("public")
if enabled {
handler = cors.New(options).Handler(handler)
}
Expand All @@ -118,7 +118,7 @@ func ServeAdmin(r driver.Registry, wg *sync.WaitGroup, cmd *cobra.Command, args
defer wg.Done()
modifiers := newOptions(opts)

c := r.Configuration(cmd.Context())
c := r.Config(cmd.Context())
l := r.Logger()
n := negroni.New()
for _, mw := range modifiers.mwf {
Expand Down Expand Up @@ -154,17 +154,17 @@ func sqa(cmd *cobra.Command, d driver.Registry) *metricsx.Service {
return metricsx.New(
cmd,
d.Logger(),
d.Configuration(cmd.Context()).Source(),
d.Config(cmd.Context()).Source(),
&metricsx.Options{
Service: "ory-kratos",
ClusterID: metricsx.Hash(
strings.Join([]string{
d.Configuration(cmd.Context()).DSN(),
d.Configuration(cmd.Context()).SelfPublicURL().String(),
d.Configuration(cmd.Context()).SelfAdminURL().String(),
d.Config(cmd.Context()).DSN(),
d.Config(cmd.Context()).SelfPublicURL().String(),
d.Config(cmd.Context()).SelfAdminURL().String(),
}, "|"),
),
IsDevelopment: d.Configuration(cmd.Context()).IsInsecureDevMode(),
IsDevelopment: d.Config(cmd.Context()).IsInsecureDevMode(),
WriteKey: "qQlI6q8Q4WvkzTjKQSor4sHYOikHIvvi",
WhitelistedPaths: []string{
"/",
Expand Down
8 changes: 4 additions & 4 deletions cmd/hashers/argon2/calibrate.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@ import (

type (
argon2Config struct {
c config.HasherArgon2Config
c config.Argon2
}
)

func (c *argon2Config) Configuration(_ context.Context) *config.Provider {
func (c *argon2Config) Config(_ context.Context) *config.Config {
panic("not supposed to be called")
}

func (c *argon2Config) HasherArgon2() *config.HasherArgon2Config {
func (c *argon2Config) HasherArgon2() *config.Argon2 {
return &c.c
}

Expand Down Expand Up @@ -56,7 +56,7 @@ func newCalibrateCmd() *cobra.Command {
)

aconfig := &argon2Config{
c: config.HasherArgon2Config{},
c: config.Argon2{},
}

cmd := &cobra.Command{
Expand Down
4 changes: 2 additions & 2 deletions cmd/serve/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ var serveCmd = &cobra.Command{
Run: func(cmd *cobra.Command, args []string) {
d := driver.New(cmd.Context(), configx.WithFlags(cmd.Flags()))

if d.Configuration(cmd.Context()).IsInsecureDevMode() {
if d.Config(cmd.Context()).IsInsecureDevMode() {
d.Logger().Warn(`
YOU ARE RUNNING ORY KRATOS IN DEV MODE.
Expand All @@ -41,7 +41,7 @@ DON'T DO THIS IN PRODUCTION!
`)
}

configVersion := d.Configuration(cmd.Context()).ConfigVersion()
configVersion := d.Config(cmd.Context()).ConfigVersion()
if configVersion == config.UnknownVersion {
d.Logger().Warn("The config has no version specified. Add the version to improve your development experience.")
} else if config.Version != "" &&
Expand Down
2 changes: 1 addition & 1 deletion corp/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@ func ContextualizeMiddleware(_ context.Context) func(rw http.ResponseWriter, r *
}
}

func ContextualizeConfig(ctx context.Context, fb *config.Provider) *config.Provider {
func ContextualizeConfig(ctx context.Context, fb *config.Config) *config.Config {
return fb
}
4 changes: 2 additions & 2 deletions courier/courier.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,14 @@ type (
Courier struct {
Dialer *gomail.Dialer
d smtpDependencies
c *config.Provider
c *config.Config
}
Provider interface {
Courier() *Courier
}
)

func NewSMTP(d smtpDependencies, c *config.Provider) *Courier {
func NewSMTP(d smtpDependencies, c *config.Config) *Courier {
uri := c.CourierSMTPURL()
password, _ := uri.User.Password()
port, _ := strconv.ParseInt(uri.Port(), 10, 64)
Expand Down
4 changes: 2 additions & 2 deletions courier/template/recovery_invalid.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ import (

type (
RecoveryInvalid struct {
c *config.Provider
c *config.Config
m *RecoveryInvalidModel
}
RecoveryInvalidModel struct {
To string
}
)

func NewRecoveryInvalid(c *config.Provider, m *RecoveryInvalidModel) *RecoveryInvalid {
func NewRecoveryInvalid(c *config.Config, m *RecoveryInvalidModel) *RecoveryInvalid {
return &RecoveryInvalid{c: c, m: m}
}

Expand Down
4 changes: 2 additions & 2 deletions courier/template/recovery_valid.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (

type (
RecoveryValid struct {
c *config.Provider
c *config.Config
m *RecoveryValidModel
}
RecoveryValidModel struct {
Expand All @@ -17,7 +17,7 @@ type (
}
)

func NewRecoveryValid(c *config.Provider, m *RecoveryValidModel) *RecoveryValid {
func NewRecoveryValid(c *config.Config, m *RecoveryValidModel) *RecoveryValid {
return &RecoveryValid{c: c, m: m}
}

Expand Down
4 changes: 2 additions & 2 deletions courier/template/stub.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
)

type TestStub struct {
c *config.Provider
c *config.Config
m *TestStubModel
}

Expand All @@ -17,7 +17,7 @@ type TestStubModel struct {
Body string
}

func NewTestStub(c *config.Provider, m *TestStubModel) *TestStub {
func NewTestStub(c *config.Config, m *TestStubModel) *TestStub {
return &TestStub{c: c, m: m}
}

Expand Down
4 changes: 2 additions & 2 deletions courier/template/verification_invalid.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ import (

type (
VerificationInvalid struct {
c *config.Provider
c *config.Config
m *VerificationInvalidModel
}
VerificationInvalidModel struct {
To string
}
)

func NewVerificationInvalid(c *config.Provider, m *VerificationInvalidModel) *VerificationInvalid {
func NewVerificationInvalid(c *config.Config, m *VerificationInvalidModel) *VerificationInvalid {
return &VerificationInvalid{c: c, m: m}
}

Expand Down
4 changes: 2 additions & 2 deletions courier/template/verification_valid.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (

type (
VerificationValid struct {
c *config.Provider
c *config.Config
m *VerificationValidModel
}
VerificationValidModel struct {
Expand All @@ -17,7 +17,7 @@ type (
}
)

func NewVerificationValid(c *config.Provider, m *VerificationValidModel) *VerificationValid {
func NewVerificationValid(c *config.Config, m *VerificationValidModel) *VerificationValid {
return &VerificationValid{c: c, m: m}
}

Expand Down
Loading

0 comments on commit 4a2f419

Please sign in to comment.