Skip to content

Commit

Permalink
Use internal pointer function (#26)
Browse files Browse the repository at this point in the history
  • Loading branch information
jlsherrill authored Aug 7, 2024
1 parent 13c3c39 commit ece9714
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 10 deletions.
1 change: 0 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ require (
github.com/ProtonMail/go-crypto v1.0.0
github.com/h2non/filetype v1.1.3
github.com/klauspost/compress v1.17.9
github.com/openlyinc/pointy v1.2.1
github.com/stretchr/testify v1.9.0
github.com/ulikunitz/xz v0.5.12
)
Expand Down
2 changes: 0 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ github.com/h2non/filetype v1.1.3 h1:FKkx9QbD7HR/zjK1Ia5XiBsq9zdLi5Kf3zGyFTAFkGg=
github.com/h2non/filetype v1.1.3/go.mod h1:319b3zT68BvV+WRj7cwy856M2ehB3HqNOt6sy1HndBY=
github.com/klauspost/compress v1.17.9 h1:6KIumPrER1LHsvBVuDa0r5xaG0Es51mhhB9BQB2qeMA=
github.com/klauspost/compress v1.17.9/go.mod h1:Di0epgTjJY877eYKx5yC51cX2A2Vl2ibi7bDH9ttBbw=
github.com/openlyinc/pointy v1.2.1 h1:36XcmSacGqyhP5C0+F+dGX0Szg74gKb8Jmvwd7gXlbo=
github.com/openlyinc/pointy v1.2.1/go.mod h1:ZY7giWW1RTb16UU+CG43tgRPtQkg8QCgxrJi13Xbv6I=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/stretchr/objx v0.5.2 h1:xuMeJ0Sdp5ZMRXx/aWO6RZxdr3beISkG5/G/aIRr3pY=
Expand Down
5 changes: 2 additions & 3 deletions pkg/yum/repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import (
"github.com/h2non/filetype"
"github.com/h2non/filetype/matchers"
"github.com/klauspost/compress/zstd"
"github.com/openlyinc/pointy"
"github.com/ulikunitz/xz"
)

Expand Down Expand Up @@ -120,7 +119,7 @@ func NewRepository(settings YummySettings) (Repository, error) {
return Repository{}, fmt.Errorf("url cannot be nil")
}
if settings.MaxXmlSize == nil {
settings.MaxXmlSize = pointy.Pointer(DefaultMaxXmlSize)
settings.MaxXmlSize = Ptr(DefaultMaxXmlSize)
}
return Repository{settings: settings}, nil
}
Expand Down Expand Up @@ -372,7 +371,7 @@ func (r *Repository) getCompsURL() (*string, error) {
return nil, err
}
url.Path = path.Join(url.Path, compsLocation)
return pointy.Pointer(url.String()), nil
return Ptr(url.String()), nil
}

func (r *Repository) getSignatureURL() (string, error) {
Expand Down
7 changes: 3 additions & 4 deletions pkg/yum/repository_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import (
"testing"
"time"

"github.com/openlyinc/pointy"
"github.com/stretchr/testify/assert"
)

Expand Down Expand Up @@ -84,7 +83,7 @@ func TestGetPrimaryURL(t *testing.T) {
xmlFile, err := os.Open("mocks/repomd.xml")
assert.Nil(t, err)
settings := YummySettings{
URL: pointy.String("http://foo.example.com/repo/"),
URL: Ptr("http://foo.example.com/repo/"),
}
r, err := NewRepository(settings)
assert.Nil(t, err)
Expand Down Expand Up @@ -168,7 +167,7 @@ func TestGetCompsURL(t *testing.T) {
xmlFile, err := os.Open("mocks/repomd.xml")
assert.Nil(t, err)
settings := YummySettings{
URL: pointy.String("http://foo.example.com/repo/"),
URL: Ptr("http://foo.example.com/repo/"),
}
r, err := NewRepository(settings)

Expand All @@ -186,7 +185,7 @@ func TestGetCompsURL(t *testing.T) {
assert.Nil(t, err)

settings = YummySettings{
URL: pointy.String("http://foo.example.com/repo/"),
URL: Ptr("http://foo.example.com/repo/"),
}
r, err = NewRepository(settings)
assert.Nil(t, err)
Expand Down
6 changes: 6 additions & 0 deletions pkg/yum/utils.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package yum

// Converts any struct to a pointer to that struct
func Ptr[T any](item T) *T {
return &item
}

0 comments on commit ece9714

Please sign in to comment.