Skip to content

Commit

Permalink
Update comments about Backend interface implementation, add implement…
Browse files Browse the repository at this point in the history
…ation assertion (#36168)

* Update comments to reflect that the backend.Enhanced interface no longer exists

* Add compile-time check that Local backend implements backendrun.OperationsBackend
  • Loading branch information
SarahFrench authored Dec 6, 2024
1 parent 0d6c1d3 commit 0daf6e8
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
1 change: 1 addition & 0 deletions internal/backend/local/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ type Local struct {
}

var _ backend.Backend = (*Local)(nil)
var _ backendrun.OperationsBackend = (*Local)(nil)

// New returns a new initialized local backend.
func New() *Local {
Expand Down
12 changes: 6 additions & 6 deletions internal/backend/remote/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ func New(services *disco.Disco) *Remote {
}
}

// ConfigSchema implements backend.Enhanced.
// ConfigSchema implements backend.Backend.
func (b *Remote) ConfigSchema() *configschema.Block {
return &configschema.Block{
Attributes: map[string]*configschema.Attribute{
Expand Down Expand Up @@ -221,7 +221,7 @@ func (b *Remote) ServiceDiscoveryAliases() ([]backendrun.HostAlias, error) {
}, nil
}

// Configure implements backend.Enhanced.
// Configure implements backend.Backend.
func (b *Remote) Configure(obj cty.Value) tfdiags.Diagnostics {
var diags tfdiags.Diagnostics
if obj.IsNull() {
Expand Down Expand Up @@ -545,7 +545,7 @@ func (b *Remote) retryLogHook(attemptNum int, resp *http.Response) {
}
}

// Workspaces implements backend.Enhanced.
// Workspaces implements backend.Backend.
func (b *Remote) Workspaces() ([]string, error) {
if b.prefix == "" {
return nil, backend.ErrWorkspacesNotSupported
Expand Down Expand Up @@ -608,7 +608,7 @@ func (b *Remote) WorkspaceNamePattern() string {
return ""
}

// DeleteWorkspace implements backend.Enhanced.
// DeleteWorkspace implements backend.Backend.
func (b *Remote) DeleteWorkspace(name string, _ bool) error {
if b.workspace == "" && name == backend.DefaultStateName {
return backend.ErrDefaultWorkspaceNotSupported
Expand Down Expand Up @@ -636,7 +636,7 @@ func (b *Remote) DeleteWorkspace(name string, _ bool) error {
return client.Delete()
}

// StateMgr implements backend.Enhanced.
// StateMgr implements backend.Backend.
func (b *Remote) StateMgr(name string) (statemgr.Full, error) {
if b.workspace == "" && name == backend.DefaultStateName {
return nil, backend.ErrDefaultWorkspaceNotSupported
Expand Down Expand Up @@ -744,7 +744,7 @@ func (b *Remote) fetchWorkspace(ctx context.Context, organization string, name s
return w, nil
}

// Operation implements backend.Enhanced.
// Operation implements backendrun.OperationsBackend.
func (b *Remote) Operation(ctx context.Context, op *backendrun.Operation) (*backendrun.RunningOperation, error) {
w, err := b.fetchWorkspace(ctx, b.organization, op.Workspace)

Expand Down
2 changes: 1 addition & 1 deletion internal/cloud/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -689,7 +689,7 @@ func (b *Cloud) Workspaces() ([]string, error) {
return names, nil
}

// DeleteWorkspace implements backend.Enhanced.
// DeleteWorkspace implements backend.Backend.
func (b *Cloud) DeleteWorkspace(name string, force bool) error {
if name == backend.DefaultStateName {
return backend.ErrDefaultWorkspaceNotSupported
Expand Down

0 comments on commit 0daf6e8

Please sign in to comment.