github.com/wanddynosios/cli/v8@v8.7.9-0.20240221182337-1a92e3a7017f/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  }