K8s: Move standalone apiserver CLI to enterprise (#93799)

This commit is contained in:
Ryan McKinley
2024-09-27 09:04:35 +03:00
committed by GitHub
parent e672796632
commit 87c81825b7
24 changed files with 63 additions and 924 deletions

View File

@ -21,38 +21,29 @@ import (
"github.com/grafana/grafana/pkg/infra/metrics"
"github.com/grafana/grafana/pkg/infra/process"
"github.com/grafana/grafana/pkg/server"
"github.com/grafana/grafana/pkg/services/apiserver/standalone"
"github.com/grafana/grafana/pkg/setting"
)
type ServerOptions struct {
Version string
Commit string
EnterpriseCommit string
BuildBranch string
BuildStamp string
Context *cli.Context
}
func ServerCommand(version, commit, enterpriseCommit, buildBranch, buildstamp string) *cli.Command {
return &cli.Command{
Name: "server",
Usage: "run the grafana server",
Flags: commonFlags,
Action: func(context *cli.Context) error {
return RunServer(ServerOptions{
return RunServer(standalone.BuildInfo{
Version: version,
Commit: commit,
EnterpriseCommit: enterpriseCommit,
BuildBranch: buildBranch,
BuildStamp: buildstamp,
Context: context,
})
}, context)
},
Subcommands: []*cli.Command{TargetCommand(version, commit, buildBranch, buildstamp)},
}
}
func RunServer(opts ServerOptions) error {
func RunServer(opts standalone.BuildInfo, cli *cli.Context) error {
if Version || VerboseVersion {
if opts.EnterpriseCommit != gcli.DefaultCommitValue && opts.EnterpriseCommit != "" {
fmt.Printf("Version %s (commit: %s, branch: %s, enterprise-commit: %s)\n", opts.Version, opts.Commit, opts.BuildBranch, opts.EnterpriseCommit)
@ -106,7 +97,7 @@ func RunServer(opts ServerOptions) error {
Config: ConfigFile,
HomePath: HomePath,
// tailing arguments have precedence over the options string
Args: append(configOptions, opts.Context.Args().Slice()...),
Args: append(configOptions, cli.Args().Slice()...),
})
if err != nil {
return err