Skip to content

Commit

Permalink
FORGET ABOUT DOLESS! 😈
Browse files Browse the repository at this point in the history
  • Loading branch information
sumboid committed Dec 1, 2023
1 parent 20b7aa2 commit e6f46e9
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 15 deletions.
3 changes: 1 addition & 2 deletions go.work.sum
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
github.com/cespare/xxhash v1.1.0 h1:a6HrQnmkObjyL+Gs60czilIUGqrzKutQD6XZog3p+ko=
github.com/cpuguy83/go-md2man/v2 v2.0.0/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
github.com/creack/pty v1.1.18/go.mod h1:MOBLtS5ELjhRRrroQr9kyvTxUAFNvYEK993ew/Vr4O4=
github.com/google/go-cmp v0.5.8/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/klauspost/cpuid v1.2.0 h1:NMpwD2G9JSFOE1/TJjGSo5zG7Yb2bTe7eq1jH+irmeE=
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
github.com/onpremless/go-client v1.0.2 h1:NhXUsdH6W5c++fHwVg9a+LF+0xgkUIihHTwn5phstM4=
github.com/onpremless/go-client v1.0.2/go.mod h1:WXiHquYP4OB2Shl2zKEP3czRhUBNS4OYrj0Q7N33FfY=
github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc=
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
Expand Down
8 changes: 4 additions & 4 deletions manager/docker/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ func NewDockerService(id string) (DockerService, error) {

func (s service) ListContainers(ctx context.Context) ([]types.Container, error) {
return s.client.ContainerList(ctx, types.ContainerListOptions{
Filters: filters.NewArgs(filters.KeyValuePair{Key: "label", Value: "doless=" + s.id}),
Filters: filters.NewArgs(filters.KeyValuePair{Key: "label", Value: "opless=" + s.id}),
})
}

Expand All @@ -66,7 +66,7 @@ func (s service) Create(ctx context.Context, lambda *api.Lambda, tar io.Reader)
images, err := s.client.ImageList(
ctx,
types.ImageListOptions{
Filters: filters.NewArgs(filters.KeyValuePair{Key: "label", Value: "doless=" + s.id}),
Filters: filters.NewArgs(filters.KeyValuePair{Key: "label", Value: "opless=" + s.id}),
})
if err != nil {
return "", err
Expand All @@ -81,7 +81,7 @@ func (s service) Create(ctx context.Context, lambda *api.Lambda, tar io.Reader)

out, err := s.client.ImageBuild(ctx, tar, types.ImageBuildOptions{
Tags: []string{*lambda.Docker.Image},
Labels: map[string]string{"doless": s.id},
Labels: map[string]string{"opless": s.id},
})
if err != nil {
return "", err
Expand Down Expand Up @@ -120,7 +120,7 @@ func (s service) CreateContainer(ctx context.Context, lambda *api.Lambda) (strin

err := creator.createContainer(ctx, &container.Config{
Image: *lambda.Docker.Image,
Labels: map[string]string{"doless": s.id},
Labels: map[string]string{"opless": s.id},
})
if err != nil {
creator.rollback()
Expand Down
4 changes: 2 additions & 2 deletions manager/lambda/minio.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ func BootstrapLambda(ctx context.Context, id string, lambda *api.CreateLambda) e
}
defer archive.Close()

tmpDir, err := os.MkdirTemp("", "doless-")
tmpDir, err := os.MkdirTemp("", "opless-")
if err != nil {
return err
}
Expand Down Expand Up @@ -182,7 +182,7 @@ func TarLambda(ctx context.Context, lambda string, runtime string) (io.Reader, e
Recursive: true,
})

dir, err := os.MkdirTemp("", "doless-lambda-")
dir, err := os.MkdirTemp("", "opless-lambda-")
if err != nil {
return nil, err
}
Expand Down
4 changes: 2 additions & 2 deletions manager/lambda/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ type LambdaService interface {
}

func CreateLambdaService() (LambdaService, error) {
dockerSvc, err := docker.NewDockerService(redis.DolessID)
dockerSvc, err := docker.NewDockerService(redis.OPlessID)

if err != nil {
return nil, err
Expand Down Expand Up @@ -207,7 +207,7 @@ func (s service) start(ctx context.Context, lambda *api.Lambda) (string, error)
}

image := lambda.Name
container := "doless-" + lambda.Name
container := "opless-" + lambda.Name
lambda.Docker.Image = &image
lambda.Docker.Container = &container

Expand Down
10 changes: 5 additions & 5 deletions manager/redis/redis.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
)

var Client *db.Redis
var DolessID = ""
var OPlessID = ""

func init() {
redisEndpoint := util.GetStrVar("REDIS_ENDPOINT")
Expand All @@ -22,16 +22,16 @@ func init() {
panic(fmt.Errorf("failed to connect to redis: %w", err))
}

res := Client.Client.Get(context.Background(), "doless-id")
res := Client.Client.Get(context.Background(), "opless-id")
err = res.Err()
if err == nil {
DolessID = res.Val()
OPlessID = res.Val()
return
}

if err == redis.Nil {
DolessID = util.UUID()
if err := Client.Client.Set(context.Background(), "doless-id", DolessID, 0).Err(); err != nil {
OPlessID = util.UUID()
if err := Client.Client.Set(context.Background(), "opless-id", OPlessID, 0).Err(); err != nil {
panic(err)
}
}
Expand Down

0 comments on commit e6f46e9

Please sign in to comment.