Skip to content

Commit

Permalink
Teams, Namespace, and Gateway types/struct definitions
Browse files Browse the repository at this point in the history
ThoughtWorks-DPS/lab-api-teams/#2

Signed-off-by: Bryan Oliver <[email protected]>
  • Loading branch information
olivercodes committed Jun 25, 2023
0 parents commit 0dc469b
Show file tree
Hide file tree
Showing 11 changed files with 107 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# lab-api-teams
Empty file added cmd/teams-api-server/main.go
Empty file.
3 changes: 3 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module twdps.io/lab-api-teams

go 1.20
18 changes: 18 additions & 0 deletions pkg/domain/gateways.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package domain

// gw-id: subdomain of gateway, e.g., dev.api.twdps.io
// gw-cert-managed: is this a supported gateway, cert-manager to manage?
// gw-custom-cert: where the customer supplies the cert?
// gw-ingress: ingress-gateway to attach

type Gateway struct {
GatewayID string `json:"gatewayID"`
GatewayCertManaged bool `json:"gatewayCertManaged"`
GatewayCustomCert string `json:"gatewayCustomCert"`
GatewayIngress string `json:"gatewayIngress"`
}

type GatewayRepository interface {
GetGateways() ([]Gateway, error)
GetGatewayByID(id string) (Gateway, error)
}
39 changes: 39 additions & 0 deletions pkg/domain/namespaces.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package domain

// ns-type: [ normal | master | standard | custom ]
// normal:     the ns definition is a normal, team ns desired state definition. Normal
//                        namespaces are subject of the sync action.
//      master:     ns definition not associated with any team. The master record contains
//                       the default values used for ram, cpu, in-or-out of mesh.
//      standard: The standard ns records represent the default namespaces provisioned
//                       for a new team at creation.
//      custom:    Teams my define custom namespace. By convention this is the equivalent
//                        of creating an 'optional' standard entry. All teams can view the list of custom
//                        ns and choose to adopt it as well as define a new one.
// ns-team: team-id used by normal ns entries
// ns-id: name to append to team-id [dev | qa | etc]
// ns-ram: k8s resource
//      [pool resource] In the master record, define the default amount of ram/cpu to assign
//      to new ns (typically a number like 1/5 of the amount of the teams pool from the team
//      record
// ns-cpu: k8s resource [pool resource like ram]
// ns-in-mesh: istio managed? boolean, true by default
// ns-cluster-location: name of cluster where the ns resides TODO - discuss if this is needed
// ns-from-default: was this created at onboarding from defaults?

type Namespace struct {
NamespaceType string `json:"namespaceType"` // normal, master, standard, custom
NamespaceTeamID string `json:"namespaceTeamID"` // ID from teams API
NamespaceID string `json:"namesapceID"` // Dev, QA, etc
NamespaceRam int `json:"namespaceRam"`
NamespaceCpu int `json:"namespaceCpu"`
NamespaceInMesh bool `json:"namespaceInMesh"`
NamespaceFromDefault bool `json:"namespaceFromDefault"`
}

type NamespacesRepository interface {
GetNamespaces() ([]Namespace, error)
GetStandardNamespaces() ([]Namespace, error)
GetCustomNamespaces() ([]Namespace, error)
GetMasterNamespaces() ([]Namespace, error)
}
46 changes: 46 additions & 0 deletions pkg/domain/teams.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package domain

// team-type: [ normal | master | admin ]
// team-id: (team github name)
// team-description: freeform
// team-ram: integer
//      In the master record this
//      represents the default pool
//      size to assign to teams.
// team-cpu: integer
// team-integrations: json
//      list of the supported integrations the
//      team wants the platform to maintain on their
//      behalf.
// team-ram-limit: only admin edit.
//      in master this is the max
//      self-managed resource limit
// team-cpu-limit: only admin edit.
//      in master this is the max
//      self-managed resource limit
// team-marked-for-deletion:
//      [ requested | pending | done ]

type Team struct {
TeamType string `json:"teamType"`
TeamID string `json:"teamID"`
TeamDescription string `json:"teamDescription"`
TeamRAM int `json:"teamRAM"`
TeamCPU int `json:"teamCPU"`
TeamRamLimit int `json:"teamRamLimit"`
TeamCpuLimit int `json:"teamCPULimit"`
TeamMarkedForDeletion string `json:"teamMarkedForDeletion"`
TeamIntegrations []TeamIntegration `json:"teamIntegrations"`
}

type TeamIntegration struct {
IntegrationName string `json:"integrationName"`
}

type TeamsRepository interface {
GetTeams() ([]Team, error)
GetTeam(id string) (Team, error)
AddTeam(newTeam Team) error
UpdateTeam(team Team) error
RemoveTeam(id string) (Team, error)
}
Empty file added pkg/handler/handler.go
Empty file.
Empty file.
Empty file.
Empty file.
Empty file added pkg/service/service.go
Empty file.

0 comments on commit 0dc469b

Please sign in to comment.