Skip to content
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
4 changes: 2 additions & 2 deletions docs/api/v2/V2_docs.go

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions docs/api/v2/V2_swagger.json

Large diffs are not rendered by default.

56 changes: 56 additions & 0 deletions docs/api/v2/V2_swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,10 @@ components:
maxLength: 30
minLength: 3
type: string
neverStale:
description: Boolean to make deployment never get disabled, despite being
stale
type: boolean
private:
description: 'Deprecated: Use Visibility instead.'
type: boolean
Expand Down Expand Up @@ -242,6 +246,8 @@ components:
type: integer
name:
type: string
neverStale:
type: boolean
ownerId:
type: string
pingResult:
Expand Down Expand Up @@ -333,6 +339,8 @@ components:
maxLength: 30
minLength: 3
type: string
neverStale:
type: boolean
private:
description: 'Deprecated: Use Visibility instead.'
type: boolean
Expand Down Expand Up @@ -1352,6 +1360,8 @@ components:
maxLength: 30
minLength: 3
type: string
neverStale:
type: boolean
ports:
items:
$ref: '#/components/schemas/body.PortCreate'
Expand Down Expand Up @@ -1433,6 +1443,8 @@ components:
type: string
name:
type: string
neverStale:
type: boolean
ownerId:
type: string
ports:
Expand Down Expand Up @@ -1503,6 +1515,8 @@ components:
maxLength: 30
minLength: 3
type: string
neverStale:
type: boolean
ports:
items:
$ref: '#/components/schemas/body.PortUpdate'
Expand Down Expand Up @@ -1700,6 +1714,18 @@ paths:
schema:
$ref: '#/components/schemas/sys.ErrorResponse'
description: Bad Request
"403":
content:
application/json:
schema:
$ref: '#/components/schemas/sys.ErrorResponse'
description: Forbidden
"404":
content:
application/json:
schema:
$ref: '#/components/schemas/sys.ErrorResponse'
description: Not Found
"500":
content:
application/json:
Expand Down Expand Up @@ -1746,6 +1772,12 @@ paths:
schema:
$ref: '#/components/schemas/sys.ErrorResponse'
description: Unauthorized
"403":
content:
application/json:
schema:
$ref: '#/components/schemas/sys.ErrorResponse'
description: Forbidden
"404":
content:
application/json:
Expand Down Expand Up @@ -1827,6 +1859,18 @@ paths:
schema:
$ref: '#/components/schemas/sys.ErrorResponse'
description: Bad Request
"403":
content:
application/json:
schema:
$ref: '#/components/schemas/sys.ErrorResponse'
description: Forbidden
"404":
content:
application/json:
schema:
$ref: '#/components/schemas/sys.ErrorResponse'
description: Not Found
"500":
content:
application/json:
Expand Down Expand Up @@ -3814,6 +3858,12 @@ paths:
schema:
$ref: '#/components/schemas/sys.ErrorResponse'
description: Unauthorized
"403":
content:
application/json:
schema:
$ref: '#/components/schemas/sys.ErrorResponse'
description: Forbidden
"404":
content:
application/json:
Expand Down Expand Up @@ -3959,6 +4009,12 @@ paths:
schema:
$ref: '#/components/schemas/sys.ErrorResponse'
description: Unauthorized
"403":
content:
application/json:
schema:
$ref: '#/components/schemas/sys.ErrorResponse'
description: Forbidden
"404":
content:
application/json:
Expand Down
7 changes: 7 additions & 0 deletions dto/v2/body/deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ type DeploymentRead struct {
CustomDomain *CustomDomainRead `json:"customDomain,omitempty"`
Visibility string `json:"visibility"`

NeverStale bool `json:"neverStale" bson:"neverStale" binding:"omitempty,boolean"`

// Deprecated: Use Visibility instead.
Private bool `json:"private"`

Expand Down Expand Up @@ -60,6 +62,9 @@ type DeploymentCreate struct {
Args []string `json:"args" bson:"args" binding:"omitempty,min=0,max=100,dive,min=0,max=100"`
Visibility string `json:"visibility" bson:"visibility" binding:"omitempty,oneof=public private auth"`

// Boolean to make deployment never get disabled, despite being stale
NeverStale bool `json:"neverStale" bson:"neverStale" binding:"omitempty,boolean"`

// Deprecated: Use Visibility instead.
Private bool `json:"private" bson:"private" binding:"omitempty,boolean"`

Expand Down Expand Up @@ -87,6 +92,8 @@ type DeploymentUpdate struct {
Args *[]string `json:"args,omitempty" bson:"args,omitempty" binding:"omitempty,min=0,max=100,dive,min=0,max=100"`
Visibility *string `json:"visibility" bson:"visibility" binding:"omitempty,oneof=public private auth"`

NeverStale *bool `json:"neverStale,omitempty" bson:"neverStale" binding:"omitempty,boolean"`

// Deprecated: Use Visibility instead.
Private *bool `json:"private,omitempty" bson:"private,omitempty" binding:"omitempty,boolean"`

Expand Down
13 changes: 9 additions & 4 deletions dto/v2/body/vm.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ type VmRead struct {
RepairedAt *time.Time `json:"repairedAt,omitempty"`
AccessedAt time.Time `json:"accessedAt"`

NeverStale bool `json:"neverStale"`

Specs VmSpecs `json:"specs"`
Ports []PortRead `json:"ports"`
GPU *VmGpuLease `json:"gpu,omitempty"`
Expand All @@ -36,13 +38,16 @@ type VmCreate struct {
DiskSize int `json:"diskSize" bson:"diskSize" binding:"required,min=10"`

Zone *string `json:"zone,omitempty" bson:"zone,omitempty" binding:"omitempty"`

NeverStale bool `json:"neverStale" bson:"neverStale" binding:"omitempty,boolean"`
}

type VmUpdate struct {
Name *string `json:"name,omitempty" bson:"name,omitempty" binding:"omitempty,rfc1035,min=3,max=30,vm_name"`
Ports *[]PortUpdate `json:"ports,omitempty" bson:"ports,omitempty" binding:"omitempty,port_list_names,port_list_numbers,port_list_http_proxies,min=0,max=10,dive"`
CpuCores *int `json:"cpuCores,omitempty" bson:"cpuCores,omitempty" binding:"omitempty,min=1"`
RAM *int `json:"ram,omitempty" bson:"ram,omitempty" binding:"omitempty,min=1"`
Name *string `json:"name,omitempty" bson:"name,omitempty" binding:"omitempty,rfc1035,min=3,max=30,vm_name"`
Ports *[]PortUpdate `json:"ports,omitempty" bson:"ports,omitempty" binding:"omitempty,port_list_names,port_list_numbers,port_list_http_proxies,min=0,max=10,dive"`
CpuCores *int `json:"cpuCores,omitempty" bson:"cpuCores,omitempty" binding:"omitempty,min=1"`
RAM *int `json:"ram,omitempty" bson:"ram,omitempty" binding:"omitempty,min=1"`
NeverStale *bool `json:"neverStale,omitempty" bson:"neverStale" binding:"omitempty,boolean"`
}

type VmUpdateOwner struct {
Expand Down
9 changes: 9 additions & 0 deletions export/types/v2/body/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ export interface DeploymentRead {
healthCheckPath?: string;
customDomain?: CustomDomainRead;
visibility: string;
neverStale: boolean;
/**
* Deprecated: Use Visibility instead.
*/
Expand All @@ -71,6 +72,10 @@ export interface DeploymentCreate {
initCommands: string[];
args: string[];
visibility: string;
/**
* Boolean to make deployment never get disabled, despite being stale
*/
neverStale: boolean;
/**
* Deprecated: Use Visibility instead.
*/
Expand Down Expand Up @@ -98,6 +103,7 @@ export interface DeploymentUpdate {
initCommands?: string[];
args?: string[];
visibility?: string;
neverStale?: boolean;
/**
* Deprecated: Use Visibility instead.
*/
Expand Down Expand Up @@ -759,6 +765,7 @@ export interface VmRead {
updatedAt?: string;
repairedAt?: string;
accessedAt: string;
neverStale: boolean;
specs: VmSpecs;
ports: PortRead[];
gpu?: VmGpuLease;
Expand All @@ -775,12 +782,14 @@ export interface VmCreate {
ram: number /* int */;
diskSize: number /* int */;
zone?: string;
neverStale: boolean;
}
export interface VmUpdate {
name?: string;
ports?: PortUpdate[];
cpuCores?: number /* int */;
ram?: number /* int */;
neverStale?: boolean;
}
export interface VmUpdateOwner {
newOwnerId: string;
Expand Down
2 changes: 2 additions & 0 deletions models/model/deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ type Deployment struct {
DeletedAt time.Time `bson:"deletedAt"`
AccessedAt time.Time `bson:"accessedAt"`

NeverStale bool `bson:"neverStale"`

Activities map[string]Activity `bson:"activities"`

Apps map[string]App `bson:"apps"`
Expand Down
8 changes: 7 additions & 1 deletion models/model/deployment_convert.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@ package model

import (
"fmt"
"strconv"

"github.com/kthcloud/go-deploy/dto/v2/body"
"github.com/kthcloud/go-deploy/pkg/log"
"github.com/kthcloud/go-deploy/utils"
"golang.org/x/net/idna"
"strconv"
)

// ToDTO converts a Deployment to a body.DeploymentRead DTO.
Expand Down Expand Up @@ -129,6 +130,8 @@ func (deployment *Deployment) ToDTO(smURL *string, externalPort *int, teams []st
CustomDomain: customDomain,
Visibility: app.Visibility,

NeverStale: deployment.NeverStale,

Status: status,
Error: deploymentError,
ReplicaStatus: replicaStatus,
Expand Down Expand Up @@ -222,6 +225,8 @@ func (p *DeploymentCreateParams) FromDTO(dto *body.DeploymentCreate, fallbackZon
} else {
p.Visibility = dto.Visibility
}

p.NeverStale = dto.NeverStale
}

// FromDTO converts body.DeploymentUpdate DTO to DeploymentUpdateParams.
Expand Down Expand Up @@ -277,4 +282,5 @@ func (p *DeploymentUpdateParams) FromDTO(dto *body.DeploymentUpdate, deploymentT
p.PingPath = dto.HealthCheckPath
p.Replicas = dto.Replicas
p.Visibility = dto.Visibility
p.NeverStale = dto.NeverStale
}
4 changes: 4 additions & 0 deletions models/model/deployment_params.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ type DeploymentCreateParams struct {
CustomDomain *string
Visibility string

NeverStale bool

Zone string
}

Expand All @@ -38,6 +40,8 @@ type DeploymentUpdateParams struct {
PingPath *string
Replicas *int
Visibility *string

NeverStale *bool
}

type DeploymentUpdateOwnerParams struct {
Expand Down
2 changes: 2 additions & 0 deletions models/model/vm.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ type VM struct {
DeletedAt time.Time `bson:"deletedAt,omitempty"`
AccessedAt time.Time `bson:"accessedAt"`

NeverStale bool `bson:"neverStale"`

SshPublicKey string `bson:"sshPublicKey"`
PortMap map[string]Port `bson:"portMap"`
Specs VmSpecs `bson:"specs"`
Expand Down
7 changes: 6 additions & 1 deletion models/model/vm_convert.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@ package model

import (
"fmt"
"time"

"github.com/kthcloud/go-deploy/dto/v2/body"
"github.com/kthcloud/go-deploy/pkg/subsystems"
"github.com/kthcloud/go-deploy/utils"
"time"
)

// ToDTOv2 converts a VM to a body.VmRead.
Expand Down Expand Up @@ -91,6 +92,8 @@ func (vm *VM) ToDTOv2(gpuLease *GpuLease, teams []string, externalPort *int, ssh
RepairedAt: utils.NonZeroOrNil(vm.RepairedAt),
AccessedAt: vm.AccessedAt,

NeverStale: vm.NeverStale,

Specs: body.VmSpecs{
CpuCores: vm.Specs.CpuCores,
RAM: vm.Specs.RAM,
Expand All @@ -113,6 +116,7 @@ func (p VmCreateParams) FromDTOv2(dto *body.VmCreate, fallbackZone *string) VmCr
p.RAM = dto.RAM
p.DiskSize = dto.DiskSize
p.PortMap = make(map[string]PortCreateParams)
p.NeverStale = dto.NeverStale

if dto.Zone == nil {
p.Zone = *fallbackZone
Expand Down Expand Up @@ -147,6 +151,7 @@ func (p VmUpdateParams) FromDTOv2(dto *body.VmUpdate) VmUpdateParams {
p.Name = dto.Name
p.CpuCores = dto.CpuCores
p.RAM = dto.RAM
p.NeverStale = dto.NeverStale

if dto.Ports != nil {
portMap := make(map[string]PortUpdateParams)
Expand Down
3 changes: 3 additions & 0 deletions models/model/vm_params.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ type VmCreateParams struct {
CpuCores int
RAM int
DiskSize int

NeverStale bool
}

type VmUpdateParams struct {
Expand All @@ -26,6 +28,7 @@ type VmUpdateParams struct {
PortMap *map[string]PortUpdateParams
CpuCores *int
RAM *int
NeverStale *bool
}

type VmUpdateOwnerParams struct {
Expand Down
3 changes: 3 additions & 0 deletions pkg/db/resources/deployment_repo/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ func (client *Client) Create(id, ownerID string, params *model.DeploymentCreateP
DeletedAt: time.Time{},
AccessedAt: time.Now(),

NeverStale: params.NeverStale,

Activities: map[string]model.Activity{model.ActivityBeingCreated: {
Name: model.ActivityBeingCreated,
CreatedAt: time.Now(),
Expand Down Expand Up @@ -141,6 +143,7 @@ func (client *Client) UpdateWithParams(id string, params *model.DeploymentUpdate
db.AddIfNotNil(&setUpdate, "apps.main.ram", params.RAM)
db.AddIfNotNil(&setUpdate, "apps.main.replicas", params.Replicas)
db.AddIfNotNil(&setUpdate, "apps.main.visibility", params.Visibility)
db.AddIfNotNil(&setUpdate, "neverStale", params.NeverStale)

err = client.UpdateWithBsonByID(id,
bson.D{
Expand Down
Loading
Loading