shared

package
v1.14.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 28, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package shared provides common utilities for Couper config generators. It extracts schema information from Go structs using reflection and HCL tags.

Index

Constants

This section is empty.

Variables

View Source
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.

View Source
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

ConfigRegistry contains all config struct types that should be processed

View Source
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

func GoTypeToSchemaType(t reflect.Type) string

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL