<commit_before>package info

import (
	"fmt"
	"net/http"
	"net/url"

	"github.com/spf13/cobra"

	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
	apirequest "k8s.io/apiserver/pkg/endpoints/request"
	"k8s.io/kubernetes/pkg/kubectl/cmd/templates"
	kcmdutil "k8s.io/kubernetes/pkg/kubectl/cmd/util"

	imageclient "github.com/openshift/client-go/image/clientset/versioned"
	"github.com/openshift/library-go/pkg/image/reference"
	"github.com/openshift/origin/pkg/image/registryclient"
	"k8s.io/cli-runtime/pkg/genericclioptions"
)

var (
	desc = templates.LongDesc(`
		Display information about the integrated registry

		This command exposes information about the integrated registry, if configured.
		Use --check to verify your local client can access the registry. If the adminstrator
		has not configured a public hostname for the registry then this command may fail when
		run outside of the server.

		Experimental: This command is under active development and may change without notice.`)

	example = templates.Examples(`
# Display information about the integrated registry
%[1]s		
`)
)

type Options struct {
	Check        bool
	Quiet        bool
	ShowInternal bool
	ShowPublic   bool

	Namespaces []string
	Client     imageclient.Interface

	genericclioptions.IOStreams
}

func NewRegistryInfoOptions(streams genericclioptions.IOStreams) *Options {
	return &Options{
		IOStreams: streams,
	}
}

// New creates a command that displays info about the registry.
func NewRegistryInfoCmd(name string, f kcmdutil.Factory, streams genericclioptions.IOStreams) *cobra.Command {
	o := NewRegistryInfoOptions(streams)

	cmd := &cobra.Command{
		Use:     "info ",
		Short:   "Print info about the integrated registry",
		Long:    desc,
		Example: fmt.Sprintf(example, name+" login"),
		Run: func(c *cobra.Command, args []string) {
			kcmdutil.CheckErr(o.Complete(f, args))
			kcmdutil.CheckErr(o.Validate())
			kcmdutil.CheckErr(o.Run())
		},
	}

	flag := cmd.Flags()
	flag.BoolVar(&o.Check, "check", o.Check, "Attempt to contact the integrated registry.")
	flag.BoolVarP(&o.Check, "quiet", "q", o.Quiet, "Suppress normal output and only print status.")
	flag.BoolVar(&o.ShowInternal, "internal", o.ShowInternal, "Only check the internal registry hostname.")
	flag.BoolVar(&o.ShowPublic, "public", o.ShowPublic, "Only check the public registry hostname.")

	return cmd
}

func (o *Options) Complete(f kcmdutil.Factory, args []string) error {
	cfg, err := f.ToRESTConfig()
	if err != nil {
		return err
	}
	client, err := imageclient.NewForConfig(cfg)
	if err != nil {
		return err
	}<commit_msg>Bug  1665357 - update oc registry info help message<commit_after>package info

import (
	"fmt"
	"net/http"
	"net/url"

	"github.com/spf13/cobra"

	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
	apirequest "k8s.io/apiserver/pkg/endpoints/request"
	"k8s.io/kubernetes/pkg/kubectl/cmd/templates"
	kcmdutil "k8s.io/kubernetes/pkg/kubectl/cmd/util"

	imageclient "github.com/openshift/client-go/image/clientset/versioned"
	"github.com/openshift/library-go/pkg/image/reference"
	"github.com/openshift/origin/pkg/image/registryclient"
	"k8s.io/cli-runtime/pkg/genericclioptions"
)

var (
	desc = templates.LongDesc(`
		Display information about the integrated registry

		This command exposes information about the integrated registry, if configured.
		Use --check to verify your local client can access the registry. If the adminstrator
		has not configured a public hostname for the registry then this command may fail when
		run outside of the server.

		Experimental: This command is under active development and may change without notice.`)

	example = templates.Examples(`
# Display information about the integrated registry
%[1]s
`)
)

type Options struct {
	Check        bool
	Quiet        bool
	ShowInternal bool
	ShowPublic   bool

	Namespaces []string
	Client     imageclient.Interface

	genericclioptions.IOStreams
}

func NewRegistryInfoOptions(streams genericclioptions.IOStreams) *Options {
	return &Options{
		IOStreams: streams,
	}
}

// New creates a command that displays info about the registry.
func NewRegistryInfoCmd(name string, f kcmdutil.Factory, streams genericclioptions.IOStreams) *cobra.Command {
	o := NewRegistryInfoOptions(streams)

	cmd := &cobra.Command{
		Use:     "info ",
		Short:   "Print info about the integrated registry",
		Long:    desc,
		Example: fmt.Sprintf(example, name+" info"),
		Run: func(c *cobra.Command, args []string) {
			kcmdutil.CheckErr(o.Complete(f, args))
			kcmdutil.CheckErr(o.Validate())
			kcmdutil.CheckErr(o.Run())
		},
	}

	flag := cmd.Flags()
	flag.BoolVar(&o.Check, "check", o.Check, "Attempt to contact the integrated registry.")
	flag.BoolVarP(&o.Check, "quiet", "q", o.Quiet, "Suppress normal output and only print status.")
	flag.BoolVar(&o.ShowInternal, "internal", o.ShowInternal, "Only check the internal registry hostname.")
	flag.BoolVar(&o.ShowPublic, "public", o.ShowPublic, "Only check the public registry hostname.")

	return cmd
}

func (o *Options) Complete(f kcmdutil.Factory, args []string) error {
	cfg, err := f.ToRESTConfig()
	if err != nil {
		return err
	}
	client, err := imageclient.NewForConfig(cfg)
	if err != nil {
		return err
	}
{'fraction_non_alphanumeric': 0.11196466295371615, 'fraction_numerical': 0.0051853274438256195, 'mean_word_length': 4.330603889457523, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2341588', 'n_tokens_mistral': 1773, 'n_tokens_neox': 1683, 'n_words': 465}