-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #593 from kubeshop/f1ames/feat/synchronizer-client-id
Pass client identity config with every API request
- Loading branch information
Showing
7 changed files
with
69 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@monokle/synchronizer": minor | ||
--- | ||
|
||
Add mechanism to pass client identity config with every API request |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,22 @@ | ||
import {DEFAULT_ORIGIN} from './constants.js'; | ||
import {ApiHandler} from './handlers/apiHandler.js'; | ||
import {ApiHandler, ClientConfig} from './handlers/apiHandler.js'; | ||
import {OriginConfig, fetchOriginConfig} from './handlers/configHandler.js'; | ||
import {Fetcher} from './utils/fetcher.js'; | ||
|
||
export async function createMonokleFetcherFromOrigin(origin: string = DEFAULT_ORIGIN) { | ||
export async function createMonokleFetcherFromOrigin(clientConfig: ClientConfig, origin: string = DEFAULT_ORIGIN) { | ||
try { | ||
const originConfig = await fetchOriginConfig(origin); | ||
|
||
return createMonokleFetcherFromConfig(originConfig); | ||
return createMonokleFetcherFromConfig(clientConfig, originConfig); | ||
} catch (err: any) { | ||
throw err; | ||
} | ||
} | ||
|
||
export function createMonokleFetcherFromConfig(config: OriginConfig) { | ||
if (!config?.apiOrigin) { | ||
export function createMonokleFetcherFromConfig(clientConfig: ClientConfig, originConfig: OriginConfig) { | ||
if (!originConfig?.apiOrigin) { | ||
throw new Error(`No api origin found in origin config from ${origin}.`); | ||
} | ||
|
||
return new Fetcher(new ApiHandler(config)); | ||
return new Fetcher(new ApiHandler(originConfig, clientConfig)); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,34 @@ | ||
import {DEFAULT_ORIGIN} from './constants.js'; | ||
import {ApiHandler} from './handlers/apiHandler.js'; | ||
import {ApiHandler, ClientConfig} from './handlers/apiHandler.js'; | ||
import {OriginConfig, fetchOriginConfig} from './handlers/configHandler.js'; | ||
import {GitHandler} from './handlers/gitHandler.js'; | ||
import {StorageHandlerPolicy} from './handlers/storageHandlerPolicy.js'; | ||
import {Synchronizer} from './utils/synchronizer.js'; | ||
|
||
export async function createMonokleSynchronizerFromOrigin( | ||
clientConfig: ClientConfig, | ||
origin: string = DEFAULT_ORIGIN, | ||
storageHandler: StorageHandlerPolicy = new StorageHandlerPolicy(), | ||
gitHandler: GitHandler = new GitHandler() | ||
) { | ||
try { | ||
const originConfig = await fetchOriginConfig(origin); | ||
|
||
return createMonokleSynchronizerFromConfig(originConfig, storageHandler, gitHandler); | ||
return createMonokleSynchronizerFromConfig(clientConfig, originConfig, storageHandler, gitHandler); | ||
} catch (err: any) { | ||
throw err; | ||
} | ||
} | ||
|
||
export function createMonokleSynchronizerFromConfig( | ||
config: OriginConfig, | ||
clientConfig: ClientConfig, | ||
originConfig: OriginConfig, | ||
storageHandler: StorageHandlerPolicy = new StorageHandlerPolicy(), | ||
gitHandler: GitHandler = new GitHandler() | ||
) { | ||
if (!config?.apiOrigin) { | ||
if (!originConfig?.apiOrigin) { | ||
throw new Error(`No api origin found in origin config from ${origin}.`); | ||
} | ||
|
||
return new Synchronizer(storageHandler, new ApiHandler(config), gitHandler); | ||
return new Synchronizer(storageHandler, new ApiHandler(originConfig, clientConfig), gitHandler); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters