github.com/cloud-foundations/dominator@v0.0.0-20221004181915-6e4fee580046/fleetmanager/topology/check.go (about)

     1  package topology
     2  
     3  import (
     4  	"fmt"
     5  )
     6  
     7  func (t *Topology) checkIfMachineHasSubnet(name, subnetId string) (
     8  	bool, error) {
     9  	if directory, ok := t.machineParents[name]; !ok {
    10  		return false, fmt.Errorf("unknown machine: %s", name)
    11  	} else {
    12  		// TODO(rgooch): It would be faster to have a single map for all the
    13  		//               subnets down to the directory, but it would consume
    14  		//               more memory. Revisit this if needed.
    15  		for ; directory != nil; directory = directory.parent {
    16  			if _, ok := directory.subnetIdToSubnet[subnetId]; ok {
    17  				return true, nil
    18  			}
    19  		}
    20  		return false, nil
    21  	}
    22  }