summaryrefslogtreecommitdiff
path: root/cluster.go
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2024-11-16 05:22:11 -0600
committerJeff Carr <[email protected]>2024-11-16 05:22:11 -0600
commit81cbb6e9d7def6f34bda77bc6940377173dfae76 (patch)
treead993ce3c2758493778d26b137c005f6f6b58c30 /cluster.go
parent74da63276ed73a78d66af45f2dca56a48f2f836a (diff)
things for create. might be duplicatesv0.2.7
Signed-off-by: Jeff Carr <[email protected]>
Diffstat (limited to 'cluster.go')
-rw-r--r--cluster.go17
1 files changed, 17 insertions, 0 deletions
diff --git a/cluster.go b/cluster.go
index 97da63a..a2c2391 100644
--- a/cluster.go
+++ b/cluster.go
@@ -17,3 +17,20 @@ type Cluster struct {
Unstable *timestamppb.Timestamp
UnstableTimeout *durationpb.Duration
}
+
+// adds a new droplet. enforce unique hostnames
+func (c *Cluster) AddDroplet(newd *Droplet) bool {
+ c.Lock()
+ defer c.Unlock()
+
+ for _, d := range c.d.Droplets {
+ if newd.Hostname == d.Hostname {
+ // boo. that one is already here
+ return false
+ }
+ }
+
+ // everything is ok, this hostname is new
+ c.d.Droplets = append(c.d.Droplets, newd)
+ return true
+}