cmd

package
v0.2.5 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2023 License: BSD-3-Clause Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var API = &cobra.Command{
	Use:   "api",
	Short: "Start API service",
	RunE: func(cmd *cobra.Command, args []string) (err error) {
		ctx := cmd.Context()
		values := ctx.Value("values").(*common.Values)
		if values.Address == "" {
			values.Address = ":3000"
		}

		var x *api.API
		if x, err = bootstrap.NewAPI(values); err != nil {
			return
		}
		var h *server.Hertz
		if h, err = x.Initialize(ctx); err != nil {
			return
		}
		if err = x.Routes(h); err != nil {
			return
		}

		defer bootstrap.ProviderOpenTelemetry(values).
			Shutdown(ctx)
		h.Spin()
		return
	},
}
View Source
var OpenAPI = &cobra.Command{
	Use:   "openapi",
	Short: "Start Open API service",
	RunE: func(cmd *cobra.Command, args []string) (err error) {
		ctx := cmd.Context()
		values := ctx.Value("values").(*common.Values)
		if values.Address == "" {
			values.Address = ":9000"
		}

		var x *openapi.API
		if x, err = bootstrap.NewOpenAPI(values); err != nil {
			return
		}
		var h *server.Hertz
		if h, err = x.Initialize(ctx); err != nil {
			return
		}
		if err = x.Routes(h); err != nil {
			return
		}
		h.Spin()
		return
	},
}
View Source
var Setup = &cobra.Command{
	Use:   "setup",
	Short: "Setup weplanx dynamic configuration",
	RunE: func(cmd *cobra.Command, args []string) (err error) {
		ctx := cmd.Context()
		values := ctx.Value("values").(*common.Values)

		var x *api.API
		if x, err = bootstrap.NewAPI(values); err != nil {
			return
		}
		if err = x.Values.Service.Update(x.V.Extra); err != nil {
			return
		}
		return
	},
}
View Source
var Sync = &cobra.Command{
	Use:   "sync",
	Short: "Sync weplanx models",
	RunE: func(cmd *cobra.Command, args []string) (err error) {
		ctx := cmd.Context()
		values := ctx.Value("values").(*common.Values)

		var x *api.API
		if x, err = bootstrap.NewAPI(values); err != nil {
			return
		}
		if err = model.SetProjects(ctx, x.Db); err != nil {
			return
		}
		if err = model.SetUsers(ctx, x.Db); err != nil {
			return
		}
		if err = model.SetClusters(ctx, x.Db); err != nil {
			return
		}
		if err = model.SetEndpoints(ctx, x.Db); err != nil {
			return
		}
		if err = model.SetWorkflows(ctx, x.Db); err != nil {
			return
		}
		if err = model.SetQueues(ctx, x.Db); err != nil {
			return
		}
		if err = model.SetImessages(ctx, x.Db); err != nil {
			return
		}
		if err = model.SetAccTasks(ctx, x.Db); err != nil {
			return
		}
		if err = model.SetCategories(ctx, x.Db); err != nil {
			return
		}
		if err = model.SetPictures(ctx, x.Db); err != nil {
			return
		}
		if err = model.SetVideos(ctx, x.Db); err != nil {
			return
		}
		if err = model.SetLogsetLogins(ctx, x.Db); err != nil {
			return
		}
		if err = model.SetLogsetJobs(ctx, x.Db); err != nil {
			return
		}
		if err = model.SetLogsetOperates(ctx, x.Db); err != nil {
			return
		}
		if err = model.SetLogsetImessages(ctx, x.Db); err != nil {
			return
		}
		return
	},
}
View Source
var Values = &cobra.Command{
	Use:   "values",
	Short: "Display the dynamic values of server distribution Kv",
	RunE: func(cmd *cobra.Command, args []string) (err error) {
		ctx := cmd.Context()
		values := ctx.Value("values").(*common.Values)

		var x *api.API
		if x, err = bootstrap.NewAPI(values); err != nil {
			return
		}
		if _, err = x.Initialize(ctx); err != nil {
			return
		}
		time.Sleep(time.Second)
		var output []byte
		if output, err = json.MarshalIndent(x.V, "", "    "); err != nil {
			return
		}
		fmt.Println(string(output))
		return
	},
}
View Source
var XAPI = &cobra.Command{
	Use:   "xapi",
	Short: "Start Internal API service",
	RunE: func(cmd *cobra.Command, args []string) (err error) {
		ctx := cmd.Context()
		values := ctx.Value("values").(*common.Values)
		if values.Address == "" {
			values.Address = ":6000"
		}

		var x *xapi.API
		if x, err = bootstrap.NewXAPI(values); err != nil {
			return
		}
		var h *server.Hertz
		if h, err = x.Initialize(ctx); err != nil {
			return
		}
		if err = x.Routes(h); err != nil {
			return
		}
		h.Spin()
		return
	},
}

Functions

func User

func User() *cobra.Command

Types

This section is empty.

Jump to

Keyboard shortcuts

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