Skip to content

Commit

Permalink
Merge pull request #1918 from timofurrer/release-assets-links-direct-…
Browse files Browse the repository at this point in the history
…asset-path

Implement DirectAssetPath for Release Assets Links
  • Loading branch information
svanharmelen committed Apr 18, 2024
2 parents 4224c3d + a070b1a commit a84a69d
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 21 deletions.
18 changes: 10 additions & 8 deletions releaselinks.go
Expand Up @@ -101,10 +101,11 @@ func (s *ReleaseLinksService) GetReleaseLink(pid interface{}, tagName string, li
//
// GitLab API docs: https://docs.gitlab.com/ee/api/releases/links.html#create-a-release-link
type CreateReleaseLinkOptions struct {
Name *string `url:"name,omitempty" json:"name,omitempty"`
URL *string `url:"url,omitempty" json:"url,omitempty"`
FilePath *string `url:"filepath,omitempty" json:"filepath,omitempty"`
LinkType *LinkTypeValue `url:"link_type,omitempty" json:"link_type,omitempty"`
Name *string `url:"name,omitempty" json:"name,omitempty"`
URL *string `url:"url,omitempty" json:"url,omitempty"`
FilePath *string `url:"filepath,omitempty" json:"filepath,omitempty"`
DirectAssetPath *string `url:"direct_asset_path,omitempty" json:"direct_asset_path,omitempty"`
LinkType *LinkTypeValue `url:"link_type,omitempty" json:"link_type,omitempty"`
}

// CreateReleaseLink creates a link.
Expand Down Expand Up @@ -137,10 +138,11 @@ func (s *ReleaseLinksService) CreateReleaseLink(pid interface{}, tagName string,
//
// GitLab API docs: https://docs.gitlab.com/ee/api/releases/links.html#update-a-release-link
type UpdateReleaseLinkOptions struct {
Name *string `url:"name,omitempty" json:"name,omitempty"`
URL *string `url:"url,omitempty" json:"url,omitempty"`
FilePath *string `url:"filepath,omitempty" json:"filepath,omitempty"`
LinkType *LinkTypeValue `url:"link_type,omitempty" json:"link_type,omitempty"`
Name *string `url:"name,omitempty" json:"name,omitempty"`
URL *string `url:"url,omitempty" json:"url,omitempty"`
FilePath *string `url:"filepath,omitempty" json:"filepath,omitempty"`
DirectAssetPath *string `url:"direct_asset_path,omitempty" json:"direct_asset_path,omitempty"`
LinkType *LinkTypeValue `url:"link_type,omitempty" json:"link_type,omitempty"`
}

// UpdateReleaseLink updates an asset link.
Expand Down
14 changes: 7 additions & 7 deletions releaselinks_test.go
Expand Up @@ -87,10 +87,10 @@ func TestReleaseLinksService_CreateReleaseLink(t *testing.T) {
{
description: "Optional Attributes",
options: &CreateReleaseLinkOptions{
Name: Ptr("release-notes.md"),
URL: Ptr("http://192.168.10.15:3000"),
FilePath: Ptr("docs/release-notes.md"),
LinkType: Ptr(OtherLinkType),
Name: Ptr("release-notes.md"),
URL: Ptr("http://192.168.10.15:3000"),
DirectAssetPath: Ptr("docs/release-notes.md"),
LinkType: Ptr(OtherLinkType),
},
response: `{
"id":1,
Expand Down Expand Up @@ -159,9 +159,9 @@ func TestReleaseLinksService_UpdateReleaseLink(t *testing.T) {
releaseLink, _, err := client.ReleaseLinks.UpdateReleaseLink(
1, exampleTagName, 1,
&UpdateReleaseLinkOptions{
Name: Ptr(exampleReleaseName),
FilePath: Ptr("http://192.168.10.15:3000/namespace/example/-/releases/v0.1/downloads/awesome-v0.2.dmg"),
LinkType: Ptr(OtherLinkType),
Name: Ptr(exampleReleaseName),
DirectAssetPath: Ptr("http://192.168.10.15:3000/namespace/example/-/releases/v0.1/downloads/awesome-v0.2.dmg"),
LinkType: Ptr(OtherLinkType),
})

require.NoError(t, err)
Expand Down
9 changes: 5 additions & 4 deletions releases.go
Expand Up @@ -187,10 +187,11 @@ type ReleaseAssetsOptions struct {
// GitLab API docs:
// https://docs.gitlab.com/ee/api/releases/index.html#create-a-release
type ReleaseAssetLinkOptions struct {
Name *string `url:"name,omitempty" json:"name,omitempty"`
URL *string `url:"url,omitempty" json:"url,omitempty"`
FilePath *string `url:"filepath,omitempty" json:"filepath,omitempty"`
LinkType *LinkTypeValue `url:"link_type,omitempty" json:"link_type,omitempty"`
Name *string `url:"name,omitempty" json:"name,omitempty"`
URL *string `url:"url,omitempty" json:"url,omitempty"`
FilePath *string `url:"filepath,omitempty" json:"filepath,omitempty"`
DirectAssetPath *string `url:"direct_asset_path,omitempty" json:"direct_asset_path,omitempty"`
LinkType *LinkTypeValue `url:"link_type,omitempty" json:"link_type,omitempty"`
}

// CreateRelease creates a release.
Expand Down
4 changes: 2 additions & 2 deletions releases_test.go
Expand Up @@ -141,7 +141,7 @@ func TestReleasesService_CreateReleaseWithAsset(t *testing.T) {
Description: Ptr("Description"),
Assets: &ReleaseAssetsOptions{
Links: []*ReleaseAssetLinkOptions{
{Ptr("sldkf"), Ptr("sldkfj"), Ptr("sldkfh"), Ptr(OtherLinkType)},
{Ptr("sldkf"), Ptr("sldkfj"), Ptr("sldkfh"), Ptr("direct-asset-path"), Ptr(OtherLinkType)},
},
},
}
Expand Down Expand Up @@ -190,7 +190,7 @@ func TestReleasesService_CreateReleaseWithAssetAndNameMetadata(t *testing.T) {
Description: Ptr("Description"),
Assets: &ReleaseAssetsOptions{
Links: []*ReleaseAssetLinkOptions{
{Ptr("sldkf"), Ptr("sldkfj"), Ptr("sldkfh"), Ptr(OtherLinkType)},
{Ptr("sldkf"), Ptr("sldkfj"), Ptr("sldkfh"), Ptr("direct-asset-path"), Ptr(OtherLinkType)},
},
},
}
Expand Down

0 comments on commit a84a69d

Please sign in to comment.