Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update comments about Backend interface implementation, add implementation assertion #36168

Merged
merged 2 commits into from
Dec 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
Copy link
Member Author

Choose a reason for hiding this comment

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

To be fair, this was already checked in a test:

func TestLocal_impl(t *testing.T) {
var _ backendrun.OperationsBackend = New()
var _ backendrun.Local = New()
var _ backendrun.CLI = New()
}

But this assertion will run at compile time


// 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
Loading