Skip to content

Commit

Permalink
fix: remove appending of descriptions from different markers (#56)
Browse files Browse the repository at this point in the history
* fix: remove appending of descriptions from different markers

If there are more than two instances of an identical marker with a
description, an error will be returned because the descriptions are
being appended to one another.  So identical markers throw an error
indicating they are different if there are > 2 instances of the
identical marker.  This fix removes the append.

Signed-off-by: Rich Lander <lander2k2@protonmail.com>

* fix: correct check on descriptions array

Previously, the descriptions array was being checked if nil.  However,
the array of strings is never nil.  It's either an empty array or it has
string values in the array.  Therefore, the descriptions were never
added.

Signed-off-by: Rich Lander <lander2k2@protonmail.com>

* fix: resolve linting error

Signed-off-by: Rich Lander <lander2k2@protonmail.com>

Signed-off-by: Rich Lander <lander2k2@protonmail.com>
  • Loading branch information
lander2k2 authored Sep 23, 2022
1 parent 8c75ef2 commit 5db1fac
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 4 deletions.
4 changes: 2 additions & 2 deletions internal/workload/v1/kinds/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -284,8 +284,8 @@ func (api *APIFields) setCommentsAndDefault(comments []string, sampleVal interfa
api.appendMarkers("+kubebuilder:validation:Required")
}

if comments != nil {
api.Comments = append(api.Comments, comments...)
if len(comments) > 0 {
api.Comments = comments
}
}

Expand Down
2 changes: 0 additions & 2 deletions internal/workload/v1/kinds/api_internal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -665,8 +665,6 @@ func TestAPIFields_setCommentsAndDefault(t *testing.T) {
"(Default: \"string\")",
},
Comments: []string{
"comment1",
"comment2",
"comment3",
"comment4",
},
Expand Down

0 comments on commit 5db1fac

Please sign in to comment.