<commit_before>// Copyright 2018 Istio Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package main

import (
	"bytes"
	"fmt"
	"strings"

	"github.com/spf13/cobra"
	"k8s.io/api/core/v1"
	"k8s.io/apimachinery/pkg/runtime/serializer"
	"k8s.io/client-go/kubernetes/scheme"
	"k8s.io/client-go/rest"
	"k8s.io/client-go/tools/clientcmd"
	"k8s.io/client-go/tools/remotecommand"

	"istio.io/istio/pkg/log"
)

var (

	// TODO - Pull in remaining xDS information from pilot agent via curl and add to output
	// TODO - Add config-diff to get the difference between pilot's xDS API response and the proxy config
	// TODO - Add support for non-default proxy config locations
	// TODO - Add support for non-kube istio deployments
	configCmd = &cobra.Command{
		Use:   "proxy-config <pod-name>",
		Short: "Retrieves proxy configuration for the specified pod [kube only]",
		Long: `
Retrieves the static/bootstrap proxy configuration for the specified pod when running in Kubernetes.
Support for other environments to follow.
`,
		Example: `  # Retrieve config for productpage-v1-bb8d5cbc7-k7qbm pod
  istioctl proxy-config productpage-v1-bb8d5cbc7-k7qbm`,
		Aliases: []string{"pc"},
		Args:    cobra.MinimumNArgs(1),
		RunE: func(c *cobra.Command, args []string) error {
			podName := args[0]
			log.Infof("Retrieving proxy config for %q", podName)

			ns := namespace
			if ns == v1.NamespaceAll {
				ns = defaultNamespace
			}
			config, err := readConfigFile(podName, ns)
			if err != nil {
				return err
			}

			fmt.Println(config)

			return nil
		},
	}
)

func init() {
	rootCmd.AddCommand(configCmd)
}

func createCoreV1Client() (*rest.RESTClient, error) {<commit_msg>Fix example spacing that was leading to odd format on istio.io (#3305)<commit_after>// Copyright 2018 Istio Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package main

import (
	"bytes"
	"fmt"
	"strings"

	"github.com/spf13/cobra"
	"k8s.io/api/core/v1"
	"k8s.io/apimachinery/pkg/runtime/serializer"
	"k8s.io/client-go/kubernetes/scheme"
	"k8s.io/client-go/rest"
	"k8s.io/client-go/tools/clientcmd"
	"k8s.io/client-go/tools/remotecommand"

	"istio.io/istio/pkg/log"
)

var (

	// TODO - Pull in remaining xDS information from pilot agent via curl and add to output
	// TODO - Add config-diff to get the difference between pilot's xDS API response and the proxy config
	// TODO - Add support for non-default proxy config locations
	// TODO - Add support for non-kube istio deployments
	configCmd = &cobra.Command{
		Use:   "proxy-config <pod-name>",
		Short: "Retrieves proxy configuration for the specified pod [kube only]",
		Long: `
Retrieves the static/bootstrap proxy configuration for the specified pod when running in Kubernetes.
Support for other environments to follow.
`,
		Example: `# Retrieve config for productpage-v1-bb8d5cbc7-k7qbm pod
istioctl proxy-config productpage-v1-bb8d5cbc7-k7qbm`,
		Aliases: []string{"pc"},
		Args:    cobra.MinimumNArgs(1),
		RunE: func(c *cobra.Command, args []string) error {
			podName := args[0]
			log.Infof("Retrieving proxy config for %q", podName)

			ns := namespace
			if ns == v1.NamespaceAll {
				ns = defaultNamespace
			}
			config, err := readConfigFile(podName, ns)
			if err != nil {
				return err
			}

			fmt.Println(config)

			return nil
		},
	}
)

func init() {
	rootCmd.AddCommand(configCmd)
}

func createCoreV1Client() (*rest.RESTClient, error) {
{'fraction_non_alphanumeric': 0.10912383971021054, 'fraction_numerical': 0.01494226850803713, 'mean_word_length': 3.5687693898655635, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '3923447', 'n_tokens_mistral': 1528, 'n_tokens_neox': 1428, 'n_words': 475}