Exemple #1
0
func (v *configurationVersion) String() string {
	return versionutil.Version(*v).String()
}
Exemple #2
0
// runnerConfiguration creates a runnerConfiguration resolving all the
// configurations from command line and provided configuration files.
func (c *ConfigurationManager) runnerConfiguration(loadDockerVersion versionutil.Version) (runnerConfiguration, error) {
	// TODO: eliminate suites and just use arguments
	var conf string
	// Get first flag
	if flag.NArg() == 0 {
		cwd, err := os.Getwd()
		if err != nil {
			return runnerConfiguration{}, err
		}
		conf = filepath.Join(cwd, "golem.conf")
		logrus.Debugf("No configuration given, trying current directory %s", conf)
	} else {
		absPath, err := filepath.Abs(flag.Arg(0))
		if err != nil {
			return runnerConfiguration{}, err
		}

		info, err := os.Stat(absPath)
		if err != nil {
			return runnerConfiguration{}, err
		}
		if info.IsDir() {
			absPath = filepath.Join(absPath, "golem.conf")
			if _, err := os.Stat(absPath); err != nil {
				return runnerConfiguration{}, err

			}
		}
		conf = absPath

	}

	suites, err := parseSuites(flag.Args())
	if err != nil {
		return runnerConfiguration{}, err
	}

	// TODO: Support non-linux by downloading and replacing executable path
	executablePath, err := osext.Executable()
	if err != nil {
		return runnerConfiguration{}, fmt.Errorf("error getting path to executable: %s", err)
	}

	runnerConfig := runnerConfiguration{
		ExecutableName: "golem_runner",
		ExecutablePath: executablePath,
	}

	for _, suite := range suites {
		resolver := newMultiResolver(c.flagResolver, suite, globalDefault)

		registrySuite := SuiteConfiguration{
			Name:           resolver.Name(),
			Path:           resolver.Path(),
			DockerInDocker: resolver.Dind(),
		}

		baseConf := BaseImageConfiguration{
			Base:              resolver.BaseImage(),
			ExtraImages:       resolver.Images(),
			DockerLoadVersion: loadDockerVersion,
			DockerVersion:     versionutil.Version(c.dockerVersion),
		}

		instances := resolver.Instances()

		for idx, instance := range instances {
			name := registrySuite.Name
			if len(instances) > 1 {
				name = fmt.Sprintf("%s-%d", name, idx+1)
			}
			imageConf := baseConf
			imageConf.CustomImages = instance.CustomImages

			conf := InstanceConfiguration{
				Name:             name,
				BaseImage:        imageConf,
				RunConfiguration: instance.RunConfiguration,
			}
			registrySuite.Instances = append(registrySuite.Instances, conf)
		}

		runnerConfig.Suites = append(runnerConfig.Suites, registrySuite)
	}

	return runnerConfig, nil
}