Add disk size as an option
ci/woodpecker/push/build Pipeline was successful Details

This commit is contained in:
Nikolai Rodionov 2024-05-06 21:57:54 +02:00
parent bfd486568a
commit 4477c558f2
Signed by: allanger
GPG Key ID: 0AA46A90E25592AD
4 changed files with 18 additions and 3 deletions

View File

@ -58,6 +58,7 @@ func (e *EnvironmentsServer) Create(ctx context.Context, in *proto.CreateOptions
Kubernetes: k8s.GetKubernetesName(),
Location: location,
ServerType: serverType,
DiskSize: int(in.GetSpec().GetDiskSize()),
}
environment := &controllers.Environemnt{
@ -114,6 +115,7 @@ func (e *EnvironmentsServer) Update(ctx context.Context, in *proto.UpdateOptions
Kubernetes: k8s.GetKubernetesName(),
Location: location,
ServerType: serverType,
DiskSize: int(in.GetSpec().GetDiskSize()),
}
environment := &controllers.Environemnt{
@ -198,6 +200,7 @@ func (e *EnvironmentsServer) Get(ctx context.Context, in *proto.GetOptions) (*pr
Kubernetes: proto.Kubernetes(proto.Kubernetes_value[k8s.RawKubernetesName()]),
ServerLocation: proto.Location(proto.Location_value[provider.RawServerLocation(environment.Data.Location)]),
ServerType: proto.ServerType(proto.ServerType_value[provider.RawServerType(environment.Data.ServerType)]),
DiskSize: int32(environment.Data.DiskSize),
},
Id: in.GetId(),
Metadata: &proto.EnvironmentMetadata{
@ -248,6 +251,7 @@ func (e *EnvironmentsServer) List(in *proto.ListOptions, stream proto.Environmen
Kubernetes: proto.Kubernetes(proto.Kubernetes_value[k8s.RawKubernetesName()]),
ServerLocation: proto.Location(proto.Location_value[provider.RawServerLocation(env.Data.Location)]),
ServerType: proto.ServerType(proto.ServerType_value[provider.RawServerType(env.Data.ServerType)]),
DiskSize: int32(env.Data.DiskSize),
},
}); err != nil {
return err

2
go.mod
View File

@ -150,7 +150,7 @@ require (
)
require (
git.badhouseplants.net/softplayer/softplayer-go-proto v0.1.11
git.badhouseplants.net/softplayer/softplayer-go-proto v0.1.12
github.com/golang/protobuf v1.5.4
golang.org/x/net v0.24.0 // indirect
golang.org/x/sys v0.19.0 // indirect

4
go.sum
View File

@ -1,6 +1,6 @@
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
git.badhouseplants.net/softplayer/softplayer-go-proto v0.1.11 h1:Kjdz7HUOhg5f8wktvf+QG6SNv0sN3OXfz9yErwrfl38=
git.badhouseplants.net/softplayer/softplayer-go-proto v0.1.11/go.mod h1:OU+833cHwvecr+gsnPEKQYlAJbpL8bqSJVLobdw63qI=
git.badhouseplants.net/softplayer/softplayer-go-proto v0.1.12 h1:aaMAZ0Pw+4QF3+azngsGNgKxLCRjrFFRngNfh8ucL6o=
git.badhouseplants.net/softplayer/softplayer-go-proto v0.1.12/go.mod h1:OU+833cHwvecr+gsnPEKQYlAJbpL8bqSJVLobdw63qI=
github.com/AdaLogics/go-fuzz-headers v0.0.0-20230811130428-ced1acdcaa24 h1:bvDV9vkmnHYOMsOr4WLk+Vo07yKIzd94sVoIqshQ4bU=
github.com/AdaLogics/go-fuzz-headers v0.0.0-20230811130428-ced1acdcaa24/go.mod h1:8o94RPi1/7XTJvwPpRSzSUedZrtlirdB3r9Z20bi2f8=
github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1 h1:UQHMgLO+TxOElx5B5HZ4hJQsoJ/PvUvKRhJHDQXO8P8=

View File

@ -4,6 +4,7 @@ import (
"context"
"errors"
"fmt"
"strconv"
"strings"
"github.com/go-logr/logr"
@ -392,6 +393,16 @@ func (env *Environemnt) Get(ctx context.Context) error {
} else {
env.Data.Location = ""
}
if val, ok := res["SP_DISK_SIZE"]; ok {
intVal, err := strconv.Atoi(val)
if err != nil {
log.Error(err, "Couldn't parse disk size")
intVal = 0
}
env.Data.DiskSize = intVal
} else {
env.Data.Location = ""
}
return nil
}