forked from daytonaio/daytona
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.go
51 lines (41 loc) · 1.56 KB
/
build.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
// Copyright 2024 Daytona Platforms Inc.
// SPDX-License-Identifier: Apache-2.0
package services
import (
"context"
"errors"
"io"
"github.com/daytonaio/daytona/pkg/models"
"github.com/daytonaio/daytona/pkg/stores"
)
type IBuildService interface {
List(ctx context.Context, filter *BuildFilter) ([]*BuildDTO, error)
Find(ctx context.Context, filter *BuildFilter) (*BuildDTO, error)
Create(ctx context.Context, createBuildDTO CreateBuildDTO) (string, error)
Delete(ctx context.Context, filter *BuildFilter, force bool) []error
UpdateLastJob(ctx context.Context, buildId, jobId string) error
HandleSuccessfulRemoval(ctx context.Context, id string) error
GetBuildLogReader(ctx context.Context, buildId string) (io.Reader, error)
GetBuildLogWriter(ctx context.Context, buildId string) (io.WriteCloser, error)
}
type BuildDTO struct {
models.Build
State models.ResourceState `json:"state" validate:"required"`
} // @name BuildDTO
type CreateBuildDTO struct {
WorkspaceTemplateName string `json:"workspaceTemplateName" validate:"required"`
Branch string `json:"branch" validate:"required"`
PrebuildId *string `json:"prebuildId" validate:"optional"`
EnvVars map[string]string `json:"envVars" validate:"required"`
} // @name CreateBuildDTO
type BuildFilter struct {
StateNames *[]models.ResourceStateName
ShowDeleted bool
StoreFilter stores.BuildFilter
}
var (
ErrBuildDeleted = errors.New("build is deleted")
)
func IsBuildDeleted(err error) bool {
return err.Error() == ErrBuildDeleted.Error()
}