Exemple #1
0
func ValidateClient(client concourse.Client, targetName TargetName) error {
	info, err := client.GetInfo()
	if err != nil {
		return err
	}

	if info.Version == version.Version || version.IsDev(version.Version) {
		return nil
	}

	atcMajor, atcMinor, atcPatch, err := version.GetSemver(info.Version)
	if err != nil {
		return err
	}

	flyMajor, flyMinor, flyPatch, err := version.GetSemver(version.Version)
	if err != nil {
		return err
	}

	if ((atcMajor == flyMajor) && (atcMinor != flyMinor)) ||
		(atcMajor != flyMajor) {
		return NewErrVersionMismatch(version.Version, info.Version, targetName)
	}

	if (atcMajor == flyMajor) && (atcMinor == flyMinor) && (atcPatch != flyPatch) {
		fmt.Fprintln(os.Stderr, ui.WarningColor("WARNING:\n"))
		fmt.Fprintln(os.Stderr, ui.WarningColor(NewErrVersionMismatch(version.Version, info.Version, targetName).Error()))
	}

	return nil
}