Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

metallb: adjust return consistency #843

Merged
merged 1 commit into from
Jan 3, 2025
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
metallb: adjust return consistency
  • Loading branch information
sebrandon1 committed Jan 3, 2025
commit cc423be28e7ade45f7c6f56055bf0fcea9842536
7 changes: 2 additions & 5 deletions pkg/metallb/addresspool.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,9 +180,8 @@ func (builder *IPAddressPoolBuilder) Create() (*IPAddressPoolBuilder, error) {
builder.Definition.Name, builder.Definition.Namespace,
)

var err error
if !builder.Exists() {
err = builder.apiClient.Create(context.TODO(), builder.Definition)
err := builder.apiClient.Create(context.TODO(), builder.Definition)
if err != nil {
glog.V(100).Infof("Failed to create IPAddressPool")

Expand All @@ -192,7 +191,7 @@ func (builder *IPAddressPoolBuilder) Create() (*IPAddressPoolBuilder, error) {

builder.Object = builder.Definition

return builder, err
return builder, nil
}

// Delete removes IPAddressPool object from a cluster.
Expand Down Expand Up @@ -304,9 +303,7 @@ func (builder *IPAddressPoolBuilder) WithOptions(options ...IPAddressPoolAdditio
glog.V(100).Infof("The IPAddressPool is undefined")

builder.errorMsg = msg.UndefinedCrdObjectErrString("IPAddressPool")
}

if builder.errorMsg != "" {
return builder
}

Expand Down
4 changes: 4 additions & 0 deletions pkg/metallb/bfdprofile.go
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,8 @@ func (builder *BFDBuilder) withBoolFlagFor(flagName string, flagValue bool) *BFD
builder.Definition.Spec.PassiveMode = &flagValue
default:
builder.errorMsg = "invalid bool flag name parameter"

return builder
}

return builder
Expand All @@ -377,6 +379,8 @@ func (builder *BFDBuilder) withInterval(intervalName string, interval uint32) *B
builder.Definition.Spec.EchoInterval = &interval
default:
builder.errorMsg = "invalid interval parameters"

return builder
}

return builder
Expand Down
5 changes: 2 additions & 3 deletions pkg/metallb/bgpadvertisement.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,9 +168,8 @@ func (builder *BGPAdvertisementBuilder) Create() (*BGPAdvertisementBuilder, erro
builder.Definition.Name, builder.Definition.Namespace,
)

var err error
if !builder.Exists() {
err = builder.apiClient.Create(context.TODO(), builder.Definition)
err := builder.apiClient.Create(context.TODO(), builder.Definition)

if err != nil {
glog.V(100).Infof("Failed to create BGPAdvertisement")
Expand All @@ -181,7 +180,7 @@ func (builder *BGPAdvertisementBuilder) Create() (*BGPAdvertisementBuilder, erro

builder.Object = builder.Definition

return builder, err
return builder, nil
}

// Delete removes BGPAdvertisement object from a cluster.
Expand Down
5 changes: 2 additions & 3 deletions pkg/metallb/bgppeer.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,16 +184,15 @@ func (builder *BGPPeerBuilder) Create() (*BGPPeerBuilder, error) {
builder.Definition.Name, builder.Definition.Namespace,
)

var err error
if !builder.Exists() {
err = builder.apiClient.Create(context.TODO(), builder.Definition)
err := builder.apiClient.Create(context.TODO(), builder.Definition)

if err == nil {
builder.Object = builder.Definition
}
}

return builder, err
return builder, nil
}

// Delete removes BGPPeer object from a cluster.
Expand Down
5 changes: 2 additions & 3 deletions pkg/metallb/metallb.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,16 +184,15 @@ func (builder *Builder) Create() (*Builder, error) {
builder.Definition.Name, builder.Definition.Namespace,
)

var err error
if !builder.Exists() {
err = builder.apiClient.Create(context.TODO(), builder.Definition)
err := builder.apiClient.Create(context.TODO(), builder.Definition)

if err == nil {
builder.Object = builder.Definition
}
}

return builder, err
return builder, nil
}

// Delete removes MetalLb object from a cluster.
Expand Down
Loading