Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ability to consume multiple config files #2

Open
armingjazi opened this issue Jun 1, 2024 · 0 comments
Open

Add ability to consume multiple config files #2

armingjazi opened this issue Jun 1, 2024 · 0 comments
Labels
enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed

Comments

@armingjazi
Copy link
Contributor

armingjazi commented Jun 1, 2024

One of Web Docker's drawbacks is its reliance on a stitched config file, which requires a server function to stitch the uploaded config files. However, in many cases, users should avoid incurring the cost of additional infrastructure. In this scenario, Web Docker should be capable of stitching the files together without relying on a server function.

Proposed API:

export type WebDockerOptions = {
  configFilePath?: string;
  configPaths?: string[];
  logEvents?: boolean;
  scope?: string;
};

const webDocker = new Webdocker({
    configPaths: ["https://folder/path1", "https://folder/path2"]
});

Possible implementation:

class RemoteConfigurationService {
  private readonly configFilePath: string | undefined = undefined;
  private readonly configPaths: string[] | undefined = undefined;

  constructor(options: WebDockerOptions) {
    if (!options.configFilePath && !options.configPaths) {
      throw Error ("No Config path was defined");
    } else if (options.configFilePath) {
      this.configFilePath = options.configFilePath;
    } else {
       this.configPaths = options.configPaths;      
    }
  }

    async fetch(): Promise<Config[] | undefined> {
    if (this.configFilePath) {
      return this.fetchConfigurations(this.configFilePath);
    }
    if (this.configPaths) {
      return this.fetchAllConfigurations(this.configPaths);
    }
  }
  
  private async fetchAllConfigurations(configPath: string[]): Config[] { 
     const configs = [] 
     for (const configPath of configPaths) {
         const data = await fetch(configFilePath);        
         configs.push(await data.json());
     }
     return configs;
  }
}```
@armingjazi armingjazi added enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed labels Jun 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

1 participant