func (v GitHub) UpdateWarningVersion(version string) (string, bool, error) {
	// A default message that can be presented to an end user.
	errorMessageUI := "Version check is unavailable at this time."

	// Some basic validation, check we have a version,
	if len(version) == 0 {
		return errorMessageUI, false, fmt.Errorf("no version found")
	}
	// Try to get the latest tag using the BitBucket API.
	resp, err := client.NewHTTPClient(client.DefaultTimeout).Get(v.bitBucketAPIRepository)
	if err != nil {
		// If network error then return message, flag to NOT update and actual error.
		return errorMessageUI, false, errors.Wrap(err, "HTTP on GET to BitBucket API")
	}

	if resp.StatusCode == http.StatusOK {
		body, err := ioutil.ReadAll(resp.Body)
		if err != nil {
			return errorMessageUI, false, errors.Wrap(err, "cannot read body API error.")
		}

		err = resp.Body.Close()
		if err != nil {
			return errorMessageUI, false, errors.Wrap(err, "error on update warning version")
		}

		s, err := getTags(body)
		if err != nil {
			return errorMessageUI, false, errors.Wrap(err, "error on update warning version")
		}

		if len(s.TagList) == 0 {
			return errorMessageUI, false, fmt.Errorf("no Tags found")
		}

		// Convert the list of tags to tagList and sort
		tags := convertSortTags(s)

		// Get latest tag
		latestTag := tags[len(tags)-1].Name

		// Format version string to compare.
		versionLocal, err := v.VersionFormatter(version)
		if err != nil {
			return errorMessageUI, false, errors.Wrap(err, "error on update warning version")
		}
		versionRemote, err := v.VersionFormatter(latestTag)
		if err != nil {
			return errorMessageUI, false, errors.Wrap(err, "error on update warning version")
		}

		if versionLocal < versionRemote {
			errorMessageUI = fmt.Sprintf("Version v%s of the Conformance Suite is out-of-date, please update to v%s", versionLocal, versionRemote)
			return errorMessageUI, true, nil
		}
		// If local and remote version match or is higher then return false update flag.
		if versionLocal >= versionRemote {
			errorMessageUI = fmt.Sprintf("Conformance Suite is running the latest version %s", v.GetHumanVersion())
			return errorMessageUI, false, nil
		}

	} else {
		// handle anything else other than 200 OK.
		return errorMessageUI, false, nil
	}

	return errorMessageUI, false, nil
}
// UpdateWarningVersion takes a version number and checks it against the
// latest tag version on Bitbucket, if a newer version is found it
// returns a message and bool value that can be used to inform a user
// a newer version is available for download.
UpdateWarningVersion takes a version number and checks it against the
latest tag version on Bitbucket, if a newer version is found it
returns a message and bool value that can be used to inform a user
a newer version is available for download.
// UpdateWarningVersion takes a version number and checks it against the // latest tag version on Bitbucket if a newer version is found it // returns a message and bool value that can be used to inform a user // a newer version is available for download .
func (v GitHub) UpdateWarningVersion(version string) (string, bool, error) {
	errorMessageUI := "Version check is unavailable at this time."
	if len(version) == 0 {
		return errorMessageUI, false, fmt.Errorf("no version found")
	}
	resp, err := client.NewHTTPClient(client.DefaultTimeout).Get(v.bitBucketAPIRepository)
	if err != nil {
		return errorMessageUI, false, errors.Wrap(err, "HTTP on GET to BitBucket API")
	}
	if resp.StatusCode == http.StatusOK {
		body, err := ioutil.ReadAll(resp.Body)
		if err != nil {
			return errorMessageUI, false, errors.Wrap(err, "cannot read body API error.")
		}
		err = resp.Body.Close()
		if err != nil {
			return errorMessageUI, false, errors.Wrap(err, "error on update warning version")
		}
		s, err := getTags(body)
		if err != nil {
			return errorMessageUI, false, errors.Wrap(err, "error on update warning version")
		}
		if len(s.TagList) == 0 {
			return errorMessageUI, false, fmt.Errorf("no Tags found")
		}
		tags := convertSortTags(s)
		latestTag := tags[len(tags)-1].Name
		versionLocal, err := v.VersionFormatter(version)
		if err != nil {
			return errorMessageUI, false, errors.Wrap(err, "error on update warning version")
		}
		versionRemote, err := v.VersionFormatter(latestTag)
		if err != nil {
			return errorMessageUI, false, errors.Wrap(err, "error on update warning version")
		}
		if versionLocal < versionRemote {
			errorMessageUI = fmt.Sprintf("Version v%s of the Conformance Suite is out-of-date, please update to v%s", versionLocal, versionRemote)
			return errorMessageUI, true, nil
		}
		if versionLocal >= versionRemote {
			errorMessageUI = fmt.Sprintf("Conformance Suite is running the latest version %s", v.GetHumanVersion())
			return errorMessageUI, false, nil
		}
	} else {
		return errorMessageUI, false, nil
	}
	return errorMessageUI, false, nil
}
func ( v GitHub ) UpdateWarningVersion ( version string ) ( string , bool , error ) { errorMessageUI := " " if len ( version ) == 0 { return errorMessageUI , false , fmt . Errorf ( " " ) } resp , err := client . NewHTTPClient ( client . DefaultTimeout ) . Get ( v . bitBucketAPIRepository ) if err != nil { return errorMessageUI , false , errors . Wrap ( err , " " ) } if resp . StatusCode == http . StatusOK { body , err := ioutil . ReadAll ( resp . Body ) if err != nil { return errorMessageUI , false , errors . Wrap ( err , " " ) } err = resp . Body . Close ( ) if err != nil { return errorMessageUI , false , errors . Wrap ( err , " " ) } s , err := getTags ( body ) if err != nil { return errorMessageUI , false , errors . Wrap ( err , " " ) } if len ( s . TagList ) == 0 { return errorMessageUI , false , fmt . Errorf ( " " ) } tags := convertSortTags ( s ) latestTag := tags [ len ( tags ) - 1 ] . Name versionLocal , err := v . VersionFormatter ( version ) if err != nil { return errorMessageUI , false , errors . Wrap ( err , " " ) } versionRemote , err := v . VersionFormatter ( latestTag ) if err != nil { return errorMessageUI , false , errors . Wrap ( err , " " ) } if versionLocal < versionRemote { errorMessageUI = fmt . Sprintf ( " " , versionLocal , versionRemote ) return errorMessageUI , true , nil } if versionLocal >= versionRemote { errorMessageUI = fmt . Sprintf ( " " , v . GetHumanVersion ( ) ) return errorMessageUI , false , nil } } else { return errorMessageUI , false , nil } return errorMessageUI , false , nil }
UpdateWarningVersion takes a version number and checks it against the
latest tag version on Bitbucket, if a newer version is found it
returns a message and bool value that can be used to inform a user
a newer version is available for download.
UpdateWarningVersion takes a version number and checks it against the latest tag version on Bitbucket if a newer version is found it returns a message and bool value that can be used to inform a user a newer version is available for download .
// A default message that can be presented to an end user. // Some basic validation, check we have a version, // Try to get the latest tag using the BitBucket API. // If network error then return message, flag to NOT update and actual error. // Convert the list of tags to tagList and sort // Get latest tag // Format version string to compare. // If local and remote version match or is higher then return false update flag. // handle anything else other than 200 OK.