Skip to content
This repository was archived by the owner on Jan 11, 2023. It is now read-only.

Fixing redundant err != nil checks #3007

Merged
merged 1 commit into from
May 18, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions pkg/api/agentPoolOnlyApi/v20170831/validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,7 @@ func (a *Properties) Validate() error {
return e
}
}
if e := validateVNET(a); e != nil {
return e
}
return nil
return validateVNET(a)
}

func validatePoolName(poolName string) error {
Expand Down
5 changes: 1 addition & 4 deletions pkg/api/agentPoolOnlyApi/v20180331/validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,7 @@ func init() {
func (a *AgentPoolProfile) Validate() error {
// Don't need to call validate.Struct(a)
// It is handled by Properties.Validate()
if e := validatePoolName(a.Name); e != nil {
return e
}
return nil
return validatePoolName(a.Name)
}

// Validate implements APIObject
Expand Down
5 changes: 1 addition & 4 deletions pkg/api/agentPoolOnlyApi/vlabs/validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,7 @@ func (a *Properties) Validate() error {
if e := a.LinuxProfile.Validate(); e != nil {
return e
}
if e := validateVNET(a); e != nil {
return e
}
return nil
return validateVNET(a)
}

func validatePoolName(poolName string) error {
Expand Down
10 changes: 2 additions & 8 deletions pkg/api/v20160330/validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,7 @@ func (m *MasterProfile) Validate() error {
if e := validateName(m.DNSPrefix, "MasterProfile.DNSPrefix"); e != nil {
return e
}
if e := validateDNSName(m.DNSPrefix); e != nil {
return e
}
return nil
return validateDNSName(m.DNSPrefix)
}

// Validate implements APIObject
Expand Down Expand Up @@ -63,10 +60,7 @@ func (l *LinuxProfile) Validate() error {
if len(l.SSH.PublicKeys) != 1 {
return errors.New("LinuxProfile.PublicKeys requires only 1 SSH Key")
}
if e := validateName(l.SSH.PublicKeys[0].KeyData, "LinuxProfile.PublicKeys.KeyData"); e != nil {
return e
}
return nil
return validateName(l.SSH.PublicKeys[0].KeyData, "LinuxProfile.PublicKeys.KeyData")
}

// Validate implements APIObject
Expand Down
10 changes: 2 additions & 8 deletions pkg/api/v20160930/validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,7 @@ func (m *MasterProfile) Validate() error {
if e := validateName(m.DNSPrefix, "MasterProfile.DNSPrefix"); e != nil {
return e
}
if e := validateDNSName(m.DNSPrefix); e != nil {
return e
}
return nil
return validateDNSName(m.DNSPrefix)
}

// Validate implements APIObject
Expand Down Expand Up @@ -71,10 +68,7 @@ func (l *LinuxProfile) Validate() error {
if len(l.SSH.PublicKeys) != 1 {
return errors.New("LinuxProfile.PublicKeys requires only 1 SSH Key")
}
if e := validateName(l.SSH.PublicKeys[0].KeyData, "LinuxProfile.PublicKeys.KeyData"); e != nil {
return e
}
return nil
return validateName(l.SSH.PublicKeys[0].KeyData, "LinuxProfile.PublicKeys.KeyData")
}

// Validate implements APIObject
Expand Down
15 changes: 3 additions & 12 deletions pkg/api/v20170131/validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,7 @@ func (m *MasterProfile) Validate() error {
if e := validateName(m.DNSPrefix, "MasterProfile.DNSPrefix"); e != nil {
return e
}
if e := validateDNSName(m.DNSPrefix); e != nil {
return e
}
return nil
return validateDNSName(m.DNSPrefix)
}

// Validate implements APIObject
Expand Down Expand Up @@ -72,10 +69,7 @@ func (l *LinuxProfile) Validate() error {
if len(l.SSH.PublicKeys) != 1 {
return errors.New("LinuxProfile.PublicKeys requires only 1 SSH Key")
}
if e := validateName(l.SSH.PublicKeys[0].KeyData, "LinuxProfile.PublicKeys.KeyData"); e != nil {
return e
}
return nil
return validateName(l.SSH.PublicKeys[0].KeyData, "LinuxProfile.PublicKeys.KeyData")
}

// Validate implements APIObject
Expand Down Expand Up @@ -132,10 +126,7 @@ func (a *Properties) Validate() error {
if e := a.LinuxProfile.Validate(); e != nil {
return e
}
if e := a.OrchestratorProfile.Validate(); e != nil {
return e
}
return nil
return a.OrchestratorProfile.Validate()
}

func validateNameEmpty(name string, label string) error {
Expand Down
5 changes: 1 addition & 4 deletions pkg/api/v20170701/validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -192,10 +192,7 @@ func (a *Properties) Validate(isUpdate bool) error {
if e := a.LinuxProfile.Validate(); e != nil {
return e
}
if e := validateVNET(a); e != nil {
return e
}
return nil
return validateVNET(a)
}

func validatePoolName(poolName string) error {
Expand Down
10 changes: 2 additions & 8 deletions pkg/api/vlabs/validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -395,10 +395,7 @@ func (l *LinuxProfile) Validate() error {
if e := validate.Var(l.SSH.PublicKeys[0].KeyData, "required"); e != nil {
return fmt.Errorf("KeyData in LinuxProfile.SSH.PublicKeys cannot be empty string")
}
if e := validateKeyVaultSecrets(l.Secrets, false); e != nil {
return e
}
return nil
return validateKeyVaultSecrets(l.Secrets, false)
}

func handleValidationErrors(e validator.ValidationErrors) error {
Expand All @@ -416,10 +413,7 @@ func (w *WindowsProfile) Validate() error {
if e := validate.Var(w.AdminPassword, "required"); e != nil {
return fmt.Errorf("WindowsProfile.AdminPassword is required, when agent pool specifies windows")
}
if e := validateKeyVaultSecrets(w.Secrets, true); e != nil {
return e
}
return nil
return validateKeyVaultSecrets(w.Secrets, true)
}

// Validate implements APIObject
Expand Down
6 changes: 1 addition & 5 deletions pkg/operations/kubernetesupgrade/upgrader.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,7 @@ func (ku *Upgrader) RunUpgrade() error {
return err
}

if err := ku.upgradeAgentPools(); err != nil {
return err
}

return nil
return ku.upgradeAgentPools()
}

// Validate will run validation post upgrade
Expand Down