Commit Graph
34 Commits
Author SHA1 Message Date
Jeff Mitchell b76b24a4ad Move prefixes for many packages into the globals package (#3069)
This is a prerequisite for some enhancements to grant validation
2023-03-10 15:06:39 -05:00
Johan Brandhorst-Satzkorn 3c29308673 chore: Add license headers to all files 2023-02-03 15:54:27 -08:00
Johan Brandhorst-Satzkorn f57454b6b9 Rewrite interface{} to any (#2535)
* chore: Rewrite interface{} to any

* Add ignore revs
2022-10-25 19:29:38 -04:00
Damian Debkowski 27e9f775be feat: add initial migration hook 2022-08-22 12:15:20 -07:00
Jeff Mitchell 7364d84835 Add mechanism for plugin to normalize attributes (#2376)
* Add mechanism for plugin to normalize attributes

This introduces a new normalization call to the plugin RPC service. If
implemented, the plugin will be given the attributes prior to saving
them in a create/update call, and can perform any normalization needed,
e.g. ensuring that a parameter passed in is represented in a canonical
way. As an example, the CLI allows a user of the AWS plugin to pass in a
string, but canonically it is a string slice, and should be returned
that way as well. Not by chance, this is the exact behavior of the
testing implementation of this function.

This does not update any individual plugin, but rather sets the
controller-side logic up for plugins to support this functionality.
2022-08-18 15:39:30 -04:00
Johan Brandhorst-Satzkorn d51ce41db8 feat(hostsets): Classify all proto fields 2022-04-20 13:32:31 -04:00
Louis Ruch 4ed4575802 chore(fmt): make fmt 2022-02-16 15:52:37 -08:00
Todd 7ee1f74388 fix(hostsets/plugin): Only delete preferred endpoints when there are preferred endpoints to delete. (#1865) 2022-02-16 16:12:34 -07:00
Justen Walker 6166d2240f bug(plugin): Fix incorrect use of WithIpAddrs in Repository.Endpoints (#1849)
When creating the options for the preferencer, this used WithIpAddrs for both the host addresses and also DNS names. This causes errors when a host contains DNS names that are not IP addresses (ie: whenever dns names are present).

This change will:
- Replace WithIpAddrs with WithDNSNames option for DNS Names when constructing options for the preferencer.
- Add a test which includes a DNS name to prevent regressions

Fixes #1848
2022-02-10 13:59:35 -07:00
Chris Marchesi bf18555d5e internal/host/plugin: remove custom queries for secrets (#1676)
* internal/host/plugin: remove custom queries for secrets

This removes the custom queries for host catalog secrets, now that #1658
has been merged.

It also does a lot of cleanup surrounding the related oplog entries,
using db.WithOplog natively.

* Simplify conflict actions by replacing SetColumnValues with SetColumns

* Remove unused oplog method
2021-12-07 12:38:34 -08:00
Chris Marchesi 9e976cb4ae internal/host/plugin: Fix TestUpdateSet (#1735)
Now asserts on error on the last lookup check and removes the plugin
lookup since we're not asserting on that.
2021-11-22 13:42:19 -08:00
Todd 5d2b0e94aa Update sync interval seconds field. (#1698)
* 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.
2021-11-12 14:55:22 -07:00
Todd 5cfcc41f00 Fix bug for adding preferred endpoint when non existed prior. (#1692) 2021-11-12 09:04:48 -07:00
Todd Knight f41bceda83 Merge from main and make gen 2021-11-12 08:57:10 -07:00
Todd 29b4537d3b Reference PreferredEndpoints by top level struct name (#1688)
* 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.
2021-11-11 13:51:52 -07:00
Jeff Mitchell 30e9f944a2 Add sync interval to host sets (#1680)
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.
2021-11-11 11:28:08 -05:00
Chris Marchesi c2cd6febca internal/host/plugin: add UpdateSet (#1686)
* 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
2021-11-10 17:08:42 -08:00
Todd 2229d1a819 Call OnCreate or OnUpdate on the plugin after db constraints are checked (#1683)
* 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.
2021-11-10 09:04:29 -07:00
Todd 050553ffcf Add update catalog support for plugin based catalogs in handler and go sdk (#1673)
* 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.
2021-11-09 14:42:48 -07:00
Todd 1312628a1e Add plugin set sync and orphaned host cleanup jobs (#1647) 2021-11-01 09:07:56 -07:00
Jeff Mitchell 5e782b6ecc Update view to return host IDs in a set on set lookup (#1646)
This removes the optional call to the plugin.
2021-10-29 15:35:06 -04:00
Todd 6eba8a4787 Lookups Catalogs and Persisted data together (#1643)
* Fixed a number of TODOs:
1. Create a catalog/persisted data view.
2. Pass all sets to the plugin when deleting a catalog.
2021-10-28 12:46:42 -07:00
Todd 8795b20fe2 Delete actions for plugin based catalogs and sets (#1622)
* Add ability to delete plugin based host catalogs and host sets

* Add plugin host catalog and set tests for API.
2021-10-25 09:37:05 -07:00
23baaac36b Add DB changes for host, set members, and host addresses for plugins. (#1584)
* Add DB changes for host, set members, and host addresses for plugins.

* Add priority, address review feedback, update tests, naming, protos

Co-authored-by: Jeff Mitchell <jeffrey.mitchell@gmail.com>
Co-authored-by: Michael Gaffney <mgaffney@users.noreply.github.com>
2021-10-20 12:20:28 -07:00
Jeff Mitchell 70e6536919 Swap server interface for client (#1580) 2021-10-07 11:56:39 -04:00
Todd e11a481256 Register Azure and AWS at controller start up (#1570)
* Register Plugins.

* Pass catalogs and persisted data when listing hosts for host sets.  Register azure plugin at startup if not present.
2021-09-29 15:46:42 -07:00
Jeff Mitchell 8b1ca4b0b8 Add host IDs to plugin host sets read response (#1568)
This also includes tweaks here and there within the service and repos.
2021-09-28 16:19:32 -04:00
Jeff Mitchell a834a14785 Add attribute flag building and parsing (#1562)
This adds a few command sketches but that's not the main point of the PR
and filling those out will come in a different PR. This adds a new flag
type that can combine inputs to a single target slice, retaining the
ability to distinguish where it came from but also keep ordering across
different flag names. It also implements a function that does the
heuristic parsing with fallback.
2021-09-26 11:48:43 -04:00
ToddandJeff Mitchell 14cc97b645 Add authorize session for plugin based host sets. (#1559)
Added a new Endpoint struct at the top level host package level to capture host, set, and address chosen.
Temporarily add a host_plugin_host table to capture the hosts returned by the plugins.  This ensures the datawarehouse is able to query the table to decide what host was chosen.  The view used to update the datawarehouse dimension table provides rows with host set ids and hosts which are not in that host set.  This is ok since the function which updates the dimension table provides the host set and host id chosen so that relationship doesn't need to be captured in the view itself.

Co-authored-by: Jeff Mitchell <jeffrey.mitchell@gmail.com>
2021-09-26 11:17:21 -04:00
Todd a4ea99047f Remove Prefix Id and Plugin Name fields (#1563)
* Remove Prefix Id and Plugin Name fields.  Creating catalogs now require either the plugin id or the name of the plugin resource (but not both).  Host Catalogs and Host Sets API resources now have a read only plugin field populated with plugin info.  Host Catalogs have a plugin id field as a top level field.
2021-09-24 13:16:13 -07:00
ToddandJeff Mitchell bbfef2802f Placeholder Plugin Providers for Repos and added testPlugin struct (#1532)
* Create minimalistic plugin map and test plugin.

* Pass secrets and attributes to the plugin when creating catalogs or sets.  Add tests for CreateSet and CreateCatalog repo methods.

* make fmt and extract out getPrivateCatalog and getCatalog helper methods.

* Exporting TestPluginServer so it can be used in the handlers.

* Keep separate persisted data from host catalogs lookups which facilitate passing it onto the plugins.

* Add TODO to merge get Catalog and get Persisted data.

* Adding tests for unimplemented being returned by the plugin.

* Use GetFields() instead of AsMap() to confirm attributes should be populated. Make clone consistent between catalog and sets.

Co-authored-by: Jeff Mitchell <jeffrey.mitchell@gmail.com>
2021-09-21 09:18:49 -07:00
Jeff Mitchell 01d4383c1b Add preferred endpoints logic to API/handler/DB and some CLI bits (#1529) 2021-09-20 12:48:38 -04:00
Todd Knight 4f09f1d74f Add create, list, lookup functions for plugin based host catalogs (#1515)
Create the repository for plugin host catalogs.  A large TODO is left in the code to interface with the plugin system once ready.
2021-09-09 11:15:14 -07:00
Todd Knight 1249f9668f Add Plugin Host Set Repo Create, List, Read Operations (#1497)
Add repo for plugin based host sets as well as tests.
2021-09-09 10:45:41 -07:00