MCPcopy Index your code
hub / github.com/coder/coder / DynamicParameterTemplate

Function DynamicParameterTemplate

coderd/coderdtest/dynamicparameters.go:39–137  ·  view source on GitHub ↗
(t *testing.T, client *codersdk.Client, org uuid.UUID, args DynamicParameterTemplateParams)

Source from the content-addressed store, hash-verified

37}
38
39func DynamicParameterTemplate(t *testing.T, client *codersdk.Client, org uuid.UUID, args DynamicParameterTemplateParams) (codersdk.Template, codersdk.TemplateVersion) {
40 t.Helper()
41
42 // Start with main.tf
43 extraFiles := map[string][]byte{
44 "main.tf": []byte(args.MainTF),
45 }
46
47 // Add any additional files
48 for name, content := range args.ExtraFiles {
49 extraFiles[name] = content
50 }
51
52 files := echo.WithExtraFiles(extraFiles)
53 files.ProvisionInit = []*proto.Response{{
54 Type: &proto.Response_Init{
55 Init: &proto.InitComplete{
56 ModuleFiles: args.ModulesArchive,
57 },
58 },
59 }}
60 files.ProvisionPlan = []*proto.Response{{
61 Type: &proto.Response_Plan{
62 Plan: &proto.PlanComplete{
63 Plan: args.Plan,
64 },
65 },
66 }}
67 files.ProvisionGraph = []*proto.Response{{
68 Type: &proto.Response_Graph{
69 Graph: &proto.GraphComplete{
70 Parameters: args.StaticParams,
71 },
72 },
73 }}
74
75 userVars := make([]codersdk.VariableValue, 0, len(args.Variables))
76 parseVars := make([]*proto.TemplateVariable, 0, len(args.Variables))
77 for _, argv := range args.Variables {
78 parseVars = append(parseVars, &proto.TemplateVariable{
79 Name: argv.Name,
80 Description: argv.Description,
81 Type: argv.Type,
82 DefaultValue: argv.DefaultValue,
83 Required: argv.Required,
84 Sensitive: argv.Sensitive,
85 })
86
87 userVars = append(userVars, codersdk.VariableValue{
88 Name: argv.Name,
89 Value: argv.Value,
90 })
91 }
92
93 files.Parse = []*proto.Response{{
94 Type: &proto.Response_Parse{
95 Parse: &proto.ParseComplete{
96 TemplateVariables: parseVars,

Callers 7

setupDynamicParamsTestFunction · 0.92
TestCreateDynamicFunction · 0.92
TestDynamicWorkspaceTagsFunction · 0.92
TestCreateUserWorkspaceFunction · 0.92
TestRunFunction · 0.92

Calls 11

WithExtraFilesFunction · 0.92
RefFunction · 0.92
CreateTemplateFunction · 0.85
VersionMethod · 0.80
UpdateTemplateMetaMethod · 0.80
HelperMethod · 0.65
ContextMethod · 0.65
EqualMethod · 0.45

Tested by 7

setupDynamicParamsTestFunction · 0.74
TestCreateDynamicFunction · 0.74
TestDynamicWorkspaceTagsFunction · 0.74
TestCreateUserWorkspaceFunction · 0.74
TestRunFunction · 0.74