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

clusterlogging: adjust return consistency #817

Merged
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
14 changes: 7 additions & 7 deletions pkg/clusterlogging/clusterlogforwarder.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,16 @@ func NewClusterLogForwarderBuilder(
glog.V(100).Infof("The name of the clusterlogforwarder is empty")

builder.errorMsg = "clusterlogforwarder 'name' cannot be empty"

return builder
}

if nsname == "" {
glog.V(100).Infof("The namespace of the clusterlogforwarder is empty")

builder.errorMsg = "clusterlogforwarder 'nsname' cannot be empty"

return builder
}

return builder
Expand All @@ -83,9 +87,7 @@ func (builder *ClusterLogForwarderBuilder) WithOutput(outputSpec *clov1.OutputSp
glog.V(100).Infof("The 'outputSpec' of the deployment is empty")

builder.errorMsg = "'outputSpec' parameter is empty"
}

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

Expand All @@ -111,9 +113,7 @@ func (builder *ClusterLogForwarderBuilder) WithPipeline(pipelineSpec *clov1.Pipe
glog.V(100).Infof("The 'pipelineSpec' of the deployment is empty")

builder.errorMsg = "'pipelineSpec' parameter is empty"
}

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

Expand Down Expand Up @@ -143,7 +143,7 @@ func PullClusterLogForwarder(apiClient *clients.Settings, name, nsname string) (
return nil, err
}

builder := ClusterLogForwarderBuilder{
builder := &ClusterLogForwarderBuilder{
apiClient: apiClient.Client,
Definition: &clov1.ClusterLogForwarder{
ObjectMeta: metav1.ObjectMeta{
Expand All @@ -169,7 +169,7 @@ func PullClusterLogForwarder(apiClient *clients.Settings, name, nsname string) (
return nil, fmt.Errorf("clusterlogforwarder object %s does not exist in namespace %s", name, nsname)
}

return &builder, nil
return builder, nil
}

// Get returns clusterlogforwarder object if found.
Expand All @@ -191,7 +191,7 @@ func (builder *ClusterLogForwarderBuilder) Get() (*clov1.ClusterLogForwarder, er
return nil, err
}

return clusterLogForwarder, err
return clusterLogForwarder, nil
}

// Create makes a clusterlogforwarder in the cluster and stores the created object in struct.
Expand Down
14 changes: 9 additions & 5 deletions pkg/clusterlogging/clusterlogging.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,16 @@ func NewBuilder(
glog.V(100).Infof("The name of the clusterLogging is empty")

builder.errorMsg = "the clusterLogging 'name' cannot be empty"

return builder
}

if nsname == "" {
glog.V(100).Infof("The namespace of the clusterLogging is empty")

builder.errorMsg = "the clusterLogging 'nsname' cannot be empty"

return builder
}

return builder
Expand All @@ -91,7 +95,7 @@ func Pull(apiClient *clients.Settings, name, nsname string) (*Builder, error) {
return nil, err
}

builder := Builder{
builder := &Builder{
apiClient: apiClient.Client,
Definition: &clov1.ClusterLogging{
ObjectMeta: metav1.ObjectMeta{
Expand Down Expand Up @@ -119,7 +123,7 @@ func Pull(apiClient *clients.Settings, name, nsname string) (*Builder, error) {

builder.Definition = builder.Object

return &builder, nil
return builder, nil
}

// Get returns clusterLogging object if found.
Expand All @@ -141,7 +145,7 @@ func (builder *Builder) Get() (*clov1.ClusterLogging, error) {
return nil, err
}

return clusterLogging, err
return clusterLogging, nil
}

// Create makes a clusterLogging in the cluster and stores the created object in struct.
Expand Down Expand Up @@ -348,13 +352,13 @@ func (builder *Builder) validate() (bool, error) {
if builder.Definition == nil {
glog.V(100).Infof("The %s is undefined", resourceCRD)

builder.errorMsg = msg.UndefinedCrdObjectErrString(resourceCRD)
return false, fmt.Errorf(msg.UndefinedCrdObjectErrString(resourceCRD))
}

if builder.apiClient == nil {
glog.V(100).Infof("The %s builder apiclient is nil", resourceCRD)

builder.errorMsg = fmt.Sprintf("%s builder cannot have nil apiClient", resourceCRD)
return false, fmt.Errorf("%s builder cannot have nil apiClient", resourceCRD)
}

if builder.errorMsg != "" {
Expand Down
8 changes: 6 additions & 2 deletions pkg/clusterlogging/elasticsearch.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,16 @@ func NewElasticsearchBuilder(
glog.V(100).Infof("The name of the elasticsearch is empty")

builder.errorMsg = "elasticsearch 'name' cannot be empty"

return builder
}

if nsname == "" {
glog.V(100).Infof("The nsname of the elasticsearch is empty")

builder.errorMsg = "elasticsearch 'nsname' cannot be empty"

return builder
}

return builder
Expand All @@ -87,7 +91,7 @@ func PullElasticsearch(apiClient *clients.Settings, name, nsname string) (*Elast
return nil, err
}

builder := ElasticsearchBuilder{
builder := &ElasticsearchBuilder{
apiClient: apiClient.Client,
Definition: &eskv1.Elasticsearch{
ObjectMeta: metav1.ObjectMeta{
Expand Down Expand Up @@ -115,7 +119,7 @@ func PullElasticsearch(apiClient *clients.Settings, name, nsname string) (*Elast

builder.Definition = builder.Object

return &builder, nil
return builder, nil
}

// Get returns elasticsearch object if found.
Expand Down
8 changes: 6 additions & 2 deletions pkg/clusterlogging/lokistack.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,16 @@ func NewLokiStackBuilder(
glog.V(100).Infof("The name of the lokiStack is empty")

builder.errorMsg = "lokiStack 'name' cannot be empty"

return builder
}

if nsname == "" {
glog.V(100).Infof("The nsname of the lokiStack is empty")

builder.errorMsg = "lokiStack 'nsname' cannot be empty"

return builder
}

return builder
Expand All @@ -91,7 +95,7 @@ func PullLokiStack(apiClient *clients.Settings, name, nsname string) (*LokiStack
return nil, err
}

builder := LokiStackBuilder{
builder := &LokiStackBuilder{
apiClient: apiClient.Client,
Definition: &lokiv1.LokiStack{
ObjectMeta: metav1.ObjectMeta{
Expand Down Expand Up @@ -119,7 +123,7 @@ func PullLokiStack(apiClient *clients.Settings, name, nsname string) (*LokiStack

builder.Definition = builder.Object

return &builder, nil
return builder, nil
}

// Get returns lokiStack object if found.
Expand Down
Loading