mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-09-01 01:08:55 +00:00
Merge pull request #60094 from juanvallejo/jvallejo/remove-printobjectspecificmessage
Automatic merge from submit-queue. If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>. remove f.PrintObjectSpecificMessage **Release note**: ```release-note NONE ``` Mailing list discussion: https://groups.google.com/forum/#!topic/kubernetes-sig-cli/gZWg8Ulo3Ao Removes the `PrintObjectSpecificMessage` helper in an effort to reduce printing stack complexity, and avoid special-casing resources.
This commit is contained in:
@@ -213,9 +213,6 @@ func (o *CreateOptions) RunCreate(f cmdutil.Factory, cmd *cobra.Command) error {
|
|||||||
if len(output) > 0 && !shortOutput {
|
if len(output) > 0 && !shortOutput {
|
||||||
return cmdutil.PrintObject(cmd, info.Object, o.Out)
|
return cmdutil.PrintObject(cmd, info.Object, o.Out)
|
||||||
}
|
}
|
||||||
if !shortOutput {
|
|
||||||
f.PrintObjectSpecificMessage(info.Object, o.Out)
|
|
||||||
}
|
|
||||||
|
|
||||||
cmdutil.PrintSuccess(shortOutput, o.Out, info.Object, dryRun, "created")
|
cmdutil.PrintSuccess(shortOutput, o.Out, info.Object, dryRun, "created")
|
||||||
return nil
|
return nil
|
||||||
|
@@ -154,7 +154,6 @@ func RunReplace(f cmdutil.Factory, out io.Writer, cmd *cobra.Command, args []str
|
|||||||
}
|
}
|
||||||
|
|
||||||
info.Refresh(obj, true)
|
info.Refresh(obj, true)
|
||||||
f.PrintObjectSpecificMessage(obj, out)
|
|
||||||
cmdutil.PrintSuccess(shortOutput, out, info.Object, false, "replaced")
|
cmdutil.PrintSuccess(shortOutput, out, info.Object, false, "replaced")
|
||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
@@ -276,7 +275,6 @@ func forceReplace(f cmdutil.Factory, out io.Writer, cmd *cobra.Command, args []s
|
|||||||
|
|
||||||
count++
|
count++
|
||||||
info.Refresh(obj, true)
|
info.Refresh(obj, true)
|
||||||
f.PrintObjectSpecificMessage(obj, out)
|
|
||||||
cmdutil.PrintSuccess(shortOutput, out, info.Object, false, "replaced")
|
cmdutil.PrintSuccess(shortOutput, out, info.Object, false, "replaced")
|
||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
|
@@ -19,7 +19,6 @@ package testing
|
|||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@@ -440,9 +439,6 @@ func (f *FakeFactory) EditorEnvs() []string {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *FakeFactory) PrintObjectSpecificMessage(obj runtime.Object, out io.Writer) {
|
|
||||||
}
|
|
||||||
|
|
||||||
func (f *FakeFactory) Command(*cobra.Command, bool) string {
|
func (f *FakeFactory) Command(*cobra.Command, bool) string {
|
||||||
return f.tf.Command
|
return f.tf.Command
|
||||||
}
|
}
|
||||||
|
@@ -18,7 +18,6 @@ package util
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
|
||||||
"sort"
|
"sort"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
@@ -172,9 +171,6 @@ type ClientAccessFactory interface {
|
|||||||
// can range over in order to determine if the user has specified an editor
|
// can range over in order to determine if the user has specified an editor
|
||||||
// of their choice.
|
// of their choice.
|
||||||
EditorEnvs() []string
|
EditorEnvs() []string
|
||||||
|
|
||||||
// PrintObjectSpecificMessage prints object-specific messages on the provided writer
|
|
||||||
PrintObjectSpecificMessage(obj runtime.Object, out io.Writer)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ObjectMappingFactory holds the second level of factory methods. These functions depend upon ClientAccessFactory methods.
|
// ObjectMappingFactory holds the second level of factory methods. These functions depend upon ClientAccessFactory methods.
|
||||||
|
@@ -660,34 +660,6 @@ func (f *ring0Factory) EditorEnvs() []string {
|
|||||||
return []string{"KUBE_EDITOR", "EDITOR"}
|
return []string{"KUBE_EDITOR", "EDITOR"}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *ring0Factory) PrintObjectSpecificMessage(obj runtime.Object, out io.Writer) {
|
|
||||||
switch obj := obj.(type) {
|
|
||||||
case *api.Service:
|
|
||||||
if obj.Spec.Type == api.ServiceTypeNodePort {
|
|
||||||
msg := fmt.Sprintf(
|
|
||||||
`You have exposed your service on an external port on all nodes in your
|
|
||||||
cluster. If you want to expose this service to the external internet, you may
|
|
||||||
need to set up firewall rules for the service port(s) (%s) to serve traffic.
|
|
||||||
|
|
||||||
See http://kubernetes.io/docs/user-guide/services-firewalls for more details.
|
|
||||||
`,
|
|
||||||
makePortsString(obj.Spec.Ports, true))
|
|
||||||
out.Write([]byte(msg))
|
|
||||||
}
|
|
||||||
|
|
||||||
if _, ok := obj.Annotations[api.AnnotationLoadBalancerSourceRangesKey]; ok {
|
|
||||||
msg := fmt.Sprintf(
|
|
||||||
`You are using service annotation [service.beta.kubernetes.io/load-balancer-source-ranges].
|
|
||||||
It has been promoted to field [loadBalancerSourceRanges] in service spec. This annotation will be deprecated in the future.
|
|
||||||
Please use the loadBalancerSourceRanges field instead.
|
|
||||||
|
|
||||||
See http://kubernetes.io/docs/user-guide/services-firewalls for more details.
|
|
||||||
`)
|
|
||||||
out.Write([]byte(msg))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// overlyCautiousIllegalFileCharacters matches characters that *might* not be supported. Windows is really restrictive, so this is really restrictive
|
// overlyCautiousIllegalFileCharacters matches characters that *might* not be supported. Windows is really restrictive, so this is really restrictive
|
||||||
var overlyCautiousIllegalFileCharacters = regexp.MustCompile(`[^(\w/\.)]`)
|
var overlyCautiousIllegalFileCharacters = regexp.MustCompile(`[^(\w/\.)]`)
|
||||||
|
|
||||||
|
@@ -17,7 +17,6 @@ limitations under the License.
|
|||||||
package util
|
package util
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"sort"
|
"sort"
|
||||||
"strings"
|
"strings"
|
||||||
@@ -418,41 +417,6 @@ func TestGetFirstPod(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestPrintObjectSpecificMessage(t *testing.T) {
|
|
||||||
f := NewFactory(nil)
|
|
||||||
tests := []struct {
|
|
||||||
obj runtime.Object
|
|
||||||
expectOutput bool
|
|
||||||
}{
|
|
||||||
{
|
|
||||||
obj: &api.Service{},
|
|
||||||
expectOutput: false,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
obj: &api.Pod{},
|
|
||||||
expectOutput: false,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
obj: &api.Service{Spec: api.ServiceSpec{Type: api.ServiceTypeLoadBalancer}},
|
|
||||||
expectOutput: false,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
obj: &api.Service{Spec: api.ServiceSpec{Type: api.ServiceTypeNodePort}},
|
|
||||||
expectOutput: true,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
for _, test := range tests {
|
|
||||||
buff := &bytes.Buffer{}
|
|
||||||
f.PrintObjectSpecificMessage(test.obj, buff)
|
|
||||||
if test.expectOutput && buff.Len() == 0 {
|
|
||||||
t.Errorf("Expected output, saw none for %v", test.obj)
|
|
||||||
}
|
|
||||||
if !test.expectOutput && buff.Len() > 0 {
|
|
||||||
t.Errorf("Expected no output, saw %s for %v", buff.String(), test.obj)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestMakePortsString(t *testing.T) {
|
func TestMakePortsString(t *testing.T) {
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
ports []api.ServicePort
|
ports []api.ServicePort
|
||||||
|
Reference in New Issue
Block a user