diff options
| author | Jeff Carr <[email protected]> | 2024-11-16 05:22:11 -0600 |
|---|---|---|
| committer | Jeff Carr <[email protected]> | 2024-11-16 05:22:11 -0600 |
| commit | 81cbb6e9d7def6f34bda77bc6940377173dfae76 (patch) | |
| tree | ad993ce3c2758493778d26b137c005f6f6b58c30 /cluster.go | |
| parent | 74da63276ed73a78d66af45f2dca56a48f2f836a (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.go | 17 |
1 files changed, 17 insertions, 0 deletions
@@ -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 +} |
