-
Notifications
You must be signed in to change notification settings - Fork 936
chore: remove coder/preview dependency from codersdk #17939
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
Merged
Merged
+292
−87
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
`go list -deps github.com/coder/coder/v2/codersdk | grep preview`
Emyrk
commented
May 20, 2025
codersdk/parameters.go
Outdated
Comment on lines
15
to
124
ParameterFormTypeTextArea ParameterFormType = "textarea" | ||
ParameterFormTypeError ParameterFormType = "error" | ||
) | ||
|
||
type OptionType = string | ||
|
||
const ( | ||
OptionTypeString OptionType = "string" | ||
OptionTypeNumber OptionType = "number" | ||
OptionTypeBoolean OptionType = "bool" | ||
OptionTypeListString OptionType = "list(string)" | ||
) | ||
|
||
type DiagnosticSeverityString string | ||
|
||
const ( | ||
DiagnosticSeverityError DiagnosticSeverityString = "error" | ||
DiagnosticSeverityWarning DiagnosticSeverityString = "warning" | ||
) | ||
|
||
// FriendlyDiagnostic == previewtypes.FriendlyDiagnostic | ||
// Copied to avoid import deps | ||
type FriendlyDiagnostic struct { | ||
Severity DiagnosticSeverityString `json:"severity"` | ||
Summary string `json:"summary"` | ||
Detail string `json:"detail"` | ||
|
||
Extra DiagnosticExtra `json:"extra"` | ||
} | ||
|
||
type DiagnosticExtra struct { | ||
Code string `json:"code"` | ||
} | ||
|
||
// NullHCLString == `previewtypes.NullHCLString`. | ||
type NullHCLString struct { | ||
Value string `json:"value"` | ||
Valid bool `json:"valid"` | ||
} | ||
|
||
type Parameter struct { | ||
ParameterData | ||
Value NullHCLString `json:"value"` | ||
Diagnostics []FriendlyDiagnostic `json:"diagnostics"` | ||
} | ||
|
||
type ParameterData struct { | ||
Name string `json:"name"` | ||
DisplayName string `json:"display_name"` | ||
Description string `json:"description"` | ||
Type OptionType `json:"type"` | ||
FormType ParameterFormType `json:"form_type"` | ||
Styling ParameterStyling `json:"styling"` | ||
Mutable bool `json:"mutable"` | ||
DefaultValue NullHCLString `json:"default_value"` | ||
Icon string `json:"icon"` | ||
Options []ParameterOption `json:"options"` | ||
Validations []ParameterValidation `json:"validations"` | ||
Required bool `json:"required"` | ||
// legacy_variable_name was removed (= 14) | ||
Order int64 `json:"order"` | ||
Ephemeral bool `json:"ephemeral"` | ||
} | ||
|
||
type ParameterStyling struct { | ||
Placeholder *string `json:"placeholder,omitempty"` | ||
Disabled *bool `json:"disabled,omitempty"` | ||
Label *string `json:"label,omitempty"` | ||
} | ||
|
||
type ParameterOption struct { | ||
Name string `json:"name"` | ||
Description string `json:"description"` | ||
Value NullHCLString `json:"value"` | ||
Icon string `json:"icon"` | ||
} | ||
|
||
type ParameterValidation struct { | ||
Error string `json:"validation_error"` | ||
|
||
// All validation attributes are optional. | ||
Regex *string `json:"validation_regex"` | ||
Min *int64 `json:"validation_min"` | ||
Max *int64 `json:"validation_max"` | ||
Monotonic *string `json:"validation_monotonic"` | ||
} | ||
|
||
type DynamicParametersRequest struct { | ||
// ID identifies the request. The response contains the same | ||
// ID so that the client can match it to the request. | ||
ID int `json:"id"` | ||
Inputs map[string]string `json:"inputs"` | ||
} | ||
|
||
type DynamicParametersResponse struct { | ||
ID int `json:"id"` | ||
Diagnostics []FriendlyDiagnostic `json:"diagnostics"` | ||
Parameters []Parameter `json:"parameters"` | ||
// TODO: Workspace tags | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should have a guts
like equivalent tool to "copy" types from other packages.
This is always unfortunate
deansheather
approved these changes
May 20, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
a3acf54
to
1a6eeae
Compare
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
No description provided.