feat(host): Add host plugin related schemas and tests (#1475)

* feat(host): Add host plugin related schemas and tests

This adds the schema files for host plugins, plugin based catalogs and
plugin based sets.  This also adds the protos and tests which utilize
gorm to ensure the schemas enforce the constraints we expect.

Along with this change was a migration which moved catalog names to the
base type table so we can ensure all catalogs in a single scope,
regardless of subtype, have a unique name.

* Updated plugin schemas to do the following:
- Add plugin_executable table
- plugin table now also has scope_id and name w/ uniqueness constraints
- host_plugin no longer has id_prefix column
- host_plugin separates name and plugin_name
- plugin_version table renamed version to symantic_version column.

* Fix typo in delete_plugin_subtype trigger.  Add update test for host plugins.

* Update id prefixes. Fix public_id typos in protos and plugin_executable name in sql diagrams.

* Created internal/plugin and moved base plugin structs to it and moved host plugin subdirectory to it.

* Created internal/plugin and moved base plugin structs to it and moved host plugin subdirectory to it.

* Add first pass at enums for OS and Arch supported by plugin executables.

* Capitalizing the const enums for OS and Architectures.

* Add comments to sql files.

* Reviewer comments.

Remove unsupported OSes and Archs from SQL and go constants.
Add missing tests.

* Be more permissive in the values the db accepts.

The go logic can restrict which values it will allow getting populated into the db.

* Removing constraints on which values can be placed inside operating_system and architecture columns.

* Updating test helper functions to only create a single catalog or set.

* Move files to new migration version.

* Fixing job/plugin test.

* Update table names, named a number of constraints, remove plugin version and executable tables.

* Add constraints for plugin name and id prefix.

* Rename constraint, remove unhelpful comment block.

* Adding semantic version to plugin_host and set attributes to not null.

* Remove semantic versioning from all locations.

* Remove semantic_version from plugin_host table comment.

* Fix op copy/paste error. Don't use deprecated errors methods. Update constraint names.  Add docs.

* Apply suggestions from code review

Fixing constraint names.

Co-authored-by: Michael Gaffney <mgaffney@users.noreply.github.com>
This commit is contained in:
Todd KnightandMichael Gaffney authored and GitHub committed 2021-09-08 10:06:38 -07:00
1 parent 71cba858e3
commit db9e1106a9
39 files changed
+3987 -4

No files matched your search

@@ -0,0 +1,45 @@
syntax = "proto3";
// Package store provides protobufs for storing types in the host package.
package controller.storage.plugin.host.store.v1;
option go_package = "github.com/hashicorp/boundary/internal/plugin/host/store;store";
import "controller/storage/timestamp/v1/timestamp.proto";
import "controller/custom_options/v1/options.proto";
message Plugin {
// public_id is a surrogate key suitable for use in a public API.
// @inject_tag: `gorm:"primary_key"`
string public_id = 10;
// The create_time is set by the database.
// @inject_tag: `gorm:"default:current_timestamp"`
timestamp.v1.Timestamp create_time = 20;
// The update_time is set by the database.
// @inject_tag: `gorm:"default:current_timestamp"`
timestamp.v1.Timestamp update_time = 30;
// name is optional. If set, it must be unique within scope_id.
// @inject_tag: `gorm:"default:null"`
string name = 4 [(custom_options.v1.mask_mapping) = {this:"Name" that: "name"}];
// description is optional.
// @inject_tag: `gorm:"default:null"`
string description = 50 [(custom_options.v1.mask_mapping) = {this:"Description" that: "description"}];
// The scope_id of the owning scope and must be set.
// @inject_tag: `gorm:"not_null"`
string scope_id = 60;
// @inject_tag: `gorm:"default:null"`
uint32 version = 70;
// plugin_name is required. The value must be unique across all host plugins
// @inject_tag: `gorm:"default:null"`
string plugin_name = 80;
// id_prefix is required. The value must be unique across all host plugins
// @inject_tag: `gorm:"default:null"`
string id_prefix = 90;
}
@@ -0,0 +1,23 @@
syntax = "proto3";
// Package store provides protobufs for storing types in the host package.
package controller.storage.plugin.store.v1;
option go_package = "github.com/hashicorp/boundary/internal/plugin/store;store";
import "controller/storage/timestamp/v1/timestamp.proto";
// This is a typeless plugin. In practice this should never be used directly.
// This is included for testing purposes only.
message Plugin {
// public_id is a surrogate key suitable for use in a public API.
// @inject_tag: `gorm:"primary_key"`
string public_id = 10;
// The scope_id of the owning scope and must be set.
// @inject_tag: `gorm:"not_null"`
string scope_id = 20;
// name is optional. If set, it must be unique within scope_id.
// @inject_tag: `gorm:"default:null"`
string name = 30;
}