Skip to content

Envelope: Implement ProvisioningEnvelope for MessageBroker integration #7468

Description

@wbreza

Summary

Create ProvisioningEnvelope implementing grpcbroker.MessageEnvelope[ProvisioningMessage] to bridge proto messages with the generic MessageBroker. This handles request ID correlation, error extraction/wrapping, inner message extraction from the oneof, and progress message identification for Deploy, Preview, and Destroy operations.

Parent Epic

Part of #7465 — Provisioning Providers in the AZD Extension Framework

Context

The MessageBroker is a generic bidirectional stream handler that requires a MessageEnvelope implementation to understand the structure of the messages it's routing. Each extension capability has its own envelope:

  • ServiceTargetEnvelope in pkg/azdext/service_target_envelope.go
  • FrameworkServiceEnvelope in pkg/azdext/framework_service_envelope.go

The envelope must implement:

type MessageEnvelope[T any] interface {
    GetRequestId(ctx context.Context, msg *T) string
    SetRequestId(ctx context.Context, msg *T, id string)
    GetError(msg *T) error
    SetError(msg *T, err error)
    GetInnerMessage(msg *T) any
    IsProgressMessage(msg *T) bool
    GetProgressMessage(msg *T) string
    CreateProgressMessage(requestId string, message string) *T
}

Detailed Requirements

GetRequestId / SetRequestId

  • Extract/set the request_id field from ProvisioningMessage
  • Used by the broker for request-response correlation

GetError / SetError

  • Extract ExtensionError from the message and convert to Go error using UnwrapError()
  • Set ExtensionError on the message using WrapError()
  • Follows the pattern in service_target_envelope.go

GetInnerMessage

  • Extract the active oneof payload from MessageType
  • Return it as any for reflection-based handler dispatch

IsProgressMessage / GetProgressMessage / CreateProgressMessage

  • IsProgressMessage returns true for ProvisioningDeployProgressMessage, ProvisioningPreviewProgressMessage, and ProvisioningDestroyProgressMessage
  • GetProgressMessage extracts the progress text string
  • CreateProgressMessage creates a new progress message with the given requestId and message text

Acceptance Criteria

  • ProvisioningEnvelope struct implementing MessageEnvelope[ProvisioningMessage]
  • GetRequestId() extracts request_id from ProvisioningMessage
  • SetRequestId() sets request_id on ProvisioningMessage
  • GetError() extracts ExtensionError and converts via UnwrapError()
  • SetError() sets ExtensionError via WrapError()
  • GetInnerMessage() extracts active oneof payload
  • IsProgressMessage() returns true for all 3 progress message types
  • GetProgressMessage() extracts progress text
  • CreateProgressMessage() creates progress message with request_id
  • Unit tests for all methods

Dependencies

Files

  • Create: pkg/azdext/provisioning_envelope.go
  • Create: pkg/azdext/provisioning_envelope_test.go

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions