Skip to content

Commit

Permalink
wip: search teams
Browse files Browse the repository at this point in the history
  • Loading branch information
katallaxie committed Aug 13, 2024
1 parent fe0774d commit 711a7c3
Show file tree
Hide file tree
Showing 22 changed files with 1,159 additions and 270 deletions.
66 changes: 55 additions & 11 deletions api/api.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,6 @@ servers:
description: Development server

tags:
- name: Server
description: |-
These are administrative operations.
- name: Operator
description: |-
These are the operators that manage Typhoon.
Expand All @@ -41,14 +38,48 @@ tags:
- name: System
description: |-
These are the system managed by Typhoon.
- name: Team
description: |-
These are the teams that are using Typhoon.
- name: Triggers
description: |-
These are the triggers that are used to send events to Typhoon.
paths:
/_health:
get:
tags:
- Liveness
summary: Get system health status
operationId: getHealth
responses:
"200":
description: System is healthy
content:
application/json:
schema:
$ref: "#/components/schemas/HealthResponse"
"500":
description: System is down
content:
application/json:
schema:
$ref: "#/components/schemas/HealthResponse"

/_ready:
get:
tags:
- Readiness
summary: Get system readiness
operationId: getReady
responses:
"200":
description: System is ready to accept traffic
content:
application/json:
schema:
$ref: "#/components/schemas/HealthResponse"
"500":
description: System not ready to accept traffic
content:
application/json:
schema:
$ref: "#/components/schemas/HealthResponse"

/version:
get:
summary: Returns the current version of the API.
Expand Down Expand Up @@ -1201,6 +1232,14 @@ components:
name: X-API-Key

schemas:
HealthResponse:
type: object
properties:
status:
type: string
errorMessage:
type: string

NKey:
description: |
An NKey is the private key of a NATS account.
Expand Down Expand Up @@ -1552,6 +1591,11 @@ components:
items:
$ref: "#/components/schemas/Team"

securitySchemes:
openId:
type: http
scheme: bearer # using bearer token
bearerFormat: JWT

security:
- bearerAuth: []
- apiKey: []
- openId: []
59 changes: 51 additions & 8 deletions api/out.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ servers:
- url: http://localhost:8080/api/v1
description: Development server
tags:
- name: Server
description: These are administrative operations.
- name: Operator
description: These are the operators that manage Typhoon.
- name: Account
Expand All @@ -31,11 +29,45 @@ tags:
description: These are the users that manage Typhonn.
- name: System
description: These are the system managed by Typhoon.
- name: Team
description: These are the teams that are using Typhoon.
- name: Triggers
description: These are the triggers that are used to send events to Typhoon.
paths:
/_health:
get:
tags:
- Liveness
summary: Get system health status
operationId: getHealth
responses:
'200':
description: System is healthy
content:
application/json:
schema:
$ref: '#/components/schemas/HealthResponse'
'500':
description: System is down
content:
application/json:
schema:
$ref: '#/components/schemas/HealthResponse'
/_ready:
get:
tags:
- Readiness
summary: Get system readiness
operationId: getReady
responses:
'200':
description: System is ready to accept traffic
content:
application/json:
schema:
$ref: '#/components/schemas/HealthResponse'
'500':
description: System not ready to accept traffic
content:
application/json:
schema:
$ref: '#/components/schemas/HealthResponse'
/version:
get:
summary: Returns the current version of the API.
Expand Down Expand Up @@ -1208,6 +1240,13 @@ components:
in: header
name: X-API-Key
schemas:
HealthResponse:
type: object
properties:
status:
type: string
errorMessage:
type: string
NKey:
description: |
An NKey is the private key of a NATS account.
Expand Down Expand Up @@ -1538,6 +1577,11 @@ components:
type: array
items:
$ref: '#/components/schemas/Team'
securitySchemes:
openId:
type: http
scheme: bearer
bearerFormat: JWT
Error:
type: object
required:
Expand Down Expand Up @@ -1614,5 +1658,4 @@ components:
description: Creation date and time
example: '2021-01-30T08:30:00Z'
security:
- bearerAuth: []
- apiKey: []
- openId: []
8 changes: 4 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,15 @@ require (
github.com/wamuir/go-xslt v0.1.5
github.com/xdg-go/scram v1.0.2
github.com/zeiss/fiber-authz v1.0.33
github.com/zeiss/fiber-goth v1.2.8
github.com/zeiss/fiber-goth v1.2.11
github.com/zeiss/fiber-htmx v1.3.21-0.20240806072406-fcc22017a231
github.com/zeiss/pkg v0.1.7-0.20240802122243-e784cdbbb776
github.com/zeiss/pkg v0.1.7
github.com/zeiss/snow-go v0.0.0-20240312201415-88f059622cff
go.opencensus.io v0.24.0
go.uber.org/zap v1.27.0
golang.org/x/mod v0.19.0
golang.org/x/mod v0.20.0
golang.org/x/net v0.27.0
golang.org/x/oauth2 v0.21.0
golang.org/x/oauth2 v0.22.0
google.golang.org/genproto/googleapis/api v0.0.0-20240604185151-ef581f913117
google.golang.org/protobuf v1.34.1
gorm.io/driver/postgres v1.5.9
Expand Down
18 changes: 10 additions & 8 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1225,14 +1225,14 @@ github.com/yusufpapurcu/wmi v1.2.4 h1:zFUKzehAFReQwLys1b/iSMl+JQGSCSjtVqQn9bBrPo
github.com/yusufpapurcu/wmi v1.2.4/go.mod h1:SBZ9tNy3G9/m5Oi98Zks0QjeHVDvuK0qfxQmPyzfmi0=
github.com/zeiss/fiber-authz v1.0.33 h1:KZnVTxG+VoQLowoCqoMwam/5H4PVu89rn9ZJ2AGOtCE=
github.com/zeiss/fiber-authz v1.0.33/go.mod h1:oVkhY0X9/xFa0Pu3BuEU8ubE7pAQmIjFMUwUGD2pQqc=
github.com/zeiss/fiber-goth v1.2.8 h1:8QoksnNLWD/3BbeCus5LS4eT1+YkDjz85bqYEL8A5iE=
github.com/zeiss/fiber-goth v1.2.8/go.mod h1:tYxywhiORkOUB2gRktCAgwz9i0Y+CTgBEwnQ3QZsAxU=
github.com/zeiss/fiber-htmx v1.3.21-0.20240802131219-e018514d2167 h1:fzK6N9l+q+dD1NOG1NConTfVQL1b5G4+rZeAmavl23o=
github.com/zeiss/fiber-htmx v1.3.21-0.20240802131219-e018514d2167/go.mod h1:Epw8nmQeR61cEAI3mmvBe77vttXRm6AFoUzZog0T8ag=
github.com/zeiss/fiber-goth v1.2.11 h1:24EiIKF1iPrmlspbW/BylcqVyj4Ltwzmx9DM7pRs6R4=
github.com/zeiss/fiber-goth v1.2.11/go.mod h1:9NuXxIeKZgmk3dfl7HWbZK/eAfukvjMCHHacGo0m84Y=
github.com/zeiss/fiber-htmx v1.3.21-0.20240806072406-fcc22017a231 h1:ARsivK9WNdGdvtCYM02+9h+WM8DrKxpzfiX96pI5IXQ=
github.com/zeiss/fiber-htmx v1.3.21-0.20240806072406-fcc22017a231/go.mod h1:Epw8nmQeR61cEAI3mmvBe77vttXRm6AFoUzZog0T8ag=
github.com/zeiss/pkg v0.1.7-0.20240802122243-e784cdbbb776 h1:JrTwqycSklujDywTZiYLtdMkGfc39oo0tfBqj1ngKxI=
github.com/zeiss/pkg v0.1.7-0.20240802122243-e784cdbbb776/go.mod h1:soMcxMxuhfHDni3KGF/diy90dqWhRI2uLNlKHV3IxPk=
github.com/zeiss/pkg v0.1.6 h1:VTbzKg+Yj54swWgTevnNgR7tmEqw5gGwsSsxeSIfwE0=
github.com/zeiss/pkg v0.1.6/go.mod h1:soMcxMxuhfHDni3KGF/diy90dqWhRI2uLNlKHV3IxPk=
github.com/zeiss/pkg v0.1.7 h1:P+kCMcZy/I7JgnXGWv/oidhj/47klSqk7xtF2/t02yc=
github.com/zeiss/pkg v0.1.7/go.mod h1:XQjoOM7oJAp065CC4Cd5lD2AXZ51cL9nYrNjs7mDmI4=
github.com/zeiss/snow-go v0.0.0-20240312201415-88f059622cff h1:IguG+jnCnFyAzZ8Fp+6v2lJNvUFPfu8Q2UUgSFw4doU=
github.com/zeiss/snow-go v0.0.0-20240312201415-88f059622cff/go.mod h1:HvitS/QkqgqhV/bNWxPKn0NjByjTaEACZnNgHKZEuio=
gitlab.com/bosi/decorder v0.4.2 h1:qbQaV3zgwnBZ4zPMhGLW4KZe7A7NwxEhJx39R3shffo=
Expand Down Expand Up @@ -1366,6 +1366,8 @@ golang.org/x/mod v0.7.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
golang.org/x/mod v0.19.0 h1:fEdghXQSo20giMthA7cd28ZC+jts4amQ3YMXiP5oMQ8=
golang.org/x/mod v0.19.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
golang.org/x/mod v0.20.0 h1:utOm6MM3R3dnawAiJgn0y+xvuYRsm1RKM/4giyfDgV0=
golang.org/x/mod v0.20.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
Expand Down Expand Up @@ -1448,8 +1450,8 @@ golang.org/x/oauth2 v0.0.0-20210819190943-2bc19b11175f/go.mod h1:KelEdhl1UZF7XfJ
golang.org/x/oauth2 v0.0.0-20211005180243-6b3c2da341f1/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A=
golang.org/x/oauth2 v0.0.0-20211104180415-d3ed0bb246c8/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A=
golang.org/x/oauth2 v0.0.0-20220223155221-ee480838109b/go.mod h1:DAh4E804XQdzx2j+YRIaUnCqCV2RuMz24cGBJ5QYIrc=
golang.org/x/oauth2 v0.21.0 h1:tsimM75w1tF/uws5rbeHzIWxEqElMehnc+iW793zsZs=
golang.org/x/oauth2 v0.21.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbhtI=
golang.org/x/oauth2 v0.22.0 h1:BzDx2FehcG7jJwgWLELCdmLuxk2i+x9UDpSiss2u0ZA=
golang.org/x/oauth2 v0.22.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbhtI=
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
Expand Down
2 changes: 2 additions & 0 deletions internal/models/operator.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ type Operator struct {
Systems []System `json:"systems" gorm:"foreignKey:OperatorID"`
// SigningKeyGroups is the list of signing key groups the account has.
SigningKeyGroups []SigningKeyGroup `json:"signing_key_groups" gorm:"many2many:operator_signing_key_groups;foreignKey:ID;joinForeignKey:OperatorID;joinReferences:SigningKeyGroupID"`
// Tags are the tags associated with the environment
Tags []Tag `json:"tags" gorm:"many2many:operator_tags;"`
// CreatedAt is the time the operator was created.
CreatedAt time.Time `json:"created_at"`
// UpdatedAt is the time the operator was updated.
Expand Down
4 changes: 2 additions & 2 deletions internal/models/system.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ type System struct {
Operator Operator `json:"operator" gorm:"foreignKey:OperatorID" validate:"-"`
// OperatorID is the operator ID that is associated with the system.
OperatorID uuid.UUID `json:"operator_id" form:"operator_id" validate:"required,uuid"`
// Tags is the tags that are associated with the system.
Tags []*Tag `json:"tags" gorm:"polymorphic:Taggable;polymorphicValue:system;" validate:"-"`
// Tags are the tags associated with the environment
Tags []Tag `json:"tags" gorm:"many2many:system_tags;"`
// CreatedAt is the time the system was created.
CreatedAt time.Time `json:"created_at"`
// UpdatedAt is the time the system was updated.
Expand Down
30 changes: 10 additions & 20 deletions internal/models/tag.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,28 +7,18 @@ import (
"gorm.io/gorm"
)

// TaggableType ...
type TaggableType string

// TaggableType ...
const (
SystemTaggable TaggableType = "system"
)

// Tag is the model for adding tags to resources.
// Tag ...
type Tag struct {
// ID is the unique identifier for the tag.
ID int `json:"id" gorm:"primary_key"`
// Name is the name of the tag.
Name string `json:"name"`
// TaggableID is the unique identifier for the taggable.
TaggableID uuid.UUID `json:"taggable_id"`
// TaggableType is the type of the taggable.
TaggableType TaggableType `json:"taggable_type"`
// CreatedAt is the time the tag was created.
// ID ...
ID uuid.UUID `json:"id" gorm:"type:uuid;primary_key;default:gen_random_uuid()"`
// Name is the tag name.
Name string `json:"name" gorm:"uniqueIndex:idx_name_value"`
// Value is the tag value.
Value string `json:"value" gorm:"uniqueIndex:idx_name_value"`
// CreatedAt ...
CreatedAt time.Time `json:"created_at"`
// UpdatedAt is the time the tag was updated.
// UpdatedAt ...
UpdatedAt time.Time `json:"updated_at"`
// DeletedAt is the time the tag was deleted.
// DeletedAt ...
DeletedAt gorm.DeletedAt `json:"deleted_at"`
}
8 changes: 2 additions & 6 deletions internal/web/components/accounts/accounts-table.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,12 +92,8 @@ func AccountsTable(props AccountsTableProps, children ...htmx.Node) htmx.Node {
),
htmx.A(
htmx.Href("accounts/new"),
buttons.Outline(
buttons.ButtonProps{
ClassNames: htmx.ClassNames{
"btn-sm": true,
},
},
buttons.Button(
buttons.ButtonProps{},
htmx.Text("Create Account"),
),
),
Expand Down
8 changes: 2 additions & 6 deletions internal/web/components/operators/operators-table.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,12 +93,8 @@ func OperatorsTable(props OperatorsTableProps, children ...htmx.Node) htmx.Node
),
htmx.A(
htmx.Href("/operators/new"),
buttons.Outline(
buttons.ButtonProps{
ClassNames: htmx.ClassNames{
"btn-sm": true,
},
},
buttons.Button(
buttons.ButtonProps{},
htmx.Text("Create Operator"),
),
),
Expand Down
9 changes: 7 additions & 2 deletions internal/web/components/page.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ type PageProps struct {
Path string
Boost bool
Children []htmx.Node
Head []htmx.Node
}

// Page is a whole document to output.
Expand All @@ -21,7 +22,7 @@ func Page(props PageProps, children ...htmx.Node) htmx.Node {
Attributes: []htmx.Node{
htmx.DataAttribute("theme", "light"),
},
Head: []htmx.Node{
Head: append([]htmx.Node{
htmx.Link(
htmx.Attribute("href", "https://cdn.jsdelivr.net/npm/daisyui/dist/full.css"),
htmx.Attribute("rel", "stylesheet"),
Expand All @@ -38,7 +39,11 @@ func Page(props PageProps, children ...htmx.Node) htmx.Node {
htmx.Attribute("src", "https://unpkg.com/hyperscript.org@0.9.12"),
htmx.Attribute("type", "application/javascript"),
),
},
htmx.Script(
htmx.Attribute("src", "//unpkg.com/alpinejs"),
htmx.Defer(),
),
}, props.Head...),
},
htmx.Body(
htmx.HxBoost(props.Boost),
Expand Down
8 changes: 2 additions & 6 deletions internal/web/components/systems/systems-table.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,12 +96,8 @@ func SystemsTable(props SystemsTableProps, children ...htmx.Node) htmx.Node {
),
htmx.A(
htmx.Href("/systems/new"),
buttons.Outline(
buttons.ButtonProps{
ClassNames: htmx.ClassNames{
"btn-sm": true,
},
},
buttons.Button(
buttons.ButtonProps{},
htmx.Text("Create System"),
),
),
Expand Down
8 changes: 2 additions & 6 deletions internal/web/components/teams/teams.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,12 +91,8 @@ func TeamsTable(props TeamsTableProps, children ...htmx.Node) htmx.Node {
),
htmx.A(
htmx.Href("/teams/new"),
buttons.Outline(
buttons.ButtonProps{
ClassNames: htmx.ClassNames{
"btn-sm": true,
},
},
buttons.Button(
buttons.ButtonProps{},
htmx.Text("Create Team"),
),
),
Expand Down
Loading

0 comments on commit 711a7c3

Please sign in to comment.