The previous PR only initialized plugins if they were required, which
meant that there may not actually be a plugin manager running because a
second node would not actually create the dev database, which is where
the plugin was being added. The assumption that a plugin manager is
running is still a fine one at the moment, but we just need to make sure
it's running in _all_ cases.
The embed package always uses Unix-style forward slashes. filepath.Join
utilization looking for files would cause the slashes to be the wrong
direction on Windows and result in the files not being found.
This updates the API generation code to allow the same option names to
be used in subtype-scoped options. This means if we have attribute
structs with the same fields, they won't overwrite each other, but will
instead create attribute-specific options.
Currently host does not use a version, which means it's not protected
against race conditions of either itself or its value objects. This adds
and plumbs through version to ensure that if a host or its value objects
change that they are not going to be affected by a race condition.
* Update sync interval seconds field.
* If the sync interval was updated, schedule the next sync job wakeup immediately.
* Calculate the next sync time for the scheduler should wake up if we only updated the sync interval.
* Reference PreferredEndpoints by top level struct name instead of embedded proto GetPreferredEndpoint method.
Reorganize the sql files a little.
* Make PreferredEndpoints replayable. Test refactoring to remove variables that persist across test calls. DeleteItems instead of trying to use WithWhere.
This adds a parameter to host sets allowing the sync interval to be
user-specified on a per-host-set basis. A value of -1 disables syncing;
a value of null uses the current default.
* internal/host/plugin: add UpdateSet
This adds the UpdateSet repository function.
UpdateSet runs the OnUpdateSet plugin call within the transaction as per
the changes in #1683.
The plugin call returns the updated set, the hosts in the set, the rows
updated, and any error.
* Ensure that attributes can be cleared by supplying a full null
* move version increment to the end and track perferred endpoint update separately
* move plugin call to end of transaction
* only clone returned set once, and move host fetch call out of transaction
* Request a sync when attributes are updated
* Add test to assert that old preferred endpoints are being removed correctly
* Only call the Plugin at create/update time after the db has been partially updated. This allows more constraints to be checked prior to calling the plugin.
* Create catalog service handler for updating plugin. Add tests for handler and run make fmt. Silently drop attributes where the value is nil when creating the catalog or set.
* chore: Update eventlogger dependency.
We need the latest version, so we can limit the type of events
that are signed.
* fix (events): Only "sign" audit events
This should help prevent issues like the one fixed in
f2ad4de554.
A version for a particular edition should only exist once, previously
which ever file was read last for a version would be included, which
would lead to some migrations not running.
* 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>