Skip to content

refactor: separate platform and IaC resource/datasource base types [ENG-9440] - #266

Open
albertodonato wants to merge 1 commit into
mainfrom
ack/split-api-resource-datasource
Open

albertodonato wants to merge 1 commit into
mainfrom
ack/split-api-resource-datasource

Conversation

@albertodonato

@albertodonato albertodonato commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

ENG-9440

what

Define separate base types for resources and datasources related to platform
and sinistral, each one carrying an api attribute pointing to the
corresponding API class

why

Each resource/datasource interacts with only one API

testing

updated tests

docs

n/a


Stack created with GitHub Stacks CLI • Give Feedback 💬

@albertodonato
albertodonato added this pull request to stack #267 October 23, 2026 14:57
@albertodonato
albertodonato marked this pull request as ready for review October 23, 2026 14:58
@albertodonato
albertodonato requested a review from a team as a code owner October 23, 2026 14:58

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 60 files

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.
Architecture diagram
sequenceDiagram
    participant TF as Terraform Core
    participant R as Resource/DataSource<br/>(e.g., accountResource)
    participant B as Base Type<br/>apiResource[T]/apiDataSource[T]
    participant PD as ProviderData<br/>Internal
    participant API as API Client<br/>(*platform.API or *iac.API)

    Note over TF,API: Provider Configure & Runtime Flow

    TF->>R: Configure request
    R->>B: Call embedded Configure()
    B->>PD: GetAPI[T]("resource"/"datasource", ProviderData)
    
    alt ProviderData not nil
        PD->>PD: Type switch on T
        alt T = *platform.API
            PD->>B: Return PlatformAPI
        else T = *iac.API
            PD->>B: Return IaCAPI
        end
        B->>B: Store API client in api field
        B-->>TF: No diagnostics
    else ProviderData is nil
        PD-->>B: Return nil API
        B-->>TF: No diagnostics (nil API)
    else ProviderData has wrong type
        PD-->>B: providerDataError
        B-->>TF: Add diagnostic error
    end

    Note over TF,API: Runtime CRUD Operations

    TF->>R: Read/Create/Update/Delete
    R->>B: Access api field
    B-->>R: API client instance
    R->>API: Call platform/IaC API endpoint
    API-->>R: Response
Loading

Re-trigger cubic

Base automatically changed from ack/iac-client to main October 23, 2026 16:01
@albertodonato
albertodonato force-pushed the ack/split-api-resource-datasource branch from 0672022 to b6d22be Compare October 23, 2026 16:01
…NG-9440]

[ENG-9440](https://stacklet.atlassian.net/browse/ENG-9440)

### what

Define separate base types for resources and datasources related to platform
and sinistral, each one carrying an `api` attribute pointing to the
corresponding API class

### why

Each resource/datasource interacts with only one API

### testing

updated tests

### docs

n/a
@albertodonato
albertodonato force-pushed the ack/split-api-resource-datasource branch from b6d22be to 5eb1c61 Compare October 23, 2026 16:02

@fwereade fwereade left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants