mirror of
https://github.com/cirruslabs/orchard.git
synced 2026-10-21 10:45:25 +02:00
Refactorings for simplify readability (#35)
This commit is contained in:
@@ -9,6 +9,7 @@ import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"github.com/cirruslabs/orchard/internal/config"
|
||||
"github.com/cirruslabs/orchard/rpc"
|
||||
"golang.org/x/net/websocket"
|
||||
"google.golang.org/grpc/credentials"
|
||||
"google.golang.org/grpc/credentials/insecure"
|
||||
@@ -18,11 +19,6 @@ import (
|
||||
"net/url"
|
||||
)
|
||||
|
||||
const MetadataServiceAccountNameKey = "x-orchard-service-account-name"
|
||||
|
||||
//nolint:gosec // G101 check yields a false-positive here, this is not a hard-coded credential
|
||||
const MetadataServiceAccountTokenKey = "x-orchard-service-account-token"
|
||||
|
||||
var (
|
||||
ErrFailed = errors.New("API client failed")
|
||||
ErrInvalidState = errors.New("invalid state")
|
||||
@@ -121,8 +117,8 @@ func (client *Client) GPRCMetadata() metadata.MD {
|
||||
|
||||
if client.serviceAccountName != "" && client.serviceAccountToken != "" {
|
||||
result = map[string]string{
|
||||
MetadataServiceAccountNameKey: client.serviceAccountName,
|
||||
MetadataServiceAccountTokenKey: client.serviceAccountToken,
|
||||
rpc.MetadataServiceAccountNameKey: client.serviceAccountName,
|
||||
rpc.MetadataServiceAccountTokenKey: client.serviceAccountToken,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -23,7 +23,7 @@ func (service *VMsService) Create(ctx context.Context, vm *v1.VM) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (service *VMsService) FindForWorker(ctx context.Context, workerName string) (map[string]v1.VM, error) {
|
||||
func (service *VMsService) FindForWorker(ctx context.Context, workerUID string) (map[string]v1.VM, error) {
|
||||
allVms, err := service.List(ctx)
|
||||
|
||||
if err != nil {
|
||||
@@ -32,7 +32,7 @@ func (service *VMsService) FindForWorker(ctx context.Context, workerName string)
|
||||
|
||||
var filteredVms = make(map[string]v1.VM)
|
||||
for _, vmResource := range allVms {
|
||||
if vmResource.Worker != workerName {
|
||||
if vmResource.WorkerUID != workerUID {
|
||||
continue
|
||||
}
|
||||
filteredVms[vmResource.UID] = vmResource
|
||||
|
||||
@@ -47,8 +47,8 @@ type VM struct {
|
||||
Status VMStatus `json:"status"`
|
||||
StatusMessage string `json:"status_message"`
|
||||
|
||||
// Worker field is set by the Controller to assign this VM to a specific Worker.
|
||||
Worker string `json:"worker"`
|
||||
// WorkerUID field is set by the Controller to assign this VM to a specific WorkerUID.
|
||||
WorkerUID string `json:"worker"`
|
||||
|
||||
Username string `json:"username"`
|
||||
Password string `json:"password"`
|
||||
|
||||
Reference in New Issue
Block a user