Example #1
0
func New(c *config.Config) *Mesos {
	m := new(Mesos)

	if c.Zk == "" {
		return nil
	}

	m.Registry = consul.New()

	if m.Registry == nil {
		log.Fatal("No registry specified")
	}

	m.zkDetector(c.Zk)
	m.IpOrder = strings.Split(c.MesosIpOrder, ",")
	for _, src := range m.IpOrder {
		switch src {
		case "netinfo", "host", "docker", "mesos":
		default:
			log.Fatalf("Invalid IP Search Order: '%v'", src)
		}
	}

	return m
}
Example #2
0
func New(c *config.Config) *Mesos {
	m := new(Mesos)

	if c.Zk == "" {
		return nil
	}

	if len(c.WhiteList) > 0 {
		m.WhiteList = strings.Join(c.WhiteList, "|")
		log.WithField("whitelist", m.WhiteList).Debug("Using whitelist regex")
		re, err := regexp.Compile(m.WhiteList)
		if err != nil {
			// For now, exit if the regex fails to compile. If we read regexes from Consul
			// maybe we emit a warning and use the old regex
			//
			log.WithField("whitelist", m.WhiteList).Fatal("WhiteList regex failed to compile")
		}
		m.whitelistRegex = re
	} else {
		m.whitelistRegex = nil
	}

	m.ServiceName = cleanName(c.ServiceName)

	m.Registry = consul.New()

	if m.Registry == nil {
		log.Fatal("No registry specified")
	}

	m.zkDetector(c.Zk)

	m.IpOrder = strings.Split(c.MesosIpOrder, ",")
	for _, src := range m.IpOrder {
		switch src {
		case "netinfo", "host", "docker", "mesos":
		default:
			log.Fatalf("Invalid IP Search Order: '%v'", src)
		}
	}
	log.Debugf("m.IpOrder = '%v'", m.IpOrder)

	if c.ServiceTags != "" {
		m.ServiceTags = strings.Split(c.ServiceTags, ",")
	}

	return m
}
Example #3
0
func New(c *config.Config) *Mesos {
	m := new(Mesos)

	if c.Zk == "" {
		return nil
	}
	m.Separator = c.Separator

	m.TaskPrivilege = NewPrivilege(c.TaskWhiteList, c.TaskBlackList)
	m.FwPrivilege = NewPrivilege(c.FwWhiteList, c.FwBlackList)

	var err error
	m.taskTag, err = buildTaskTag(c.TaskTag)
	if err != nil {
		log.WithField("task-tag", c.TaskTag).Fatal(err.Error())
	}

	m.ServiceName = cleanName(c.ServiceName, c.Separator)

	m.Registry = consul.New()

	if m.Registry == nil {
		log.Fatal("No registry specified")
	}

	m.zkDetector(c.Zk)

	m.IpOrder = strings.Split(c.MesosIpOrder, ",")
	for _, src := range m.IpOrder {
		switch src {
		case "netinfo", "host", "docker", "mesos":
		default:
			log.Fatalf("Invalid IP Search Order: '%v'", src)
		}
	}
	log.Debugf("m.IpOrder = '%v'", m.IpOrder)

	if c.ServiceTags != "" {
		m.ServiceTags = strings.Split(c.ServiceTags, ",")
	}

	return m
}
Example #4
0
func New(c *config.Config) *Mesos {
	m := new(Mesos)

	if c.Zk == "" {
		return nil
	}

	if consul.IsEnabled() {
		m.Registry = consul.New()
	}

	if m.Registry == nil {
		log.Fatal("No registry specified")
	}

	m.zkDetector(c.Zk)

	return m
}