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

Function parseTemplateInsightsSections

coderd/insights.go:804–824  ·  view source on GitHub ↗
(ctx context.Context, rw http.ResponseWriter, sections []string)

Source from the content-addressed store, hash-verified

802}
803
804func parseTemplateInsightsSections(ctx context.Context, rw http.ResponseWriter, sections []string) ([]codersdk.TemplateInsightsSection, bool) {
805 t := make([]codersdk.TemplateInsightsSection, len(sections))
806 for i, s := range sections {
807 switch v := codersdk.TemplateInsightsSection(s); v {
808 case codersdk.TemplateInsightsSectionIntervalReports, codersdk.TemplateInsightsSectionReport:
809 t[i] = v
810 default:
811 httpapi.Write(ctx, rw, http.StatusBadRequest, codersdk.Response{
812 Message: "Query parameter has invalid value.",
813 Validations: []codersdk.ValidationError{
814 {
815 Field: "sections",
816 Detail: fmt.Sprintf("must be one of %v", []codersdk.TemplateInsightsSection{codersdk.TemplateInsightsSectionIntervalReports, codersdk.TemplateInsightsSectionReport}),
817 },
818 },
819 })
820 return nil, false
821 }
822 }
823 return t, true
824}

Callers 1

insightsTemplatesMethod · 0.85

Calls 2

TemplateInsightsSectionTypeAlias · 0.92
WriteFunction · 0.92

Tested by

no test coverage detected