Skip to content

Commit

Permalink
feat(utils): add helper for creating a byte array pointer (#173)
Browse files Browse the repository at this point in the history
We have pointer-creation functions for a few other types. There is now a need to have a function like
this for byte arrays within our generated Terraform code, so I've added it alongside the
others.

Signed-off-by: Dustin Popp <dpopp07@gmail.com>
  • Loading branch information
dpopp07 committed Jan 10, 2023
1 parent 576e686 commit df9dcc6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
5 changes: 5 additions & 0 deletions v5/core/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,11 @@ func UUIDPtr(literal strfmt.UUID) *strfmt.UUID {
return &literal
}

// ByteArrayPtr returns a pointer to []byte literal.
func ByteArrayPtr(literal []byte) *[]byte {
return &literal
}

// IsJSONMimeType Returns true iff the specified mimeType value represents a
// "JSON" mimetype.
func IsJSONMimeType(mimeType string) bool {
Expand Down
3 changes: 3 additions & 0 deletions v5/core/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,9 @@ func TestPointers(t *testing.T) {

var uuidVar = strfmt.UUID("12345678-1234-1234-1234-123456123456")
assert.Equal(t, &uuidVar, UUIDPtr(uuidVar))

var byteArrayVar = []byte(str)
assert.Equal(t, &byteArrayVar, ByteArrayPtr(byteArrayVar))
}

func TestConvertSliceFloat64(t *testing.T) {
Expand Down

0 comments on commit df9dcc6

Please sign in to comment.