Exemple #1
0
func newCoreosSources(options map[string][]string) ([]api.Source, error) {
	fleetEndpoints := defaultFleetEndpoints
	if len(options["fleetEndpoint"]) > 0 {
		fleetEndpoints = options["fleetEndpoint"]
	}

	nodesApi, err := nodes.NewCoreOSNodes(fleetEndpoints)
	if err != nil {
		return nil, err
	}

	cadvisorPort := defaultCadvisorPort
	if len(options["cadvisorPort"]) > 0 {
		cadvisorPort, err = strconv.Atoi(options["cadvisorPort"][0])
		if err != nil {
			return nil, err
		}
	}

	return []api.Source{
		&cadvisorSource{
			cadvisorApi:  datasource.NewCadvisor(),
			nodesApi:     nodesApi,
			cadvisorPort: cadvisorPort,
		},
	}, nil
}
Exemple #2
0
func newExternalSources(options map[string][]string) ([]api.Source, error) {
	hostsFile := defaultHostsFile
	if len(options["hostsFile"]) > 0 {
		hostsFile = options["hostsFile"][0]
	}
	standalone := defaultStandalone
	if len(options["standalone"]) > 0 {
		standaloneOption, err := strconv.ParseBool(options["standalone"][0])
		if err != nil {
			return nil, err
		}
		standalone = standaloneOption
	}

	nodesApi, err := nodes.NewExternalNodes(standalone, hostsFile)
	if err != nil {
		return nil, err
	}

	cadvisorPort := defaultCadvisorPort
	if len(options["cadvisorPort"]) > 0 {
		cadvisorPort, err = strconv.Atoi(options["cadvisorPort"][0])
		if err != nil {
			return nil, err
		}
	}

	return []api.Source{
		&cadvisorSource{
			cadvisorApi:  datasource.NewCadvisor(),
			nodesApi:     nodesApi,
			cadvisorPort: cadvisorPort,
		},
	}, nil
}