mirror of https://github.com/kubernetes/kops.git
Merge pull request #8202 from johngmyers/kops-staticcheck
Fix cmd/kops staticcheck failures
This commit is contained in:
commit
c1f5c7acd6
|
|
@ -92,8 +92,6 @@ func NewCmdDeleteCluster(f *util.Factory, out io.Writer) *cobra.Command {
|
|||
return cmd
|
||||
}
|
||||
|
||||
type getter func(o interface{}) interface{}
|
||||
|
||||
func RunDeleteCluster(f *util.Factory, out io.Writer, options *DeleteClusterOptions) error {
|
||||
clusterName := options.ClusterName
|
||||
if clusterName == "" {
|
||||
|
|
|
|||
|
|
@ -37,9 +37,6 @@ var (
|
|||
exportShort = i18n.T(`Export configuration.`)
|
||||
)
|
||||
|
||||
type ExportOptions struct {
|
||||
}
|
||||
|
||||
func NewCmdExport(f *util.Factory, out io.Writer) *cobra.Command {
|
||||
|
||||
cmd := &cobra.Command{
|
||||
|
|
|
|||
|
|
@ -27,7 +27,6 @@ import (
|
|||
api "k8s.io/kops/pkg/apis/kops"
|
||||
"k8s.io/kops/pkg/commands"
|
||||
"k8s.io/kops/pkg/kubeconfig"
|
||||
"k8s.io/kops/upup/pkg/fi"
|
||||
"k8s.io/kubernetes/pkg/kubectl/util/i18n"
|
||||
"k8s.io/kubernetes/pkg/kubectl/util/templates"
|
||||
)
|
||||
|
|
@ -48,8 +47,6 @@ var (
|
|||
)
|
||||
|
||||
type ExportKubecfgOptions struct {
|
||||
tmpdir string
|
||||
keyStore fi.CAStore
|
||||
KubeConfigPath string
|
||||
all bool
|
||||
}
|
||||
|
|
|
|||
|
|
@ -99,9 +99,7 @@ func TestExistingIAMCloudformation(t *testing.T) {
|
|||
|
||||
// TestExistingSG runs the test with existing Security Group, similar to kops create cluster minimal.example.com --zones us-west-1a
|
||||
func TestExistingSG(t *testing.T) {
|
||||
lifecycleOverrides := []string{"SecurityGroup=ExistsAndWarnIfChanges", "SecurityGroupRule=ExistsAndWarnIfChanges"}
|
||||
lifecycleOverrides = nil
|
||||
runTestAWS(t, "existingsg.example.com", "existing_sg", "v1alpha2", false, 3, true, false, lifecycleOverrides)
|
||||
runTestAWS(t, "existingsg.example.com", "existing_sg", "v1alpha2", false, 3, true, false, nil)
|
||||
}
|
||||
|
||||
// TestAdditionalUserData runs the test on passing additional user-data to an instance at bootstrap.
|
||||
|
|
|
|||
|
|
@ -20,7 +20,6 @@ import (
|
|||
"bytes"
|
||||
"crypto/x509/pkix"
|
||||
"fmt"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func pkixNameToString(name *pkix.Name) string {
|
||||
|
|
@ -57,27 +56,3 @@ func pkixNameToString(name *pkix.Name) string {
|
|||
}
|
||||
return s.String()
|
||||
}
|
||||
|
||||
func parsePkixName(s string) (*pkix.Name, error) {
|
||||
name := new(pkix.Name)
|
||||
|
||||
tokens := strings.Split(s, ",")
|
||||
for _, token := range tokens {
|
||||
token = strings.TrimSpace(token)
|
||||
kv := strings.SplitN(token, "=", 2)
|
||||
if len(kv) != 2 {
|
||||
return nil, fmt.Errorf("unrecognized token (expected k=v): %q", token)
|
||||
}
|
||||
k := strings.ToLower(kv[0])
|
||||
v := kv[1]
|
||||
|
||||
switch k {
|
||||
case "cn":
|
||||
name.CommonName = v
|
||||
default:
|
||||
return nil, fmt.Errorf("unrecognized key %q in token %q", k, token)
|
||||
}
|
||||
}
|
||||
|
||||
return name, nil
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,8 +34,6 @@ import (
|
|||
"k8s.io/kops/cmd/kops/util"
|
||||
kopsapi "k8s.io/kops/pkg/apis/kops"
|
||||
"k8s.io/kops/pkg/client/simple"
|
||||
"k8s.io/kops/pkg/kubeconfig"
|
||||
"k8s.io/kops/upup/pkg/kutil"
|
||||
"k8s.io/kubernetes/pkg/kubectl/util/i18n"
|
||||
"k8s.io/kubernetes/pkg/kubectl/util/templates"
|
||||
)
|
||||
|
|
@ -272,27 +270,6 @@ func ClusterNameFromKubecfg() string {
|
|||
return clusterName
|
||||
}
|
||||
|
||||
func readKubectlClusterConfig() (*kubeconfig.KubectlClusterWithName, error) {
|
||||
kubectl := &kutil.Kubectl{}
|
||||
context, err := kubectl.GetCurrentContext()
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("error getting current context from kubectl: %v", err)
|
||||
}
|
||||
klog.V(4).Infof("context = %q", context)
|
||||
|
||||
config, err := kubectl.GetConfig(true)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("error getting current config from kubectl: %v", err)
|
||||
}
|
||||
|
||||
// Minify should have done this
|
||||
if len(config.Clusters) != 1 {
|
||||
return nil, fmt.Errorf("expected exactly one cluster in kubectl config, found %d", len(config.Clusters))
|
||||
}
|
||||
|
||||
return config.Clusters[0], nil
|
||||
}
|
||||
|
||||
func (c *RootCmd) Clientset() (simple.Clientset, error) {
|
||||
return c.factory.Clientset()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,9 +17,7 @@ limitations under the License.
|
|||
package main
|
||||
|
||||
import (
|
||||
"archive/tar"
|
||||
"bytes"
|
||||
"compress/gzip"
|
||||
"fmt"
|
||||
"io"
|
||||
"os"
|
||||
|
|
@ -32,7 +30,6 @@ import (
|
|||
"k8s.io/klog"
|
||||
"k8s.io/kops/cmd/kops/util"
|
||||
"k8s.io/kops/pkg/bundle"
|
||||
"k8s.io/kops/pkg/try"
|
||||
"k8s.io/kops/upup/pkg/kutil"
|
||||
"k8s.io/kops/util/pkg/vfs"
|
||||
"k8s.io/kubernetes/pkg/kubectl/util/i18n"
|
||||
|
|
@ -185,31 +182,6 @@ func runSshCommand(sshClient *ssh.Client, cmd string) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func writeToTar(files []*bundle.DataFile, bundlePath string) error {
|
||||
f, err := os.Create(bundlePath)
|
||||
if err != nil {
|
||||
return fmt.Errorf("error creating output bundle file %q: %v", bundlePath, err)
|
||||
}
|
||||
defer try.CloseFile(f)
|
||||
|
||||
gw := gzip.NewWriter(f)
|
||||
defer gw.Close()
|
||||
tw := tar.NewWriter(gw)
|
||||
defer tw.Close()
|
||||
|
||||
for _, file := range files {
|
||||
if err := tw.WriteHeader(&file.Header); err != nil {
|
||||
return fmt.Errorf("error writing tar file header: %v", err)
|
||||
}
|
||||
|
||||
if _, err := tw.Write(file.Data); err != nil {
|
||||
return fmt.Errorf("error writing tar file data: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// bazel build //cmd/kops && bazel-bin/cmd/kops/kops toolbox bundle --name ${CLUSTER} ${IGNAME} && scp output.tar.gz ${TARGET}:/tmp/output.tar.gz
|
||||
// sudo apt-get install --yes ca-certificates
|
||||
// sudo mkdir -p /etc/kubernetes/bootstrap
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
cloudmock/aws/mockelbv2
|
||||
cmd/kops
|
||||
node-authorizer/pkg/authorizers/aws
|
||||
node-authorizer/pkg/server
|
||||
pkg/resources/openstack
|
||||
|
|
|
|||
Loading…
Reference in New Issue