From 9273aee29079433eebc0f55195b9b38268ec8d40 Mon Sep 17 00:00:00 2001 From: Grady Ward Date: Wed, 15 Nov 2023 19:04:59 -0700 Subject: [PATCH] s/process/parse/g --- azure/azevents/azevents.go | 32 ++++++++++--------- cmd/runner/configs/dev.conf | 4 +-- cmd/runner/configs/local.conf | 4 +-- cmd/runner/main.go | 26 +++++++-------- cmd/runner/taskrunner/taskrunner.go | 4 +-- cmd/server/configs/dev.conf | 2 +- cmd/server/configs/local.conf | 2 +- cmd/server/main.go | 16 +++++----- cmd/server/pactasrv/pactasrv.go | 2 +- cmd/server/pactasrv/portfolio.go | 8 ++--- frontend/openapi/generated/pacta/index.ts | 4 +-- .../openapi/generated/pacta/models/Error.ts | 1 - ...ssPortfolioReq.ts => ParsePortfolioReq.ts} | 2 +- ...PortfolioResp.ts => ParsePortfolioResp.ts} | 2 +- .../pacta/services/DefaultService.ts | 14 ++++---- frontend/pages/admin/portfolio_test.vue | 2 +- openapi/pacta.yaml | 12 +++---- scripts/run_server.sh | 5 +-- task/task.go | 8 ++--- 19 files changed, 76 insertions(+), 74 deletions(-) rename frontend/openapi/generated/pacta/models/{ProcessPortfolioReq.ts => ParsePortfolioReq.ts} (82%) rename frontend/openapi/generated/pacta/models/{ProcessPortfolioResp.ts => ParsePortfolioResp.ts} (86%) diff --git a/azure/azevents/azevents.go b/azure/azevents/azevents.go index 7617465..3fdc863 100644 --- a/azure/azevents/azevents.go +++ b/azure/azevents/azevents.go @@ -28,9 +28,11 @@ type Config struct { // prevent random unauthenticated internet requests from triggering webhooks. AllowedAuthSecrets []string - ProcessedPortfolioTopicName string + ParsedPortfolioTopicName string } +const parsedPortfolioPath = "/events/parsed_portfolio" + func (c *Config) validate() error { if c.Logger == nil { return errors.New("no logger was given") @@ -44,8 +46,8 @@ func (c *Config) validate() error { if len(c.AllowedAuthSecrets) == 0 { return errors.New("no auth secrets were given") } - if c.ProcessedPortfolioTopicName == "" { - return errors.New("no resource group given") + if c.ParsedPortfolioTopicName == "" { + return errors.New("no parsed portfolio topic name given") } return nil } @@ -72,7 +74,7 @@ func NewServer(cfg *Config) (*Server, error) { subscription: cfg.Subscription, resourceGroup: cfg.ResourceGroup, pathToTopic: map[string]string{ - "/events/processed_portfolio": cfg.ProcessedPortfolioTopicName, + parsedPortfolioPath: cfg.ParsedPortfolioTopicName, }, }, nil } @@ -182,16 +184,16 @@ func (s *Server) verifyWebhook(next http.Handler) http.Handler { func (s *Server) RegisterHandlers(r chi.Router) { r.Use(s.verifyWebhook) - r.Post("/events/processed_portfolio", func(w http.ResponseWriter, r *http.Request) { + r.Post(parsedPortfolioPath, func(w http.ResponseWriter, r *http.Request) { var reqs []struct { - Data *task.ProcessPortfolioResponse `json:"data"` - EventType string `json:"eventType"` - ID string `json:"id"` - Subject string `json:"subject"` - DataVersion string `json:"dataVersion"` - MetadataVersion string `json:"metadataVersion"` - EventTime time.Time `json:"eventTime"` - Topic string `json:"topic"` + Data *task.ParsePortfolioResponse `json:"data"` + EventType string `json:"eventType"` + ID string `json:"id"` + Subject string `json:"subject"` + DataVersion string `json:"dataVersion"` + MetadataVersion string `json:"metadataVersion"` + EventTime time.Time `json:"eventTime"` + Topic string `json:"topic"` } if err := json.NewDecoder(r.Body).Decode(&reqs); err != nil { s.logger.Error("failed to parse webhook request body", zap.Error(err)) @@ -211,7 +213,7 @@ func (s *Server) RegisterHandlers(r chi.Router) { return } - // TODO: Add any database persistence and other things we'd want to do after a portfolio was processed. - s.logger.Info("processed portfolio", zap.String("task_id", string(req.Data.TaskID)), zap.Strings("outputs", req.Data.Outputs)) + // TODO: Add any database persistence and other things we'd want to do after a portfolio was parsed. + s.logger.Info("parsed portfolio", zap.String("task_id", string(req.Data.TaskID)), zap.Strings("outputs", req.Data.Outputs)) }) } diff --git a/cmd/runner/configs/dev.conf b/cmd/runner/configs/dev.conf index 9c41fbc..297a18f 100644 --- a/cmd/runner/configs/dev.conf +++ b/cmd/runner/configs/dev.conf @@ -1,10 +1,10 @@ env dev min_log_level warn -azure_processed_portfolio_topic processed-portfolios-dev +azure_event_parsed_portfolio_topic parsed-portfolios-dev azure_topic_location centralus-1 azure_storage_account rmipactadev azure_source_portfolio_container uploadedportfolios -azure_dest_portfolio_container processedportfolios +azure_dest_portfolio_container parsedportfolios azure_report_container reports diff --git a/cmd/runner/configs/local.conf b/cmd/runner/configs/local.conf index 6d7ca07..038a61b 100644 --- a/cmd/runner/configs/local.conf +++ b/cmd/runner/configs/local.conf @@ -1,10 +1,10 @@ env local min_log_level debug -azure_processed_portfolio_topic processed-portfolios-local +azure_event_parsed_portfolio_topic parsed-portfolios-local azure_topic_location centralus-1 azure_storage_account rmipactalocal azure_source_portfolio_container uploadedportfolios -azure_dest_portfolio_container processedportfolios +azure_dest_portfolio_container parsedportfolios azure_report_container reports diff --git a/cmd/runner/main.go b/cmd/runner/main.go index 59d581b..cb98c9d 100644 --- a/cmd/runner/main.go +++ b/cmd/runner/main.go @@ -49,8 +49,8 @@ func run(args []string) error { var ( env = fs.String("env", "", "The environment we're running in.") - azProcessedPortfolioTopic = fs.String("azure_processed_portfolio_topic", "", "The EventGrid topic to send notifications of processed portfolios") - azTopicLocation = fs.String("azure_topic_location", "", "The location (like 'centralus-1') where our EventGrid topics are hosted") + azEventParsePortfolioCompleteTopic = fs.String("azure_event_parse_portfolio_complete_topic", "", "The EventGrid topic to send notifications when processing of portfolio(s) has finished") + azTopicLocation = fs.String("azure_topic_location", "", "The location (like 'centralus-1') where our EventGrid topics are hosted") azStorageAccount = fs.String("azure_storage_account", "", "The storage account to authenticate against for blob operations") azSourcePortfolioContainer = fs.String("azure_source_portfolio_container", "", "The container in the storage account where we read raw portfolios from") @@ -99,7 +99,7 @@ func run(args []string) error { } } - pubsubClient, err := publisher.NewClient(fmt.Sprintf("https://%s.%s.eventgrid.azure.net/api/events", *azProcessedPortfolioTopic, *azTopicLocation), creds, nil) + pubsubClient, err := publisher.NewClient(fmt.Sprintf("https://%s.%s.eventgrid.azure.net/api/events", *azEventParsePortfolioCompleteTopic, *azTopicLocation), creds, nil) if err != nil { return fmt.Errorf("failed to init pub/sub client: %w", err) } @@ -120,8 +120,8 @@ func run(args []string) error { } validTasks := map[task.Type]func(context.Context, task.ID) error{ - task.ProcessPortfolio: toRunFn(processPortfolioReq, h.processPortfolio), - task.CreateReport: toRunFn(createReportReq, h.createReport), + task.ParsePortfolio: toRunFn(parsePortfolioReq, h.parsePortfolio), + task.CreateReport: toRunFn(createReportReq, h.createReport), } taskID := task.ID(os.Getenv("TASK_ID")) @@ -166,7 +166,7 @@ type handler struct { reportContainer string } -func processPortfolioReq() (*task.ProcessPortfolioRequest, error) { +func parsePortfolioReq() (*task.ParsePortfolioRequest, error) { rawAssetIDs := os.Getenv("ASSET_IDS") if rawAssetIDs == "" { return nil, errors.New("no ASSET_IDS given") @@ -177,7 +177,7 @@ func processPortfolioReq() (*task.ProcessPortfolioRequest, error) { return nil, fmt.Errorf("failed to load asset IDs: %w", err) } - return &task.ProcessPortfolioRequest{ + return &task.ParsePortfolioRequest{ AssetIDs: assetIDs, }, nil } @@ -250,7 +250,7 @@ func (h *handler) downloadBlob(ctx context.Context, srcURI, destPath string) err return nil } -func (h *handler) processPortfolio(ctx context.Context, taskID task.ID, req *task.ProcessPortfolioRequest) error { +func (h *handler) parsePortfolio(ctx context.Context, taskID task.ID, req *task.ParsePortfolioRequest) error { // Load the portfolio from blob storage, place it in /mnt/raw_portfolios, where // the `process_portfolios.R` script expects it to be. for _, assetID := range req.AssetIDs { @@ -295,20 +295,20 @@ func (h *handler) processPortfolio(ctx context.Context, taskID task.ID, req *tas for _, p := range paths { destURI := blob.Join(h.blob.Scheme(), h.destPortfolioContainer, filepath.Base(p)) if err := h.uploadBlob(ctx, p, destURI); err != nil { - return fmt.Errorf("failed to copy processed portfolio from %q to %q: %w", p, destURI, err) + return fmt.Errorf("failed to copy parsed portfolio from %q to %q: %w", p, destURI, err) } out = append(out, destURI) } events := []publisher.Event{ { - Data: task.ProcessPortfolioResponse{ + Data: task.ParsePortfolioResponse{ TaskID: taskID, AssetIDs: req.AssetIDs, Outputs: out, }, DataVersion: to.Ptr("1.0"), - EventType: to.Ptr("processed-portfolio"), + EventType: to.Ptr("parse-portfolio-complete"), EventTime: to.Ptr(time.Now()), ID: to.Ptr(string(taskID)), Subject: to.Ptr("subject"), @@ -319,7 +319,7 @@ func (h *handler) processPortfolio(ctx context.Context, taskID task.ID, req *tas return fmt.Errorf("failed to publish event: %w", err) } - h.logger.Info("processed portfolio", zap.String("task_id", string(taskID))) + h.logger.Info("parsed portfolio", zap.String("task_id", string(taskID))) return nil } @@ -338,7 +338,7 @@ func createReportReq() (*task.CreateReportRequest, error) { func (h *handler) createReport(ctx context.Context, taskID task.ID, req *task.CreateReportRequest) error { baseName := string(req.PortfolioID) + ".json" - // Load the processed portfolio from blob storage, place it in /mnt/ + // Load the parsed portfolio from blob storage, place it in /mnt/ // processed_portfolios, where the `create_report.R` script expects it // to be. srcURI := blob.Join(h.blob.Scheme(), h.destPortfolioContainer, baseName) diff --git a/cmd/runner/taskrunner/taskrunner.go b/cmd/runner/taskrunner/taskrunner.go index f164f14..a254ce0 100644 --- a/cmd/runner/taskrunner/taskrunner.go +++ b/cmd/runner/taskrunner/taskrunner.go @@ -82,7 +82,7 @@ func New(cfg *Config) (*TaskRunner, error) { }, nil } -func (tr *TaskRunner) ProcessPortfolio(ctx context.Context, req *task.ProcessPortfolioRequest) (task.ID, task.RunnerID, error) { +func (tr *TaskRunner) ParsePortfolio(ctx context.Context, req *task.ParsePortfolioRequest) (task.ID, task.RunnerID, error) { var buf bytes.Buffer if err := json.NewEncoder(&buf).Encode(req.AssetIDs); err != nil { return "", "", fmt.Errorf("failed to encode asset IDs: %w", err) @@ -90,7 +90,7 @@ func (tr *TaskRunner) ProcessPortfolio(ctx context.Context, req *task.ProcessPor return tr.run(ctx, []task.EnvVar{ { Key: "TASK_TYPE", - Value: string(task.ProcessPortfolio), + Value: string(task.ParsePortfolio), }, { Key: "ASSET_IDS", diff --git a/cmd/server/configs/dev.conf b/cmd/server/configs/dev.conf index 40e9374..3f4cd9b 100644 --- a/cmd/server/configs/dev.conf +++ b/cmd/server/configs/dev.conf @@ -6,4 +6,4 @@ use_azure_runner true azure_event_subscription 69b6db12-37e3-4e1f-b48c-aa41dba612a9 azure_event_resource_group rmi-pacta-dev -azure_event_processed_portfolio_topic processed-portfolios-dev +azure_event_parsed_portfolio_topic parsed-portfolios-dev diff --git a/cmd/server/configs/local.conf b/cmd/server/configs/local.conf index 95f3095..533be0d 100644 --- a/cmd/server/configs/local.conf +++ b/cmd/server/configs/local.conf @@ -3,7 +3,7 @@ allowed_cors_origin http://localhost:3000 azure_event_subscription 69b6db12-37e3-4e1f-b48c-aa41dba612a9 azure_event_resource_group rmi-pacta-local -azure_event_processed_portfolio_topic processed-portfolios-local +azure_event_parsed_portfolio_topic parsed-portfolios-local secret_postgres_host UNUSED # Also unused diff --git a/cmd/server/main.go b/cmd/server/main.go index e690acd..7f365c5 100644 --- a/cmd/server/main.go +++ b/cmd/server/main.go @@ -64,9 +64,9 @@ func run(args []string) error { env = fs.String("env", "", "The environment that we're running in.") localDSN = fs.String("local_dsn", "", "If set, override the DB addresses retrieved from the secret configuration. Can only be used when running locally.") - azEventSubscription = fs.String("azure_event_subscription", "", "The Azure Subscription ID to allow webhook registrations from") - azEventResourceGroup = fs.String("azure_event_resource_group", "", "The Azure resource group to allow webhook registrations from") - azEventProcessedPortfolioTopic = fs.String("azure_event_processed_portfolio_topic", "", "The name of the topic for webhooks about processed portfolios") + azEventSubscription = fs.String("azure_event_subscription", "", "The Azure Subscription ID to allow webhook registrations from") + azEventResourceGroup = fs.String("azure_event_resource_group", "", "The Azure resource group to allow webhook registrations from") + azEventParsedPortfolioTopic = fs.String("azure_event_parsed_portfolio_topic", "", "The name of the topic for webhooks about parsed portfolios") // Only when running locally because the Dockerized runner can't use local `az` CLI credentials localDockerTenantID = fs.String("local_docker_tenant_id", "", "The Azure Tenant ID the localdocker service principal lives in") @@ -285,11 +285,11 @@ func run(args []string) error { }) eventSrv, err := azevents.NewServer(&azevents.Config{ - Logger: logger, - AllowedAuthSecrets: strings.Split(*azEventWebhookSecrets, ","), - Subscription: *azEventSubscription, - ResourceGroup: *azEventResourceGroup, - ProcessedPortfolioTopicName: *azEventProcessedPortfolioTopic, + Logger: logger, + AllowedAuthSecrets: strings.Split(*azEventWebhookSecrets, ","), + Subscription: *azEventSubscription, + ResourceGroup: *azEventResourceGroup, + ParsedPortfolioTopicName: *azEventParsedPortfolioTopic, }) if err != nil { return fmt.Errorf("failed to init Azure Event Grid handler: %w", err) diff --git a/cmd/server/pactasrv/pactasrv.go b/cmd/server/pactasrv/pactasrv.go index 06bfd13..4e0a09b 100644 --- a/cmd/server/pactasrv/pactasrv.go +++ b/cmd/server/pactasrv/pactasrv.go @@ -19,7 +19,7 @@ var ( ) type TaskRunner interface { - ProcessPortfolio(ctx context.Context, req *task.ProcessPortfolioRequest) (task.ID, task.RunnerID, error) + ParsePortfolio(ctx context.Context, req *task.ParsePortfolioRequest) (task.ID, task.RunnerID, error) CreateReport(ctx context.Context, req *task.CreateReportRequest) (task.ID, task.RunnerID, error) } diff --git a/cmd/server/pactasrv/portfolio.go b/cmd/server/pactasrv/portfolio.go index 848e3d9..ad35877 100644 --- a/cmd/server/pactasrv/portfolio.go +++ b/cmd/server/pactasrv/portfolio.go @@ -24,18 +24,18 @@ func (s *Server) CreatePortfolioAsset(ctx context.Context, req api.CreatePortfol }, nil } -func (s *Server) ProcessPortfolio(ctx context.Context, req api.ProcessPortfolioRequestObject) (api.ProcessPortfolioResponseObject, error) { - taskID, runnerID, err := s.TaskRunner.ProcessPortfolio(ctx, &task.ProcessPortfolioRequest{ +func (s *Server) ParsePortfolio(ctx context.Context, req api.ParsePortfolioRequestObject) (api.ParsePortfolioResponseObject, error) { + taskID, runnerID, err := s.TaskRunner.ParsePortfolio(ctx, &task.ParsePortfolioRequest{ AssetIDs: req.Body.AssetIds, // PortfolioID: req.Body.PortfolioID, }) if err != nil { return nil, oapierr.Internal("failed to start task", zap.Error(err)) } - s.Logger.Info("triggered process portfolio task", + s.Logger.Info("triggered parse portfolio task", zap.String("task_id", string(taskID)), zap.String("task_runner_id", string(runnerID))) - return api.ProcessPortfolio200JSONResponse{ + return api.ParsePortfolio200JSONResponse{ TaskId: string(taskID), }, nil } diff --git a/frontend/openapi/generated/pacta/index.ts b/frontend/openapi/generated/pacta/index.ts index 01cd498..2462bfa 100644 --- a/frontend/openapi/generated/pacta/index.ts +++ b/frontend/openapi/generated/pacta/index.ts @@ -23,8 +23,8 @@ export type { NewPortfolioAsset } from './models/NewPortfolioAsset'; export type { PactaVersion } from './models/PactaVersion'; export type { PactaVersionChanges } from './models/PactaVersionChanges'; export type { PactaVersionCreate } from './models/PactaVersionCreate'; -export type { ProcessPortfolioReq } from './models/ProcessPortfolioReq'; -export type { ProcessPortfolioResp } from './models/ProcessPortfolioResp'; +export type { ParsePortfolioReq } from './models/ParsePortfolioReq'; +export type { ParsePortfolioResp } from './models/ParsePortfolioResp'; export { User } from './models/User'; export { UserChanges } from './models/UserChanges'; diff --git a/frontend/openapi/generated/pacta/models/Error.ts b/frontend/openapi/generated/pacta/models/Error.ts index a728a8b..cf64101 100644 --- a/frontend/openapi/generated/pacta/models/Error.ts +++ b/frontend/openapi/generated/pacta/models/Error.ts @@ -12,7 +12,6 @@ export type Error = { * An enum-like type indicating a more specific type of error. * * An example might be getting a 401 Unauthorized because you're logged in with multiple emails and haven't selected one, the error_id could be 'multiple_emails'. - * */ error_id: string; }; diff --git a/frontend/openapi/generated/pacta/models/ProcessPortfolioReq.ts b/frontend/openapi/generated/pacta/models/ParsePortfolioReq.ts similarity index 82% rename from frontend/openapi/generated/pacta/models/ProcessPortfolioReq.ts rename to frontend/openapi/generated/pacta/models/ParsePortfolioReq.ts index 7ec3df0..5970619 100644 --- a/frontend/openapi/generated/pacta/models/ProcessPortfolioReq.ts +++ b/frontend/openapi/generated/pacta/models/ParsePortfolioReq.ts @@ -3,7 +3,7 @@ /* tslint:disable */ /* eslint-disable */ -export type ProcessPortfolioReq = { +export type ParsePortfolioReq = { asset_ids: Array; }; diff --git a/frontend/openapi/generated/pacta/models/ProcessPortfolioResp.ts b/frontend/openapi/generated/pacta/models/ParsePortfolioResp.ts similarity index 86% rename from frontend/openapi/generated/pacta/models/ProcessPortfolioResp.ts rename to frontend/openapi/generated/pacta/models/ParsePortfolioResp.ts index 7cb606e..08ca30d 100644 --- a/frontend/openapi/generated/pacta/models/ProcessPortfolioResp.ts +++ b/frontend/openapi/generated/pacta/models/ParsePortfolioResp.ts @@ -3,7 +3,7 @@ /* tslint:disable */ /* eslint-disable */ -export type ProcessPortfolioResp = { +export type ParsePortfolioResp = { /** * The ID of the async task for processing the portfoio */ diff --git a/frontend/openapi/generated/pacta/services/DefaultService.ts b/frontend/openapi/generated/pacta/services/DefaultService.ts index 8ceb3dd..fe208c3 100644 --- a/frontend/openapi/generated/pacta/services/DefaultService.ts +++ b/frontend/openapi/generated/pacta/services/DefaultService.ts @@ -13,8 +13,8 @@ import type { NewPortfolioAsset } from '../models/NewPortfolioAsset'; import type { PactaVersion } from '../models/PactaVersion'; import type { PactaVersionChanges } from '../models/PactaVersionChanges'; import type { PactaVersionCreate } from '../models/PactaVersionCreate'; -import type { ProcessPortfolioReq } from '../models/ProcessPortfolioReq'; -import type { ProcessPortfolioResp } from '../models/ProcessPortfolioResp'; +import type { ParsePortfolioReq } from '../models/ParsePortfolioReq'; +import type { ParsePortfolioResp } from '../models/ParsePortfolioResp'; import type { User } from '../models/User'; import type { UserChanges } from '../models/UserChanges'; @@ -508,15 +508,15 @@ export class DefaultService { * Starts processing raw uploaded files * * @param requestBody The raw portfolio files to process - * @returns ProcessPortfolioResp The task has been started successfully + * @returns ParsePortfolioResp The task has been started successfully * @throws ApiError */ - public processPortfolio( - requestBody: ProcessPortfolioReq, - ): CancelablePromise { + public parsePortfolio( + requestBody: ParsePortfolioReq, + ): CancelablePromise { return this.httpRequest.request({ method: 'POST', - url: '/test:processPortfolio', + url: '/test:parsePortfolio', body: requestBody, mediaType: 'application/json', }); diff --git a/frontend/pages/admin/portfolio_test.vue b/frontend/pages/admin/portfolio_test.vue index 2c6229e..14d2c5d 100644 --- a/frontend/pages/admin/portfolio_test.vue +++ b/frontend/pages/admin/portfolio_test.vue @@ -24,7 +24,7 @@ const startProcessing = async () => { if (assetIDs.value?.length === 0) { return } - const resp = await pactaClient.processPortfolio({ asset_ids: assetIDs.value }) + const resp = await pactaClient.parsePortfolio({ asset_ids: assetIDs.value }) alert(`TASK ID: ${resp.task_id}`) } diff --git a/openapi/pacta.yaml b/openapi/pacta.yaml index ef1ec5a..ae4c0c8 100644 --- a/openapi/pacta.yaml +++ b/openapi/pacta.yaml @@ -464,26 +464,26 @@ paths: application/json: schema: $ref: '#/components/schemas/NewPortfolioAsset' - /test:processPortfolio: + /test:parsePortfolio: post: summary: Test endpoint, triggers a task to process the portfolio description: | Starts processing raw uploaded files - operationId: processPortfolio + operationId: parsePortfolio requestBody: description: The raw portfolio files to process required: true content: application/json: schema: - $ref: '#/components/schemas/ProcessPortfolioReq' + $ref: '#/components/schemas/ParsePortfolioReq' responses: '200': description: The task has been started successfully content: application/json: schema: - $ref: '#/components/schemas/ProcessPortfolioResp' + $ref: '#/components/schemas/ParsePortfolioResp' components: responses: Unauthorized: @@ -838,7 +838,7 @@ components: asset_id: type: string description: A unique identifier for the uploaded asset - ProcessPortfolioReq: + ParsePortfolioReq: type: object required: - asset_ids @@ -847,7 +847,7 @@ components: type: array items: type: string - ProcessPortfolioResp: + ParsePortfolioResp: type: object required: - task_id diff --git a/scripts/run_server.sh b/scripts/run_server.sh index aed8a0c..c1874fc 100755 --- a/scripts/run_server.sh +++ b/scripts/run_server.sh @@ -37,6 +37,7 @@ LOCAL_DOCKER_CREDS="$(echo $SOPS_DATA | jq .localdocker)" WEBHOOK_CREDS="$(echo $SOPS_DATA | jq .webhook)" TOPIC_ID="$(echo $WEBHOOK_CREDS | jq -r .topic_id)" +WEBHOOK_PATH="/events/parsed_portfolio" WEBHOOK_SHARED_SECRET="$(echo $WEBHOOK_CREDS | jq -r .shared_secret)" FRP="$(echo $SOPS_DATA | jq .frpc)" @@ -64,7 +65,7 @@ function create_eventgrid_subscription { --name "local-webhook-$1" \ --source-resource-id "$TOPIC_ID" \ --endpoint-type=webhook \ - --endpoint="https://$1.${FRP_ADDR}/events/processed_portfolio" \ + --endpoint="https://$1.${FRP_ADDR}${WEBHOOK_PATH}" \ --delivery-attribute-mapping "Authorization static $WEBHOOK_SHARED_SECRET true" } @@ -149,7 +150,7 @@ if [[ ! -z "$EG_SUB_NAME" ]]; then --name "local-webhook-$EG_SUB_NAME" \ --source-resource-id "$TOPIC_ID" \ --endpoint-type=webhook \ - --endpoint="https://${EG_SUB_NAME}.${FRP_ADDR}/events/processed_portfolio" \ + --endpoint="https://${EG_SUB_NAME}.${FRP_ADDR}${WEBHOOK_PATH}" \ --delivery-attribute-mapping Authorization static "$WEBHOOK_SHARED_SECRET" true set -e } & diff --git a/task/task.go b/task/task.go index 6a400ee..ffbefda 100644 --- a/task/task.go +++ b/task/task.go @@ -17,17 +17,17 @@ type RunnerID string type Type string const ( - ProcessPortfolio = Type("process_portfolio") - CreateReport = Type("create_report") + ParsePortfolio = Type("parse_portfolio") + CreateReport = Type("create_report") ) -type ProcessPortfolioRequest struct { +type ParsePortfolioRequest struct { // Note: This is temporary just to test the full end-to-end flow. We'll likely // want to reference assets by the portfolio (group?) they were uploaded to. AssetIDs []string } -type ProcessPortfolioResponse struct { +type ParsePortfolioResponse struct { TaskID ID AssetIDs []string Outputs []string