Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: nobl9/nobl9-go
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v0.80.0
Choose a base ref
...
head repository: nobl9/nobl9-go
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v0.81.0
Choose a head ref
  • 4 commits
  • 54 files changed
  • 3 contributors

Commits on Apr 5, 2024

  1. chore: Update minor and patch golang dependencies (#360)

    [![Mend
    Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)
    
    This PR contains the following updates:
    
    | Package | Change | Age | Adoption | Passing | Confidence |
    |---|---|---|---|---|---|
    | [github.com/aws/aws-sdk-go](https://togithub.com/aws/aws-sdk-go) |
    `v1.51.15` -> `v1.51.16` |
    [![age](https://developer.mend.io/api/mc/badges/age/go/github.com%2faws%2faws-sdk-go/v1.51.16?slim=true)](https://docs.renovatebot.com/merge-confidence/)
    |
    [![adoption](https://developer.mend.io/api/mc/badges/adoption/go/github.com%2faws%2faws-sdk-go/v1.51.16?slim=true)](https://docs.renovatebot.com/merge-confidence/)
    |
    [![passing](https://developer.mend.io/api/mc/badges/compatibility/go/github.com%2faws%2faws-sdk-go/v1.51.15/v1.51.16?slim=true)](https://docs.renovatebot.com/merge-confidence/)
    |
    [![confidence](https://developer.mend.io/api/mc/badges/confidence/go/github.com%2faws%2faws-sdk-go/v1.51.15/v1.51.16?slim=true)](https://docs.renovatebot.com/merge-confidence/)
    |
    | [github.com/nobl9/nobl9-go](https://togithub.com/nobl9/nobl9-go) |
    `v0.79.2` -> `v0.80.0` |
    [![age](https://developer.mend.io/api/mc/badges/age/go/github.com%2fnobl9%2fnobl9-go/v0.80.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
    |
    [![adoption](https://developer.mend.io/api/mc/badges/adoption/go/github.com%2fnobl9%2fnobl9-go/v0.80.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
    |
    [![passing](https://developer.mend.io/api/mc/badges/compatibility/go/github.com%2fnobl9%2fnobl9-go/v0.79.2/v0.80.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
    |
    [![confidence](https://developer.mend.io/api/mc/badges/confidence/go/github.com%2fnobl9%2fnobl9-go/v0.79.2/v0.80.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
    |
    
    ---
    
    ### Release Notes
    
    <details>
    <summary>aws/aws-sdk-go (github.com/aws/aws-sdk-go)</summary>
    
    ###
    [`v1.51.16`](https://togithub.com/aws/aws-sdk-go/blob/HEAD/CHANGELOG.md#Release-v15116-2024-04-05)
    
    [Compare
    Source](https://togithub.com/aws/aws-sdk-go/compare/v1.51.15...v1.51.16)
    
    \===
    
    ##### Service Client Updates
    
    -   `service/quicksight`: Updates service API and documentation
    - Adding IAMIdentityCenterInstanceArn parameter to
    CreateAccountSubscription
    -   `service/resource-groups`: Updates service API and documentation
    -   `service/verifiedpermissions`: Updates service API and documentation
    
    </details>
    
    <details>
    <summary>nobl9/nobl9-go (github.com/nobl9/nobl9-go)</summary>
    
    ###
    [`v0.80.0`](https://togithub.com/nobl9/nobl9-go/releases/tag/v0.80.0)
    
    [Compare
    Source](https://togithub.com/nobl9/nobl9-go/compare/v0.79.2...v0.80.0)
    
    ### What's Changed
    
    #### 🚀 Features
    
    - feat: Allow for mocking sdk.Client
    ([#&#8203;355](https://togithub.com/nobl9/nobl9-go/issues/355))
    [@&#8203;nieomylnieja](https://togithub.com/nieomylnieja)
    - feat: Add rules for maps in validation
    ([#&#8203;345](https://togithub.com/nobl9/nobl9-go/issues/345))
    [@&#8203;nieomylnieja](https://togithub.com/nieomylnieja)
    
    #### 🐞 Bug Fixes
    
    - fix: reorder objective validation rules to produce more adequate
    composite objective validation messages \[PC-12021]
    ([#&#8203;339](https://togithub.com/nobl9/nobl9-go/issues/339))
    [@&#8203;nikodemrafalski](https://togithub.com/nikodemrafalski)
    
    #### 🧰 Maintenance
    
    <details>
    <summary>5 changes</summary>
    
    - chore: Update module golang.org/x/tools/cmd/goimports to v0.20.0
    ([#&#8203;358](https://togithub.com/nobl9/nobl9-go/issues/358))
    [@&#8203;renovate](https://togithub.com/renovate)
    - chore: Update module github.com/aws/aws-sdk-go to v1.51.15
    ([#&#8203;357](https://togithub.com/nobl9/nobl9-go/issues/357))
    [@&#8203;renovate](https://togithub.com/renovate)
    - chore: Update module github.com/aws/aws-sdk-go to v1.51.14
    ([#&#8203;353](https://togithub.com/nobl9/nobl9-go/issues/353))
    [@&#8203;renovate](https://togithub.com/renovate)
    - chore: Update Go to 1.22
    ([#&#8203;356](https://togithub.com/nobl9/nobl9-go/issues/356))
    [@&#8203;nieomylnieja](https://togithub.com/nieomylnieja)
    - chore: Update module github.com/aws/aws-sdk-go to v1.51.13
    ([#&#8203;352](https://togithub.com/nobl9/nobl9-go/issues/352))
    [@&#8203;renovate](https://togithub.com/renovate)
    
    </details>
    
    </details>
    
    ---
    
    ### Configuration
    
    📅 **Schedule**: Branch creation - "after 10pm every weekday,before 5am
    every weekday,every weekend" (UTC), Automerge - At any time (no schedule
    defined).
    
    🚦 **Automerge**: Enabled.
    
    ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the
    rebase/retry checkbox.
    
    👻 **Immortal**: This PR will be recreated if closed unmerged. Get
    [config help](https://togithub.com/renovatebot/renovate/discussions) if
    that's undesired.
    
    ---
    
    - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
    this box
    
    ---
    
    This PR has been generated by [Mend
    Renovate](https://www.mend.io/free-developer-tools/renovate/). View
    repository job log
    [here](https://developer.mend.io/github/nobl9/nobl9-go).
    
    <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy4yNjkuMiIsInVwZGF0ZWRJblZlciI6IjM3LjI2OS4yIiwidGFyZ2V0QnJhbmNoIjoibWFpbiJ9-->
    
    
    [PC-12021]:
    https://nobl9.atlassian.net/browse/PC-12021?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ
    
    Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
    renovate[bot] authored Apr 5, 2024

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    1d40bfd View commit details

Commits on Apr 8, 2024

  1. feat: Improve labels validation (#359)

    ## Summary
    
    Improved `v1alpha.Labels` validation which now relies entirely on
    `validation` package ensuring consistent and informative errors.
    
    Removed old checks for whole error message in object's validation in
    favour of regex check.
    
    Labels validation is now performed against each object supporting
    labels.
    nieomylnieja authored Apr 8, 2024
    Copy the full SHA
    30c24b4 View commit details

Commits on Apr 9, 2024

  1. chore: Update module github.com/aws/aws-sdk-go to v1.51.17 (#363)

    [![Mend
    Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)
    
    This PR contains the following updates:
    
    | Package | Change | Age | Adoption | Passing | Confidence |
    |---|---|---|---|---|---|
    | [github.com/aws/aws-sdk-go](https://togithub.com/aws/aws-sdk-go) |
    `v1.51.16` -> `v1.51.17` |
    [![age](https://developer.mend.io/api/mc/badges/age/go/github.com%2faws%2faws-sdk-go/v1.51.17?slim=true)](https://docs.renovatebot.com/merge-confidence/)
    |
    [![adoption](https://developer.mend.io/api/mc/badges/adoption/go/github.com%2faws%2faws-sdk-go/v1.51.17?slim=true)](https://docs.renovatebot.com/merge-confidence/)
    |
    [![passing](https://developer.mend.io/api/mc/badges/compatibility/go/github.com%2faws%2faws-sdk-go/v1.51.16/v1.51.17?slim=true)](https://docs.renovatebot.com/merge-confidence/)
    |
    [![confidence](https://developer.mend.io/api/mc/badges/confidence/go/github.com%2faws%2faws-sdk-go/v1.51.16/v1.51.17?slim=true)](https://docs.renovatebot.com/merge-confidence/)
    |
    
    ---
    
    ### Release Notes
    
    <details>
    <summary>aws/aws-sdk-go (github.com/aws/aws-sdk-go)</summary>
    
    ###
    [`v1.51.17`](https://togithub.com/aws/aws-sdk-go/blob/HEAD/CHANGELOG.md#Release-v15117-2024-04-08)
    
    [Compare
    Source](https://togithub.com/aws/aws-sdk-go/compare/v1.51.16...v1.51.17)
    
    \===
    
    ##### Service Client Updates
    
    -   `service/controlcatalog`: Adds new service
    -   `service/mgn`: Updates service API and documentation
    -   `service/networkmonitor`: Updates service API and documentation
    
    </details>
    
    ---
    
    ### Configuration
    
    📅 **Schedule**: Branch creation - "after 10pm every weekday,before 5am
    every weekday,every weekend" (UTC), Automerge - At any time (no schedule
    defined).
    
    🚦 **Automerge**: Enabled.
    
    ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the
    rebase/retry checkbox.
    
    🔕 **Ignore**: Close this PR and you won't be reminded about this update
    again.
    
    ---
    
    - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
    this box
    
    ---
    
    This PR has been generated by [Mend
    Renovate](https://www.mend.io/free-developer-tools/renovate/). View
    repository job log
    [here](https://developer.mend.io/github/nobl9/nobl9-go).
    
    <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy4yNjkuMiIsInVwZGF0ZWRJblZlciI6IjM3LjI2OS4yIiwidGFyZ2V0QnJhbmNoIjoibWFpbiJ9-->
    
    Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
    renovate[bot] authored Apr 9, 2024
    Copy the full SHA
    fd47b38 View commit details
  2. PC-12282 Introduce metadata annotations

    skrolikiewicz authored Apr 9, 2024
    Copy the full SHA
    a55aa67 View commit details
Showing with 1,172 additions and 517 deletions.
  1. +1 −0 cspell.yaml
  2. +14 −2 docs/mock_example/go.mod
  3. +8 −4 docs/mock_example/go.sum
  4. +1 −1 go.mod
  5. +2 −2 go.sum
  6. +8 −1 internal/manifest/v1alpha/validation.go
  7. +5 −0 internal/manifest/v1alphatest/doc.go
  8. +146 −0 internal/manifest/v1alphatest/labels_validation.go
  9. +111 −0 internal/manifest/v1alphatest/metadata_annotations_validation.go
  10. +4 −0 internal/testutils/assert.go
  11. +9 −3 internal/validation/errors.go
  12. +3 −1 internal/validation/length.go
  13. +15 −3 internal/validation/rules_for_map.go
  14. +91 −0 internal/validation/rules_for_map_test.go
  15. +10 −2 internal/validation/rules_for_slice.go
  16. +69 −26 internal/validation/rules_for_slice_test.go
  17. +0 −12 manifest/v1alpha/agent/test_data/expected_error.txt
  18. +35 −8 manifest/v1alpha/agent/validation_test.go
  19. +0 −10 manifest/v1alpha/alertmethod/test_data/expected_metadata_error.txt
  20. +21 −5 manifest/v1alpha/alertmethod/validation_test.go
  21. +5 −4 manifest/v1alpha/alertpolicy/alert_policy.go
  22. +0 −10 manifest/v1alpha/alertpolicy/test_data/expected_error.txt
  23. +3 −0 manifest/v1alpha/alertpolicy/validation.go
  24. +48 −32 manifest/v1alpha/alertpolicy/validation_test.go
  25. +0 −10 manifest/v1alpha/alertsilence/test_data/expected_error.txt
  26. +30 −6 manifest/v1alpha/alertsilence/validation_test.go
  27. +0 −10 manifest/v1alpha/annotation/test_data/expected_error.txt
  28. +43 −7 manifest/v1alpha/annotation/validation_test.go
  29. +68 −24 manifest/v1alpha/budgetadjustment/validation_test.go
  30. +0 −10 manifest/v1alpha/dataexport/test_data/expected_metadata_error.txt
  31. +22 −6 manifest/v1alpha/dataexport/validation_test.go
  32. +0 −12 manifest/v1alpha/direct/test_data/expected_error.txt
  33. +35 −8 manifest/v1alpha/direct/validation_test.go
  34. +18 −68 manifest/v1alpha/labels.go
  35. +0 −111 manifest/v1alpha/labels_test.go
  36. +41 −0 manifest/v1alpha/metadata_annotations.go
  37. +4 −3 manifest/v1alpha/project/project.go
  38. +0 −11 manifest/v1alpha/project/test_data/expected_error.txt
  39. +3 −0 manifest/v1alpha/project/validation.go
  40. +66 −14 manifest/v1alpha/project/validation_test.go
  41. +0 −10 manifest/v1alpha/rolebinding/test_data/expected_error.txt
  42. +55 −8 manifest/v1alpha/rolebinding/validation_test.go
  43. +5 −4 manifest/v1alpha/service/service.go
  44. +0 −14 manifest/v1alpha/service/test_data/expected_error.txt
  45. +3 −0 manifest/v1alpha/service/validation.go
  46. +70 −13 manifest/v1alpha/service/validation_test.go
  47. +5 −4 manifest/v1alpha/slo/slo.go
  48. +0 −12 manifest/v1alpha/slo/test_data/expected_metadata_error.txt
  49. +3 −0 manifest/v1alpha/slo/validation.go
  50. +53 −10 manifest/v1alpha/slo/validation_test.go
  51. +0 −7 manifest/v1alpha/usergroup/test_data/expected_error.txt
  52. +37 −8 manifest/v1alpha/usergroup/validation_test.go
  53. +1 −1 sdk/test_data/client/simple_module/go.mod
  54. +1 −0 sdk/test_data/client/simple_module/go.sum
1 change: 1 addition & 0 deletions cspell.yaml
Original file line number Diff line number Diff line change
@@ -34,6 +34,7 @@ words:
- alertmethod
- alertpolicy
- alertsilence
- alphatest
- apiurl
- appingress
- atoi
16 changes: 14 additions & 2 deletions docs/mock_example/go.mod
Original file line number Diff line number Diff line change
@@ -3,21 +3,33 @@ module mock_example
go 1.22

require (
github.com/nobl9/nobl9-go v0.79.2
github.com/nobl9/nobl9-go v0.80.0
github.com/stretchr/testify v1.9.0
go.uber.org/mock v0.4.0
)

require (
github.com/aws/aws-sdk-go v1.51.11 // indirect
github.com/BurntSushi/toml v1.3.2 // indirect
github.com/MicahParks/jwkset v0.5.17 // indirect
github.com/MicahParks/keyfunc/v3 v3.3.2 // indirect
github.com/aws/aws-sdk-go v1.51.15 // indirect
github.com/bmatcuk/doublestar/v4 v4.6.1 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/fatih/color v1.10.0 // indirect
github.com/goccy/go-yaml v1.11.3 // indirect
github.com/golang-jwt/jwt/v5 v5.2.1 // indirect
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
github.com/hashicorp/go-retryablehttp v0.7.5 // indirect
github.com/jmespath/go-jmespath v0.4.0 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.19 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/teambition/rrule-go v1.8.2 // indirect
golang.org/x/exp v0.0.0-20240205201215-2c58cdc269a3 // indirect
golang.org/x/sys v0.15.0 // indirect
golang.org/x/text v0.14.0 // indirect
golang.org/x/time v0.5.0 // indirect
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
12 changes: 8 additions & 4 deletions docs/mock_example/go.sum
Original file line number Diff line number Diff line change
@@ -4,8 +4,8 @@ github.com/MicahParks/jwkset v0.5.17 h1:DrcwyKwSP5adD0G2XJTvDulnWXjD6gbjROMgMXDb
github.com/MicahParks/jwkset v0.5.17/go.mod h1:q8ptTGn/Z9c4MwbcfeCDssADeVQb3Pk7PnVxrvi+2QY=
github.com/MicahParks/keyfunc/v3 v3.3.2 h1:YTtwc4dxalBZKFqHhqctBWN6VhbLdGhywmne9u5RQVM=
github.com/MicahParks/keyfunc/v3 v3.3.2/go.mod h1:GJBeEjnv25OnD9y2OYQa7ELU6gYahEMBNXINZb+qm34=
github.com/aws/aws-sdk-go v1.51.11 h1:El5VypsMIz7sFwAAj/j06JX9UGs4KAbAIEaZ57bNY4s=
github.com/aws/aws-sdk-go v1.51.11/go.mod h1:LF8svs817+Nz+DmiMQKTO3ubZ/6IaTpq3TjupRn3Eqk=
github.com/aws/aws-sdk-go v1.51.15 h1:rxRcn4hmkhxUfIQrmnFfOOW4NQRiRve7GlgQcor13JE=
github.com/aws/aws-sdk-go v1.51.15/go.mod h1:LF8svs817+Nz+DmiMQKTO3ubZ/6IaTpq3TjupRn3Eqk=
github.com/bmatcuk/doublestar/v4 v4.6.1 h1:FH9SifrbvJhnlQpztAx++wlkk70QBf0iBWDwNy7PA4I=
github.com/bmatcuk/doublestar/v4 v4.6.1/go.mod h1:xBQ8jztBU6kakFMg+8WGxn0c6z1fTSPVIjEY1Wr7jzc=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
@@ -27,6 +27,8 @@ github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/hashicorp/go-cleanhttp v0.5.2 h1:035FKYIWjmULyFRBKPs8TBQoi0x6d9G4xc9neXJWAZQ=
github.com/hashicorp/go-cleanhttp v0.5.2/go.mod h1:kO/YDlP8L1346E6Sodw+PrpBSV4/SoxCXGY6BqNFT48=
github.com/hashicorp/go-hclog v0.9.2 h1:CG6TE5H9/JXsFWJCfoIVpKFIkFe6ysEuHirp4DxCsHI=
github.com/hashicorp/go-hclog v0.9.2/go.mod h1:5CU+agLiy3J7N7QjHK5d05KxGsuXiQLrjA0H7acj2lQ=
github.com/hashicorp/go-retryablehttp v0.7.5 h1:bJj+Pj19UZMIweq/iie+1u5YCdGrnxCT9yvm0e+Nd5M=
github.com/hashicorp/go-retryablehttp v0.7.5/go.mod h1:Jy/gPYAdjqffZ/yFGCFV2doI5wjtH1ewM9u8iYVjtX8=
github.com/jmespath/go-jmespath v0.4.0 h1:BEgLn5cpjn8UN1mAw4NjwDrS35OdebyEtFe+9YPoQUg=
@@ -42,13 +44,14 @@ github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Ky
github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
github.com/mattn/go-isatty v0.0.19 h1:JITubQf0MOLdlGRuRq+jtsDlekdYPia9ZFsB8h/APPA=
github.com/mattn/go-isatty v0.0.19/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
github.com/nobl9/nobl9-go v0.79.2 h1:4Zeo8I2JEi/uW/gjcm9lb41O6locV68fCzul6mq3MqQ=
github.com/nobl9/nobl9-go v0.79.2/go.mod h1:KVIRTmt2nu9d/tP6urcs5uC6otoA2LyOjZrE35mJL+A=
github.com/nobl9/nobl9-go v0.80.0 h1:O2MJ3+fV0QlZJUWl9iyQviQEnWHG5tCZiSjx+OdM73E=
github.com/nobl9/nobl9-go v0.80.0/go.mod h1:SNTDtMOOr6sOY06YCA6JfUiqZGE71CK/cbOBGS+LqDc=
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
github.com/teambition/rrule-go v1.8.2 h1:lIjpjvWTj9fFUZCmuoVDrKVOtdiyzbzc93qTmRVe/J8=
@@ -71,6 +74,7 @@ golang.org/x/time v0.5.0 h1:o7cqy6amK/52YcAKIPlM3a+Fpj35zvRj2TP+e1xFSfk=
golang.org/x/time v0.5.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM=
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE=
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v2 v2.2.8 h1:obN1ZagJSUGI0Ek/LBmuj4SNLPfIny3KsKFopxRdj10=
gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -6,7 +6,7 @@ require (
github.com/BurntSushi/toml v1.3.2
github.com/MicahParks/jwkset v0.5.17
github.com/MicahParks/keyfunc/v3 v3.3.2
github.com/aws/aws-sdk-go v1.51.15
github.com/aws/aws-sdk-go v1.51.17
github.com/bmatcuk/doublestar/v4 v4.6.1
github.com/goccy/go-yaml v1.11.3
github.com/golang-jwt/jwt/v5 v5.2.1
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
@@ -4,8 +4,8 @@ github.com/MicahParks/jwkset v0.5.17 h1:DrcwyKwSP5adD0G2XJTvDulnWXjD6gbjROMgMXDb
github.com/MicahParks/jwkset v0.5.17/go.mod h1:q8ptTGn/Z9c4MwbcfeCDssADeVQb3Pk7PnVxrvi+2QY=
github.com/MicahParks/keyfunc/v3 v3.3.2 h1:YTtwc4dxalBZKFqHhqctBWN6VhbLdGhywmne9u5RQVM=
github.com/MicahParks/keyfunc/v3 v3.3.2/go.mod h1:GJBeEjnv25OnD9y2OYQa7ELU6gYahEMBNXINZb+qm34=
github.com/aws/aws-sdk-go v1.51.15 h1:rxRcn4hmkhxUfIQrmnFfOOW4NQRiRve7GlgQcor13JE=
github.com/aws/aws-sdk-go v1.51.15/go.mod h1:LF8svs817+Nz+DmiMQKTO3ubZ/6IaTpq3TjupRn3Eqk=
github.com/aws/aws-sdk-go v1.51.17 h1:Cfa40lCdjv9OxC3X1Ks3a6O1Tu3gOANSyKHOSw/zuWU=
github.com/aws/aws-sdk-go v1.51.17/go.mod h1:LF8svs817+Nz+DmiMQKTO3ubZ/6IaTpq3TjupRn3Eqk=
github.com/bmatcuk/doublestar/v4 v4.6.1 h1:FH9SifrbvJhnlQpztAx++wlkk70QBf0iBWDwNy7PA4I=
github.com/bmatcuk/doublestar/v4 v4.6.1/go.mod h1:xBQ8jztBU6kakFMg+8WGxn0c6z1fTSPVIjEY1Wr7jzc=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
9 changes: 8 additions & 1 deletion internal/manifest/v1alpha/validation.go
Original file line number Diff line number Diff line change
@@ -29,7 +29,14 @@ func FieldRuleMetadataProject[S any](getter func(S) string) validation.PropertyR
func FieldRuleMetadataLabels[S any](getter func(S) v1alpha.Labels) validation.PropertyRules[v1alpha.Labels, S] {
return validation.For(getter).
WithName("metadata.labels").
Rules(v1alpha.ValidationRuleLabels())
Include(v1alpha.LabelsValidationRules())
}

func FieldRuleMetadataAnnotations[S any](getter func(S) v1alpha.MetadataAnnotations,
) validation.PropertyRules[v1alpha.MetadataAnnotations, S] {
return validation.For(getter).
WithName("metadata.annotations").
Include(v1alpha.MetadataAnnotationsValidationRules())
}

func FieldRuleSpecDescription[S any](getter func(S) string) validation.PropertyRules[string, S] {
5 changes: 5 additions & 0 deletions internal/manifest/v1alphatest/doc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// Package v1alphatest provides test utilities specifically for [v1alpha] manifest validation.
// Since we want to test the validation of whole [manifest.Object] and not it's individual fields,
// duplicating logic for objects like [v1alpha.Labels] can be cumbersome and hard to maintain.
// This package solves the issue by defining a single source of truth for test cases for objects like [v1alpha.Labels].
package v1alphatest
146 changes: 146 additions & 0 deletions internal/manifest/v1alphatest/labels_validation.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
package v1alphatest

import (
"strings"
"testing"

"github.com/nobl9/nobl9-go/internal/testutils"
"github.com/nobl9/nobl9-go/internal/validation"
"github.com/nobl9/nobl9-go/manifest"
"github.com/nobl9/nobl9-go/manifest/v1alpha"
)

type LabelsTestCase[T manifest.Object] struct {
Labels v1alpha.Labels
isValid bool
error testutils.ExpectedError
}

func (tc LabelsTestCase[T]) Test(t *testing.T, object T, validate func(T) *v1alpha.ObjectError) {
err := validate(object)
if tc.isValid {
testutils.AssertNoError(t, object, err)
} else {
testutils.AssertContainsErrors(t, object, err, 1, tc.error)
}
}

func GetLabelsTestCases[T manifest.Object](propertyPath string) map[string]LabelsTestCase[T] {
return map[string]LabelsTestCase[T]{
"valid: simple strings": {
Labels: v1alpha.Labels{
"net": {"vast", "infinite"},
"project": {"nobl9"},
},
isValid: true,
},
// FIXME: We're currently not handling empty map keys well when formatting property paths.
// "invalid: empty label key": {
// Labels: v1alpha.Labels{
// "": {"vast", "infinite"},
// },
// error: testutils.ExpectedError{
// Prop: propertyPath + "." + "",
// IsKeyError: true,
// Code: validation.ErrorCodeStringLength,
// },
// },
"valid: one empty label value": {
Labels: v1alpha.Labels{
"net": {""},
},
isValid: true,
},
"invalid: label value duplicates": {
Labels: v1alpha.Labels{
"net": {"same", "same", "same"},
},
error: testutils.ExpectedError{
Prop: propertyPath + "." + "net",
Code: validation.ErrorCodeSliceUnique,
},
},
"invalid: two empty label values (because duplicates)": {
Labels: v1alpha.Labels{
"net": {"", ""},
},
error: testutils.ExpectedError{
Prop: propertyPath + "." + "net",
Code: validation.ErrorCodeSliceUnique,
},
},
"valid: no label values for a given key": {
Labels: v1alpha.Labels{
"net": {},
},
isValid: true,
},
"invalid: label key is too long": {
Labels: v1alpha.Labels{
strings.Repeat("net", 40): {},
},
error: testutils.ExpectedError{
Prop: propertyPath + "." + strings.Repeat("net", 40),
IsKeyError: true,
Code: validation.ErrorCodeStringLength,
},
},
"invalid: label key starts with non letter": {
Labels: v1alpha.Labels{
"9net": {},
},
error: testutils.ExpectedError{
Prop: propertyPath + "." + "9net",
IsKeyError: true,
Code: validation.ErrorCodeStringMatchRegexp,
},
},
"invalid: label key ends with non alphanumeric char": {
Labels: v1alpha.Labels{
"net_": {},
},
error: testutils.ExpectedError{
Prop: propertyPath + "." + "net_",
IsKeyError: true,
Code: validation.ErrorCodeStringMatchRegexp,
},
},
"invalid: label key contains uppercase character": {
Labels: v1alpha.Labels{
"nEt": {},
},
error: testutils.ExpectedError{
Prop: propertyPath + "." + "nEt",
IsKeyError: true,
Code: validation.ErrorCodeStringMatchRegexp,
},
},
"invalid: label value is too long (over 200 chars)": {
Labels: v1alpha.Labels{
"net": {strings.Repeat("label-", 40)},
},
error: testutils.ExpectedError{
Prop: propertyPath + "." + "net[0]",
Code: validation.ErrorCodeStringMaxLength,
},
},
"valid: label value with uppercase characters": {
Labels: v1alpha.Labels{
"net": {"THE NET is vast AND INFINITE"},
},
isValid: true,
},
"valid: label value with DNS compliant name": {
Labels: v1alpha.Labels{
"net": {"the-net-is-vast-and-infinite"},
},
isValid: true,
},
"valid: any unicode with rune count 1-200": {
Labels: v1alpha.Labels{
"net": {"\uE005[\\\uE006\uE007"},
},
isValid: true,
},
}
}
111 changes: 111 additions & 0 deletions internal/manifest/v1alphatest/metadata_annotations_validation.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
package v1alphatest

import (
"strings"
"testing"

"github.com/nobl9/nobl9-go/internal/testutils"
"github.com/nobl9/nobl9-go/internal/validation"
"github.com/nobl9/nobl9-go/manifest"
"github.com/nobl9/nobl9-go/manifest/v1alpha"
)

type MetadataAnnotationsTestCase[T manifest.Object] struct {
Annotations v1alpha.MetadataAnnotations
isValid bool
error testutils.ExpectedError
}

func (tc MetadataAnnotationsTestCase[T]) Test(t *testing.T, object T, validate func(T) *v1alpha.ObjectError) {
err := validate(object)
if tc.isValid {
testutils.AssertNoError(t, object, err)
} else {
testutils.AssertContainsErrors(t, object, err, 1, tc.error)
}
}

func GetMetadataAnnotationsTestCases[T manifest.Object](propertyPath string) map[string]MetadataAnnotationsTestCase[T] {
return map[string]MetadataAnnotationsTestCase[T]{
"valid: simple strings": {
Annotations: v1alpha.MetadataAnnotations{
"domain": "foundations",
"project": "nobl9",
},
isValid: true,
},
"valid: empty value": {
Annotations: v1alpha.MetadataAnnotations{
"experimental": "",
},
isValid: true,
},
"invalid: key is too long": {
Annotations: v1alpha.MetadataAnnotations{
strings.Repeat("l", 256): "x",
},
error: testutils.ExpectedError{
Prop: propertyPath + "." + strings.Repeat("l", 256),
IsKeyError: true,
Code: validation.ErrorCodeStringLength,
},
},
"invalid: key starts with non letter": {
Annotations: v1alpha.MetadataAnnotations{
"9net": "x",
},
error: testutils.ExpectedError{
Prop: propertyPath + "." + "9net",
IsKeyError: true,
Code: validation.ErrorCodeStringMatchRegexp,
},
},
"invalid: key ends with non alphanumeric char": {
Annotations: v1alpha.MetadataAnnotations{
"net_": "x",
},
error: testutils.ExpectedError{
Prop: propertyPath + "." + "net_",
IsKeyError: true,
Code: validation.ErrorCodeStringMatchRegexp,
},
},
"invalid: key contains uppercase character": {
Annotations: v1alpha.MetadataAnnotations{
"nEt": "x",
},
error: testutils.ExpectedError{
Prop: propertyPath + "." + "nEt",
IsKeyError: true,
Code: validation.ErrorCodeStringMatchRegexp,
},
},
"invalid: value is too long (over 1050 chars)": {
Annotations: v1alpha.MetadataAnnotations{
"net": strings.Repeat("l", 2051),
},
error: testutils.ExpectedError{
Prop: propertyPath + "." + "net",
Code: validation.ErrorCodeStringMaxLength,
},
},
"valid: value with uppercase characters": {
Annotations: v1alpha.MetadataAnnotations{
"net": "THE NET is vast AND INFINITE",
},
isValid: true,
},
"valid: value with DNS compliant name": {
Annotations: v1alpha.MetadataAnnotations{
"net": "the-net-is-vast-and-infinite",
},
isValid: true,
},
"valid: any unicode with valid length": {
Annotations: v1alpha.MetadataAnnotations{
"net": "\uE005[\\\uE006\uE007",
},
isValid: true,
},
}
}
Loading