Skip to content

Instantly share code, notes, and snippets.

@evantahler
Created August 12, 2022 18:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save evantahler/69d81b258babebee74058ef168df9d33 to your computer and use it in GitHub Desktop.
Save evantahler/69d81b258babebee74058ef168df9d33 to your computer and use it in GitHub Desktop.
Airbyte Mutatable Spec
getSpec() {
// start the returned spec with constant properties that are always needed in all ways the connector can be deployed
let spec = {
properties: {
host: { required:true, type: string },
username: { required:true, type: string },
password: { required:true, type: string },
}
};
// if the platform has not set S3_URL for this connector, we need to ask the user for it, otherwise this is excluded from the spec
if (!process.env.S3_URL) {
spec.properties.s3_url = { required:true, type: string }
}
return spec
}
read (config, configuredCatalog, ...) {
// when the connector runs, we source the ENV again to pre-fill any properties we get from the ENV and not the config
if (!config.properties.s3_url && process.env.S3_URL) {
config.properties.s3_url = process.env.S3_URL
}
}
// Notes:
// All of the above can be simplified and done dynamically with helpers like:
function stripConfigOfEnvs (config) {
for (const [key,value] in process.env){
if (key.startsWith(`AIRBYTE_CONNECTOR_${connector_name}_`)){
//...
delete config.properties.key_name
}
}
}
function addEnvConfigsBackToConfig (config) {
//...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment