Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
petemoore committed May 16, 2023
1 parent 871e120 commit f8ab742
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 18 deletions.
28 changes: 16 additions & 12 deletions workers/generic-worker/azure.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package main

import (
"encoding/base64"
"encoding/json"
"fmt"
"io"
Expand Down Expand Up @@ -30,10 +29,14 @@ type (

AzureMetaData struct {
Compute struct {
CustomData string `json:"customData"`
Location string `json:"location"`
VMID string `json:"vmId"`
VMSize string `json:"vmSize"`
Location string `json:"location"`
Name string `json:"name"`
VMID string `json:"vmId"`
VMSize string `json:"vmSize"`
TagsList []struct {
Name string `json:"name"`
Value string `json:"value"`
} `json:"tagsList"`
} `json:"compute"`
Network struct {
Interface []struct {
Expand Down Expand Up @@ -85,15 +88,16 @@ func (g *AzureConfigProvider) UpdateConfig(c *gwconfig.Config) error {
return fmt.Errorf("Could not unmarshal instance metadata %q into AzureMetaData struct - is it valid JSON? %v", string(instanceMetaData), err)
}

taskclusterConfig, err := base64.StdEncoding.DecodeString(azureMetaData.Compute.CustomData)
if err != nil {
return fmt.Errorf("Custom data %q is not valid base64: %v", azureMetaData.Compute.CustomData, err)
tags := map[string]string{}
for _, i := range azureMetaData.Compute.TagsList {
tags[i.Name] = i.Value
}

userData := new(WorkerManagerUserData)
err = json.Unmarshal(taskclusterConfig, userData)
if err != nil {
return fmt.Errorf("Could not parse base64 decoded custom data %q as JSON: %v", taskclusterConfig, err)
userData := &WorkerManagerUserData{
WorkerPoolID: tags["worker-pool-id"],
ProviderID: tags["provider-id"],
WorkerGroup: tags["worker-group"],
RootURL: tags["root-url"],
}

c.WorkerTypeMetadata["azure"] = map[string]interface{}{
Expand Down
11 changes: 5 additions & 6 deletions workers/generic-worker/workermanager.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,10 @@ import (
)

type WorkerManagerUserData struct {
WorkerPoolID string `json:"workerPoolId"`
ProviderID string `json:"providerId"`
WorkerGroup string `json:"workerGroup"`
RootURL string `json:"rootUrl"`
WorkerConfig BootstrapConfig `json:"workerConfig"`
WorkerPoolID string `json:"workerPoolId"`
ProviderID string `json:"providerId"`
WorkerGroup string `json:"workerGroup"`
RootURL string `json:"rootUrl"`
}

type Provider uint
Expand Down Expand Up @@ -66,7 +65,7 @@ func (userData *WorkerManagerUserData) UpdateConfig(c *gwconfig.Config, provider

// TODO: process reg.Expires

return Bootstrap(c, &userData.WorkerConfig, "worker-pool")
return Bootstrap(c, &BootstrapConfig{GenericWorker: reg.WorkerConfig}, "worker-pool")
}

func WMDeploymentID() (string, error) {
Expand Down

0 comments on commit f8ab742

Please sign in to comment.