73eae98929
schemas / vulnerabilities (pull_request) Successful in 2m15s
schemas / check-release (pull_request) Successful in 2m17s
schemas / check (pull_request) Successful in 4m48s
pre-commit / pre-commit (pull_request) Successful in 5m58s
schemas / build (pull_request) Successful in 3m36s
schemas / deploy-prod (pull_request) Has been skipped
- Update git remote to git.unbound.se - Add Gitea workflows: ci.yaml, pre-commit.yaml, release.yaml, goreleaser.yaml - Delete .gitlab-ci.yml - Update Go module path to gitea.unbound.se/unboundsoftware/schemas - Update all imports to new module path - Update Docker registry to oci.unbound.se - Update .goreleaser.yml for Gitea releases with internal cluster URL - Remove GitLab CI linter from pre-commit config - Use shared release workflow with tag_only for versioning Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
50 lines
1.2 KiB
Go
50 lines
1.2 KiB
Go
package graph
|
|
|
|
import (
|
|
"gitea.unbound.se/unboundsoftware/schemas/domain"
|
|
"gitea.unbound.se/unboundsoftware/schemas/graph/model"
|
|
)
|
|
|
|
func ToGqlOrganizations(orgs []domain.Organization) []*model.Organization {
|
|
result := make([]*model.Organization, len(orgs))
|
|
for i, o := range orgs {
|
|
result[i] = ToGqlOrganization(o)
|
|
}
|
|
return result
|
|
}
|
|
|
|
func ToGqlOrganization(o domain.Organization) *model.Organization {
|
|
users := ToGqlUsers(o.Users)
|
|
apiKeys := ToGqlAPIKeys(o.APIKeys)
|
|
return &model.Organization{
|
|
ID: o.ID.String(),
|
|
Name: o.Name,
|
|
Users: users,
|
|
APIKeys: apiKeys,
|
|
}
|
|
}
|
|
|
|
func ToGqlUsers(users []string) []*model.User {
|
|
result := make([]*model.User, len(users))
|
|
for i, u := range users {
|
|
result[i] = &model.User{ID: u}
|
|
}
|
|
return result
|
|
}
|
|
|
|
func ToGqlAPIKeys(keys []domain.APIKey) []*model.APIKey {
|
|
result := make([]*model.APIKey, len(keys))
|
|
for i, k := range keys {
|
|
result[i] = &model.APIKey{
|
|
ID: apiKeyId(k.OrganizationId, k.Name),
|
|
Name: k.Name,
|
|
Key: nil, // Never return the hashed key - only return plaintext on creation
|
|
Organization: nil,
|
|
Refs: k.Refs,
|
|
Read: k.Read,
|
|
Publish: k.Publish,
|
|
}
|
|
}
|
|
return result
|
|
}
|