reflectx.TypeFor => reflect.TypeFor

Since go1.22 it is now in the standard library and is removed from a
future versio from pkglib
This commit is contained in:
Tom Wiesing 2024-04-08 23:30:15 +02:00
parent ee2f6e08c6
commit 84799afda2
No known key found for this signature in database
9 changed files with 19 additions and 19 deletions

View file

@ -2,12 +2,12 @@ package policy
import ( import (
"context" "context"
"reflect"
"github.com/FAU-CDI/wisski-distillery/internal/dis/component" "github.com/FAU-CDI/wisski-distillery/internal/dis/component"
"github.com/FAU-CDI/wisski-distillery/internal/dis/component/auth" "github.com/FAU-CDI/wisski-distillery/internal/dis/component/auth"
"github.com/FAU-CDI/wisski-distillery/internal/dis/component/sql" "github.com/FAU-CDI/wisski-distillery/internal/dis/component/sql"
"github.com/FAU-CDI/wisski-distillery/internal/models" "github.com/FAU-CDI/wisski-distillery/internal/models"
"github.com/tkw1536/pkglib/reflectx"
"gorm.io/gorm" "gorm.io/gorm"
) )
@ -29,7 +29,7 @@ var (
func (pol *Policy) TableInfo() component.TableInfo { func (pol *Policy) TableInfo() component.TableInfo {
return component.TableInfo{ return component.TableInfo{
Name: models.GrantTable, Name: models.GrantTable,
Model: reflectx.TypeFor[models.Grant](), Model: reflect.TypeFor[models.Grant](),
} }
} }

View file

@ -3,13 +3,13 @@ package tokens
import ( import (
"context" "context"
"crypto/rand" "crypto/rand"
"reflect"
"strings" "strings"
"github.com/FAU-CDI/wisski-distillery/internal/dis/component" "github.com/FAU-CDI/wisski-distillery/internal/dis/component"
"github.com/FAU-CDI/wisski-distillery/internal/dis/component/sql" "github.com/FAU-CDI/wisski-distillery/internal/dis/component/sql"
"github.com/FAU-CDI/wisski-distillery/internal/models" "github.com/FAU-CDI/wisski-distillery/internal/models"
"github.com/tkw1536/pkglib/password" "github.com/tkw1536/pkglib/password"
"github.com/tkw1536/pkglib/reflectx"
"gorm.io/gorm" "gorm.io/gorm"
) )
@ -30,7 +30,7 @@ var (
func (tok *Tokens) TableInfo() component.TableInfo { func (tok *Tokens) TableInfo() component.TableInfo {
return component.TableInfo{ return component.TableInfo{
Name: models.TokensTable, Name: models.TokensTable,
Model: reflectx.TypeFor[models.Token](), Model: reflect.TypeFor[models.Token](),
} }
} }

View file

@ -6,6 +6,7 @@ import (
"encoding/base64" "encoding/base64"
"fmt" "fmt"
"image/png" "image/png"
"reflect"
"strings" "strings"
"github.com/FAU-CDI/wisski-distillery/internal/dis/component" "github.com/FAU-CDI/wisski-distillery/internal/dis/component"
@ -15,7 +16,6 @@ import (
"github.com/pquerna/otp" "github.com/pquerna/otp"
"github.com/pquerna/otp/totp" "github.com/pquerna/otp/totp"
"github.com/tkw1536/pkglib/password" "github.com/tkw1536/pkglib/password"
"github.com/tkw1536/pkglib/reflectx"
"golang.org/x/crypto/bcrypt" "golang.org/x/crypto/bcrypt"
) )
@ -25,7 +25,7 @@ var ErrUserNotFound = errors.New("user not found")
func (auth *Auth) TableInfo() component.TableInfo { func (auth *Auth) TableInfo() component.TableInfo {
return component.TableInfo{ return component.TableInfo{
Name: models.UserTable, Name: models.UserTable,
Model: reflectx.TypeFor[models.User](), Model: reflect.TypeFor[models.User](),
} }
} }

View file

@ -5,13 +5,13 @@ import (
"errors" "errors"
"io/fs" "io/fs"
"os" "os"
"reflect"
"github.com/FAU-CDI/wisski-distillery/internal/dis/component" "github.com/FAU-CDI/wisski-distillery/internal/dis/component"
"github.com/FAU-CDI/wisski-distillery/internal/dis/component/sql" "github.com/FAU-CDI/wisski-distillery/internal/dis/component/sql"
"github.com/FAU-CDI/wisski-distillery/internal/models" "github.com/FAU-CDI/wisski-distillery/internal/models"
"github.com/FAU-CDI/wisski-distillery/internal/status" "github.com/FAU-CDI/wisski-distillery/internal/status"
"github.com/tkw1536/pkglib/collection" "github.com/tkw1536/pkglib/collection"
"github.com/tkw1536/pkglib/reflectx"
) )
// Logger is responsible for logging backups and snapshots // Logger is responsible for logging backups and snapshots
@ -28,7 +28,7 @@ var (
func (*Logger) TableInfo() component.TableInfo { func (*Logger) TableInfo() component.TableInfo {
return component.TableInfo{ return component.TableInfo{
Model: reflectx.TypeFor[models.Export](), Model: reflect.TypeFor[models.Export](),
Name: models.ExportTable, Name: models.ExportTable,
} }
} }

View file

@ -1,12 +1,12 @@
package meta package meta
import ( import (
"reflect"
"sync" "sync"
"github.com/FAU-CDI/wisski-distillery/internal/dis/component" "github.com/FAU-CDI/wisski-distillery/internal/dis/component"
"github.com/FAU-CDI/wisski-distillery/internal/dis/component/sql" "github.com/FAU-CDI/wisski-distillery/internal/dis/component/sql"
"github.com/FAU-CDI/wisski-distillery/internal/models" "github.com/FAU-CDI/wisski-distillery/internal/models"
"github.com/tkw1536/pkglib/reflectx"
) )
// Component meta is responsible for managing metadata per WissKI Instance // Component meta is responsible for managing metadata per WissKI Instance
@ -27,7 +27,7 @@ var (
func (*Meta) TableInfo() component.TableInfo { func (*Meta) TableInfo() component.TableInfo {
return component.TableInfo{ return component.TableInfo{
Model: reflectx.TypeFor[models.Metadatum](), Model: reflect.TypeFor[models.Metadatum](),
Name: models.MetadataTable, Name: models.MetadataTable,
} }
} }

View file

@ -4,12 +4,12 @@ import (
"fmt" "fmt"
"html/template" "html/template"
"net/http" "net/http"
"reflect"
"time" "time"
"github.com/FAU-CDI/wisski-distillery/internal/dis/component" "github.com/FAU-CDI/wisski-distillery/internal/dis/component"
"github.com/FAU-CDI/wisski-distillery/internal/dis/component/server/assets" "github.com/FAU-CDI/wisski-distillery/internal/dis/component/server/assets"
"github.com/rs/zerolog" "github.com/rs/zerolog"
"github.com/tkw1536/pkglib/reflectx"
"golang.org/x/exp/slices" "golang.org/x/exp/slices"
) )
@ -52,7 +52,7 @@ func (rf RuntimeFlags) TookHTML() template.HTML {
return template.HTML(fmt.Sprintf("<time datetime=\"P%.3f\">%s</time>", took.Seconds(), took)) return template.HTML(fmt.Sprintf("<time datetime=\"P%.3f\">%s</time>", took.Seconds(), took))
} }
var runtimeFlagsName = reflectx.TypeFor[RuntimeFlags]().Name() var runtimeFlagsName = reflect.TypeFor[RuntimeFlags]().Name()
// Clone clones this flags // Clone clones this flags
func (flags Flags) Clone() Flags { func (flags Flags) Clone() Flags {

View file

@ -4,7 +4,6 @@ import (
"html/template" "html/template"
"reflect" "reflect"
"github.com/tkw1536/pkglib/reflectx"
"golang.org/x/exp/slices" "golang.org/x/exp/slices"
) )
@ -21,7 +20,7 @@ type Parsed[C any] struct {
// If base is not nil, every template associated with the base template is copied into the given template. // If base is not nil, every template associated with the base template is copied into the given template.
// Functions will be applied on creation time to represent the context for the given template. // Functions will be applied on creation time to represent the context for the given template.
func Parse[C any](name string, source []byte, base *template.Template, funcs ...FlagFunc) Parsed[C] { func Parse[C any](name string, source []byte, base *template.Template, funcs ...FlagFunc) Parsed[C] {
tp := reflectx.TypeFor[C]() tp := reflect.TypeFor[C]()
// determine if we have an embedded field in the struct // determine if we have an embedded field in the struct
var hasEmbed bool var hasEmbed bool

View file

@ -1,9 +1,10 @@
package sql package sql
import ( import (
"reflect"
"github.com/FAU-CDI/wisski-distillery/internal/dis/component" "github.com/FAU-CDI/wisski-distillery/internal/dis/component"
"github.com/FAU-CDI/wisski-distillery/internal/models" "github.com/FAU-CDI/wisski-distillery/internal/models"
"github.com/tkw1536/pkglib/reflectx"
) )
// This file defines additional tables used by multiple components // This file defines additional tables used by multiple components
@ -18,7 +19,7 @@ var (
func (*InstanceTable) TableInfo() component.TableInfo { func (*InstanceTable) TableInfo() component.TableInfo {
return component.TableInfo{ return component.TableInfo{
Model: reflectx.TypeFor[models.Instance](), Model: reflect.TypeFor[models.Instance](),
Name: models.InstanceTable, Name: models.InstanceTable,
} }
} }
@ -33,7 +34,7 @@ var (
func (*LockTable) TableInfo() component.TableInfo { func (*LockTable) TableInfo() component.TableInfo {
return component.TableInfo{ return component.TableInfo{
Model: reflectx.TypeFor[models.Lock](), Model: reflect.TypeFor[models.Lock](),
Name: models.LockTable, Name: models.LockTable,
} }
} }

View file

@ -2,16 +2,16 @@ package sshkeys
import ( import (
"context" "context"
"reflect"
"github.com/FAU-CDI/wisski-distillery/internal/dis/component" "github.com/FAU-CDI/wisski-distillery/internal/dis/component"
"github.com/FAU-CDI/wisski-distillery/internal/models" "github.com/FAU-CDI/wisski-distillery/internal/models"
"github.com/gliderlabs/ssh" "github.com/gliderlabs/ssh"
"github.com/tkw1536/pkglib/reflectx"
) )
func (ssh2 *SSHKeys) TableInfo() component.TableInfo { func (ssh2 *SSHKeys) TableInfo() component.TableInfo {
return component.TableInfo{ return component.TableInfo{
Model: reflectx.TypeFor[models.Keys](), Model: reflect.TypeFor[models.Keys](),
Name: models.KeysTable, Name: models.KeysTable,
} }
} }