cmd

package
v0.1.37 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 3, 2024 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Migrate = &cobra.Command{
	Use:   "migrate",
	Short: "Migrate the database",
	RunE: func(cmd *cobra.Command, args []string) error {
		conn, err := gorm.Open(postgres.Open(cfg.Flags.DatabaseURI), &gorm.Config{
			NamingStrategy: schema.NamingStrategy{
				TablePrefix: cfg.Flags.DatabaseTablePrefix,
			},
		})
		if err != nil {
			return err
		}

		db, err := db.NewDB(conn)
		if err != nil {
			return err
		}

		err = db.Migrate(cmd.Context())
		if err != nil {
			return err
		}

		return nil
	},
}
View Source
var Root = &cobra.Command{
	PersistentPreRunE: func(cmd *cobra.Command, args []string) error {
		err := envconfig.Process("", cfg.Flags)
		if err != nil {
			return err
		}

		return nil
	},
	RunE: func(cmd *cobra.Command, args []string) error {
		srv := NewWebSrv(cfg)

		s, _ := server.WithContext(cmd.Context())
		s.Listen(srv, false)

		return s.Wait()
	},
}

Functions

This section is empty.

Types

type Config

type Config struct {
	Flags *Flags
}

Config ...

func New

func New() *Config

New ...

func (*Config) Cwd

func (c *Config) Cwd() (string, error)

Cwd returns the current working directory.

type DB

type DB struct {
	Addr     string
	Database string
	Password string
	Port     int
	Username string
	Prefix   string
}

DB ...

type Flags

type Flags struct {
	Addr                    string `envconfig:"TYPHOON_WEB_ADDR" default:":3000"`
	DatabaseURI             string `envconfig:"TYPHOON_WEB_DATABASE_URI" default:""`
	DatabaseTablePrefix     string `envconfig:"TYPHOON_WEB_DATABASE_TABLE_PREFIX" default:"typhoon_"`
	FGAApiUrl               string `envconfig:"TYPHOON_WEB_FGA_API_URL" default:"http://host.docker.internal:8080"`
	FGAStoreID              string `envconfig:"TYPHOON_WEB_FGA_STORE_ID" default:""`
	FGAAuthorizationModelID string `envconfig:"TYPHOON_WEB_FGA_AUTHORIZATION_MODEL_ID" default:""`
	GothGitbubKey           string `envconfig:"TYPHOON_WEB_GITHUB_CLIENT_ID" default:""`
	GothGithubSecret        string `envconfig:"TYPHOON_WEB_GITHUB_SECRET" default:""`
	GothGithubCallback      string `envconfig:"TYPHOON_WEB_GITHUB_CALLBACK" default:"http://localhost:3000/auth/github/callback"`
}

Flags contains the command line flags.

func NewFlags

func NewFlags() *Flags

NewFlags ...

type WebSrv

type WebSrv struct {
	// contains filtered or unexported fields
}

WebSrv is the server that implements the Noop interface.

func NewWebSrv

func NewWebSrv(cfg *Config) *WebSrv

NewWebSrv returns a new instance of NoopSrv.

func (*WebSrv) Start

func (s *WebSrv) Start(ctx context.Context, ready server.ReadyFunc, run server.RunFunc) func() error

Start starts the server.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL