-
Notifications
You must be signed in to change notification settings - Fork 904
feat: remove server subcommand from slim binaries #5747
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
c64afee
e7209fe
0aca8f7
02f257e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
//go:build slim | ||
|
||
package buildinfo | ||
|
||
func init() { | ||
slim = true | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
//go:build slim | ||
|
||
package cli | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
"io" | ||
"os" | ||
|
||
"github.com/spf13/cobra" | ||
"github.com/spf13/viper" | ||
|
||
"github.com/coder/coder/cli/cliui" | ||
"github.com/coder/coder/cli/deployment" | ||
"github.com/coder/coder/coderd" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Importing There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sadly also There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah, didn't think of that. Yes makes sense 👍🏻. |
||
) | ||
|
||
func Server(vip *viper.Viper, _ func(context.Context, *coderd.Options) (*coderd.API, io.Closer, error)) *cobra.Command { | ||
root := &cobra.Command{ | ||
Use: "server", | ||
Short: "Start a Coder server", | ||
Hidden: true, | ||
RunE: func(cmd *cobra.Command, args []string) error { | ||
serverUnsupported(cmd.ErrOrStderr()) | ||
return nil | ||
}, | ||
} | ||
|
||
var pgRawURL bool | ||
postgresBuiltinURLCmd := &cobra.Command{ | ||
Use: "postgres-builtin-url", | ||
Short: "Output the connection URL for the built-in PostgreSQL deployment.", | ||
Hidden: true, | ||
RunE: func(cmd *cobra.Command, _ []string) error { | ||
serverUnsupported(cmd.ErrOrStderr()) | ||
return nil | ||
}, | ||
} | ||
postgresBuiltinServeCmd := &cobra.Command{ | ||
Use: "postgres-builtin-serve", | ||
Short: "Run the built-in PostgreSQL deployment.", | ||
Hidden: true, | ||
RunE: func(cmd *cobra.Command, args []string) error { | ||
serverUnsupported(cmd.ErrOrStderr()) | ||
return nil | ||
}, | ||
} | ||
|
||
// We still have to attach the flags to the commands so users don't get | ||
// an error when they try to use them. | ||
postgresBuiltinURLCmd.Flags().BoolVar(&pgRawURL, "raw-url", false, "Output the raw connection URL instead of a psql command.") | ||
postgresBuiltinServeCmd.Flags().BoolVar(&pgRawURL, "raw-url", false, "Output the raw connection URL instead of a psql command.") | ||
|
||
root.AddCommand(postgresBuiltinURLCmd, postgresBuiltinServeCmd) | ||
|
||
deployment.AttachFlags(root.Flags(), vip, false) | ||
|
||
return root | ||
} | ||
|
||
func serverUnsupported(w io.Writer) { | ||
_, _ = fmt.Fprintf(w, "You are using a 'slim' build of Coder, which does not support the %s subcommand.\n", cliui.Styles.Code.Render("server")) | ||
_, _ = fmt.Fprintln(w, "") | ||
_, _ = fmt.Fprintln(w, "Please use a build of Coder from GitHub releases:") | ||
_, _ = fmt.Fprintln(w, " https://github.com/coder/coder/releases") | ||
os.Exit(1) | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
//go:build !slim | ||
|
||
package cli | ||
|
||
import ( | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
//go:build slim | ||
|
||
package cli | ||
|
||
import ( | ||
"context" | ||
"io" | ||
|
||
"github.com/spf13/cobra" | ||
"golang.org/x/xerrors" | ||
|
||
"github.com/coder/coder/cli/deployment" | ||
|
||
agpl "github.com/coder/coder/cli" | ||
agplcoderd "github.com/coder/coder/coderd" | ||
) | ||
|
||
func server() *cobra.Command { | ||
vip := deployment.NewViper() | ||
cmd := agpl.Server(vip, func(ctx context.Context, options *agplcoderd.Options) (*agplcoderd.API, io.Closer, error) { | ||
return nil, nil, xerrors.Errorf("slim build does not support `coder server`") | ||
}) | ||
|
||
deployment.AttachFlags(cmd.Flags(), vip, true) | ||
|
||
return cmd | ||
} |
Uh oh!
There was an error while loading. Please reload this page.