Repository: xanzy/go-gitlab
Pull request #1305 (2021-12-02 23:08:00)

Added missing FilePath and LinkType to ReleaseAssetLink
See: https://docs.gitlab.com/ee/api/releases/#create-a-release


Patch:
diff --git a/releases.go b/releases.go
index 0059fbb..5140a60 100644
--- a/releases.go
+++ b/releases.go
@@ -116,35 +116,38 @@ func (s *ReleasesService) GetRelease(pid interface{}, tagName string, options ..
 	return r, resp, err
 }
 
-// ReleaseAssets represents release assets in CreateRelease() options
+// CreateReleaseOptions represents CreateRelease() options.
 //
 // GitLab API docs:
 // https://docs.gitlab.com/ce/api/releases/index.html#create-a-release
-type ReleaseAssets struct {
-	Links []*ReleaseAssetLink `url:"links" json:"links"`
+type CreateReleaseOptions struct {
+	Name        *string               `url:"name" json:"name"`
+	TagName     *string               `url:"tag_name" json:"tag_name"`
+	Description *string               `url:"description" json:"description"`
+	Ref         *string               `url:"ref,omitempty" json:"ref,omitempty"`
+	Milestones  []string              `url:"milestones,omitempty" json:"milestones,omitempty"`
+	Assets      *ReleaseAssetsOptions `url:"assets,omitempty" json:"assets,omitempty"`
+	ReleasedAt  *time.Time            `url:"released_at,omitempty" json:"released_at,omitempty"`
 }
 
-// ReleaseAssetLink represents release asset link in CreateRelease() options
+// ReleaseAssetsOptions represents release assets in CreateRelease() options.
 //
 // GitLab API docs:
 // https://docs.gitlab.com/ce/api/releases/index.html#create-a-release
-type ReleaseAssetLink struct {
-	Name string `url:"name" json:"name"`
-	URL  string `url:"url" json:"url"`
+type ReleaseAssetsOptions struct {
+	Links []*ReleaseAssetLinkOptions `url:"links,omitempty" json:"links,omitempty"`
 }
 
-// CreateReleaseOptions represents CreateRelease() options.
+// ReleaseAssetLinkOptions represents release asset link in CreateRelease()
+// options.
 //
 // GitLab API docs:
 // https://docs.gitlab.com/ce/api/releases/index.html#create-a-release
-type CreateReleaseOptions struct {
-	Name        *string        `url:"name" json:"name"`
-	TagName     *string        `url:"tag_name" json:"tag_name"`
-	Description *string        `url:"description" json:"description"`
-	Ref         *string        `url:"ref,omitempty" json:"ref,omitempty"`
-	Milestones  []string       `url:"milestones,omitempty" json:"milestones,omitempty"`
-	Assets      *ReleaseAssets `url:"assets,omitempty" json:"assets,omitempty"`
-	ReleasedAt  *time.Time     `url:"released_at,omitempty" json:"released_at,omitempty"`
+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"`
 }
 
 // CreateRelease creates a release.


Test patch:
diff --git a/releases_test.go b/releases_test.go
index 69e2206..a45fc38 100644
--- a/releases_test.go
+++ b/releases_test.go
@@ -143,9 +143,9 @@ func TestReleasesService_CreateReleaseWithAsset(t *testing.T) {
 		Name:        String("name"),
 		TagName:     String(exampleTagName),
 		Description: String("Description"),
-		Assets: &ReleaseAssets{
-			Links: []*ReleaseAssetLink{
-				{"sldkf", "sldkfj"},
+		Assets: &ReleaseAssetsOptions{
+			Links: []*ReleaseAssetLinkOptions{
+				{String("sldkf"), String("sldkfj"), String("sldkfh"), LinkType(OtherLinkType)},
 			},
 		},
 	}
@@ -193,9 +193,9 @@ func TestReleasesService_CreateReleaseWithAssetAndNameMetadata(t *testing.T) {
 		Name:        String("name"),
 		TagName:     String(exampleTagNameWithMetadata),
 		Description: String("Description"),
-		Assets: &ReleaseAssets{
-			Links: []*ReleaseAssetLink{
-				{"sldkf", "sldkfj"},
+		Assets: &ReleaseAssetsOptions{
+			Links: []*ReleaseAssetLinkOptions{
+				{String("sldkf"), String("sldkfj"), String("sldkfh"), LinkType(OtherLinkType)},
 			},
 		},
 	}