CompareServiceVersion compares whether two service version have the same major, minor and patch version.
(required, provided string)
| 64 | |
| 65 | // CompareServiceVersion compares whether two service version have the same major, minor and patch version. |
| 66 | func 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. |
| 91 | func UpdateCompDefinitionImages4ServiceVersion(ctx context.Context, cli client.Reader, |
no test coverage detected
searching dependent graphs…