Documentation
¶
Index ¶
- Constants
- func FixTemplate(body string, tplType string) string
- func ValidateFixedTemplate(fixedBody string, tplType string) error
- func ValidateFixedTemplateWithOriginal(fixedBody string, originalBody string, tplType string) error
- type EmpiricalTestResult
- type EmpiricalTestSuite
- type ObjectReader
- type RegexpShorthand
- type StreamTransformer
- type StreamTransformerFactory
- type TemplateAnalysisContext
- type TemplateAnalysisResult
- type TemplateFinding
- type TemplateStaticAnalyzer
- type XMLShorthand
- type XMLStringShorthand
Constants ¶
const ( BinResponseShapeUnsafe = "response-shape-unsafe" BinEmptyResponseUnsafe = "empty-response-unsafe" )
Warning bin tags — must stay in sync with discovery.Bin* constants.
const ( GolangTemplateXMLV1 = "golang_template_mxj_v0.1.0" GolangTemplateXMLV2 = "golang_template_mxj_v0.2.0" GolangTemplateXMLV3 = "golang_template_mxj_v0.3.0" GolangTemplateJSONV1 = "golang_template_json_v0.1.0" GolangTemplateJSONV3 = "golang_template_json_v0.3.0" GolangTemplateTextV1 = "golang_template_text_v0.1.0" GolangTemplateTextV3 = "golang_template_text_v0.3.0" GolangTemplateUnspecifiedV1 = "golang_template_v0.1.0" GolangTemplateUnspecifiedV3 = "golang_template_v0.3.0" )
Variables ¶
This section is empty.
Functions ¶
func FixTemplate ¶
FixTemplate attempts to produce a corrected version of a busted template. Returns the fixed template body, or empty string if no fix is applicable.
func ValidateFixedTemplate ¶
ValidateFixedTemplate checks that a proposed fixed template: 1. Passes the same static analysis (no chained index, no unguarded dot access) 2. Parses successfully 3. Executes against empty input without error
func ValidateFixedTemplateWithOriginal ¶
ValidateFixedTemplateWithOriginal performs the full validation including empty-input execution, only failing if the fix introduces NEW errors that the original template didn't have.
Types ¶
type EmpiricalTestResult ¶
type EmpiricalTestResult struct {
Input string `json:"input"`
Output string `json:"output,omitempty"`
Error string `json:"error,omitempty"`
OK bool `json:"ok"`
}
EmpiricalTestResult holds the outcome of running a template against test inputs.
func RunEmpiricalTestWithInput ¶
func RunEmpiricalTestWithInput(templateBody string, templateType string, input string) EmpiricalTestResult
RunEmpiricalTestWithInput executes a template against a specific input.
type EmpiricalTestSuite ¶
type EmpiricalTestSuite struct {
Results []EmpiricalTestResult `json:"results"`
}
EmpiricalTestSuite holds all empirical test results for a template.
func RunEmpiricalTests ¶
func RunEmpiricalTests(templateBody string, templateType string) EmpiricalTestSuite
RunEmpiricalTests executes a response transform template against a suite of test inputs including empty string, and returns structured results.
func (*EmpiricalTestSuite) FailureMessages ¶
func (s *EmpiricalTestSuite) FailureMessages() []string
func (*EmpiricalTestSuite) HasFailures ¶
func (s *EmpiricalTestSuite) HasFailures() bool
type ObjectReader ¶
type ObjectReader interface {
Read() (interface{}, error)
}
type RegexpShorthand ¶
type RegexpShorthand interface {
GetFirstMatch(string, string) (string, error)
GetAllMatches(string, string) ([]string, error)
}
func NewRegexpShorthand ¶
func NewRegexpShorthand() RegexpShorthand
type StreamTransformer ¶
type StreamTransformerFactory ¶
type StreamTransformerFactory interface {
IsTransformable() bool
GetTransformer(input string) (StreamTransformer, error)
}
func NewStreamTransformerFactory ¶
func NewStreamTransformerFactory(tplType string, tplStr string) StreamTransformerFactory
type TemplateAnalysisContext ¶
type TemplateAnalysisContext struct {
ProviderName string
ServiceName string
MethodName string
ResourceKey string
TemplateType string
TemplateBody string
IsFixValidation bool // true when analyzing a proposed fix — suppresses fix generation
}
TemplateAnalysisContext provides the caller's context.
type TemplateAnalysisResult ¶
type TemplateAnalysisResult interface {
GetErrors() []error
GetWarnings() []string
GetAffirmatives() []string
GetFindings() []TemplateFinding
}
TemplateAnalysisResult holds the outcomes of template static analysis.
type TemplateFinding ¶
type TemplateFinding struct {
Level string `json:"level"`
Bin string `json:"bin,omitempty"`
Provider string `json:"provider,omitempty"`
Service string `json:"service,omitempty"`
Resource string `json:"resource,omitempty"`
Method string `json:"method,omitempty"`
Message string `json:"message"`
PriorTemplate string `json:"prior_template,omitempty"`
FixedTemplate string `json:"fixed_template,omitempty"`
}
TemplateFinding is a structured finding from template static analysis.
func (TemplateFinding) Error ¶
func (f TemplateFinding) Error() string
func (TemplateFinding) String ¶
func (f TemplateFinding) String() string
type TemplateStaticAnalyzer ¶
type TemplateStaticAnalyzer interface {
Analyze() TemplateAnalysisResult
}
TemplateStaticAnalyzer performs static analysis on Go templates.
func NewTemplateStaticAnalyzer ¶
func NewTemplateStaticAnalyzer(ctx TemplateAnalysisContext) TemplateStaticAnalyzer
type XMLShorthand ¶
type XMLShorthand interface {
GetFirstFull(io.Reader, string) (string, error)
GetAllFull(io.Reader, string) ([]string, error)
GetFirstInner(io.Reader, string) (string, error)
GetAllInner(io.Reader, string) ([]string, error)
}
func NewXMLShorthand ¶
func NewXMLShorthand() XMLShorthand
type XMLStringShorthand ¶
type XMLStringShorthand interface {
GetFirstFull(string, string) (string, error)
GetAllFull(string, string) ([]string, error)
GetFirstInner(string, string) (string, error)
GetAllInner(string, string) ([]string, error)
}
func NewXMLStringShorthand ¶
func NewXMLStringShorthand() XMLStringShorthand