You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// Verify that selected workspace exists in the state store.
1652
1652
ifopts.Init&&b!=nil {
1653
1653
err:=m.selectWorkspace(b)
1654
-
ifstrings.Contains(err.Error(), "No existing workspaces") {
1655
-
// If there are no workspaces, Terraform either needs to create the default workspace here,
1656
-
// or instruct the user to run a `terraform workspace new` command.
1657
-
ws, err:=m.Workspace()
1658
-
iferr!=nil {
1659
-
diags=diags.Append(fmt.Errorf("Failed to check current workspace: %w", err))
1660
-
returnnil, diags
1661
-
}
1654
+
iferr!=nil {
1655
+
ifstrings.Contains(err.Error(), "No existing workspaces") {
1656
+
// If there are no workspaces, Terraform either needs to create the default workspace here,
1657
+
// or instruct the user to run a `terraform workspace new` command.
1658
+
ws, err:=m.Workspace()
1659
+
iferr!=nil {
1660
+
diags=diags.Append(fmt.Errorf("Failed to check current workspace: %w", err))
1661
+
returnnil, diags
1662
+
}
1662
1663
1663
-
switch {
1664
-
casews!=backend.DefaultStateName:
1665
-
// User needs to run a `terraform workspace new` command.
1666
-
diags=append(diags, tfdiags.Sourceless(
1667
-
tfdiags.Error,
1668
-
fmt.Sprintf("Workspace %q has not been created yet", ws),
1669
-
fmt.Sprintf("State store %q in provider %s (%q) reports that no workspaces currently exist. To create the custom workspace %q use the command `terraform workspace new %s`.",
1670
-
c.Type,
1671
-
c.Provider.Name,
1672
-
c.ProviderAddr,
1673
-
ws,
1674
-
ws,
1675
-
),
1676
-
))
1677
-
returnnil, diags
1664
+
switch {
1665
+
casews!=backend.DefaultStateName:
1666
+
// User needs to run a `terraform workspace new` command.
1667
+
diags=append(diags, tfdiags.Sourceless(
1668
+
tfdiags.Error,
1669
+
fmt.Sprintf("Workspace %q has not been created yet", ws),
1670
+
fmt.Sprintf("State store %q in provider %s (%q) reports that no workspaces currently exist. To create the custom workspace %q use the command `terraform workspace new %s`.",
1671
+
c.Type,
1672
+
c.Provider.Name,
1673
+
c.ProviderAddr,
1674
+
ws,
1675
+
ws,
1676
+
),
1677
+
))
1678
+
returnnil, diags
1678
1679
1679
-
casews==backend.DefaultStateName:
1680
-
// Users control if the default workspace is created through the -create-default-workspace flag (defaults to true)
Detail: "Terraform has been configured to skip creation of the default workspace in the state store. To create it, either run an 'init' command without `-create-default-workspace=true`, or create it using a 'workspace new' command",
1688
-
})
1680
+
casews==backend.DefaultStateName:
1681
+
// Users control if the default workspace is created through the -create-default-workspace flag (defaults to true)
Detail: "Terraform has been configured to skip creation of the default workspace in the state store. To create it, either run an 'init' command without `-create-default-workspace=true`, or create it using a 'workspace new' command",
1689
+
})
1690
+
}
1691
+
default:
1692
+
diags=diags.Append(err)
1693
+
returnnil, diags
1689
1694
}
1690
-
default:
1691
-
diags=diags.Append(err)
1692
-
returnnil,diags
1695
+
} else {
1696
+
// For all other errors, report via diagnostics
1697
+
diags=diags.Append(fmt.Errorf("Failed to select a workspace: %w", err))
0 commit comments