Skip to content

Commit

Permalink
Better tag structs and rip out RepositoryTagConnection (#248)
Browse files Browse the repository at this point in the history
* set alias omitempty

* changie

* taggable constructors

* don't need constructors use reflection

* remove unnecessary repository tag connection

* changie
  • Loading branch information
taimoor ahmad authored Sep 15, 2023
1 parent f0428d0 commit c305d10
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
3 changes: 3 additions & 0 deletions .changes/unreleased/Bugfix-20230913-180221.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
kind: Bugfix
body: fix using alias only to create a tag
time: 2023-09-13T18:02:21.120286-04:00
3 changes: 3 additions & 0 deletions .changes/unreleased/Deprecated-20230914-180537.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
kind: Deprecated
body: removed RepositoryTagConnection since TagConnection already exists
time: 2023-09-14T18:05:37.573959-04:00
16 changes: 5 additions & 11 deletions repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ type Repository struct {
Private bool
RepoKey string
Services *RepositoryServiceConnection
Tags *RepositoryTagConnection
Tags *TagConnection
Tier Tier
Type string
Url string
Expand Down Expand Up @@ -93,12 +93,6 @@ type ServiceRepositoryConnection struct {
TotalCount int
}

type RepositoryTagConnection struct {
Nodes []Tag
PageInfo PageInfo
TotalCount int
}

type ServiceRepositoryCreateInput struct {
Service IdentifierInput `json:"service"`
Repository IdentifierInput `json:"repository"`
Expand Down Expand Up @@ -137,7 +131,7 @@ func (r *Repository) Hydrate(client *Client) error {
}

if r.Tags == nil {
r.Tags = &RepositoryTagConnection{}
r.Tags = &TagConnection{}
}
if r.Tags.PageInfo.HasNextPage {
variables := client.InitialPageVariablesPointer()
Expand Down Expand Up @@ -184,11 +178,11 @@ func (r *Repository) GetServices(client *Client, variables *PayloadVariables) (*
return r.Services, nil
}

func (r *Repository) GetTags(client *Client, variables *PayloadVariables) (*RepositoryTagConnection, error) {
func (r *Repository) GetTags(client *Client, variables *PayloadVariables) (*TagConnection, error) {
var q struct {
Account struct {
Repository struct {
Tags RepositoryTagConnection `graphql:"tags(after: $after, first: $first)"`
Tags TagConnection `graphql:"tags(after: $after, first: $first)"`
} `graphql:"repository(id: $id)"`
}
}
Expand All @@ -203,7 +197,7 @@ func (r *Repository) GetTags(client *Client, variables *PayloadVariables) (*Repo
return nil, err
}
if r.Tags == nil {
r.Tags = &RepositoryTagConnection{}
r.Tags = &TagConnection{}
}
r.Tags.Nodes = append(r.Tags.Nodes, q.Account.Repository.Tags.Nodes...)
r.Tags.PageInfo = q.Account.Repository.Tags.PageInfo
Expand Down
2 changes: 1 addition & 1 deletion tags.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ type TagAssignInput struct {
}

type TagCreateInput struct {
Id ID `json:"id"`
Id ID `json:"id,omitempty"`
Alias string `json:"alias,omitempty"`
Type TaggableResource `json:"type,omitempty"`
Key string `json:"key"`
Expand Down

0 comments on commit c305d10

Please sign in to comment.