Skip to content

Commit d73941c

Browse files
author
OpenShift Bot
committed
Merge pull request #2835 from smarterclayton/remove_unnecessary_prints
Merged by openshift-bot
2 parents 1b97fff + 7b23556 commit d73941c

18 files changed

+55
-85
lines changed

pkg/cmd/cli/cmd/request_project.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@ func NewCmdRequestProject(name, fullName, oscLoginName, oscProjectName string, f
6767
}
6868
},
6969
}
70-
cmd.SetOutput(out)
7170

7271
cmd.Flags().StringVar(&options.DisplayName, "display-name", "", "Project display name")
7372
cmd.Flags().StringVar(&options.Description, "description", "", "Project description")

pkg/cmd/server/admin/create_bootstrap_project_template.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ func NewCommandCreateBootstrapProjectTemplate(f *clientcmd.Factory, commandName
4141
}
4242
},
4343
}
44-
cmd.SetOutput(out)
4544

4645
cmd.Flags().StringVar(&options.Name, "name", delegated.DefaultTemplateName, "The name of the template to output.")
4746
cmdutil.AddPrinterFlags(cmd)

pkg/cmd/server/admin/create_bootstrappolicy_file.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ func NewCommandCreateBootstrapPolicyFile(commandName string, fullName string, ou
4747
}
4848
},
4949
}
50-
cmd.SetOutput(out)
5150

5251
flags := cmd.Flags()
5352

pkg/cmd/server/admin/create_client.go

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import (
1212
kcmdutil "github.com/GoogleCloudPlatform/kubernetes/pkg/kubectl/cmd/util"
1313

1414
"github.com/GoogleCloudPlatform/kubernetes/pkg/util"
15-
cmdutil "github.com/openshift/origin/pkg/cmd/util"
1615
)
1716

1817
const CreateClientCommandName = "create-api-client-config"
@@ -28,7 +27,7 @@ type CreateClientOptions struct {
2827
APIServerCAFile string
2928
APIServerURL string
3029
PublicAPIServerURL string
31-
Output cmdutil.Output
30+
Output io.Writer
3231
}
3332

3433
const createClientLong = `
@@ -40,7 +39,7 @@ master as the provided user.
4039
`
4140

4241
func NewCommandCreateClient(commandName string, fullName string, out io.Writer) *cobra.Command {
43-
options := &CreateClientOptions{GetSignerCertOptions: &GetSignerCertOptions{}, Output: cmdutil.Output{out}}
42+
options := &CreateClientOptions{GetSignerCertOptions: &GetSignerCertOptions{}, Output: out}
4443

4544
cmd := &cobra.Command{
4645
Use: commandName,
@@ -56,7 +55,6 @@ func NewCommandCreateClient(commandName string, fullName string, out io.Writer)
5655
}
5756
},
5857
}
59-
cmd.SetOutput(out)
6058

6159
flags := cmd.Flags()
6260

@@ -102,7 +100,7 @@ func (o CreateClientOptions) Validate(args []string) error {
102100
}
103101

104102
func (o CreateClientOptions) CreateClientFolder() error {
105-
glog.V(2).Infof("creating a .kubeconfig with: %#v", o)
103+
glog.V(4).Infof("creating a .kubeconfig with: %#v", o)
106104

107105
clientCertFile := DefaultCertFilename(o.ClientDir, o.User)
108106
clientKeyFile := DefaultKeyFilename(o.ClientDir, o.User)

pkg/cmd/server/admin/create_clientcert.go

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,14 @@ package admin
22

33
import (
44
"errors"
5-
"fmt"
5+
"io"
66

77
"github.com/golang/glog"
88

99
"github.com/GoogleCloudPlatform/kubernetes/pkg/auth/user"
1010
"github.com/GoogleCloudPlatform/kubernetes/pkg/util"
1111

1212
"github.com/openshift/origin/pkg/cmd/server/crypto"
13-
cmdutil "github.com/openshift/origin/pkg/cmd/util"
1413
)
1514

1615
type CreateClientCertOptions struct {
@@ -23,7 +22,7 @@ type CreateClientCertOptions struct {
2322
Groups util.StringList
2423

2524
Overwrite bool
26-
Output cmdutil.Output
25+
Output io.Writer
2726
}
2827

2928
func (o CreateClientCertOptions) Validate(args []string) error {
@@ -51,7 +50,7 @@ func (o CreateClientCertOptions) Validate(args []string) error {
5150
}
5251

5352
func (o CreateClientCertOptions) CreateClientCert() (*crypto.TLSCertificateConfig, error) {
54-
glog.V(2).Infof("Creating a client cert with: %#v and %#v", o, o.GetSignerCertOptions)
53+
glog.V(4).Infof("Creating a client cert with: %#v and %#v", o, o.GetSignerCertOptions)
5554

5655
signerCert, err := o.GetSignerCertOptions.GetSignerCert()
5756
if err != nil {
@@ -67,9 +66,9 @@ func (o CreateClientCertOptions) CreateClientCert() (*crypto.TLSCertificateConfi
6766
cert, written, err = signerCert.EnsureClientCertificate(o.CertFile, o.KeyFile, userInfo)
6867
}
6968
if written {
70-
fmt.Fprintf(o.Output.Get(), "Generated new client cert as %s and key as %s\n", o.CertFile, o.KeyFile)
69+
glog.V(3).Infof("Generated new client cert as %s and key as %s\n", o.CertFile, o.KeyFile)
7170
} else {
72-
fmt.Fprintf(o.Output.Get(), "Keeping existing client cert at %s and key at %s\n", o.CertFile, o.KeyFile)
71+
glog.V(3).Infof("Keeping existing client cert at %s and key at %s\n", o.CertFile, o.KeyFile)
7372
}
7473
return cert, err
7574
}

pkg/cmd/server/admin/create_keypair.go

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ import (
1717
"github.com/spf13/cobra"
1818

1919
kcmdutil "github.com/GoogleCloudPlatform/kubernetes/pkg/kubectl/cmd/util"
20-
cmdutil "github.com/openshift/origin/pkg/cmd/util"
2120
)
2221

2322
const CreateKeyPairCommandName = "create-key-pair"
@@ -27,7 +26,7 @@ type CreateKeyPairOptions struct {
2726
PrivateKeyFile string
2827

2928
Overwrite bool
30-
Output cmdutil.Output
29+
Output io.Writer
3130
}
3231

3332
const create_key_pair_long = `
@@ -40,7 +39,7 @@ Example: Creating service account signing and authenticating key files:
4039
`
4140

4241
func NewCommandCreateKeyPair(commandName string, fullName string, out io.Writer) *cobra.Command {
43-
options := &CreateKeyPairOptions{Output: cmdutil.Output{out}}
42+
options := &CreateKeyPairOptions{Output: out}
4443

4544
cmd := &cobra.Command{
4645
Use: commandName,
@@ -55,7 +54,6 @@ func NewCommandCreateKeyPair(commandName string, fullName string, out io.Writer)
5554
kcmdutil.CheckErr(err)
5655
},
5756
}
58-
cmd.SetOutput(out)
5957

6058
flags := cmd.Flags()
6159

@@ -85,15 +83,15 @@ func (o CreateKeyPairOptions) Validate(args []string) error {
8583
}
8684

8785
func (o CreateKeyPairOptions) CreateKeyPair() error {
88-
glog.V(2).Infof("Creating a key pair with: %#v", o)
86+
glog.V(4).Infof("Creating a key pair with: %#v", o)
8987

9088
if !o.Overwrite {
9189
if _, err := os.Stat(o.PrivateKeyFile); err == nil {
92-
fmt.Fprintf(o.Output.Get(), "Keeping existing private key file %s\n", o.PrivateKeyFile)
90+
glog.V(3).Infof("Keeping existing private key file %s\n", o.PrivateKeyFile)
9391
return nil
9492
}
9593
if _, err := os.Stat(o.PublicKeyFile); err == nil {
96-
fmt.Fprintf(o.Output.Get(), "Keeping existing public key file %s\n", o.PublicKeyFile)
94+
glog.V(3).Infof("Keeping existing public key file %s\n", o.PublicKeyFile)
9795
return nil
9896
}
9997
}
@@ -111,7 +109,7 @@ func (o CreateKeyPairOptions) CreateKeyPair() error {
111109
return err
112110
}
113111

114-
fmt.Fprintf(o.Output.Get(), "Generated new key pair as %s and %s\n", o.PublicKeyFile, o.PrivateKeyFile)
112+
fmt.Fprintf(o.Output, "Generated new key pair as %s and %s\n", o.PublicKeyFile, o.PrivateKeyFile)
115113

116114
return nil
117115
}

pkg/cmd/server/admin/create_kubeconfig.go

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package admin
22

33
import (
44
"errors"
5-
"fmt"
65
"io"
76
"io/ioutil"
87
"os"
@@ -18,7 +17,6 @@ import (
1817
clientcmdapi "github.com/GoogleCloudPlatform/kubernetes/pkg/client/clientcmd/api"
1918
cliconfig "github.com/openshift/origin/pkg/cmd/cli/config"
2019
"github.com/openshift/origin/pkg/cmd/server/crypto"
21-
cmdutil "github.com/openshift/origin/pkg/cmd/util"
2220
)
2321

2422
const CreateKubeConfigCommandName = "create-kubeconfig"
@@ -34,11 +32,11 @@ type CreateKubeConfigOptions struct {
3432
ContextNamespace string
3533

3634
KubeConfigFile string
37-
Output cmdutil.Output
35+
Output io.Writer
3836
}
3937

4038
func NewCommandCreateKubeConfig(commandName string, fullName string, out io.Writer) *cobra.Command {
41-
options := &CreateKubeConfigOptions{Output: cmdutil.Output{out}}
39+
options := &CreateKubeConfigOptions{Output: out}
4240

4341
cmd := &cobra.Command{
4442
Use: commandName,
@@ -84,7 +82,6 @@ users:
8482
}
8583
},
8684
}
87-
cmd.SetOutput(out)
8885

8986
flags := cmd.Flags()
9087

@@ -126,7 +123,7 @@ func (o CreateKubeConfigOptions) Validate(args []string) error {
126123
}
127124

128125
func (o CreateKubeConfigOptions) CreateKubeConfig() (*clientcmdapi.Config, error) {
129-
glog.V(2).Infof("creating a .kubeconfig with: %#v", o)
126+
glog.V(4).Infof("creating a .kubeconfig with: %#v", o)
130127

131128
// read all the refenced filenames
132129
caData, err := ioutil.ReadFile(o.APIServerCAFile)
@@ -200,7 +197,7 @@ func (o CreateKubeConfigOptions) CreateKubeConfig() (*clientcmdapi.Config, error
200197
CurrentContext: contextNick,
201198
}
202199

203-
fmt.Fprintf(o.Output.Get(), "Generating '%s' API client config as %s\n", userNick, o.KubeConfigFile)
200+
glog.V(3).Infof("Generating '%s' API client config as %s\n", userNick, o.KubeConfigFile)
204201
// Ensure the parent dir exists
205202
if err := os.MkdirAll(filepath.Dir(o.KubeConfigFile), os.FileMode(0755)); err != nil {
206203
return nil, err

pkg/cmd/server/admin/create_mastercerts.go

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import (
1313
kcmdutil "github.com/GoogleCloudPlatform/kubernetes/pkg/kubectl/cmd/util"
1414

1515
"github.com/GoogleCloudPlatform/kubernetes/pkg/util"
16-
cmdutil "github.com/openshift/origin/pkg/cmd/util"
1716
)
1817

1918
const CreateMasterCertsCommandName = "create-master-certs"
@@ -72,11 +71,11 @@ type CreateMasterCertsOptions struct {
7271
PublicAPIServerURL string
7372

7473
Overwrite bool
75-
Output cmdutil.Output
74+
Output io.Writer
7675
}
7776

7877
func NewCommandCreateMasterCerts(commandName string, fullName string, out io.Writer) *cobra.Command {
79-
options := &CreateMasterCertsOptions{Output: cmdutil.Output{out}}
78+
options := &CreateMasterCertsOptions{Output: out}
8079

8180
cmd := &cobra.Command{
8281
Use: commandName,
@@ -92,7 +91,6 @@ func NewCommandCreateMasterCerts(commandName string, fullName string, out io.Wri
9291
}
9392
},
9493
}
95-
cmd.SetOutput(out)
9694

9795
flags := cmd.Flags()
9896

@@ -128,7 +126,7 @@ func (o CreateMasterCertsOptions) Validate(args []string) error {
128126
}
129127

130128
func (o CreateMasterCertsOptions) CreateMasterCerts() error {
131-
glog.V(2).Infof("Creating all certs with: %#v", o)
129+
glog.V(4).Infof("Creating all certs with: %#v", o)
132130

133131
signerCertOptions := CreateSignerCertOptions{
134132
CertFile: DefaultCertFilename(o.CertDir, CAFilePrefix),

pkg/cmd/server/admin/create_nodeconfig.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,13 @@ type CreateNodeConfigOptions struct {
4949
NodeClientCAFile string
5050
APIServerCAFile string
5151
APIServerURL string
52-
Output cmdutil.Output
52+
Output io.Writer
5353
NetworkPluginName string
5454
}
5555

5656
func NewCommandNodeConfig(commandName string, fullName string, out io.Writer) *cobra.Command {
5757
options := NewDefaultCreateNodeConfigOptions()
58+
options.Output = out
5859

5960
cmd := &cobra.Command{
6061
Use: commandName,
@@ -69,8 +70,6 @@ func NewCommandNodeConfig(commandName string, fullName string, out io.Writer) *c
6970
}
7071
},
7172
}
72-
cmd.SetOutput(out)
73-
options.Output = cmdutil.Output{out}
7473

7574
flags := cmd.Flags()
7675

@@ -211,6 +210,8 @@ func (o CreateNodeConfigOptions) CreateNodeFolder() error {
211210
nodeConfigFile := path.Join(o.NodeConfigDir, "node-config.yaml")
212211
nodeJSONFile := path.Join(o.NodeConfigDir, "node-registration.json")
213212

213+
fmt.Fprintf(o.Output, "Generating node credentials ...\n")
214+
214215
if err := o.MakeClientCert(clientCertFile, clientKeyFile); err != nil {
215216
return err
216217
}
@@ -237,6 +238,8 @@ func (o CreateNodeConfigOptions) CreateNodeFolder() error {
237238
return err
238239
}
239240

241+
fmt.Fprintf(o.Output, "Created node config for %s in %s\n", o.NodeName, o.NodeConfigDir)
242+
240243
return nil
241244
}
242245

@@ -383,7 +386,6 @@ func (o CreateNodeConfigOptions) MakeNodeConfig(serverCertFile, serverKeyFile, n
383386
return err
384387
}
385388

386-
fmt.Fprintf(o.Output.Get(), "Creating node config for %s in %s\n", o.NodeName, o.NodeConfigDir)
387389
// Relativize to config file dir
388390
base, err := cmdutil.MakeAbs(o.NodeConfigDir, cwd)
389391
if err != nil {

pkg/cmd/server/admin/create_servercert.go

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import (
1010

1111
kcmdutil "github.com/GoogleCloudPlatform/kubernetes/pkg/kubectl/cmd/util"
1212
"github.com/GoogleCloudPlatform/kubernetes/pkg/util"
13-
cmdutil "github.com/openshift/origin/pkg/cmd/util"
1413

1514
"github.com/openshift/origin/pkg/cmd/server/crypto"
1615
)
@@ -25,7 +24,7 @@ type CreateServerCertOptions struct {
2524

2625
Hostnames util.StringList
2726
Overwrite bool
28-
Output cmdutil.Output
27+
Output io.Writer
2928
}
3029

3130
const create_server_long = `
@@ -44,7 +43,7 @@ Example: Creating a secure router certificate.
4443
`
4544

4645
func NewCommandCreateServerCert(commandName string, fullName string, out io.Writer) *cobra.Command {
47-
options := &CreateServerCertOptions{GetSignerCertOptions: &GetSignerCertOptions{}, Output: cmdutil.Output{out}}
46+
options := &CreateServerCertOptions{GetSignerCertOptions: &GetSignerCertOptions{}, Output: out}
4847

4948
cmd := &cobra.Command{
5049
Use: commandName,
@@ -60,7 +59,6 @@ func NewCommandCreateServerCert(commandName string, fullName string, out io.Writ
6059
}
6160
},
6261
}
63-
cmd.SetOutput(out)
6462

6563
flags := cmd.Flags()
6664
BindGetSignerCertOptions(options.GetSignerCertOptions, flags, "")
@@ -99,7 +97,7 @@ func (o CreateServerCertOptions) Validate(args []string) error {
9997
}
10098

10199
func (o CreateServerCertOptions) CreateServerCert() (*crypto.TLSCertificateConfig, error) {
102-
glog.V(2).Infof("Creating a server cert with: %#v", o)
100+
glog.V(4).Infof("Creating a server cert with: %#v", o)
103101

104102
signerCert, err := o.GetSignerCertOptions.GetSignerCert()
105103
if err != nil {
@@ -114,9 +112,9 @@ func (o CreateServerCertOptions) CreateServerCert() (*crypto.TLSCertificateConfi
114112
ca, written, err = signerCert.EnsureServerCert(o.CertFile, o.KeyFile, util.NewStringSet([]string(o.Hostnames)...))
115113
}
116114
if written {
117-
fmt.Fprintf(o.Output.Get(), "Generated new server certificate as %s, key as %s\n", o.CertFile, o.KeyFile)
115+
glog.V(3).Infof("Generated new server certificate as %s, key as %s\n", o.CertFile, o.KeyFile)
118116
} else {
119-
fmt.Fprintf(o.Output.Get(), "Keeping existing server certificate at %s, key at %s\n", o.CertFile, o.KeyFile)
117+
glog.V(3).Infof("Keeping existing server certificate at %s, key at %s\n", o.CertFile, o.KeyFile)
120118
}
121119
return ca, err
122120
}

0 commit comments

Comments
 (0)