From 069a2383e8efa2161b281917ac24ddf3b7d86f8a Mon Sep 17 00:00:00 2001 From: David Schmitt Date: Tue, 30 Jul 2024 15:08:13 +0200 Subject: [PATCH 1/2] Rename apikey.proto to match the actual package name --- apikey.proto => apikeys.proto | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename apikey.proto => apikeys.proto (100%) diff --git a/apikey.proto b/apikeys.proto similarity index 100% rename from apikey.proto rename to apikeys.proto From 2195044a09d4ebd57d261aacf0f7bc89898e7a22 Mon Sep 17 00:00:00 2001 From: David Schmitt Date: Tue, 30 Jul 2024 15:20:12 +0200 Subject: [PATCH 2/2] Endpoints for HCP Terraform integration To enable/configure the HCP Terraform integration, we need to create an API Key to hold the user's authorization. To capture the authorization this will go through the same redirect lap as `apikeys.CreateAPIKey` does. To facilitate code-reuse, `CreateHcpConfig` re-uses the messages from the former and will pass through the request internally. --- config.proto | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/config.proto b/config.proto index 5932ae4..44c6e70 100644 --- a/config.proto +++ b/config.proto @@ -1,6 +1,9 @@ syntax = "proto3"; package config; + +import "apikeys.proto"; + option go_package = "github.com/overmindtech/sdp-go;sdp"; // a simple key-value store to store configuration data for accounts and users (TODO) @@ -9,6 +12,15 @@ service ConfigurationService { rpc GetAccountConfig(GetAccountConfigRequest) returns (GetAccountConfigResponse); // Update the account config for the user's account rpc UpdateAccountConfig(UpdateAccountConfigRequest) returns (UpdateAccountConfigResponse); + + // Create a new HCP Terraform config for the user's account. This follows + // the same flow as CreateAPIKey, to create a new API key that is then used + // for the HCP Terraform endpoint URL. + rpc CreateHcpConfig(CreateHcpConfigRequest) returns (CreateHcpConfigResponse); + // Get the existing HCP Terraform config for the user's account. + rpc GetHcpConfig(GetHcpConfigRequest) returns (GetHcpConfigResponse); + // Remove the existing HCP Terraform config from the user's account. + rpc DeleteHcpConfig(DeleteHcpConfigRequest) returns (DeleteHcpConfigResponse); } // The config that is used when calculating the blast radius for a change, this @@ -67,3 +79,32 @@ message UpdateAccountConfigRequest { message UpdateAccountConfigResponse { AccountConfig config = 1; } + +message CreateHcpConfigRequest { + // The URL that the user should be redirected to after the whole process is + // over. This should be a page in the frontend, probably the HCP Terraform + // Integration page. + string finalFrontendRedirect = 1; +} + +message CreateHcpConfigResponse { + HcpConfig config = 1; + apikeys.CreateAPIKeyResponse apiKey = 2; +} + +message HcpConfig { + // the Endpoint URL for the HCP Run Task configuration + string endpoint = 1; + // the HMAC secret for the HCP Run Task configuration + string secret = 2; +} + +message GetHcpConfigRequest {} + +message GetHcpConfigResponse { + HcpConfig config = 1; +} + +message DeleteHcpConfigRequest {} + +message DeleteHcpConfigResponse {}