package ebi import ( "bytes" "os" "text/template" ) const queryTemplatePath = "pkg/collection/ebi/sql/" // QueryParams defines the options available to pass into // Data warehouse SQL queries type QueryParams struct { Account string Device string DC string } // QueryString will return the actual query to send to SQL with the resolved // values in the QueryParams. func QueryString(params QueryParams, templateName string) (string, error) { var buff = new(bytes.Buffer) // nolint:gosec byt, err := os.ReadFile(queryTemplatePath + templateName) if err != nil { return "", err } t, err := template.New("sql_query").Parse(string(byt)) if err != nil { return "", err } if err := t.Execute(buff, params); err != nil { return "", err } return buff.String(), nil }