Files
coder/enterprise/cli/templateedit_test.go
T
Nick Vigilante c6a47c4428 docs: replace references to the retired Enterprise license tier (#30853)
## Summary

Coder has only Community and Premium license tiers, but several docs
pages, CLI help strings, and SDK field comments still called features
"Enterprise" or "enterprise-only".
This PR changes them to say Premium and regenerates the reference docs
built from those strings.

Resolves
[DOCS-1298](https://linear.app/codercom/issue/DOCS-1298/remove-references-to-the-retired-enterprise-license-tier).

## Changes

- `docs/admin/users/quotas.md`: Replace "scoped to Groups in Enterprise
and organizations in Premium" with a correct sentence. Quotas are
Premium, allowances are set on groups, and each user's budget is
calculated separately in each organization (per
`GetQuotaAllowanceForUser`).
- `docs/user-guides/workspace-lifecycle.md`: Replace "Enterprise" with
Premium, and correct the quotas sentence to match the quotas page.
- `docs/ai-coder/agents/platform-controls/mcp-servers.md`: Replace
"enterprise entitlement" with Premium license.
- `cli/templatecreate.go`, `cli/templateedit.go`: Update
`--require-active-version`, `--allow-user-autostart`, and
`--allow-user-autostop` help text. Point the `--require-active-version`
help at the renamed `#template-update-policies` section, because the old
`#require-automatic-updates-enterprise` anchor is broken. Make the
errors for these flags tier-neutral.
- `enterprise/cli/features.go`: `coder features` now says "List license
features and entitlements", and its AGPL error no longer names a tier.
- `codersdk/templates.go`, `codersdk/organizations.go`: Update field
comments that feed the API reference and TypeScript types.
- `docs/reference/glossary.md`: The Premium entry now says "paid license
tier" instead of "paid enterprise tier".
- `docs/.style/style-guide/voice-and-tone.md`: The example sentence now
says "Premium licensing".
- Regenerated: CLI golden files, `docs/reference/cli/`,
`docs/manifest.json`, `docs/manifest/generated/cli.json`,
`docs/reference/api/`, `coderd/apidoc/`, and
`site/src/api/typesGenerated.ts`.

## Testing

- `go test ./cli -run 'TestCommandHelp|TestCliTemplateCreate'` and `go
test ./enterprise/cli -run
'TestEnterpriseCommandHelp|TestTemplateCreate|TestTemplateEdit|TestFeaturesList'`
pass.
- The pre-commit hook passed, including `make gen`, `fmt`, `lint/go`,
`lint/ts`, `lint/markdown`, and a slim build.

<details>
<summary>Decisions and out-of-scope items</summary>

### Decisions

- **Premium wording and legacy Enterprise licenses:** Coder still
accepts existing Enterprise licenses, and `FeatureSetEnterprise`
includes the features labeled Premium here. Docs and help text say
"Premium" because that is the tier sold today, and about 25 other docs
pages already use "Premium feature". Error strings are tier-neutral, so
they're accurate for every license holder.
- **Glossary and style guide:** The issue marked these as borderline.
Both were one-word changes, so I made them.

### Not changed

- `docs/reference/api/enterprise.md` keeps the "Enterprise" sidebar
title. It comes from the swagger tag on the `enterprise/` Go package, so
renaming it is a larger change.
- Other "Enterprise" references the review flagged as out of scope: the
`coder server --help` option group, quiet hours SDK comments, internal
`coderd` comments, and the dashboard's "Enterprise" badge on the
require-active-version option.
- No docs page says that legacy Enterprise licenses are still valid.
- Uses that don't refer to the license tier: GitHub Enterprise, Red Hat
Enterprise Linux, "enterprise environments", and `enterprise/` package
paths.

</details>

---

_This PR was generated by Coder Agents on behalf of @nickvigilante._
2026-10-15 17:46:05 +00:00

316 lines
11 KiB
Go

package cli_test
import (
"testing"
"time"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/coder/coder/v2/cli/clitest"
"github.com/coder/coder/v2/coderd/coderdtest"
"github.com/coder/coder/v2/coderd/database"
"github.com/coder/coder/v2/coderd/database/dbfake"
"github.com/coder/coder/v2/coderd/rbac"
"github.com/coder/coder/v2/codersdk"
"github.com/coder/coder/v2/enterprise/coderd/coderdenttest"
"github.com/coder/coder/v2/enterprise/coderd/license"
"github.com/coder/coder/v2/testutil"
)
func TestTemplateEdit(t *testing.T) {
t.Parallel()
t.Run("OK", func(t *testing.T) {
t.Parallel()
ownerClient, owner := coderdenttest.New(t, &coderdenttest.Options{
LicenseOptions: &coderdenttest.LicenseOptions{
Features: license.Features{
codersdk.FeatureAccessControl: 1,
},
},
Options: &coderdtest.Options{
IncludeProvisionerDaemon: true,
},
})
templateAdmin, _ := coderdtest.CreateAnotherUser(t, ownerClient, owner.OrganizationID, rbac.RoleTemplateAdmin())
version := coderdtest.CreateTemplateVersion(t, templateAdmin, owner.OrganizationID, nil)
_ = coderdtest.AwaitTemplateVersionJobCompleted(t, templateAdmin, version.ID)
template := coderdtest.CreateTemplate(t, templateAdmin, owner.OrganizationID, version.ID)
require.False(t, template.RequireActiveVersion)
inv, conf := newCLI(t, "templates",
"edit", template.Name,
"--require-active-version",
"-y",
)
clitest.SetupConfig(t, templateAdmin, conf)
err := inv.Run()
require.NoError(t, err)
ctx := testutil.Context(t, testutil.WaitMedium)
template, err = templateAdmin.Template(ctx, template.ID)
require.NoError(t, err)
require.True(t, template.RequireActiveVersion)
})
t.Run("NotEntitled", func(t *testing.T) {
t.Parallel()
client, owner := coderdenttest.New(t, &coderdenttest.Options{
LicenseOptions: &coderdenttest.LicenseOptions{
Features: license.Features{},
},
Options: &coderdtest.Options{
IncludeProvisionerDaemon: true,
},
})
templateAdmin, _ := coderdtest.CreateAnotherUser(t, client, owner.OrganizationID, rbac.RoleTemplateAdmin())
version := coderdtest.CreateTemplateVersion(t, client, owner.OrganizationID, nil)
_ = coderdtest.AwaitTemplateVersionJobCompleted(t, client, version.ID)
template := coderdtest.CreateTemplate(t, client, owner.OrganizationID, version.ID)
require.False(t, template.RequireActiveVersion)
inv, conf := newCLI(t, "templates",
"edit", template.Name,
"--require-active-version",
"-y",
)
clitest.SetupConfig(t, templateAdmin, conf)
err := inv.Run()
require.Error(t, err)
require.Contains(t, err.Error(), "your license is not entitled to use access control, so you cannot set --require-active-version")
})
t.Run("WorkspaceCleanup", func(t *testing.T) {
t.Parallel()
ownerClient, owner := coderdenttest.New(t, &coderdenttest.Options{
LicenseOptions: &coderdenttest.LicenseOptions{
Features: license.Features{
codersdk.FeatureAdvancedTemplateScheduling: 1,
},
},
Options: &coderdtest.Options{
IncludeProvisionerDaemon: true,
},
})
templateAdmin, _ := coderdtest.CreateAnotherUser(t, ownerClient, owner.OrganizationID, rbac.RoleTemplateAdmin())
version := coderdtest.CreateTemplateVersion(t, templateAdmin, owner.OrganizationID, nil)
_ = coderdtest.AwaitTemplateVersionJobCompleted(t, templateAdmin, version.ID)
template := coderdtest.CreateTemplate(t, templateAdmin, owner.OrganizationID, version.ID)
require.False(t, template.RequireActiveVersion)
const (
expectedFailureTTL = time.Hour * 3
expectedDormancyThreshold = time.Hour * 4
expectedDormancyAutoDeletion = time.Minute * 10
)
inv, conf := newCLI(t, "templates",
"edit", template.Name,
"--failure-ttl="+expectedFailureTTL.String(),
"--dormancy-threshold="+expectedDormancyThreshold.String(),
"--dormancy-auto-deletion="+expectedDormancyAutoDeletion.String(),
"-y",
)
clitest.SetupConfig(t, templateAdmin, conf)
err := inv.Run()
require.NoError(t, err)
ctx := testutil.Context(t, testutil.WaitMedium)
template, err = templateAdmin.Template(ctx, template.ID)
require.NoError(t, err)
require.Equal(t, expectedFailureTTL.Milliseconds(), template.FailureTTLMillis)
require.Equal(t, expectedDormancyThreshold.Milliseconds(), template.TimeTilDormantMillis)
require.Equal(t, expectedDormancyAutoDeletion.Milliseconds(), template.TimeTilDormantAutoDeleteMillis)
inv, conf = newCLI(t, "templates",
"edit", template.Name,
"--display-name=idc",
"-y",
)
clitest.SetupConfig(t, templateAdmin, conf)
err = inv.Run()
require.NoError(t, err)
// Refetch the template to assert we haven't inadvertently updated
// the values to their default values.
template, err = templateAdmin.Template(ctx, template.ID)
require.NoError(t, err)
require.Equal(t, expectedFailureTTL.Milliseconds(), template.FailureTTLMillis)
require.Equal(t, expectedDormancyThreshold.Milliseconds(), template.TimeTilDormantMillis)
require.Equal(t, expectedDormancyAutoDeletion.Milliseconds(), template.TimeTilDormantAutoDeleteMillis)
})
// Test that omitting a flag does not update a template with the
// default for a flag.
t.Run("DefaultsDontOverride", func(t *testing.T) {
t.Parallel()
ctx := testutil.Context(t, testutil.WaitMedium)
ownerClient, db, owner := coderdenttest.NewWithDatabase(t, &coderdenttest.Options{
LicenseOptions: &coderdenttest.LicenseOptions{
Features: license.Features{
codersdk.FeatureAdvancedTemplateScheduling: 1,
codersdk.FeatureAccessControl: 1,
codersdk.FeatureTemplateRBAC: 1,
},
},
})
dbtemplate := dbfake.TemplateVersion(t, db).Seed(database.TemplateVersion{
CreatedBy: owner.UserID,
OrganizationID: owner.OrganizationID,
}).Do().Template
var (
expectedName = "template"
expectedDisplayName = "template_display"
expectedDescription = "My description"
expectedIcon = "icon.pjg"
expectedDefaultTTLMillis = time.Hour.Milliseconds()
expectedAllowAutostart = false
expectedAllowAutostop = false
expectedFailureTTLMillis = time.Minute.Milliseconds()
expectedDormancyMillis = 2 * time.Minute.Milliseconds()
expectedAutoDeleteMillis = 3 * time.Minute.Milliseconds()
expectedRequireActiveVersion = true
expectedAllowCancelJobs = false
deprecationMessage = "Deprecate me"
expectedDisableEveryone = true
expectedAutostartDaysOfWeek = []string{}
expectedAutoStopDaysOfWeek = []string{}
expectedAutoStopWeeks = 1
)
assertFieldsFn := func(t *testing.T, tpl codersdk.Template, acl codersdk.TemplateACL) {
t.Helper()
assert.Equal(t, expectedName, tpl.Name)
assert.Equal(t, expectedDisplayName, tpl.DisplayName)
assert.Equal(t, expectedDescription, tpl.Description)
assert.Equal(t, expectedIcon, tpl.Icon)
assert.Equal(t, expectedDefaultTTLMillis, tpl.DefaultTTLMillis)
assert.Equal(t, expectedAllowAutostart, tpl.AllowUserAutostart)
assert.Equal(t, expectedAllowAutostop, tpl.AllowUserAutostop)
assert.Equal(t, expectedFailureTTLMillis, tpl.FailureTTLMillis)
assert.Equal(t, expectedDormancyMillis, tpl.TimeTilDormantMillis)
assert.Equal(t, expectedAutoDeleteMillis, tpl.TimeTilDormantAutoDeleteMillis)
assert.Equal(t, expectedRequireActiveVersion, tpl.RequireActiveVersion)
assert.Equal(t, deprecationMessage, tpl.DeprecationMessage)
assert.Equal(t, expectedAllowCancelJobs, tpl.AllowUserCancelWorkspaceJobs)
assert.Equal(t, len(acl.Groups) == 0, expectedDisableEveryone)
assert.Equal(t, expectedAutostartDaysOfWeek, tpl.AutostartRequirement.DaysOfWeek)
assert.Equal(t, expectedAutoStopDaysOfWeek, tpl.AutostopRequirement.DaysOfWeek)
assert.Equal(t, int64(expectedAutoStopWeeks), tpl.AutostopRequirement.Weeks)
}
template, err := ownerClient.UpdateTemplateMeta(ctx, dbtemplate.ID, codersdk.UpdateTemplateMeta{
Name: new(expectedName),
DisplayName: &expectedDisplayName,
Description: &expectedDescription,
Icon: &expectedIcon,
DefaultTTLMillis: new(expectedDefaultTTLMillis),
AllowUserAutostop: new(expectedAllowAutostop),
AllowUserAutostart: new(expectedAllowAutostart),
FailureTTLMillis: new(expectedFailureTTLMillis),
TimeTilDormantMillis: new(expectedDormancyMillis),
TimeTilDormantAutoDeleteMillis: new(expectedAutoDeleteMillis),
RequireActiveVersion: new(expectedRequireActiveVersion),
DeprecationMessage: new(deprecationMessage),
DisableEveryoneGroupAccess: new(expectedDisableEveryone),
AllowUserCancelWorkspaceJobs: new(expectedAllowCancelJobs),
AutostartRequirement: &codersdk.TemplateAutostartRequirement{
DaysOfWeek: expectedAutostartDaysOfWeek,
},
})
require.NoError(t, err)
templateACL, err := ownerClient.TemplateACL(ctx, template.ID)
require.NoError(t, err)
assertFieldsFn(t, template, templateACL)
expectedName = "newName"
inv, conf := newCLI(t, "templates",
"edit", template.Name,
"--name=newName",
"-y",
)
clitest.SetupConfig(t, ownerClient, conf)
err = inv.Run()
require.NoError(t, err)
template, err = ownerClient.Template(ctx, template.ID)
require.NoError(t, err)
templateACL, err = ownerClient.TemplateACL(ctx, template.ID)
require.NoError(t, err)
assertFieldsFn(t, template, templateACL)
expectedAutostartDaysOfWeek = []string{"monday", "wednesday", "friday"}
expectedAutoStopDaysOfWeek = []string{"tuesday", "thursday"}
expectedAutoStopWeeks = 2
template, err = ownerClient.UpdateTemplateMeta(ctx, dbtemplate.ID, codersdk.UpdateTemplateMeta{
Name: new(expectedName),
DisplayName: &expectedDisplayName,
Description: &expectedDescription,
Icon: &expectedIcon,
DefaultTTLMillis: new(expectedDefaultTTLMillis),
AllowUserAutostop: new(expectedAllowAutostop),
AllowUserAutostart: new(expectedAllowAutostart),
FailureTTLMillis: new(expectedFailureTTLMillis),
TimeTilDormantMillis: new(expectedDormancyMillis),
TimeTilDormantAutoDeleteMillis: new(expectedAutoDeleteMillis),
RequireActiveVersion: new(expectedRequireActiveVersion),
DeprecationMessage: new(deprecationMessage),
DisableEveryoneGroupAccess: new(expectedDisableEveryone),
AllowUserCancelWorkspaceJobs: new(expectedAllowCancelJobs),
AutostartRequirement: &codersdk.TemplateAutostartRequirement{
DaysOfWeek: expectedAutostartDaysOfWeek,
},
AutostopRequirement: &codersdk.TemplateAutostopRequirement{
DaysOfWeek: expectedAutoStopDaysOfWeek,
Weeks: int64(expectedAutoStopWeeks),
},
})
require.NoError(t, err)
assertFieldsFn(t, template, templateACL)
// Rerun the update so we can assert that autostop days aren't
// mucked with.
expectedName = "newName2"
inv, conf = newCLI(t, "templates",
"edit", template.Name,
"--name=newName2",
"-y",
)
clitest.SetupConfig(t, ownerClient, conf)
err = inv.Run()
require.NoError(t, err)
template, err = ownerClient.Template(ctx, template.ID)
require.NoError(t, err)
templateACL, err = ownerClient.TemplateACL(ctx, template.ID)
require.NoError(t, err)
assertFieldsFn(t, template, templateACL)
})
}