github.com/DaAlbrecht/cf-cli@v0.0.0-20231128151943-1fe19bb400b9/actor/versioncheck/minimum_version_check.go (about)

     1  package versioncheck
     2  
     3  import (
     4  	"github.com/blang/semver/v4"
     5  )
     6  
     7  func IsMinimumAPIVersionMet(current string, minimum string) (bool, error) {
     8  	if minimum == "" {
     9  		return true, nil
    10  	}
    11  
    12  	currentSemver, err := semver.Make(current)
    13  	if err != nil {
    14  		return false, err
    15  	}
    16  
    17  	minimumSemver, err := semver.Make(minimum)
    18  	if err != nil {
    19  		return false, err
    20  	}
    21  
    22  	if currentSemver.GTE(minimumSemver) {
    23  		return true, nil
    24  	}
    25  
    26  	return false, nil
    27  }