Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( Identity = func(field string) string { return field } ToString = func(field string) string { return fmt.Sprintf("%s.String()", field) } FullyQualifiedName = func(field string) string { return fmt.Sprintf("%s.FullyQualifiedName()", field) } Name = func(field string) string { return fmt.Sprintf("%s.Name()", field) } CastToString = func(field string) string { return fmt.Sprintf("string(%s)", field) } CastToInt = func(field string) string { return fmt.Sprintf("int(%s)", field) } )
var (
PreambleTemplate, _ = template.New("preambleTemplate").Parse(preambleTemplateContent)
SchemaTemplate, _ = template.New("schemaTemplate").Funcs(template.FuncMap{
"firstLetterLowercase": func(in string) string { return strings.ToLower(in[:1]) + in[1:] },
}).Parse(schemaTemplateContent)
ToSchemaMapperTemplate, _ = template.New("toSchemaMapperTemplate").Funcs(template.FuncMap{
"firstLetterLowercase": func(in string) string { return strings.ToLower(in[:1]) + in[1:] },
"runMapper": func(mapper Mapper, in ...string) string { return mapper(strings.Join(in, "")) },
}).Parse(toSchemaMapperTemplateContent)
)
TODO [SNOW-1501905]: extract common funcs
var AdditionalStructs = []any{ sdk.SecurityIntegrationProperty{}, }
TODO [SNOW-1501905]: currently all this structs have the "Show" added to the schema, while these are not show outputs TODO [SNOW-1501905]: temporary struct, may be refactored with addition to generation of describe results; for now used to some structs needing a schema representation
var SdkShowResultStructs = []any{ sdk.Account{}, sdk.Alert{}, sdk.ApiIntegration{}, sdk.ApplicationPackage{}, sdk.ApplicationRole{}, sdk.Application{}, sdk.DatabaseRole{}, sdk.Database{}, sdk.DynamicTable{}, sdk.EventTable{}, sdk.ExternalFunction{}, sdk.ExternalTable{}, sdk.FailoverGroup{}, sdk.FileFormat{}, sdk.Function{}, sdk.Grant{}, sdk.ManagedAccount{}, sdk.MaskingPolicy{}, sdk.MaterializedView{}, sdk.NetworkPolicy{}, sdk.NetworkRule{}, sdk.NotificationIntegration{}, sdk.Parameter{}, sdk.PasswordPolicy{}, sdk.Pipe{}, sdk.PolicyReference{}, sdk.Procedure{}, sdk.ReplicationAccount{}, sdk.ReplicationDatabase{}, sdk.Region{}, sdk.ResourceMonitor{}, sdk.Role{}, sdk.RowAccessPolicy{}, sdk.Schema{}, sdk.SecurityIntegration{}, sdk.Sequence{}, sdk.SessionPolicy{}, sdk.Share{}, sdk.Stage{}, sdk.StorageIntegration{}, sdk.Streamlit{}, sdk.Stream{}, sdk.Table{}, sdk.Tag{}, sdk.Task{}, sdk.User{}, sdk.View{}, sdk.Warehouse{}, }
Functions ¶
func ColumnOutput ¶
ColumnOutput is a helper to align a tabular output with the given columnWidth, e.g. (for 20 spaces column width): Name string string State sdk.WarehouseState string
func Generate ¶
func Generate(model ShowResultSchemaModel, writer io.Writer)
TODO [SNOW-1501905]: handle panics better TODO [SNOW-1501905]: test and describe
func ToSnakeCase ¶
ToSnakeCase allows converting a CamelCase text to camel_case one (needed for schema attribute names). Examples: - CamelCase -> camel_case - ACamelCase -> a_camel_case - URLParser -> url_parser - Camel1Case -> camel1_case - camelCase -> camel_case - camelURL -> camel_url - camelURLSomething -> camel_url_something
Types ¶
type SchemaField ¶
type SchemaField struct {
Name string
SchemaType schema.ValueType
OriginalName string
IsOriginalTypePointer bool
Mapper Mapper
}
func MapToSchemaField ¶
func MapToSchemaField(field Field) SchemaField
TODO [SNOW-1501905]: handle other basic type variants TODO [SNOW-1501905]: handle any other interface (error) TODO [SNOW-1501905]: handle slices TODO [SNOW-1501905]: handle structs (chosen one or all)
type ShowResultSchemaModel ¶
type ShowResultSchemaModel struct {
Name string
SdkType string
SchemaFields []SchemaField
}
func ModelFromStructDetails ¶
func ModelFromStructDetails(sdkStruct Struct) ShowResultSchemaModel