MCPcopy
hub / github.com/apecloud/kubeblocks / CompareServiceVersion

Function CompareServiceVersion

pkg/controller/component/component_version.go:66–88  ·  view source on GitHub ↗

CompareServiceVersion compares whether two service version have the same major, minor and patch version.

(required, provided string)

Source from the content-addressed store, hash-verified

64
65// CompareServiceVersion compares whether two service version have the same major, minor and patch version.
66func CompareServiceVersion(required, provided string) (bool, error) {
67 if len(required) == 0 {
68 return true, nil
69 }
70 rv, err1 := version.ParseSemantic(required)
71 if err1 != nil {
72 return false, err1
73 }
74 pv, err2 := version.ParseSemantic(provided)
75 if err2 != nil {
76 return false, err2
77 }
78 ret, _ := rv.WithPreRelease("").Compare(pv.WithPreRelease("").String())
79 if ret != 0 {
80 return false, nil
81 }
82 if len(rv.PreRelease()) == 0 {
83 return true, nil
84 }
85 // required version has specified the pre-release, so the provided version should match it exactly
86 ret, _ = rv.Compare(provided)
87 return ret == 0, nil
88}
89
90// UpdateCompDefinitionImages4ServiceVersion resolves and updates images for the component definition.
91func UpdateCompDefinitionImages4ServiceVersion(ctx context.Context, cli client.Reader,

Callers 3

checkNMergeImagesFunction · 0.85

Calls 1

StringMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…