func (t Team) Apps() <-chan set.Set {
	channel := make(chan set.Set)
	go func() {
		registrychannel := make(chan set.Set)
		extraschannel := berthateam.Team{t.Name(), "1JcsgN_YLG67KXqRQi-vRloUgvywj7BWdg4rt4OoGsDw"}.Apps()
		go func() {
			rawservices := make([]struct {
				Nodes []struct {
					Url string
				}
			}, 0)
			if err := fetch.Fetch("GET", "https://next-registry.ft.com/v2/", &rawservices, nil, nil); err != nil {
				// TODO: Something better than this
				panic(err)
			}

			apps := set.New()
			re := regexp.MustCompile(`^https?:\/\/([^.]+)\.herokuapp\.com`)
			for _, rawservice := range rawservices {
				for _, node := range rawservice.Nodes {
					if rawapp := re.FindStringSubmatch(node.Url); rawapp != nil {
						apps.Add(rawapp[1])
					}
				}
			}
			registrychannel <- apps
		}()
		registryset, extrasset := <-registrychannel, <-extraschannel
		channel <- set.Union(registryset, extrasset)
	}()
	return channel
}
func GetOrganizationMembers() <-chan set.Set {
	channel := make(chan set.Set)
	go func() {
		rawmembers := make([]struct {
			Email                     string
			Role                      string
			Two_factor_authentication bool
			Federated                 bool
		}, 0)
		if err := fetchHeroku("GET", "https://api.heroku.com/organizations/financial-times/members", &rawmembers, nil); err != nil {
			panic(err)
		}

		// Remove any ‘admin’ users and users without 2FA from the list
		members := set.New()
		for _, rawmember := range rawmembers {
			if rawmember.Role != "admin" && (rawmember.Two_factor_authentication == true || rawmember.Federated == true) {
				members.Add(rawmember.Email)
			}

		}
		channel <- members
	}()
	return channel
}
Esempio n. 3
0
func FilterHerokuMembers(devsChannel <-chan set.Set) <-chan set.Set {
	channel := make(chan set.Set)
	go func() {
		nextDevs, herokuMembers := <-devsChannel, getOrganizationMembers()

		// Only try to add collaborators who are properly set up Heroku members (i.e. not admins, not unknown and have 2FA)
		devs := set.New()
		for nextDev := range nextDevs.Iter() {
			if herokuMembers.Has(nextDev) {
				devs.Add(nextDev)
			}
		}
		channel <- devs
	}()
	return channel
}
func (t Team) Devs() <-chan set.Set {
	channel := make(chan set.Set)
	go func() {
		rawdevs := make([]struct {
			Email string
		}, 0)
		if err := fetch.Fetch("GET", "https://bertha.ig.ft.com/view/publish/gss/"+t.Sheet+"/devs", &rawdevs, nil, nil); err != nil {
			panic(err)
		}

		devs := set.New()
		for _, rawdev := range rawdevs {
			devs.Add(rawdev.Email)
		}
		channel <- devs
	}()
	return channel
}
func (t Team) Apps() <-chan set.Set {
	channel := make(chan set.Set)
	go func() {
		rawapps := make([]struct {
			App string
		}, 0)
		if err := fetch.Fetch("GET", "https://bertha.ig.ft.com/view/publish/gss/"+t.Sheet+"/apps", &rawapps, nil, nil); err != nil {
			panic(err)
		}

		apps := set.New()
		for _, rawapp := range rawapps {
			apps.Add(rawapp.App)
		}
		channel <- apps
	}()
	return channel

}