Commit Graph
46 Commits
Author SHA1 Message Date
Jim 1e71c55920 deprecate access to underlying *sql.DB via internal/db.DB() (#506) 2020-09-30 18:11:59 -04:00
Jeff Mitchell 31fe9292b3 Instantiate default resources (#425) 2020-09-24 03:31:26 -04:00
Jeff MitchellandJim Lambert 62baef1b7e Add multi connection parameters through targets and into session creation (#375)
* Update protos and gen

* Add new values to targets CLI command

* Lots more plumbing of new parameters through everything

* allow fields to be set to zero value.

* Disallow set but empty name/description strings in create/update verifiers

Co-authored-by: Jim Lambert <jlambert@hashicorp.com>
2020-09-19 10:31:49 -04:00
Todd Knight b998591add Adding and updating host address validation checks (#350) 2020-09-12 22:07:56 -07:00
Todd Knight c3ecea172d Generate new version of SDK resources and Add Tests (#331) 2020-09-08 16:27:51 -04:00
Jim 96e4b1cdba add option db.WithSkipVetForWrite(true) so the db tests don't get intercepted by app validation (#332) 2020-09-07 13:20:49 -04:00
Todd Knight 1c2c078e0a Adding Authz checks that support new pathing (#328) 2020-09-04 14:48:11 -07:00
Michael Gaffney 9ca8a4ec20 Host set members (#301)
* Update host set member test

* Add ListSetMembers method signature and doc

* Move repository methods for host set members to new file

* Add TestSetMembers

* Implement ListSetMembers

* Return hosts from ListSetMembers

* Implement AddSetMembers

* Implement DeleteSetMembers

* Use sql.QueryContext not sql.Query

* Implement SetSetMembers

* Refactor: extract getHosts method

* Refactor: extract createMembers method

* Refactor: extract common functions

* Return correct count of changed

In SetSetMembers, retrieving the current list of hosts in the set
happens after the transaction to modify the set has completed. This
retrieval can result in an error but the number of modified rows is not
effected.

* Make list set members an unexported method

* Get hosts within the same transaction as mutations of the set

* Return hosts of set from LookupSet method

* Return hosts of set from UpdateSet method

* Remove listSetMembers

* Fix merge conflict

* Add NOTE and TODOs about using new pattern in "SetMembers" methods
2020-08-26 12:31:18 -04:00
Michael Gaffney de162c5533 Replace and remove ErrNilParameter with ErrInvalidParameter (#295) 2020-08-25 12:18:14 -04:00
Jeff Mitchell 8f579c75c3 paum -> ampw (#303) 2020-08-25 00:21:08 -04:00
Todd Knight c4d3414016 Add Host Set CUDLR handler and SDK (#290) 2020-08-21 10:57:30 -07:00
Michael Gaffney 14dd7b49b2 Add method signatures for host set operations (#291)
* Add method signatures for host set operations

* Rename ReplaceSetMembers to SetSetMembers
2020-08-20 17:53:58 -04:00
Michael Gaffney b24fc185a7 Export TestSets helper function (#292) 2020-08-20 15:13:12 -04:00
Michael Gaffney 3a3cdd7219 Static host set repository methods (#289)
* Implement CreateSet

* Implement UpdateSet

* Implement LookupSet

* Implement ListSets

* Implement DeleteSet

* Remove unused parameter from test helper function

* Update to use new kms structure

* Remove unused parameter for test helper function

* Fix resource-type string for host set
2020-08-20 13:56:52 -04:00
Todd Knight d5678c4f80 Handler for Host CRUDL actions (#287) 2020-08-20 08:20:26 -07:00
Todd Knight 7474e956dd List Catalogs for Repo and API Handler (#288) 2020-08-19 21:49:52 -07:00
Jim 9570897032 basic keys mgmt repo (#264) 2020-08-19 16:47:18 -04:00
Michael Gaffney a413ad7b84 Static Host: Lookup, List and Delete (#283)
* Implement LookupHost

* Implement ListHosts

* Implement DeleteHost
2020-08-19 14:14:14 -04:00
Todd Knight eaae887bbe Don't require type for children of subtyped resources. (#285) 2020-08-19 10:51:15 -07:00
Michael Gaffney 041e1f9fd3 Update host (#278)
* Add IsNotNullError function to db package

* Let the database handle default values not gorm

* Implement UpdateHost

* Remove unnecessary clone
2020-08-18 16:50:26 -04:00
Michael Gaffney e18cdc52b3 Create host (#276)
* Change testHostCatalog methods to be like other resource test methods

* Implement CreateHost

* Make allocHost return a pointer to a Host
2020-08-17 17:06:31 -04:00
Michael Gaffney 7d133878be Add base types for host catalog, host set, and host (#272)
* Move static host migrations to higher number

* Add wt_host_address domain type

* Add base tables for host catalog, host set, and host

* Reformat create trigger statements

* Add subtype triggers for host catalog, host set, and host

* Remove wt_host_address domain type

* Rename columns in host_set_member

* Add delete trigger functions for base types

* Add delete after triggers to static host subtypes

* Add protobufs for host base types
2020-08-17 11:00:41 -04:00
Michael Gaffney 7ac4be51c0 Refactor static host package (#263)
* Refactor: inline tablename constants

* Refactor: move functionality to new files
2020-08-13 14:00:15 -04:00
Jeff Mitchell 78d7f539c5 Add versioning to host catalogs/sets/hosts and fix up tests (#247)
* Start adding version to host resources and fixing up tests

* Add versioning to host resources and update API tests

* Fix nil in test

* Add missing update
2020-08-11 11:20:06 -04:00
Jeff Mitchell 6661117d4c The name. The name. The name! 2020-08-10 17:15:02 -04:00
Michael Gaffney bdb31cf8b5 Bump deps (#245) 2020-08-08 10:49:43 -04:00
Jeff Mitchell 908a299ea3 Convert SDK to the new options API (#238) 2020-08-07 12:55:02 -04:00
Jim cb89422d9d define immutable fields including PKs. (#205) 2020-07-30 16:04:15 -04:00
Michael Gaffney e03a0ff9d7 Simplify SetTableName pattern (#214) 2020-07-23 17:58:41 -04:00
Todd Knight f47046f158 Update Watchtower to use grpc-gateway v2 (#204)
* Migration to grpc gateway v2.
2020-07-23 11:26:15 -07:00
Michael Gaffney 799242fce4 Bump deps and run 'make gen' (#212) 2020-07-22 17:00:22 -04:00
Todd KnightandJeff Mitchell 168ae3a726 Create MaskManager to guarantee wire/storage update mask consistency (#121)
* Feature: Create MaskManager logic to handle project -> scope update mask logic.

* Updating resource protos and services to use new mask manager setup.

Co-authored-by: Jeff Mitchell <jeffrey.mitchell@gmail.com>
2020-07-20 11:17:09 -07:00
Jeff Mitchell dec1f07266 Update deps and make proto 2020-07-20 13:47:27 -04:00
Jim c83e90ed38 implement SetTableName patttern that allows table name to be set back to the default for the storage type. (#196) 2020-07-17 16:20:56 -04:00
Todd Knight bb4a185412 Pushing test db cleanup up to where the database objects are created using t.Cleanup. (#166) 2020-07-06 10:15:01 -07:00
Todd Knight 0c8385b423 Updating TxHandler to accept a reader as well in order to support reads inside the same transactions as writes. (#139) 2020-06-22 13:27:26 -07:00
Michael Gaffney 4f30983c14 Bump deps and run make gen (#115) 2020-06-11 10:08:54 -04:00
Michael Gaffney ce166c0bdf Use dbassert package (#114)
Removes direct dependency on gorm in tests.
2020-06-10 09:06:41 -04:00
Michael Gaffney cce06c2cc3 Do not explicitly call the embedded store.HostCatalog (#88) 2020-06-02 07:53:35 -04:00
Michael Gaffney 5bdd8a46ea Extract timestamp scanners into reusable package (#91)
* Refactor: move Timestamp from static/store to db/timestamp

* Refactor: convert remaining Timestamps to timestamp.Timestamp

* Use new db timestamp
2020-06-01 11:46:50 -04:00
Michael Gaffney 9eaf8afb6f Rename db.IsUnique to db.IsUniqueError (#90) 2020-06-01 09:54:02 -04:00
Michael Gaffney 4f3f9ed222 Check for nil in embedded HostCatalog (#89) 2020-06-01 09:53:47 -04:00
Jim ef6edbd515 Null updates (#78) 2020-05-31 19:55:56 -04:00
Michael Gaffney be97e5cac8 Remove dead code 2020-05-29 14:21:30 -04:00
Jeff Mitchell 31ef4a65ac Bump deps and make gen 2020-05-29 11:21:12 -04:00
0c7f6da936 Static Host Catalog (#51)
* database: add wt_public_id domain type

* static-hosts: add migrations

* Rename migrations

* migrations: add description column and fix foreign keys

* Add protobuf for static host

* Add HostCatalog and HostSet

* Add Options

* Add foreign key constraint

* Add package doc

* Add copied scanner code

* Add NewHostCatalog with tests

* Override default table name for static host catalog

* WIP: save static host catalog to database

* WIP: Print db url for debugging

* Add iam test helper function

* Make gorm default to null for names and descriptions

* Add foreign key constraint from host catalog to scope

* Names are not needed for the test org and project

* Avoid an ordering dependency in down migrations

* Use wt_timestamp

* Add check constraint on host address column

* Add Host

* Add HostSet

* Add HostSetMember

* Test a HostSetMember can be written to the database

* Move the getters and setters for table name to a new file

The TableName methods are needed by gorm and the SetTableName methods
are for oplog. Moving them to a new file so related functionality is in
the same file.

* Add repository

* Add NewRepository

* Close connection before cleanup of database

* Add comments to protobuf file and regenerate

* Define repository methods for HostCatalog

* Assign PublicId when resource is inserted into the database

* Wrap a nil parameter error

* Add oplog tickets for static host types

* WIP: first cut at CreateCatalog

* CreateHostCatalog: more tests

* Detect unique constraint violation

* Use const for PublicId prefixes

* Use PostgreSQL error name instead of error code

* Add TODO comments

* Fix comments

* Use PublicId not PublicID

* Refactor: move error variables from host/static to db

The error variables defined in host/static are generic and can be reused
by other packages.

* Create a new repository for each test

* Validate CreateCatalog returns a new HostCatalog

* Do not modify the HostCatalog passed in

* Implement UpdateCatalog

* Minor cleanup to make folds work

* Implement LookupCatalog

* Refactor: extract allocCatalog function

* Add comment

* Refactor: extract newCatalogMetadata function

* Make error strings more consistent

* Move database specific error check to internal/db package

* Change signature of DeleteCatalog and update docs

* Implement DeleteCatalog

* Make error strings more consistent

* Add examples

* Update docs

* Add package level doc and example for repository

* No need for using reflect.DeepEqual

* Remove redundant comment

* Clarify ErrMultipleRecords results in the transaction being rolled back

* Remove redundant error checks

* Remove unnecessary check

* Return early instead of using nested 'else' statements

* Update and Delete must return a row count

* catch err on defers (#82)

Co-authored-by: Jim Lambert <jimlambrt@Jims-MBP-3.home>

* Remove 'if assert' pattern

* Use assert package in test helper function

* Add test for updating a non existent catalog

* Use a single assert when a specific error is expected

* Use assert package when it clarifies the check

* Catch errors in cleanup functions

* Update comments in protobuf file

* Update doc for UpdateCatalog to reflect the new behavior

* Add common error values for field mask errors

* Require a field mask when calling update methods

* Add TODO for removing direct call to gorm

* Export Public ID prefixes

* Add db timestamp guards

* Remove unused option

Co-authored-by: Jim <jlambert@hashicorp.com>
Co-authored-by: Jim Lambert <jimlambrt@Jims-MBP-3.home>
2020-05-27 18:16:43 -04:00