Merge pull request #7854 from FayerZhang/master

fix golint failures
This commit is contained in:
Kubernetes Prow Robot 2019-11-07 11:37:43 -08:00 committed by GitHub
commit e29a04e5af
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
16 changed files with 53 additions and 73 deletions

View File

@ -131,9 +131,8 @@ func (c *ChannelVersion) replaces(existing *ChannelVersion) bool {
if c.ManifestHash == existing.ManifestHash { if c.ManifestHash == existing.ManifestHash {
klog.V(4).Infof("Manifest Match") klog.V(4).Infof("Manifest Match")
return false return false
} else {
klog.V(4).Infof("Channels had same version and ids %q, %q but different ManifestHash (%q vs %q); will replace", *c.Version, c.Id, c.ManifestHash, existing.ManifestHash)
} }
klog.V(4).Infof("Channels had same version and ids %q, %q but different ManifestHash (%q vs %q); will replace", *c.Version, c.Id, c.ManifestHash, existing.ManifestHash)
} else { } else {
klog.V(4).Infof("Channels had same version %q but different ids (%q vs %q); will replace", *c.Version, c.Id, existing.Id) klog.V(4).Infof("Channels had same version %q but different ids (%q vs %q); will replace", *c.Version, c.Id, existing.Id)
} }

View File

@ -137,9 +137,8 @@ func (m *MockRoute53) ChangeResourceRecordSets(request *route53.ChangeResourceRe
if foundIndex == -1 { if foundIndex == -1 {
// TODO: Use correct error // TODO: Use correct error
return nil, fmt.Errorf("record not found %s %q", changeType, changeName) return nil, fmt.Errorf("record not found %s %q", changeType, changeName)
} else {
zone.records = append(zone.records[:foundIndex], zone.records[foundIndex+1:]...)
} }
zone.records = append(zone.records[:foundIndex], zone.records[foundIndex+1:]...)
default: default:
// TODO: Use correct error // TODO: Use correct error

View File

@ -183,9 +183,8 @@ func RunCreate(f *util.Factory, out io.Writer, c *CreateOptions) error {
return fmt.Errorf("instanceGroup %q already exists", v.ObjectMeta.Name) return fmt.Errorf("instanceGroup %q already exists", v.ObjectMeta.Name)
} }
return fmt.Errorf("error creating instanceGroup: %v", err) return fmt.Errorf("error creating instanceGroup: %v", err)
} else {
fmt.Fprintf(&sb, "Created instancegroup/%s\n", v.ObjectMeta.Name)
} }
fmt.Fprintf(&sb, "Created instancegroup/%s\n", v.ObjectMeta.Name)
case *kopsapi.SSHCredential: case *kopsapi.SSHCredential:
clusterName = v.ObjectMeta.Labels[kopsapi.LabelClusterName] clusterName = v.ObjectMeta.Labels[kopsapi.LabelClusterName]

View File

@ -272,27 +272,26 @@ func (c *UpgradeClusterCmd) Run(args []string) error {
if !c.Yes { if !c.Yes {
fmt.Printf("\nMust specify --yes to perform upgrade\n") fmt.Printf("\nMust specify --yes to perform upgrade\n")
return nil return nil
} else {
for _, action := range actions {
action.apply()
}
if err := commands.UpdateCluster(clientset, cluster, instanceGroups); err != nil {
return err
}
for _, g := range instanceGroups {
_, err := clientset.InstanceGroupsFor(cluster).Update(g)
if err != nil {
return fmt.Errorf("error writing InstanceGroup %q: %v", g.ObjectMeta.Name, err)
}
}
fmt.Printf("\nUpdates applied to configuration.\n")
// TODO: automate this step
fmt.Printf("You can now apply these changes, using `kops update cluster %s`\n", cluster.ObjectMeta.Name)
} }
for _, action := range actions {
action.apply()
}
if err := commands.UpdateCluster(clientset, cluster, instanceGroups); err != nil {
return err
}
for _, g := range instanceGroups {
_, err := clientset.InstanceGroupsFor(cluster).Update(g)
if err != nil {
return fmt.Errorf("error writing InstanceGroup %q: %v", g.ObjectMeta.Name, err)
}
}
fmt.Printf("\nUpdates applied to configuration.\n")
// TODO: automate this step
fmt.Printf("You can now apply these changes, using `kops update cluster %s`\n", cluster.ObjectMeta.Name)
return nil return nil
} }

View File

@ -139,11 +139,10 @@ func RunValidateCluster(f *util.Factory, cmd *cobra.Command, args []string, out
if err != nil { if err != nil {
if time.Now().After(timeout) { if time.Now().After(timeout) {
return nil, fmt.Errorf("unexpected error during validation: %v", err) return nil, fmt.Errorf("unexpected error during validation: %v", err)
} else {
klog.Warningf("(will retry): unexpected error during validation: %v", err)
time.Sleep(pollInterval)
continue
} }
klog.Warningf("(will retry): unexpected error during validation: %v", err)
time.Sleep(pollInterval)
continue
} }
switch options.output { switch options.output {

View File

@ -79,9 +79,8 @@ func (s *s3PublicAclStrategy) GetACL(p vfs.Path, cluster *kops.Cluster) (vfs.ACL
return &vfs.S3Acl{ return &vfs.S3Acl{
RequestACL: values.String("public-read"), RequestACL: values.String("public-read"),
}, nil }, nil
} else {
klog.V(8).Infof("path %q is not inside the file registry %q, not setting public-read acl", u.Path, config.Path)
} }
klog.V(8).Infof("path %q is not inside the file registry %q, not setting public-read acl", u.Path, config.Path)
return nil, nil return nil, nil
} }

View File

@ -140,9 +140,8 @@ func (v *KubernetesVersionSpec) FindRecommendedUpgrade(version semver.Version) (
if recommendedVersion.GT(version) { if recommendedVersion.GT(version) {
klog.V(2).Infof("RecommendedVersion=%q, Have=%q. Recommending upgrade", recommendedVersion, version) klog.V(2).Infof("RecommendedVersion=%q, Have=%q. Recommending upgrade", recommendedVersion, version)
return recommendedVersion, nil return recommendedVersion, nil
} else {
klog.V(4).Infof("RecommendedVersion=%q, Have=%q. No upgrade needed.", recommendedVersion, version)
} }
klog.V(4).Infof("RecommendedVersion=%q, Have=%q. No upgrade needed.", recommendedVersion, version)
return nil, nil return nil, nil
} }
@ -160,9 +159,8 @@ func (v *KopsVersionSpec) FindRecommendedUpgrade(version semver.Version) (*semve
if recommendedVersion.GT(version) { if recommendedVersion.GT(version) {
klog.V(2).Infof("RecommendedVersion=%q, Have=%q. Recommending upgrade", recommendedVersion, version) klog.V(2).Infof("RecommendedVersion=%q, Have=%q. Recommending upgrade", recommendedVersion, version)
return &recommendedVersion, nil return &recommendedVersion, nil
} else {
klog.V(4).Infof("RecommendedVersion=%q, Have=%q. No upgrade needed.", recommendedVersion, version)
} }
klog.V(4).Infof("RecommendedVersion=%q, Have=%q. No upgrade needed.", recommendedVersion, version)
return nil, nil return nil, nil
} }
@ -180,9 +178,8 @@ func (v *KubernetesVersionSpec) IsUpgradeRequired(version semver.Version) (bool,
if requiredVersion.GT(version) { if requiredVersion.GT(version) {
klog.V(2).Infof("RequiredVersion=%q, Have=%q. Requiring upgrade", requiredVersion, version) klog.V(2).Infof("RequiredVersion=%q, Have=%q. Requiring upgrade", requiredVersion, version)
return true, nil return true, nil
} else {
klog.V(4).Infof("RequiredVersion=%q, Have=%q. No upgrade needed.", requiredVersion, version)
} }
klog.V(4).Infof("RequiredVersion=%q, Have=%q. No upgrade needed.", requiredVersion, version)
return false, nil return false, nil
} }
@ -200,9 +197,8 @@ func (v *KopsVersionSpec) IsUpgradeRequired(version semver.Version) (bool, error
if requiredVersion.GT(version) { if requiredVersion.GT(version) {
klog.V(2).Infof("RequiredVersion=%q, Have=%q. Requiring upgrade", requiredVersion, version) klog.V(2).Infof("RequiredVersion=%q, Have=%q. Requiring upgrade", requiredVersion, version)
return true, nil return true, nil
} else {
klog.V(4).Infof("RequiredVersion=%q, Have=%q. No upgrade needed.", requiredVersion, version)
} }
klog.V(4).Infof("RequiredVersion=%q, Have=%q. No upgrade needed.", requiredVersion, version)
return false, nil return false, nil
} }

View File

@ -79,9 +79,8 @@ func (c *CloudInstanceGroup) NewCloudInstanceGroupMember(instanceId string, newG
func (c *CloudInstanceGroup) Status() string { func (c *CloudInstanceGroup) Status() string {
if len(c.NeedUpdate) == 0 { if len(c.NeedUpdate) == 0 {
return "Ready" return "Ready"
} else {
return "NeedsUpdate"
} }
return "NeedsUpdate"
} }
// GetNodeMap returns a list of nodes keyed by their external id // GetNodeMap returns a list of nodes keyed by their external id

View File

@ -136,10 +136,9 @@ func (r *RollingUpdateInstanceGroup) RollingUpdate(rollingUpdateData *RollingUpd
if err = r.ValidateCluster(rollingUpdateData, cluster, instanceGroupList); err != nil { if err = r.ValidateCluster(rollingUpdateData, cluster, instanceGroupList); err != nil {
if rollingUpdateData.FailOnValidate { if rollingUpdateData.FailOnValidate {
return fmt.Errorf("error validating cluster: %v", err) return fmt.Errorf("error validating cluster: %v", err)
} else {
klog.V(2).Infof("Ignoring cluster validation error: %v", err)
klog.Info("Cluster validation failed, but proceeding since fail-on-validate-error is set to false")
} }
klog.V(2).Infof("Ignoring cluster validation error: %v", err)
klog.Info("Cluster validation failed, but proceeding since fail-on-validate-error is set to false")
} }
} }
@ -165,9 +164,8 @@ func (r *RollingUpdateInstanceGroup) RollingUpdate(rollingUpdateData *RollingUpd
if err = r.DrainNode(u, rollingUpdateData); err != nil { if err = r.DrainNode(u, rollingUpdateData); err != nil {
if rollingUpdateData.FailOnDrainError { if rollingUpdateData.FailOnDrainError {
return fmt.Errorf("failed to drain node %q: %v", nodeName, err) return fmt.Errorf("failed to drain node %q: %v", nodeName, err)
} else {
klog.Infof("Ignoring error draining node %q: %v", nodeName, err)
} }
klog.Infof("Ignoring error draining node %q: %v", nodeName, err)
} }
} else { } else {
klog.Warningf("Skipping drain of instance %q, because it is not registered in kubernetes", instanceId) klog.Warningf("Skipping drain of instance %q, because it is not registered in kubernetes", instanceId)

View File

@ -127,9 +127,8 @@ func (b *ScalingGroupModelBuilder) Build(c *fi.ModelBuilderContext) error {
if err != nil { if err != nil {
return err return err
} else {
launchConfiguration.SSHKey = b.LinkToSSHKey()
} }
launchConfiguration.SSHKey = b.LinkToSSHKey()
if launchConfiguration.UserData, err = b.BootstrapScript.ResourceNodeUp(ig, b.Cluster); err != nil { if launchConfiguration.UserData, err = b.BootstrapScript.ResourceNodeUp(ig, b.Cluster); err != nil {
return err return err
} }

View File

@ -102,9 +102,8 @@ func parsePEMCertificate(pemData []byte) (*x509.Certificate, error) {
if block.Type == "CERTIFICATE" { if block.Type == "CERTIFICATE" {
klog.V(10).Infof("Parsing pem block: %q", block.Type) klog.V(10).Infof("Parsing pem block: %q", block.Type)
return x509.ParseCertificate(block.Bytes) return x509.ParseCertificate(block.Bytes)
} else {
klog.Infof("Ignoring unexpected PEM block: %q", block.Type)
} }
klog.Infof("Ignoring unexpected PEM block: %q", block.Type)
pemData = rest pemData = rest
} }

View File

@ -453,11 +453,10 @@ func DeleteRoleRam(cloud fi.Cloud, r *resources.Resource) error {
response, err := c.RamClient().ListPoliciesForRole(roleQueryRequest) response, err := c.RamClient().ListPoliciesForRole(roleQueryRequest)
if err != nil { if err != nil {
return fmt.Errorf("err listing Policies for role:%v", err) return fmt.Errorf("err listing Policies for role:%v", err)
} else { }
if len(response.Policies.Policy) != 0 { if len(response.Policies.Policy) != 0 {
for _, policy := range response.Policies.Policy { for _, policy := range response.Policies.Policy {
policies = append(policies, policy.PolicyName) policies = append(policies, policy.PolicyName)
}
} }
} }

View File

@ -54,15 +54,14 @@ func (s *StringOrSlice) UnmarshalJSON(value []byte) error {
return nil return nil
} }
return nil return nil
} else {
s.forceEncodeAsArray = false
var stringValue string
if err := json.Unmarshal(value, &stringValue); err != nil {
return err
}
s.values = []string{stringValue}
return nil
} }
s.forceEncodeAsArray = false
var stringValue string
if err := json.Unmarshal(value, &stringValue); err != nil {
return err
}
s.values = []string{stringValue}
return nil
} }
// String returns the string value, or the Itoa of the int value. // String returns the string value, or the Itoa of the int value.

View File

@ -114,10 +114,9 @@ func (p *peer) OnGossip(buf []byte) (delta mesh.GossipData, err error) {
// per OnGossip requirements // per OnGossip requirements
klog.V(4).Infof("OnGossip %v => delta empty", message) klog.V(4).Infof("OnGossip %v => delta empty", message)
return nil, nil return nil, nil
} else {
klog.V(4).Infof("OnGossip %v => delta %v", message, deltas)
return deltas, nil
} }
klog.V(4).Infof("OnGossip %v => delta %v", message, deltas)
return deltas, nil
} }
// Merge the gossiped data represented by buf into our state. // Merge the gossiped data represented by buf into our state.

View File

@ -423,11 +423,10 @@ func (a *AWSVolumes) AttachVolume(volume *Volume) error {
volume.LocalDevice = device volume.LocalDevice = device
return nil return nil
} else {
a.releaseDevice(device, volumeID)
return fmt.Errorf("Unable to attach volume %q, was attached to %q", volumeID, v.AttachedTo)
} }
a.releaseDevice(device, volumeID)
return fmt.Errorf("Unable to attach volume %q, was attached to %q", volumeID, v.AttachedTo)
} }
switch v.Status { switch v.Status {

View File

@ -178,9 +178,8 @@ func (k *VolumeMountController) safeFormatAndMount(volume *Volume, mountpoint st
} }
return fmt.Errorf("found multiple existing mounts of %q at %q", device, mountpoint) return fmt.Errorf("found multiple existing mounts of %q at %q", device, mountpoint)
} else {
klog.Infof("Found existing mount of %q at %q", device, mountpoint)
} }
klog.Infof("Found existing mount of %q at %q", device, mountpoint)
} }
// If we're containerized we also want to mount the device (again) into our container // If we're containerized we also want to mount the device (again) into our container