Documentation ¶
Index ¶
Constants ¶
View Source
const ( VersionKey string = "version" SourcesKey string = "sources" TablesKey string = "tables" FunctionsKey string = "functions" ActionsKey string = "actions" CustomTypesKey string = "custom_types" RemoteSchemasKey string = "remote_schemas" QueryCollectionsKey string = "query_collections" AllowListKey string = "allowlist" CronTriggersKey string = "cron_triggers" APILimitsKey string = "api_limits" RestEndpointsKey string = "rest_endpoints" InheritedRolesKey string = "inherited_roles" GraphQLSchemaIntrospectionKey string = "graphql_schema_introspection" NetworkKey string = "network" )
Variables ¶
This section is empty.
Functions ¶
func DefaultGetFiles ¶
DefaultGetFiles is a default implementation for Object.GetFiles
func DefaultWriteDiff ¶
func DefaultWriteDiff(opts DefaultWriteDiffOpts) error
DefaultWriteDiff is the default implementation for Object.WriteDiff
func GetEncoder ¶ added in v2.5.1
GetEncoder is the YAML encoder which is expected to be used in all implementations of Object. This helps bring uniformity in the format of generated YAML
Types ¶
type DefaultObjectType ¶ added in v2.5.1
type DefaultObjectType int
const ( DefaultObjectTypeSequence DefaultObjectType = iota DefaultObjectTypeMapping )
type DefaultWriteDiffOpts ¶
type DefaultWriteDiffOpts struct { From Object WriteDiffOpts ExcludeFilesPatterns []string }
type ErrParsingMetadataObject ¶
type ErrParsingMetadataObject interface { // ObjectName corresponds to metadata object in JSON format // eg: source, api_limits etc ObjectName() string // Filename corresponding to metadata object // eg: databases.yaml, actions.yaml Filename() string // ErrorContext will contain any additional information regarding error ErrorContext() string // Unwrap will make sure the error returned is unwrappable // https://blog.golang.org/go1.13-errors#TOC_3.1. Unwrap() error error }
func DefaultExport ¶ added in v2.5.1
func DefaultExport(object Object, metadata map[string]yaml.Node, errorFunc func(error, ...string) ErrParsingMetadataObject, objectType DefaultObjectType) (map[string][]byte, ErrParsingMetadataObject)
DefaultExport is an implementation for Object.Export metadata objects which doesn't require additional customisations can make use of this implementation
func NewErrParsingMetadataObject ¶
func NewErrParsingMetadataObject(o Object, err error, context ...string) ErrParsingMetadataObject
type Object ¶
type Object interface { // Build will be responsible for reading the metadata object from metadata files in project directory // It should return nil if it was not able to find the matching metadata file // Build returns a map of the objects, and it's corresponding unmarshalled content // For example: // an implementation for handling the "remote_schemas" object might return a map like // "remote_schemas": []yaml.Node // since there is a chance that this function can return a yaml.Node. The return value is not expected to // directly be unmarshalled to JSON using json.Marshal Build() (map[string]interface{}, ErrParsingMetadataObject) // Export is responsible for writing the yaml Node(s) for the metadata object // to project directory // Export expects a map[string]yaml.Node specifically rather than a builtin data structure like // map[string]interface{} because it does not guarantee the order in which contents will be unmarshalled. // eg: say we received the following JSON metadata from the server // { // "foo": [ // "x": 1, // "a": 2, // ], // } // we are interested in preserving the order of keys when transforming this to YAML. Something like the following // foo: // x: 1 // a: 2 // This ordering is not guaranteed if we are using map[string]interface{} to unmarshal the JSON. This might look // something like the following // foo: // a: 2 // x: 1 // This not bug, since JSON spec doesn't guarantee the ordering anyway. // We are interested in writing or transforming the JSON object received from the server in // the same order to YAML files. This coupled with our requirement of NOT strongly typing metadata on CLI requires // using yaml.Node to preserve the ordering. Export(metadata map[string]yaml.Node) (map[string][]byte, ErrParsingMetadataObject) CreateFiles() error // GetFiles will return an array of file paths which make up the metadata object. // For example the "sources" metadata key is made up of files like // databases.yaml. which then will have !include tags which will branch to include // files like databases/<source-name>/tables/tables.yaml // this function is expected to return the list of all these files which make up the metadata object GetFiles() ([]string, ErrParsingMetadataObject) // WriteDiff should be implemented such that it should write the difference // between the current object and passed in object on the provided writer WriteDiff(WriteDiffOpts) ErrParsingMetadataObject Key() string Filename() string // BaseDirectory will return the parent directory of `Filename()` BaseDirectory() string }
Click to show internal directories.
Click to hide internal directories.