Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Offer configuration schema to connectors (#166)
* WIP: new better config struct * Add module configschema This module compiles a go source file as a plugin and execute it, retrieving the configuration schema defined by the user * Add field functional options * Add list of global fields * Set default values when creating fields * Render templates with field schema create source code for configuring a connector and also configures the Cobra command-line for the connector too * Fix line length of source code * Break down source file in files * Implement entry point function * Make render* functions private * Simplify function body * Separate templates in files * Extract comands from pkg/cli/cli.go * Move function to pkg/config and use it on template * Add command for capabilities * Add description to default fields * Implement additional field options - `WithHidden`: for hidden flags - `WithShortHand`: for flags shorthand * Add missing fields and sort them alphabetically * Rename type to SchemaField * Implement cobra.Command field relationship schema * Add function back * Add function to ensure default relationships * Make load un-exported * Adapt search code for relationship definition * Find and execute function with fields relationships * Add relationship definitions to template data * Split line of field description * Apply minor adjustments to source code comments * Write go.mod file during tests for pkg/configschema * Fix input source code for unit tests * Fix unit tests of template rendering * Fix value of outputdir for fictional go.mod in tests * Always copy the file with the schema * Remove auxiliar functions from test I'm unable to bypass the error: ``` failed to open plugin: plugin.Open("/tmp/baton-alternative-location-3073697725/plugin"): plugin was built with a different version of package github.com/conductorone/baton-sdk/pkg/configschema ``` In tests. * Remove test artifacts only when tests passes * Fix lint incidents * Change CWD during plugin compilation if needed * Redefine type to receive *viper.Viper * Apply configuration schema and constrains at run-time * Delete old unit tests * Delete code generation files * Delete another file * Update vendors * Rename package configschema to config * Implement function for configuration validation * Add gRPC and capabilities flags * Add interface that matches configschema.SchemaField * Comment the call to AdditionalCommands function * Add missing $ symbol for env vars in description * Move schema field type to its own package * Add additional commands in Windows build * Rename module * Remove cli module * Update go.mod * Remove unused argument * Rename module commands to cli --------- Co-authored-by: Geoff Greer <geoff@greer.fm>
- Loading branch information