-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add netbox version compatibility check
- Loading branch information
xoc
committed
Sep 11, 2024
1 parent
c3b8b6f
commit 6863919
Showing
8 changed files
with
54 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,4 @@ coverage.out | |
config.yml | ||
netbox_sd | ||
bin/ | ||
.testing |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package netbox | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/Masterminds/semver" | ||
) | ||
|
||
// netboxIsCompatible returns true when a version string of Netbox is supported. | ||
func netboxIsCompatible(version string) bool { | ||
var ( | ||
compatibleVersion *semver.Constraints | ||
givenVersion *semver.Version | ||
err error | ||
) | ||
|
||
compatibleVersion, err = semver.NewConstraint(compatibleNetboxVersion) | ||
if err != nil { | ||
panic(fmt.Sprintf("could not parse Netbox version constraint '%s'", compatibleNetboxVersion)) | ||
} | ||
|
||
givenVersion, err = semver.NewVersion(version) | ||
if err != nil { | ||
panic(fmt.Sprintf("could not parse given Netbox version '%s'", version)) | ||
} | ||
|
||
return compatibleVersion.Check(givenVersion) | ||
} |