Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitdd5f55c

Browse files
authored
feat: include deprecation message in docs (#245)
1 parentb73066b commitdd5f55c

File tree

6 files changed

+103
-13
lines changed

6 files changed

+103
-13
lines changed

‎Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ fmt:
55

66
gen:
77
go run github.com/hashicorp/terraform-plugin-docs/cmd/tfplugindocs@latest
8+
go run ./scripts/docsgen/...
89

910
build: terraform-provider-coder
1011

‎docs/data-sources/workspace.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,13 @@ resource "kubernetes_pod" "dev" {
3030
-`access_url` (String) The access URL of the Coder deployment provisioning this workspace.
3131
-`id` (String) UUID of the workspace.
3232
-`name` (String) Name of the workspace.
33-
-`owner` (String, Deprecated) Username of the workspace owner.
34-
-`owner_email` (String, Deprecated) Email address of the workspace owner.
35-
-`owner_groups` (List of String, Deprecated) List of groups the workspace owner belongs to.
36-
-`owner_id` (String, Deprecated) UUID of the workspace owner.
37-
-`owner_name` (String, Deprecated) Name of the workspace owner.
38-
-`owner_oidc_access_token` (String, Deprecated) A valid OpenID Connect access token of the workspace owner. This is only available if the workspace owner authenticated with OpenID Connect. If a valid token cannot be obtained, this value will be an empty string.
39-
-`owner_session_token` (String, Deprecated) Session token for authenticating with a Coder deployment. It is regenerated everytime a workspace is started.
33+
-`owner` (String, Deprecated: Use`coder_workspace_owner.name` instead.) Username of the workspace owner.
34+
-`owner_email` (String, Deprecated: Use`coder_workspace_owner.email` instead.) Email address of the workspace owner.
35+
-`owner_groups` (List of String, Deprecated: Use`coder_workspace_owner.groups` instead.) List of groups the workspace owner belongs to.
36+
-`owner_id` (String, Deprecated: Use`coder_workspace_owner.id` instead.) UUID of the workspace owner.
37+
-`owner_name` (String, Deprecated: Use`coder_workspace_owner.full_name` instead.) Name of the workspace owner.
38+
-`owner_oidc_access_token` (String, Deprecated: Use`coder_workspace_owner.oidc_access_token` instead.) A valid OpenID Connect access token of the workspace owner. This is only available if the workspace owner authenticated with OpenID Connect. If a valid token cannot be obtained, this value will be an empty string.
39+
-`owner_session_token` (String, Deprecated: Use`coder_workspace_owner.session_token` instead.) Session token for authenticating with a Coder deployment. It is regenerated everytime a workspace is started.
4040
-`start_count` (Number) A computed count based on "transition" state. If "start", count will equal 1.
4141
-`template_id` (String) ID of the workspace's template.
4242
-`template_name` (String) Name of the workspace's template.

‎docs/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,5 +62,5 @@ resource "google_compute_instance" "dev" {
6262

6363
###Optional
6464

65-
-`feature_use_managed_variables` (Boolean, Deprecated) Feature: use managed Terraform variables. The feature flag is not used anymore as Terraform variables are now exclusively utilized for template-wide variables.
65+
-`feature_use_managed_variables` (Boolean, Deprecated: Terraform variables are now exclusively utilized for template-wide variables after the removal of support for legacy parameters.) Feature: use managed Terraform variables. The feature flag is not used anymore as Terraform variables are now exclusively utilized for template-wide variables.
6666
-`url` (String) The URL to access Coder.

‎docs/resources/agent.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,15 +76,15 @@ resource "kubernetes_pod" "dev" {
7676
-`dir` (String) The starting directory when a user creates a shell session. Defaults to $HOME.
7777
-`display_apps` (Block Set, Max: 1) The list of built-in apps to display in the agent bar. (see[below for nested schema](#nestedblock--display_apps))
7878
-`env` (Map of String) A mapping of environment variables to set inside the workspace.
79-
-`login_before_ready` (Boolean, Deprecated) This option defines whether or not the user can (by default) login to the workspace before it is ready. Ready means that e.g. the startup_script is done and has exited. When enabled, users may see an incomplete workspace when logging in.
79+
-`login_before_ready` (Boolean, Deprecated: Configure startup_script_behavior instead. This attribute will be removed in a future version of the provider.) This option defines whether or not the user can (by default) login to the workspace before it is ready. Ready means that e.g. the startup_script is done and has exited. When enabled, users may see an incomplete workspace when logging in.
8080
-`metadata` (Block List) Each "metadata" block defines a single item consisting of a key/value pair. This feature is in alpha and may break in future releases. (see[below for nested schema](#nestedblock--metadata))
8181
-`motd_file` (String) The path to a file within the workspace containing a message to display to users when they login via SSH. A typical value would be /etc/motd.
8282
-`order` (Number) The order determines the position of agents in the UI presentation. The lowest order is shown first and agents with equal order are sorted by name (ascending order).
8383
-`shutdown_script` (String) A script to run before the agent is stopped. The script should exit when it is done to signal that the workspace can be stopped. This option is an alias for defining a "coder_script" resource with "run_on_stop" set to true.
84-
-`shutdown_script_timeout` (Number, Deprecated) Time in seconds until the agent lifecycle status is marked as timed out during shutdown, this happens when the shutdown script has not completed (exited) in the given time.
84+
-`shutdown_script_timeout` (Number, Deprecated: This feature is deprecated and has no effect. This attribute will be removed in a future version of the provider.) Time in seconds until the agent lifecycle status is marked as timed out during shutdown, this happens when the shutdown script has not completed (exited) in the given time.
8585
-`startup_script` (String) A script to run after the agent starts. The script should exit when it is done to signal that the agent is ready. This option is an alias for defining a "coder_script" resource with "run_on_start" set to true.
8686
-`startup_script_behavior` (String) This option sets the behavior of the "startup_script". When set to "blocking", the startup_script must exit before the workspace is ready. When set to "non-blocking", the startup_script may run in the background and the workspace will be ready immediately. Default is "non-blocking", although "blocking" is recommended. This option is an alias for defining a "coder_script" resource with "start_blocks_login" set to true (blocking).
87-
-`startup_script_timeout` (Number, Deprecated) Time in seconds until the agent lifecycle status is marked as timed out during start, this happens when the startup script has not completed (exited) in the given time.
87+
-`startup_script_timeout` (Number, Deprecated: This feature is deprecated and has no effect. This attribute will be removed in a future version of the provider.) Time in seconds until the agent lifecycle status is marked as timed out during start, this happens when the startup script has not completed (exited) in the given time.
8888
-`troubleshooting_url` (String) A URL to a document with instructions for troubleshooting problems with the agent.
8989

9090
###Read-Only

‎docs/resources/app.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,9 @@ resource "coder_app" "vim" {
6464
-`external` (Boolean) Specifies whether "url" is opened on the client machine instead of proxied through the workspace.
6565
-`healthcheck` (Block Set, Max: 1) HTTP health checking to determine the application readiness. (see[below for nested schema](#nestedblock--healthcheck))
6666
-`icon` (String) A URL to an icon that will display in the dashboard. View built-in icons here:https://github.com/coder/coder/tree/main/site/static/icon. Use a built-in icon with`data.coder_workspace.me.access_url + "/icon/<path>"`.
67-
-`name` (String, Deprecated) A display name to identify the app.
67+
-`name` (String, Deprecated:`name` on apps is deprecated, use`display_name` instead) A display name to identify the app.
6868
-`order` (Number) The order determines the position of app in the UI presentation. The lowest order is shown first and apps with equal order are sorted by name (ascending order).
69-
-`relative_path` (Boolean, Deprecated) Specifies whether the URL will be accessed via a relative path or wildcard. Use if wildcard routing is unavailable. Defaults to true.
69+
-`relative_path` (Boolean, Deprecated:`relative_path` on apps is deprecated, use`subdomain` instead.) Specifies whether the URL will be accessed via a relative path or wildcard. Use if wildcard routing is unavailable. Defaults to true.
7070
-`share` (String) Determines the "level" which the application is shared at. Valid levels are "owner" (default), "authenticated" and "public". Level "owner" disables sharing on the app, so only the workspace owner can access it. Level "authenticated" shares the app with all authenticated users. Level "public" shares it with any user, including unauthenticated users. Permitted application sharing levels can be configured site-wide via a flag on`coder server` (Enterprise only).
7171
-`subdomain` (Boolean) Determines whether the app will be accessed via it's own subdomain or whether it will be accessed via a path on Coder. If wildcards have not been setup by the administrator then apps with "subdomain" set to true will not be accessible. Defaults to false.
7272
-`url` (String) An external url if "external=true" or a URL to be proxied to from inside the workspace. This should be of the form "http://localhost:PORT[/SUBPATH]". Either "command" or "url" may be specified, but not both.

‎scripts/docsgen/main.go

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
package main
2+
3+
import (
4+
"bytes"
5+
"fmt"
6+
"log"
7+
"os"
8+
"path/filepath"
9+
"regexp"
10+
"strings"
11+
12+
"github.com/coder/terraform-provider-coder/provider"
13+
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
14+
"golang.org/x/xerrors"
15+
)
16+
17+
// This script patches Markdown docs generated by `terraform-plugin-docs` to expose the original deprecation message.
18+
19+
constdocsDir="docs"// FIXME expose as flag?
20+
21+
varreDeprecatedProperty=regexp.MustCompile("`([^`]+)`\\(([^,\\)]+), Deprecated\\) ([^\n]+)")
22+
23+
funcmain() {
24+
p:=provider.New()
25+
err:=exposeDeprecationMessage(p)
26+
iferr!=nil {
27+
log.Fatal(err)
28+
}
29+
}
30+
31+
funcexposeDeprecationMessage(p*schema.Provider)error {
32+
// Patch data-sources
33+
fordataSourceName,dataSource:=rangep.DataSourcesMap {
34+
docFile:=filepath.Join(docsDir,"data-sources",strings.Replace(dataSourceName,"coder_","",1)+".md")
35+
36+
err:=adjustDocFile(docFile,dataSource.Schema)
37+
iferr!=nil {
38+
returnxerrors.Errorf("unable to adjust data-source doc file (data-source: %s): %w",dataSourceName,err)
39+
}
40+
}
41+
42+
// Patch resources
43+
forresourceName,resource:=rangep.ResourcesMap {
44+
docFile:=filepath.Join(docsDir,"resources",strings.Replace(resourceName,"coder_","",1)+".md")
45+
46+
err:=adjustDocFile(docFile,resource.Schema)
47+
iferr!=nil {
48+
returnxerrors.Errorf("unable to adjust resource doc file (resource: %s): %w",resourceName,err)
49+
}
50+
}
51+
52+
// Patch index
53+
docFile:=filepath.Join(docsDir,"index.md")
54+
err:=adjustDocFile(docFile,p.Schema)
55+
iferr!=nil {
56+
returnxerrors.Errorf("unable to adjust index doc file: %w",err)
57+
}
58+
returnnil
59+
}
60+
61+
funcadjustDocFile(docPathstring,schemasmap[string]*schema.Schema)error {
62+
doc,err:=os.ReadFile(docPath)
63+
iferr!=nil {
64+
returnxerrors.Errorf("can't read the source doc file: %w",err)
65+
}
66+
67+
result:=writeDeprecationMessage(doc,schemas)
68+
69+
err=os.WriteFile(docPath,result,0644)
70+
iferr!=nil {
71+
returnxerrors.Errorf("can't write modified doc file: %w",err)
72+
}
73+
returnnil
74+
}
75+
76+
funcwriteDeprecationMessage(doc []byte,schemasmap[string]*schema.Schema) []byte {
77+
returnreDeprecatedProperty.ReplaceAllFunc(doc,func(m []byte) []byte {
78+
matches:=reDeprecatedProperty.FindSubmatch(m)
79+
propertyName:=matches[1]
80+
description:=matches[3]
81+
82+
sch:=schemas[string(propertyName)]
83+
ifstring(description)!=sch.Description {
84+
log.Printf("warn: same property name `%s` but description does not match, most likely a different property",propertyName)
85+
returnm
86+
}
87+
returnbytes.Replace(m, []byte("Deprecated"), []byte(fmt.Sprintf("Deprecated: %s",sch.Deprecated)),1)
88+
})
89+
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp