apiserver

package
v0.1.41 Latest Latest
Warning

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

Go to latest
Published: Jun 16, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package apiserver provides the command for the apiserver.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewCommand

func NewCommand(opt CommandOption) *cobra.Command

NewCommand creates a new apiserver command.

Types

type CommandOption

type CommandOption struct {

	// flags
	Address  string `mapstructure:"address"`
	ServerID string `mapstructure:"serverId"`
	Database struct {
		Type           string        `mapstructure:"type"`
		Endpoints      []string      `mapstructure:"endpoints"`
		ConnectTimeout time.Duration `mapstructure:"connectTimeout"`
		DatabaseName   string        `mapstructure:"databaseName"`
		DDLAuto        bool          `mapstructure:"ddlAuto"`
	} `mapstructure:"database"`
	ServiceName string `mapstructure:"serviceName"`
	Event       struct {
		Type  string `mapstructure:"type"`
		Kafka struct {
			Brokers []string `mapstructure:"brokers"`
			Topic   string   `mapstructure:"topic"`
		}
	} `mapstructure:"event"`
	Management struct {
		Address string `mapstructure:"address"`
		Metric  struct {
			Enabled    bool   `mapstructure:"enabled"`
			Type       string `mapstructure:"type"`
			Prometheus struct {
				Path string `mapstructure:"path"`
			} `mapstructure:"prometheus"`
			OpenTelemetry struct {
				Endpoint string `mapstructure:"endpoint"`
			} `mapstructure:"openTelemetry"`
		}
		Log struct {
			Enabled bool   `mapstructure:"enabled"`
			Level   string `mapstructure:"level"`
			Format  string `mapstructure:"format"`
		} `mapstructure:"log"`
		Trace struct {
			Enabled              bool              `mapstructure:"enabled"`
			Protocol             string            `mapstructure:"protocol"`
			Compression          bool              `mapstructure:"compression"`
			CompressionAlgorithm string            `mapstructure:"compressionAlgorithm"`
			Insecure             bool              `mapstructure:"insecure"`
			Headers              map[string]string `mapstructure:"headers"`
			Endpoint             string            `mapstructure:"endpoint"`
			Sampler              string            `mapstructure:"sampler"`
			SamplerRatio         float64           `mapstructure:"samplerRatio"`
		} `mapstructure:"trace"`
	} `mapstructure:"management"`
	Auth struct {
		Enabled bool `mapstructure:"enabled"`
		Admin   struct {
			Username string `mapstructure:"username"`
			Password string `mapstructure:"password"`
			Email    string `mapstructure:"email"`
		} `mapstructure:"admin"`
		Basic struct {
			Pepper string `mapstructure:"pepper"`
		} `mapstructure:"basic"`
		JWT struct {
			Issuer        string        `mapstructure:"issuer"`
			Expire        time.Duration `mapstructure:"expire"`
			RefreshExpire time.Duration `mapstructure:"refreshExpire"`
			Secret        string        `mapstructure:"secret"`
			Audience      []string      `mapstructure:"audience"`
		}
		Type   string `mapstructure:"type"`
		OAuth2 struct {
			Provider             string   `mapstructure:"provider"`
			ClientID             string   `mapstructure:"clientId"`
			ClientSecret         string   `mapstructure:"clientSecret"`
			RedirectURI          string   `mapstructure:"redirectUri"`
			AllowedRedirectHosts []string `mapstructure:"allowedRedirectHosts"`
			State                struct {
				Mode string `mapstructure:"mode"`
				JWT  struct {
					Issuer   string        `mapstructure:"issuer"`
					Expire   time.Duration `mapstructure:"expire"`
					Secret   string        `mapstructure:"secret"`
					Audience []string      `mapstructure:"audience"`
				} `mapstructure:"jwt"`
			} `mapstructure:"state"`
		} `mapstructure:"oauth2"`
	} `mapstructure:"auth"`
	Bootstrap struct {
		Dir              string `mapstructure:"dir"`
		DefaultNamespace string `mapstructure:"defaultNamespace"`
		DefaultRole      string `mapstructure:"defaultRole"`
	} `mapstructure:"bootstrap"`
	// contains filtered or unexported fields
}

CommandOption contains the options for the apiserver command.

func (*CommandOption) Init added in v0.1.0

func (opt *CommandOption) Init(cmd *cobra.Command, _ []string) error

Init initializes the command options.

func (*CommandOption) Prepare

func (opt *CommandOption) Prepare(_ *cobra.Command, _ []string) error

Prepare prepares the command.

func (*CommandOption) Run

func (opt *CommandOption) Run(cmd *cobra.Command, _ []string) error

Run runs the command.

Jump to

Keyboard shortcuts

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