Skip to content

feat: Allow inheriting parameters from previous template_versions when updating a template #2397

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 18 commits into from
Jun 17, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Merge remote-tracking branch 'origin/main' into stevenmasley/template…
…_update_params
  • Loading branch information
Emyrk committed Jun 15, 2022
commit effbde79e507fa60893cd5c80a68301136399e56
13 changes: 10 additions & 3 deletions cli/parameters.go
Original file line number Diff line number Diff line change
@@ -1,16 +1,24 @@
package cli

import (
"github.com/coder/coder/cli/cliui"
"github.com/coder/coder/codersdk"
"github.com/jedib0t/go-pretty/v6/table"
"github.com/spf13/cobra"

"github.com/coder/coder/cli/cliui"
"github.com/coder/coder/codersdk"
)

func parameters() *cobra.Command {
cmd := &cobra.Command{
Short: "List parameters for a given scope",
Example: "coder parameters list workspace my-workspace",
Use: "parameters",
// Currently hidden as this shows parameter values, not parameter
// schemes. Until we have a good way to distinguish the two, it's better
// not to add confusion or lock ourselves into a certain api.
// This cmd is still valuable debugging tool for devs to avoid
// constructing curl requests.
Hidden: true,
Aliases: []string{"params"},
}
cmd.AddCommand(
Expand All @@ -31,7 +39,6 @@ func displayParameters(filterColumns []string, params ...codersdk.Parameter) str
Name: "name",
}})
for _, param := range params {
//fmt.Println(param, filterColumns)
tableWriter.AppendRow(table.Row{
param.ID.String(),
param.Scope,
Expand Down
10 changes: 5 additions & 5 deletions cli/parameterslist.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ import (
"fmt"

"github.com/google/uuid"
"github.com/spf13/cobra"
"golang.org/x/xerrors"

"github.com/coder/coder/codersdk"
"github.com/spf13/cobra"
)

func parameterList() *cobra.Command {
Expand Down Expand Up @@ -46,19 +46,19 @@ func parameterList() *cobra.Command {
}
scopeID = template.ID

case codersdk.ParameterImportJob, "template_version":
scope = string(codersdk.ParameterImportJob)
case codersdk.ParameterScopeImportJob, "template_version":
scope = string(codersdk.ParameterScopeImportJob)
scopeID, err = uuid.Parse(name)
if err != nil {
return xerrors.Errorf("%q must be a uuid for this scope type", name)
}
default:
return xerrors.Errorf("%q is an unsupported scope, use %v", scope, []codersdk.ParameterScope{
codersdk.ParameterWorkspace, codersdk.ParameterTemplate, codersdk.ParameterImportJob,
codersdk.ParameterWorkspace, codersdk.ParameterTemplate, codersdk.ParameterScopeImportJob,
})
}

params, err := client.Parameters(cmd.Context(), codersdk.ParameterScope(args[0]), scopeID)
params, err := client.Parameters(cmd.Context(), codersdk.ParameterScope(scope), scopeID)
if err != nil {
return xerrors.Errorf("fetch params: %w", err)
}
Expand Down
4 changes: 2 additions & 2 deletions cli/templates.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ func displayTemplates(filterColumns []string, templates ...codersdk.Template) st
template.Provisioner,
template.ActiveVersionID.String(),
cliui.Styles.Fuschia.Render(fmt.Sprintf("%d developer%s", template.WorkspaceOwnerCount, suffix)),
fmt.Sprintf("%s", time.Duration(template.MaxTTLMillis)*time.Millisecond),
fmt.Sprintf("%s", time.Duration(template.MinAutostartIntervalMillis)*time.Millisecond),
(time.Duration(template.MaxTTLMillis) * time.Millisecond).String(),
(time.Duration(template.MinAutostartIntervalMillis) * time.Millisecond).String(),
})
}
return tableWriter.Render()
Expand Down
6 changes: 3 additions & 3 deletions codersdk/parameters.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ import (
type ParameterScope string

const (
ParameterTemplate ParameterScope = "template"
ParameterWorkspace ParameterScope = "workspace"
ParameterImportJob ParameterScope = "import_job"
ParameterTemplate ParameterScope = "template"
ParameterWorkspace ParameterScope = "workspace"
ParameterScopeImportJob ParameterScope = "import_job"
)

type ParameterSourceScheme string
Expand Down
2 changes: 1 addition & 1 deletion scripts/develop.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ echo '== Without these binaries, workspaces will fail to start!'

trap 'kill 0' SIGINT
CODERV2_HOST=http://127.0.0.1:3000 INSPECT_XSTATE=true yarn --cwd=./site dev &
CODER_PG_CONNECTION_URL=postgresql://${POSTGRES_USER:-postgres}:${POSTGRES_PASSWORD:-postgres}@localhost:5432/${POSTGRES_DB:-postgres}?sslmode=disable go run -tags embed cmd/coder/main.go server --dev --tunnel=true &
go run -tags embed cmd/coder/main.go server --in-memory --tunnel &

# Just a minor sleep to ensure the first user was created to make the member.
sleep 2
Expand Down
You are viewing a condensed version of this merge commit. You can view the full changes here.