Skip to content

Commit

Permalink
Use hostname as key in annotation.json (#20)
Browse files Browse the repository at this point in the history
  • Loading branch information
robertodauria committed May 16, 2024
1 parent ce9cca3 commit 210d0ff
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions cmd/register/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
v0 "github.com/m-lab/autojoin/api/v0"
"github.com/m-lab/go/rtx"
v2 "github.com/m-lab/locate/api/v2"
"github.com/m-lab/uuid-annotator/annotator"
)

const (
Expand Down Expand Up @@ -71,6 +72,7 @@ func main() {
}

heartbeat := map[string]v2.Registration{r.Registration.Hostname: *r.Registration.Heartbeat}
annotation := map[string]annotator.ServerAnnotations{r.Registration.Hostname: r.Registration.Annotation.Annotation}

// Write the hostname to a file.
err = os.WriteFile(path.Join(*outputPath, hostnameFilename), []byte(r.Registration.Hostname), 0644)
Expand All @@ -79,11 +81,11 @@ func main() {
// Marshall and write the heartbeat and annotation config files.
heartbeatJSON, err := json.Marshal(heartbeat)
rtx.Must(err, "Failed to marshal heartbeat")
annotation, err := json.Marshal(r.Registration.Annotation)
annotationJSON, err := json.Marshal(annotation)
rtx.Must(err, "Failed to marshal annotation")

err = os.WriteFile(path.Join(*outputPath, heartbeatFilename), heartbeatJSON, 0644)
rtx.Must(err, "Failed to write heartbeat file")
err = os.WriteFile(path.Join(*outputPath, annotationFilename), annotation, 0644)
err = os.WriteFile(path.Join(*outputPath, annotationFilename), annotationJSON, 0644)
rtx.Must(err, "Failed to write annotation file")
}

0 comments on commit 210d0ff

Please sign in to comment.