github.com/crossplane/upjet@v1.3.0/pkg/controller/interfaces.go (about)

     1  // SPDX-FileCopyrightText: 2023 The Crossplane Authors <https://crossplane.io>
     2  //
     3  // SPDX-License-Identifier: Apache-2.0
     4  
     5  package controller
     6  
     7  import (
     8  	"context"
     9  
    10  	"github.com/crossplane/upjet/pkg/config"
    11  	"github.com/crossplane/upjet/pkg/resource"
    12  	"github.com/crossplane/upjet/pkg/terraform"
    13  )
    14  
    15  // TODO(muvaf): It's a bit weird that the functions return the struct of a
    16  // specific implementation of this interface. Maybe a different package for the
    17  // returned result types?
    18  
    19  // Workspace is the set of methods that are needed for the controller to work.
    20  type Workspace interface {
    21  	ApplyAsync(terraform.CallbackFn) error
    22  	Apply(context.Context) (terraform.ApplyResult, error)
    23  	DestroyAsync(terraform.CallbackFn) error
    24  	Destroy(context.Context) error
    25  	Refresh(context.Context) (terraform.RefreshResult, error)
    26  	Import(context.Context, resource.Terraformed) (terraform.ImportResult, error)
    27  	Plan(context.Context) (terraform.PlanResult, error)
    28  }
    29  
    30  // ProviderSharer shares a native provider process with the receiver.
    31  type ProviderSharer interface {
    32  	UseProvider(inuse terraform.InUse, attachmentConfig string)
    33  }
    34  
    35  // Store is where we can get access to the Terraform workspace of given resource.
    36  type Store interface {
    37  	Workspace(ctx context.Context, c resource.SecretClient, tr resource.Terraformed, ts terraform.Setup, cfg *config.Resource) (*terraform.Workspace, error)
    38  }
    39  
    40  // CallbackProvider provides functions that can be called with the result of
    41  // async operations.
    42  type CallbackProvider interface {
    43  	Create(name string) terraform.CallbackFn
    44  	Update(name string) terraform.CallbackFn
    45  	Destroy(name string) terraform.CallbackFn
    46  }