Skip to content

Commit

Permalink
fix: remove obsolete clihelpers
Browse files Browse the repository at this point in the history
  • Loading branch information
aeneasr committed Jan 11, 2021
1 parent 4391fe5 commit 230fd13
Show file tree
Hide file tree
Showing 30 changed files with 90 additions and 75 deletions.
5 changes: 3 additions & 2 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import (
"fmt"
"os"

"github.com/ory/kratos/driver/config"

"github.com/ory/kratos/cmd/hashers"

"github.com/ory/kratos/cmd/remote"
Expand All @@ -13,7 +15,6 @@ import (
"github.com/ory/kratos/cmd/jsonnet"
"github.com/ory/kratos/cmd/migrate"
"github.com/ory/kratos/cmd/serve"
"github.com/ory/kratos/internal/clihelpers"
"github.com/ory/x/cmdx"

"github.com/spf13/cobra"
Expand Down Expand Up @@ -45,5 +46,5 @@ func init() {
remote.RegisterCommandRecursive(RootCmd)
hashers.RegisterCommandRecursive(RootCmd)

RootCmd.AddCommand(cmdx.Version(&clihelpers.BuildVersion, &clihelpers.BuildGitHash, &clihelpers.BuildTime))
RootCmd.AddCommand(cmdx.Version(&config.Version, &config.Commit, &config.Date))
}
7 changes: 3 additions & 4 deletions cmd/serve/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ package serve

import (
"github.com/ory/kratos/driver/config"
"github.com/ory/kratos/internal/clihelpers"
"github.com/ory/x/configx"

"github.com/spf13/cobra"
Expand Down Expand Up @@ -45,9 +44,9 @@ DON'T DO THIS IN PRODUCTION!
configVersion := d.Configuration(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 clihelpers.BuildVersion != "" &&
configVersion != clihelpers.BuildVersion {
d.Logger().Warnf("Config version is '%s' but kratos runs on version '%s'", configVersion, clihelpers.BuildVersion)
} else if config.Version != "" &&
configVersion != config.Version {
d.Logger().Warnf("Config version is '%s' but kratos runs on version '%s'", configVersion, config.Version)
}

daemon.ServeAll(d)(cmd, args)
Expand Down
4 changes: 2 additions & 2 deletions continuity/container.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"context"
"time"

"github.com/ory/kratos/corp/tablename"
"github.com/ory/kratos/corp"

"github.com/gofrs/uuid"
"github.com/pkg/errors"
Expand Down Expand Up @@ -41,7 +41,7 @@ func (c *Container) UTC() *Container {
}

func (c Container) TableName(ctx context.Context) string {
return tablename.Contextualize(ctx, "continuity_containers")
return corp.ContextualizeTableName(ctx, "continuity_containers")
}

func NewContainer(name string, o managerOptions) *Container {
Expand Down
22 changes: 22 additions & 0 deletions corp/context.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package corp

import (
"context"
"net/http"

"github.com/ory/kratos/driver/config"
)

func ContextualizeTableName(_ context.Context, name string) string {
return name
}

func ContextualizeMiddleware(_ context.Context) func(rw http.ResponseWriter, r *http.Request, next http.HandlerFunc) {
return func(w http.ResponseWriter, r *http.Request, n http.HandlerFunc) {
n(w, r)
}
}

func ContextualizeConfig(ctx context.Context, fb config.Provider) config.Provider {
return fb
}
7 changes: 7 additions & 0 deletions corp/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module github.com/ory/kratos/corp

go 1.14

replace github.com/ory/kratos => ../

require github.com/urfave/negroni v1.0.0
2 changes: 2 additions & 0 deletions corp/go.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
github.com/urfave/negroni v1.0.0 h1:kIimOitoypq34K7TG7DUaJ9kq/N4Ofuwi1sjz0KipXc=
github.com/urfave/negroni v1.0.0/go.mod h1:Meg73S6kFm/4PpbYdq35yYWoCZ9mS/YSx+lKnmiohz4=
7 changes: 0 additions & 7 deletions corp/tablename/context.go

This file was deleted.

3 changes: 0 additions & 3 deletions corp/tablename/go.mod

This file was deleted.

4 changes: 2 additions & 2 deletions courier/message.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"context"
"time"

"github.com/ory/kratos/corp/tablename"
"github.com/ory/kratos/corp"

"github.com/gofrs/uuid"
)
Expand Down Expand Up @@ -37,5 +37,5 @@ type Message struct {
}

func (m Message) TableName(ctx context.Context) string {
return tablename.Contextualize(ctx, "courier_messages")
return corp.ContextualizeTableName(ctx, "courier_messages")
}
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ replace gopkg.in/DataDog/dd-trace-go.v1 => gopkg.in/DataDog/dd-trace-go.v1 v1.27
replace github.com/ory/kratos-client-go => ./internal/httpclient

// Use the internal name for tablename generation
replace github.com/ory/kratos/corp/tablename => ./corp/tablename
replace github.com/ory/kratos/corp => ./corp

require (
github.com/HdrHistogram/hdrhistogram-go v1.0.1 // indirect
Expand Down Expand Up @@ -61,7 +61,7 @@ require (
github.com/ory/herodot v0.9.0
github.com/ory/jsonschema/v3 v3.0.1
github.com/ory/kratos-client-go v0.0.0-00010101000000-000000000000
github.com/ory/kratos/corp/tablename v0.0.0-00010101000000-000000000000
github.com/ory/kratos/corp v0.0.0-00010101000000-000000000000
github.com/ory/mail/v3 v3.0.0
github.com/ory/nosurf v1.2.3
github.com/ory/x v0.0.170
Expand Down
12 changes: 6 additions & 6 deletions identity/credentials.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"reflect"
"time"

"github.com/ory/kratos/corp/tablename"
"github.com/ory/kratos/corp"

"github.com/gofrs/uuid"

Expand Down Expand Up @@ -90,23 +90,23 @@ type (
)

func (c CredentialsTypeTable) TableName(ctx context.Context) string {
return tablename.Contextualize(ctx, "identity_credential_types")
return corp.ContextualizeTableName(ctx, "identity_credential_types")
}

func (c CredentialsCollection) TableName(ctx context.Context) string {
return tablename.Contextualize(ctx, "identity_credentials")
return corp.ContextualizeTableName(ctx, "identity_credentials")
}

func (c Credentials) TableName(ctx context.Context) string {
return tablename.Contextualize(ctx, "identity_credentials")
return corp.ContextualizeTableName(ctx, "identity_credentials")
}

func (c CredentialIdentifierCollection) TableName(ctx context.Context) string {
return tablename.Contextualize(ctx, "identity_credential_identifiers")
return corp.ContextualizeTableName(ctx, "identity_credential_identifiers")
}

func (c CredentialIdentifier) TableName(ctx context.Context) string {
return tablename.Contextualize(ctx, "identity_credential_identifiers")
return corp.ContextualizeTableName(ctx, "identity_credential_identifiers")
}

func CredentialsEqual(a, b map[CredentialsType]Credentials) bool {
Expand Down
4 changes: 2 additions & 2 deletions identity/identity.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"sync"
"time"

"github.com/ory/kratos/corp/tablename"
"github.com/ory/kratos/corp"

"github.com/ory/herodot"
"github.com/ory/x/sqlxx"
Expand Down Expand Up @@ -117,7 +117,7 @@ func (t *Traits) UnmarshalJSON(data []byte) error {
}

func (i Identity) TableName(ctx context.Context) string {
return tablename.Contextualize(ctx, "identities")
return corp.ContextualizeTableName(ctx, "identities")
}

func (i *Identity) lock() *sync.RWMutex {
Expand Down
4 changes: 2 additions & 2 deletions identity/identity_recovery.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"context"
"time"

"github.com/ory/kratos/corp/tablename"
"github.com/ory/kratos/corp"

"github.com/gofrs/uuid"
)
Expand Down Expand Up @@ -49,7 +49,7 @@ func (v RecoveryAddressType) HTMLFormInputType() string {
}

func (a RecoveryAddress) TableName(ctx context.Context) string {
return tablename.Contextualize(ctx, "identity_recovery_addresses")
return corp.ContextualizeTableName(ctx, "identity_recovery_addresses")
}

func NewRecoveryEmailAddress(
Expand Down
4 changes: 2 additions & 2 deletions identity/identity_verification.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"context"
"time"

"github.com/ory/kratos/corp/tablename"
"github.com/ory/kratos/corp"

"github.com/gofrs/uuid"

Expand Down Expand Up @@ -62,7 +62,7 @@ func (v VerifiableAddressType) HTMLFormInputType() string {
}

func (a VerifiableAddress) TableName(ctx context.Context) string {
return tablename.Contextualize(ctx, "identity_verifiable_addresses")
return corp.ContextualizeTableName(ctx, "identity_verifiable_addresses")
}

func NewVerifiableEmailAddress(value string, identity uuid.UUID) *VerifiableAddress {
Expand Down
6 changes: 0 additions & 6 deletions internal/clihelpers/helpers.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
package clihelpers

var (
BuildVersion = ""
BuildTime = ""
BuildGitHash = ""
)

const (
WarningJQIsComplicated = "We have to admit, this is not easy if you don't speak jq fluently. What about opening an issue and telling us what predefined selectors you want to have? https:/ory/kratos/issues/new/choose"
)
4 changes: 2 additions & 2 deletions selfservice/errorx/error.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"encoding/json"
"time"

"github.com/ory/kratos/corp/tablename"
"github.com/ory/kratos/corp"

"github.com/gofrs/uuid"
)
Expand Down Expand Up @@ -36,5 +36,5 @@ type ErrorContainer struct {
}

func (e ErrorContainer) TableName(ctx context.Context) string {
return tablename.Contextualize(ctx, "selfservice_errors")
return corp.ContextualizeTableName(ctx, "selfservice_errors")
}
4 changes: 2 additions & 2 deletions selfservice/flow/login/flow.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"net/url"
"time"

"github.com/ory/kratos/corp/tablename"
"github.com/ory/kratos/corp"

"github.com/gobuffalo/pop/v5"
"github.com/gofrs/uuid"
Expand Down Expand Up @@ -132,7 +132,7 @@ func (f *Flow) AfterFind(_ *pop.Connection) error {
}

func (f Flow) TableName(ctx context.Context) string {
return tablename.Contextualize(ctx, "selfservice_login_flows")
return corp.ContextualizeTableName(ctx, "selfservice_login_flows")
}

func (f *Flow) Valid() error {
Expand Down
6 changes: 3 additions & 3 deletions selfservice/flow/login/flow_method.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"encoding/json"
"time"

"github.com/ory/kratos/corp/tablename"
"github.com/ory/kratos/corp"

"github.com/ory/x/sqlxx"

Expand Down Expand Up @@ -45,13 +45,13 @@ type FlowMethod struct {
}

func (u FlowMethod) TableName(ctx context.Context) string {
return tablename.Contextualize(ctx, "selfservice_login_flow_methods")
return corp.ContextualizeTableName(ctx, "selfservice_login_flow_methods")
}

type FlowMethods map[identity.CredentialsType]*FlowMethod

func (u FlowMethods) TableName(ctx context.Context) string {
return tablename.Contextualize(ctx, "selfservice_login_flow_methods")
return corp.ContextualizeTableName(ctx, "selfservice_login_flow_methods")
}

// swagger:ignore
Expand Down
4 changes: 2 additions & 2 deletions selfservice/flow/recovery/flow.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"net/url"
"time"

"github.com/ory/kratos/corp/tablename"
"github.com/ory/kratos/corp"

"github.com/gobuffalo/pop/v5"
"github.com/gofrs/uuid"
Expand Down Expand Up @@ -120,7 +120,7 @@ func NewFlow(exp time.Duration, csrf string, r *http.Request, strategies Strateg
}

func (f Flow) TableName(ctx context.Context) string {
return tablename.Contextualize(ctx, "selfservice_recovery_flows")
return corp.ContextualizeTableName(ctx, "selfservice_recovery_flows")
}

func (f *Flow) GetID() uuid.UUID {
Expand Down
6 changes: 3 additions & 3 deletions selfservice/flow/recovery/flow_method.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"encoding/json"
"time"

"github.com/ory/kratos/corp/tablename"
"github.com/ory/kratos/corp"

"github.com/ory/x/sqlxx"

Expand Down Expand Up @@ -44,13 +44,13 @@ type FlowMethod struct {
}

func (u FlowMethod) TableName(ctx context.Context) string {
return tablename.Contextualize(ctx, "selfservice_recovery_flow_methods")
return corp.ContextualizeTableName(ctx, "selfservice_recovery_flow_methods")
}

type FlowMethods map[string]*FlowMethod

func (u FlowMethods) TableName(ctx context.Context) string {
return tablename.Contextualize(ctx, "selfservice_recovery_flow_methods")
return corp.ContextualizeTableName(ctx, "selfservice_recovery_flow_methods")
}

// swagger:ignore
Expand Down
4 changes: 2 additions & 2 deletions selfservice/flow/registration/flow.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"net/url"
"time"

"github.com/ory/kratos/corp/tablename"
"github.com/ory/kratos/corp"

"github.com/gobuffalo/pop/v5"
"github.com/gofrs/uuid"
Expand Down Expand Up @@ -118,7 +118,7 @@ func (f *Flow) AfterFind(_ *pop.Connection) error {
}

func (f Flow) TableName(ctx context.Context) string {
return tablename.Contextualize(ctx, "selfservice_registration_flows")
return corp.ContextualizeTableName(ctx, "selfservice_registration_flows")
}

func (f *Flow) GetID() uuid.UUID {
Expand Down
6 changes: 3 additions & 3 deletions selfservice/flow/registration/flow_method.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"encoding/json"
"time"

"github.com/ory/kratos/corp/tablename"
"github.com/ory/kratos/corp"

"github.com/ory/x/sqlxx"

Expand Down Expand Up @@ -45,13 +45,13 @@ type FlowMethod struct {
}

func (u FlowMethod) TableName(ctx context.Context) string {
return tablename.Contextualize(ctx, "selfservice_registration_flow_methods")
return corp.ContextualizeTableName(ctx, "selfservice_registration_flow_methods")
}

type FlowMethods map[identity.CredentialsType]*FlowMethod

func (u FlowMethods) TableName(ctx context.Context) string {
return tablename.Contextualize(ctx, "selfservice_registration_flow_methods")
return corp.ContextualizeTableName(ctx, "selfservice_registration_flow_methods")
}

// swagger:ignore
Expand Down
Loading

0 comments on commit 230fd13

Please sign in to comment.