-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Expand file tree
/
Copy pathcreate_login_template.go
More file actions
70 lines (54 loc) · 1.83 KB
/
create_login_template.go
File metadata and controls
70 lines (54 loc) · 1.83 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
package createlogintemplate
import (
"errors"
"io"
"github.com/spf13/cobra"
"k8s.io/cli-runtime/pkg/genericclioptions"
kcmdutil "k8s.io/kubernetes/pkg/kubectl/cmd/util"
"k8s.io/kubernetes/pkg/kubectl/util/templates"
"github.com/openshift/origin/pkg/oauthserver/server/login"
)
const CreateLoginTemplateCommand = "create-login-template"
var longDescription = templates.LongDesc(`
Create a template for customizing the login page
This command creates a basic template to use as a starting point for
customizing the login page. Save the output to a file and edit the template to
change the look and feel or add content. Be careful not to remove any parameter
values inside curly braces.
To use the template, set oauthConfig.templates.login in the master
configuration to point to the template file. For example,
oauthConfig:
templates:
login: templates/login.html
`)
type CreateLoginTemplateOptions struct {
genericclioptions.IOStreams
}
func NewCreateLoginTemplateOptions(streams genericclioptions.IOStreams) *CreateLoginTemplateOptions {
return &CreateLoginTemplateOptions{
IOStreams: streams,
}
}
func NewCommandCreateLoginTemplate(f kcmdutil.Factory, commandName string, fullName string, streams genericclioptions.IOStreams) *cobra.Command {
o := NewCreateLoginTemplateOptions(streams)
cmd := &cobra.Command{
Use: commandName,
Short: "Create a login template",
Long: longDescription,
Run: func(cmd *cobra.Command, args []string) {
kcmdutil.CheckErr(o.Validate(args))
kcmdutil.CheckErr(o.Run())
},
}
return cmd
}
func (o CreateLoginTemplateOptions) Validate(args []string) error {
if len(args) != 0 {
return errors.New("no arguments are supported")
}
return nil
}
func (o *CreateLoginTemplateOptions) Run() error {
_, err := io.WriteString(o.Out, login.LoginTemplateExample)
return err
}