func createRecordSets(internal bool, zone, value string, zkRouter *datamodel.ZkRouter) ([]dns.Record, error) { var suffix string var err error if suffix, err = preCreateRecordSets(internal, zone, value, zkRouter); err != nil { return nil, err } records := make([]dns.Record, 3) // WEIGHT=1 router.<suffix> records[0] = dns.NewRecord(helper.GetRegionRouterCName(internal, suffix), value, 1) // WEIGHT=1 routerX.<zone>.<suffix> records[1] = dns.NewRecord(zkRouter.CName, value, 1) // WEIGHT=1 router.<zone>.<suffix> records[2] = dns.NewRecord(helper.GetZoneRouterCName(internal, zkRouter.Zone, suffix), value, 1) /*// WEIGHT=0 router.<zone>.<suffix> -> will be activated when needed for _, azone := range AvailableZones { if azone == zone { continue } record := dns.NewRecord(helper.GetZoneRouterCName(internal, azone, suffix), value, 0) records = append(records, record) }*/ // we don't need this yet return records, nil }
func ResolveDepValuesForZone(app string, zkEnv *datamodel.ZkEnv, zone string, names []string, encrypt bool, t *Task) (DepsType, error) { var ( err error suffix string ) deps := DepsType{} // if we're using DNS and the app is registered, try to get the app cname (if deployed) if dns.Provider != nil { suffix, err = dns.Provider.Suffix(Region) if err != nil { return deps, err } } for _, name := range names { // if app is registered for this dependency name zkApp, err := datamodel.GetApp(name) if err != nil { continue } appEnvData := zkApp.GetDependerEnvDataForDependerApp(app, zkEnv.Name, true) if appEnvData == nil { continue } envData := zkApp.GetDependerEnvData(zkEnv.Name, true) if envData == nil { envData = &DependerEnvData{Name: appEnvData.Name} } // merge the data mergedEnvData := MergeDependerEnvData(envData, appEnvData) appDep := &AppDep{ SecurityGroup: mergedEnvData.SecurityGroup, DataMap: mergedEnvData.DataMap, } if dns.Provider != nil && !zkApp.NonAtlantis && zkApp.Internal { // auto-populate Address port, created, err := datamodel.ReserveRouterPortAndUpdateTrie(zkApp.Internal, name, "", zkEnv.Name) if err != nil { return deps, err } if created { // add warning since this means that the app has not been deployed in this env yet t.AddWarning("App dependency " + name + " has not yet been deployed in environment " + zkEnv.Name) } if appDep.DataMap == nil { appDep.DataMap = map[string]interface{}{} } appDep.DataMap["address"] = helper.GetZoneRouterCName(true, zone, suffix) + ":" + port // auto-populate SecurityGroup portUint, err := strconv.ParseUint(port, 10, 16) if err != nil { return deps, err } appDep.SecurityGroup = map[string][]uint16{netsec.InternalRouterIPGroup: []uint16{uint16(portUint)}} } deps[name] = appDep } if encrypt { for _, value := range deps { crypto.EncryptAppDep(value) } } for _, name := range names { if _, ok := deps[name]; !ok { return deps, errors.New("Could not resolve dep " + name) } } return deps, nil }