Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better tag structs and rip out RepositoryTagConnection #248

Merged
6 commits merged into from
Sep 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading