Skip to content

feat: assign empty value to ephemeral, required parameter while stopping #8545

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

Closed
wants to merge 1 commit into from

Conversation

mtojek
Copy link
Member

@mtojek mtojek commented Jul 17, 2023

… workspace

Related: #6828

Ephemeral parameters are still rich parameters, so they must undergo the same business logic rules.

Parameters with required values (= no default provided) force the workspace owner to provide these values before starting or updating the workspace (if the new template revision introduces a new parameter). Whenever it is possible the value is pulled from the previous workspace build.

Ephemeral parameters don't pull values from previous builds, so in terms of required parameters, user input is obligatory on every workspace build. This PR bends this rule by assuming an empty value for "stop" and "delete" workspace builds.

Side note:

@bpmct It is a product question: maybe it is a better idea to mark properties required=true and ephemeral=true as conflicting. So far we identified only one business case:

checkmark on every workspace build: I agree not to violate TOS and...

Currently, only properties mutable=false and ephemeral=true are marked as conflicting.

@mtojek mtojek requested review from johnstcn and bpmct July 17, 2023 11:57
@mtojek mtojek self-assigned this Jul 17, 2023
@mtojek mtojek changed the title feat: assume empty value for ephemeral, required parameter while stop… assign empty value to ephemeral, required parameter during stopping Jul 17, 2023
@mtojek mtojek changed the title assign empty value to ephemeral, required parameter during stopping feat: assign empty value to ephemeral, required parameter during stopping Jul 17, 2023
@mtojek mtojek changed the title feat: assign empty value to ephemeral, required parameter during stopping feat: assign empty value to ephemeral, required parameter while stopping Jul 17, 2023
@mtojek mtojek marked this pull request as ready for review July 17, 2023 12:00
}

// ValidateResolve checks the provided value, v, against the parameter, p, and the previous build. If v is nil, it also
// resolves the correct value. It returns the value of the parameter, if valid, and an error if invalid.
func (r *ParameterResolver) ValidateResolve(p TemplateVersionParameter, v *WorkspaceBuildParameter) (value string, err error) {
// Assume value for required, ephemeral parameter for stopped/deleted workspace
if p.Ephemeral && r.Transition != "" && r.Transition != WorkspaceTransitionStart {
Copy link
Member

Choose a reason for hiding this comment

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

In what situation will we get an empty transition?

Copy link
Member Author

Choose a reason for hiding this comment

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

I guess, only unit tests?

@bpmct
Copy link
Member

bpmct commented Jul 17, 2023

We decided to make ephemeral=true and required=true conflicting to avoid awkward flows that we'd have to support, such as in the VS Code extension.

@mtojek mtojek closed this Jul 18, 2023
@github-actions github-actions bot locked and limited conversation to collaborators Jul 18, 2023
@github-actions github-actions bot deleted the 6828-stop-ephemeral branch January 18, 2024 00:04
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants