Files
threshold/internal/host/plugin
Chris MarchesiandTodd 0670e272e3 internal/host/plugin: Add UpdateCatalog (#1634)
* internal/host/plugin: Add UpdateCatalog

This adds support for updating plugin-based host catalogs.

The workflow is:

* The existing catalog is fetched.
* Any attribute changes are patched against it, along with other changes
  such as name and description.
* Both the existing catalog, and the state of the catalog as it will
  exist post-update, along with any persisted secrets, are sent to the
  plugin via an OnUpdateCatalog request.

Upon success, the following is done:

* The record is updated if non-secret updates need to be made.
* Secrets are updated if they still exist.
* If an empty secret set was sent back, secrets are instead deleted.
* If the secrets field was instead null, secret update is skipped
  altogether.

There has also been a lot of helper code added to the tests to help make
the update tests more readable and reduce boilerplate. While the create
tests have not been updated to use these new helpers, it might be a good
idea to do so for consistency.

* move secret/persisted state closer to plugin call

* Update internal/host/plugin/repository_host_catalog.go

Co-authored-by: Todd <T.Alan.Knight@gmail.com>

* Update internal/host/plugin/repository_host_catalog_test.go

Co-authored-by: Todd <T.Alan.Knight@gmail.com>

* move all test helpers for UpdateCatalog inline

* WIP - transparent attributes struct/wire conversion

* Revert "WIP - transparent attributes struct/wire conversion"

This reverts commit 31af1b1b7e535119aa23bd0aa936da1a80eb5aa2.

* deal with multiple attribute masks

* Note TODO for upsertQuery for HostCatalogSecret

* add version check guard

* Update internal/host/plugin/host_catalog_secret.go

Co-authored-by: Todd <T.Alan.Knight@gmail.com>

* remove redundant JIRA reference

* don't separate number of updated catalogs and secrets

* increment version when secrets is the only thing being updated

* add another test for updating both catalog and secrets at once

* correct comment for mock plugin manager section

* add first-part path matching for secrets

* update plugin lookup error to return errors.Internal

* only add name/description to plugin request if they are non-empty

* update duplicate tests to use two project scopes

* remove unused test checks

* return plugin record along with host catalog in update

* move away from using passed in catalog after patching newCatalog

* use t.Cleanup() instead of defer

Co-authored-by: Todd <T.Alan.Knight@gmail.com>
2021-11-05 10:43:58 -07:00
..