Move to github.com/tkw1536/pkglib package

This commit removes various modules that can be migrated to the
github.com/tkw1536/pkglib package without any code changes (beyond
module renamings).
This commit is contained in:
Tom Wiesing 2023-02-26 09:53:25 +01:00
parent 30c25b8e2a
commit c3ca8e2974
No known key found for this signature in database
65 changed files with 103 additions and 1254 deletions

View file

@ -7,7 +7,7 @@ import (
"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/models"
"github.com/tkw1536/goprogram/lib/reflectx"
"github.com/tkw1536/pkglib/reflectx"
"gorm.io/gorm"
)

View file

@ -10,11 +10,11 @@ import (
"github.com/FAU-CDI/wisski-distillery/internal/dis/component"
"github.com/FAU-CDI/wisski-distillery/internal/models"
"github.com/FAU-CDI/wisski-distillery/pkg/password"
"github.com/FAU-CDI/wisski-distillery/pkg/pools"
"github.com/pkg/errors"
"github.com/pquerna/otp"
"github.com/pquerna/otp/totp"
"github.com/tkw1536/goprogram/lib/reflectx"
"github.com/tkw1536/pkglib/pools"
"github.com/tkw1536/pkglib/reflectx"
"golang.org/x/crypto/bcrypt"
)

View file

@ -8,8 +8,8 @@ import (
"github.com/FAU-CDI/wisski-distillery/internal/models"
"github.com/FAU-CDI/wisski-distillery/internal/status"
"github.com/FAU-CDI/wisski-distillery/pkg/environment"
"github.com/tkw1536/goprogram/lib/collection"
"github.com/tkw1536/goprogram/lib/reflectx"
"github.com/tkw1536/pkglib/collection"
"github.com/tkw1536/pkglib/reflectx"
)
// Logger is responsible for logging backups and snapshots

View file

@ -5,8 +5,8 @@ import (
"fmt"
"io"
"github.com/FAU-CDI/wisski-distillery/pkg/countwriter"
"github.com/FAU-CDI/wisski-distillery/pkg/pools"
"github.com/tkw1536/pkglib/pools"
"github.com/tkw1536/pkglib/sequence"
)
func (snapshot Snapshot) String() string {
@ -19,7 +19,7 @@ func (snapshot Snapshot) String() string {
// Report writes a report from snapshot into w
func (snapshot Snapshot) Report(w io.Writer) (int, error) {
ww := countwriter.NewCountWriter(w)
ww := &sequence.Writer{Writer: w}
encoder := json.NewEncoder(ww)
encoder.SetIndent("", " ")
@ -74,7 +74,7 @@ func (backup Backup) String() string {
// Report formats a report for this backup, and writes it into Writer.
func (backup Backup) Report(w io.Writer) (int, error) {
cw := countwriter.NewCountWriter(w)
cw := &sequence.Writer{Writer: w}
encoder := json.NewEncoder(cw)
encoder.SetIndent("", " ")

View file

@ -12,8 +12,8 @@ import (
"github.com/FAU-CDI/wisski-distillery/internal/wisski"
"github.com/FAU-CDI/wisski-distillery/internal/wisski/ingredient/locker"
"github.com/FAU-CDI/wisski-distillery/pkg/logging"
"github.com/tkw1536/goprogram/lib/collection"
"github.com/tkw1536/goprogram/status"
"github.com/tkw1536/pkglib/collection"
"golang.org/x/exp/slices"
)

View file

@ -6,7 +6,7 @@ import (
"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/models"
"github.com/tkw1536/goprogram/lib/reflectx"
"github.com/tkw1536/pkglib/reflectx"
)
// Component meta is responsible for managing metadata per WissKI Instance

View file

@ -8,7 +8,7 @@ import (
"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/models"
"github.com/tkw1536/goprogram/lib/collection"
"github.com/tkw1536/pkglib/collection"
"gorm.io/gorm"
)

View file

@ -4,7 +4,7 @@ import (
"context"
"net/http"
"github.com/FAU-CDI/wisski-distillery/pkg/mux"
"github.com/tkw1536/pkglib/mux"
)
// Routeable is a component that is servable

View file

@ -10,8 +10,8 @@ import (
"time"
"github.com/FAU-CDI/wisski-distillery/internal/dis/component"
"github.com/FAU-CDI/wisski-distillery/pkg/timex"
"github.com/rs/zerolog"
"github.com/tkw1536/pkglib/timex"
)
type Cron struct {

View file

@ -11,7 +11,7 @@ import (
"github.com/FAU-CDI/wisski-distillery/internal/dis/component/server/templating"
"github.com/FAU-CDI/wisski-distillery/internal/status"
"github.com/FAU-CDI/wisski-distillery/pkg/httpx"
"github.com/FAU-CDI/wisski-distillery/pkg/pools"
"github.com/tkw1536/pkglib/pools"
)
//go:embed "public.html"

View file

@ -12,8 +12,8 @@ import (
"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/templating"
"github.com/FAU-CDI/wisski-distillery/pkg/pools"
"github.com/rs/zerolog"
"github.com/tkw1536/pkglib/pools"
"github.com/yuin/goldmark"
gmmeta "github.com/yuin/goldmark-meta"
"github.com/yuin/goldmark/parser"

View file

@ -8,9 +8,10 @@ import (
"github.com/FAU-CDI/wisski-distillery/internal/dis/component"
"github.com/FAU-CDI/wisski-distillery/internal/dis/component/server/templating"
"github.com/FAU-CDI/wisski-distillery/pkg/cancel"
"github.com/tkw1536/pkglib/contextx"
"github.com/tkw1536/pkglib/mux"
"github.com/FAU-CDI/wisski-distillery/pkg/httpx"
"github.com/FAU-CDI/wisski-distillery/pkg/mux"
"github.com/gorilla/csrf"
"github.com/rs/zerolog"
)
@ -103,8 +104,8 @@ func (server *Server) Server(ctx context.Context, progress io.Writer) (public ht
}
// apply the given context function
public = httpx.WithContextWrapper(&publicM, func(rcontext context.Context) context.Context { return cancel.ValuesOf(rcontext, ctx) })
internal = httpx.WithContextWrapper(&internalM, func(rcontext context.Context) context.Context { return cancel.ValuesOf(rcontext, ctx) })
public = httpx.WithContextWrapper(&publicM, func(rcontext context.Context) context.Context { return contextx.WithValuesOf(rcontext, ctx) })
internal = httpx.WithContextWrapper(&internalM, func(rcontext context.Context) context.Context { return contextx.WithValuesOf(rcontext, ctx) })
err = nil
return
}

View file

@ -11,10 +11,10 @@ import (
"time"
"github.com/FAU-CDI/wisski-distillery/pkg/httpx"
"github.com/FAU-CDI/wisski-distillery/pkg/pools"
"github.com/FAU-CDI/wisski-distillery/pkg/timex"
"github.com/gorilla/csrf"
"github.com/rs/zerolog"
"github.com/tkw1536/pkglib/pools"
"github.com/tkw1536/pkglib/timex"
)
//go:embed "src/base.html"

View file

@ -9,7 +9,7 @@ import (
"github.com/FAU-CDI/wisski-distillery/internal/dis/component"
"github.com/FAU-CDI/wisski-distillery/internal/dis/component/server/assets"
"github.com/rs/zerolog"
"github.com/tkw1536/goprogram/lib/reflectx"
"github.com/tkw1536/pkglib/reflectx"
"golang.org/x/exp/slices"
)

View file

@ -5,7 +5,7 @@ import (
"net/http"
"github.com/FAU-CDI/wisski-distillery/internal/dis/component"
"github.com/FAU-CDI/wisski-distillery/pkg/mux"
"github.com/tkw1536/pkglib/mux"
"golang.org/x/exp/slices"
)

View file

@ -4,7 +4,7 @@ import (
"html/template"
"reflect"
"github.com/tkw1536/goprogram/lib/reflectx"
"github.com/tkw1536/pkglib/reflectx"
"golang.org/x/exp/slices"
)

View file

@ -16,7 +16,7 @@ import (
"github.com/FAU-CDI/wisski-distillery/internal/dis/component"
"github.com/FAU-CDI/wisski-distillery/internal/models"
"github.com/FAU-CDI/wisski-distillery/pkg/timex"
"github.com/tkw1536/pkglib/timex"
)
//

View file

@ -5,8 +5,8 @@ import (
"errors"
"github.com/FAU-CDI/wisski-distillery/internal/models"
"github.com/FAU-CDI/wisski-distillery/pkg/errorx"
"github.com/FAU-CDI/wisski-distillery/pkg/sqle"
"github.com/tkw1536/pkglib/errorx"
"github.com/tkw1536/pkglib/sqlx"
)
var errProvisionInvalidDatabaseParams = errors.New("Provision: Invalid parameters")
@ -36,7 +36,7 @@ func (sql *SQL) CreateDatabase(ctx context.Context, name, user, password string)
// Apparently it's a "feature", see https://github.com/go-sql-driver/mysql/issues/398#issuecomment-169951763.
// quick and dirty check to make sure that all the names won't sql inject.
if !sqle.IsSafeDatabaseLiteral(name) || !sqle.IsSafeDatabaseSingleQuote(user) || !sqle.IsSafeDatabaseSingleQuote(password) {
if !sqlx.IsSafeDatabaseLiteral(name) || !sqlx.IsSafeDatabaseSingleQuote(user) || !sqlx.IsSafeDatabaseSingleQuote(password) {
return errProvisionInvalidDatabaseParams
}
@ -71,7 +71,7 @@ func (sql *SQL) CreateSuperuser(ctx context.Context, user, password string, allo
// (2) The underlying driver doesn't support "GRANT ALL PRIVILEGES"
// See also [sql.Provision].
if !sqle.IsSafeDatabaseSingleQuote(user) || !sqle.IsSafeDatabaseSingleQuote(password) {
if !sqlx.IsSafeDatabaseSingleQuote(user) || !sqlx.IsSafeDatabaseSingleQuote(password) {
return errProvisionInvalidDatabaseParams
}
@ -97,7 +97,7 @@ var errPurgeUser = errors.New("PurgeUser: Failed to drop user")
// SQLPurgeUser deletes the specified user from the database
func (sql *SQL) PurgeUser(ctx context.Context, user string) error {
if !sqle.IsSafeDatabaseSingleQuote(user) {
if !sqlx.IsSafeDatabaseSingleQuote(user) {
return errPurgeUser
}
@ -114,7 +114,7 @@ var errSQLPurgeDB = errors.New("unable to drop database: unsafe database name")
// SQLPurgeDatabase deletes the specified db from the database
func (sql *SQL) PurgeDatabase(db string) error {
if !sqle.IsSafeDatabaseLiteral(db) {
if !sqlx.IsSafeDatabaseLiteral(db) {
return errSQLPurgeDB
}
return sql.Exec("DROP DATABASE IF EXISTS `" + db + "`")

View file

@ -3,7 +3,7 @@ package sql
import (
"github.com/FAU-CDI/wisski-distillery/internal/dis/component"
"github.com/FAU-CDI/wisski-distillery/internal/models"
"github.com/tkw1536/goprogram/lib/reflectx"
"github.com/tkw1536/pkglib/reflectx"
)
// This file defines additional tables used by multiple components

View file

@ -9,10 +9,10 @@ import (
"time"
"github.com/FAU-CDI/wisski-distillery/pkg/logging"
"github.com/FAU-CDI/wisski-distillery/pkg/sqle"
"github.com/FAU-CDI/wisski-distillery/pkg/timex"
"github.com/tkw1536/goprogram/exit"
"github.com/tkw1536/goprogram/stream"
"github.com/tkw1536/pkglib/sqlx"
"github.com/tkw1536/pkglib/timex"
)
// Shell runs a mysql shell with the provided databases.
@ -65,7 +65,7 @@ func (sql *SQL) Update(ctx context.Context, progress io.Writer) error {
// create the admin user
logging.LogMessage(progress, ctx, "Creating sql database")
{
if !sqle.IsSafeDatabaseLiteral(sql.Config.SQL.Database) {
if !sqlx.IsSafeDatabaseLiteral(sql.Config.SQL.Database) {
return errSQLUnsafeDatabaseName
}
createDBSQL := fmt.Sprintf("CREATE DATABASE IF NOT EXISTS `%s`;", sql.Config.SQL.Database)

View file

@ -6,7 +6,7 @@ import (
"github.com/FAU-CDI/wisski-distillery/internal/dis/component"
"github.com/FAU-CDI/wisski-distillery/internal/models"
"github.com/gliderlabs/ssh"
"github.com/tkw1536/goprogram/lib/reflectx"
"github.com/tkw1536/pkglib/reflectx"
)
func (ssh2 *SSHKeys) TableInfo() component.TableInfo {

View file

@ -12,10 +12,10 @@ import (
"github.com/FAU-CDI/wisski-distillery/pkg/environment"
"github.com/FAU-CDI/wisski-distillery/pkg/fsx"
"github.com/FAU-CDI/wisski-distillery/pkg/logging"
"github.com/FAU-CDI/wisski-distillery/pkg/pools"
"github.com/FAU-CDI/wisski-distillery/pkg/unpack"
"github.com/pkg/errors"
"github.com/tkw1536/goprogram/stream"
"github.com/tkw1536/pkglib/pools"
)
// Stack represents a 'docker compose' stack living in a specific directory

View file

@ -9,10 +9,10 @@ import (
"net/http"
"time"
"github.com/FAU-CDI/wisski-distillery/pkg/pools"
"github.com/FAU-CDI/wisski-distillery/pkg/timex"
"github.com/pkg/errors"
"github.com/rs/zerolog"
"github.com/tkw1536/pkglib/pools"
"github.com/tkw1536/pkglib/timex"
)
type TriplestoreUserPayload struct {

View file

@ -8,10 +8,10 @@ import (
_ "embed"
"github.com/FAU-CDI/wisski-distillery/internal/models"
"github.com/FAU-CDI/wisski-distillery/pkg/errorx"
"github.com/FAU-CDI/wisski-distillery/pkg/pools"
"github.com/FAU-CDI/wisski-distillery/pkg/unpack"
"github.com/tkw1536/goprogram/exit"
"github.com/tkw1536/pkglib/errorx"
"github.com/tkw1536/pkglib/pools"
)
var errTripleStoreFailedRepository = exit.Error{