forked from openshift/origin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
create_provider_selection_template.go
64 lines (49 loc) · 1.77 KB
/
create_provider_selection_template.go
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
package admin
import (
"errors"
"io"
"github.com/spf13/cobra"
cmdutil "k8s.io/kubernetes/pkg/kubectl/cmd/util"
"github.com/openshift/origin/pkg/auth/server/selectprovider"
"github.com/openshift/origin/pkg/cmd/util/clientcmd"
)
const (
CreateProviderSelectionTemplateCommand = "create-provider-selection-template"
providerSelectionLongDescription = `
Create a template for customizing the provider selection page
This command creates a basic template to use as a starting point for
customizing the login provider selection 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.providerSelection in the master
configuration to point to the template file. For example,
oauthConfig:
templates:
providerSelection: templates/provider-selection.html
`
)
type CreateProviderSelectionTemplateOptions struct{}
func NewCommandCreateProviderSelectionTemplate(f *clientcmd.Factory, commandName string, fullName string, out io.Writer) *cobra.Command {
options := &CreateProviderSelectionTemplateOptions{}
cmd := &cobra.Command{
Use: commandName,
Short: "Create a provider selection template",
Long: providerSelectionLongDescription,
Run: func(cmd *cobra.Command, args []string) {
if err := options.Validate(args); err != nil {
cmdutil.CheckErr(cmdutil.UsageError(cmd, err.Error()))
}
_, err := io.WriteString(out, selectprovider.SelectProviderTemplateExample)
if err != nil {
cmdutil.CheckErr(err)
}
},
}
return cmd
}
func (o CreateProviderSelectionTemplateOptions) Validate(args []string) error {
if len(args) != 0 {
return errors.New("no arguments are supported")
}
return nil
}