mirror of
https://git.vectorsigma.ru/public/k3s.git
synced 2026-07-29 07:09:28 +00:00
Move request handlers out of server package
The servers package, and router.go in particular, had become quite large. Address this by moving some things out to separate packages: * http request handlers all move to pkg/server/handlers. * node password bootstrap auth handler goes into pkg/nodepassword with the other nodepassword code. While we're at it, also be more consistent about calling variables that hold a config.Control struct or reference `control` instead of `config` or `server`. Signed-off-by: Brad Davidson <brad.davidson@rancher.com>
This commit is contained in:
committed by
Brad Davidson
parent
17feb8bed1
commit
2e4e7cf2c1
@@ -15,6 +15,7 @@ import (
|
||||
"github.com/k3s-io/k3s/pkg/proctitle"
|
||||
"github.com/k3s-io/k3s/pkg/secretsencrypt"
|
||||
"github.com/k3s-io/k3s/pkg/server"
|
||||
"github.com/k3s-io/k3s/pkg/server/handlers"
|
||||
"github.com/k3s-io/k3s/pkg/version"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/urfave/cli"
|
||||
@@ -54,7 +55,7 @@ func Enable(app *cli.Context) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
b, err := json.Marshal(server.EncryptionRequest{Enable: ptr.To(true)})
|
||||
b, err := json.Marshal(handlers.EncryptionRequest{Enable: ptr.To(true)})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -73,7 +74,7 @@ func Disable(app *cli.Context) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
b, err := json.Marshal(server.EncryptionRequest{Enable: ptr.To(false)})
|
||||
b, err := json.Marshal(handlers.EncryptionRequest{Enable: ptr.To(false)})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -96,7 +97,7 @@ func Status(app *cli.Context) error {
|
||||
if err != nil {
|
||||
return wrapServerError(err)
|
||||
}
|
||||
status := server.EncryptionState{}
|
||||
status := handlers.EncryptionState{}
|
||||
if err := json.Unmarshal(data, &status); err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -153,7 +154,7 @@ func Prepare(app *cli.Context) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
b, err := json.Marshal(server.EncryptionRequest{
|
||||
b, err := json.Marshal(handlers.EncryptionRequest{
|
||||
Stage: ptr.To(secretsencrypt.EncryptionPrepare),
|
||||
Force: cmds.ServerConfig.EncryptForce,
|
||||
})
|
||||
@@ -175,7 +176,7 @@ func Rotate(app *cli.Context) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
b, err := json.Marshal(server.EncryptionRequest{
|
||||
b, err := json.Marshal(handlers.EncryptionRequest{
|
||||
Stage: ptr.To(secretsencrypt.EncryptionRotate),
|
||||
Force: cmds.ServerConfig.EncryptForce,
|
||||
})
|
||||
@@ -197,7 +198,7 @@ func Reencrypt(app *cli.Context) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
b, err := json.Marshal(server.EncryptionRequest{
|
||||
b, err := json.Marshal(handlers.EncryptionRequest{
|
||||
Stage: ptr.To(secretsencrypt.EncryptionReencryptActive),
|
||||
Force: cmds.ServerConfig.EncryptForce,
|
||||
Skip: cmds.ServerConfig.EncryptSkip,
|
||||
@@ -220,7 +221,7 @@ func RotateKeys(app *cli.Context) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
b, err := json.Marshal(server.EncryptionRequest{
|
||||
b, err := json.Marshal(handlers.EncryptionRequest{
|
||||
Stage: ptr.To(secretsencrypt.EncryptionRotateKeys),
|
||||
})
|
||||
if err != nil {
|
||||
|
||||
@@ -16,6 +16,7 @@ import (
|
||||
"github.com/k3s-io/k3s/pkg/kubeadm"
|
||||
"github.com/k3s-io/k3s/pkg/proctitle"
|
||||
"github.com/k3s-io/k3s/pkg/server"
|
||||
"github.com/k3s-io/k3s/pkg/server/handlers"
|
||||
"github.com/k3s-io/k3s/pkg/util"
|
||||
"github.com/k3s-io/k3s/pkg/version"
|
||||
"github.com/pkg/errors"
|
||||
@@ -153,7 +154,7 @@ func Rotate(app *cli.Context) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
b, err := json.Marshal(server.TokenRotateRequest{
|
||||
b, err := json.Marshal(handlers.TokenRotateRequest{
|
||||
NewToken: ptr.To(cmds.TokenConfig.NewToken),
|
||||
})
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user