Documentation
¶
Overview ¶
Package shared provides common utilities for Couper config generators. It extracts schema information from Go structs using reflection and HCL tags.
Index ¶
- Variables
- func CollectFields(t reflect.Type, fields []reflect.StructField) []reflect.StructField
- func GetBlockName(impl interface{}) string
- func GetInlineFields(impl interface{}) []reflect.StructField
- func GetTypeName(impl interface{}) string
- func GoTypeToSchemaType(t reflect.Type) string
- func IsInlineType(impl interface{}) bool
- func NewFields(impl interface{}) []reflect.StructField
- type ConfigStructInfo
- type HCLTagInfo
Constants ¶
This section is empty.
Variables ¶
var AttributesMap = map[string][]reflect.StructField{ "RequestHeadersAttributes": NewFields(&meta.RequestHeadersAttributes{}), "ResponseHeadersAttributes": NewFields(&meta.ResponseHeadersAttributes{}), "FormParamsAttributes": NewFields(&meta.FormParamsAttributes{}), "QueryParamsAttributes": NewFields(&meta.QueryParamsAttributes{}), "LogFieldsAttribute": NewFields(&meta.LogFieldsAttribute{}), }
AttributesMap maps meta attribute type names to their struct fields. Used to expand embedded meta types into their individual fields.
var BlockNamesMap = map[string]string{
"oauth2_ac": "beta_oauth2",
"oauth2_req_auth": "oauth2",
}
BlockNamesMap provides mappings from internal type names to HCL block names Used by docs generator to match documentation file names
var ConfigRegistry = []interface{}{ &config.API{}, &config.Backend{}, &config.BackendTLS{}, &config.BasicAuth{}, &config.CORS{}, &config.Defaults{}, &config.Definitions{}, &config.Endpoint{}, &config.ErrorHandler{}, &config.Files{}, &config.Health{}, &config.Introspection{}, &config.JWTSigningProfile{}, &config.JWT{}, &config.Job{}, &config.OAuth2AC{}, &config.OAuth2ReqAuth{}, &config.OIDC{}, &config.OpenAPI{}, &config.Proxy{}, &config.Throttle{}, &config.RateLimiter{}, &config.Request{}, &config.Response{}, &config.SAML{}, &config.Server{}, &config.ClientCertificate{}, &config.ServerCertificate{}, &config.ServerTLS{}, &config.Settings{}, &config.Spa{}, &config.TokenRequest{}, &config.Websockets{}, }
ConfigRegistry contains all config struct types that should be processed
var VSCodeBlockNamesMap = map[string]string{
"introspection": "beta_introspection",
"oauth2_ac": "beta_oauth2",
"oauth2_req_auth": "oauth2",
"backend_tls": "tls",
"server_tls": "tls",
}
VSCodeBlockNamesMap provides mappings for VS Code schema (HCL block names). Maps internal Go type names to their HCL block names when they differ.
Functions ¶
func CollectFields ¶
func CollectFields(t reflect.Type, fields []reflect.StructField) []reflect.StructField
CollectFields recursively collects all struct fields, expanding anonymous/embedded fields
func GetBlockName ¶
func GetBlockName(impl interface{}) string
GetBlockName returns the HCL block name for a config struct type
func GetInlineFields ¶
func GetInlineFields(impl interface{}) []reflect.StructField
GetInlineFields returns fields from both the main struct and its Inline() type
func GetTypeName ¶
func GetTypeName(impl interface{}) string
GetTypeName returns the Go type name without package prefix
func GoTypeToSchemaType ¶
GoTypeToSchemaType converts a Go type to the corresponding schema type string
func IsInlineType ¶
func IsInlineType(impl interface{}) bool
IsInlineType checks if the given interface implements the Inline interface
func NewFields ¶
func NewFields(impl interface{}) []reflect.StructField
NewFields extracts struct fields from the given interface
Types ¶
type ConfigStructInfo ¶
type ConfigStructInfo struct {
Impl interface{}
BlockName string
TypeName string
Type reflect.Type
}
ConfigStructInfo holds information about a config struct
func GetAllConfigStructs ¶
func GetAllConfigStructs() []ConfigStructInfo
GetAllConfigStructs returns information about all registered config structs
func GetAllConfigStructsForVSCode ¶
func GetAllConfigStructsForVSCode() []ConfigStructInfo
GetAllConfigStructsForVSCode returns config structs with VS Code-specific block name mappings
type HCLTagInfo ¶
type HCLTagInfo struct {
Name string
IsBlock bool
IsLabel bool
IsOptional bool
LabelOptional bool
IsRemain bool
}
HCLTagInfo contains parsed information from an hcl struct tag
func ParseHCLTag ¶
func ParseHCLTag(tag string) HCLTagInfo
ParseHCLTag parses an hcl struct tag value