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

(java): implement environment variable scanning in java sdk #2885

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion generators/java/sdk/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.7.0-rc0] - 2024-02-04
## [0.7.0-rc1] - 2024-02-04
- Chore: Bump intermediate representation to v31
- Feature: The SDK generator now supports idempotency headers. Users
will be able to specify the idempotency headers in RequestOptions.
Expand All @@ -18,6 +18,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
.idempotencyKey("...")
.build());
```
- Feature: The SDK generator now supports scanning API credentials
via environment varaibles.
```java
Imdb imdb = Imdb.builder()
.apiKey("...") // defaults to System.getenv("IMDB_API_KEY")
.build();
```

## [0.6.1] - 2024-02-03

Expand Down
2 changes: 1 addition & 1 deletion generators/java/sdk/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.7.0-rc0
0.7.0-rc1

Large diffs are not rendered by default.

11 changes: 9 additions & 2 deletions packages/seed/src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@ function addTestCommand(cli: Argv) {
demandOption: false,
description: "Runs on all fixtures if not provided"
})
.option("keepDocker", {
type: "boolean",
demandOption: false,
description: "Keeps the docker container after the tests are finished"
})
.option("update", {
type: "boolean",
alias: "u",
Expand Down Expand Up @@ -94,7 +99,8 @@ function addTestCommand(cli: Argv) {
language: workspace.workspaceConfig.language,
docker: parsedDockerImage,
logLevel: argv["log-level"],
numDockers: argv.parallel
numDockers: argv.parallel,
keepDocker: argv.keepDocker
});
} else {
await testWorkspaceFixtures({
Expand All @@ -106,7 +112,8 @@ function addTestCommand(cli: Argv) {
scripts: workspace.workspaceConfig.scripts,
logLevel: argv["log-level"],
numDockers: argv.parallel,
taskContextFactory
taskContextFactory,
keepDocker: argv.keepDocker
});
}
}
Expand Down
6 changes: 4 additions & 2 deletions packages/seed/src/commands/test/runDockerForWorkspace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ export async function runDockerForWorkspace({
irVersion,
outputVersion,
outputMode,
fixtureName
fixtureName,
keepDocker
}: {
absolutePathToOutput: AbsoluteFilePath;
docker: ParsedDockerName;
Expand All @@ -35,6 +36,7 @@ export async function runDockerForWorkspace({
outputVersion?: string;
outputMode: OutputMode;
fixtureName: string;
keepDocker: boolean | undefined;
}): Promise<void> {
const generatorGroup: GeneratorGroup = {
groupName: "test",
Expand All @@ -56,7 +58,7 @@ export async function runDockerForWorkspace({
organization: DUMMY_ORGANIZATION,
workspace,
generatorGroup,
keepDocker: true,
keepDocker: keepDocker ?? false,
context: taskContext,
irVersionOverride: irVersion,
outputVersionOverride: outputVersion
Expand Down
7 changes: 5 additions & 2 deletions packages/seed/src/commands/test/testCustomFixture.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ export async function testCustomFixture({
language,
docker,
logLevel,
numDockers
numDockers,
keepDocker
}: {
pathToFixture: AbsoluteFilePath;
workspace: SeedWorkspace;
Expand All @@ -24,6 +25,7 @@ export async function testCustomFixture({
docker: ParsedDockerName;
logLevel: LogLevel;
numDockers: number;
keepDocker: boolean | undefined;
}): Promise<void> {
const lock = new Semaphore(numDockers);
const outputDir = await tmp.dir();
Expand All @@ -46,7 +48,8 @@ export async function testCustomFixture({
outputDir: absolutePathToOutput,
outputMode: "github",
outputFolder: "custom",
id: "custom"
id: "custom",
keepDocker
});

if (result.type === "failure") {
Expand Down
24 changes: 17 additions & 7 deletions packages/seed/src/commands/test/testWorkspaceFixtures.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ export async function testWorkspaceFixtures({
docker,
scripts,
taskContextFactory,
numDockers
numDockers,
keepDocker
}: {
workspace: SeedWorkspace;
irVersion: string | undefined;
Expand All @@ -55,6 +56,7 @@ export async function testWorkspaceFixtures({
logLevel: LogLevel;
taskContextFactory: TaskContextFactory;
numDockers: number;
keepDocker: boolean | undefined;
}): Promise<void> {
const lock = new Semaphore(numDockers);

Expand Down Expand Up @@ -94,7 +96,8 @@ export async function testWorkspaceFixtures({
RelativeFilePath.of(fixtureConfigInstance.outputFolder)
),
outputMode: fixtureConfigInstance.outputMode ?? workspace.workspaceConfig.defaultOutputMode,
outputFolder: fixtureConfigInstance.outputFolder
outputFolder: fixtureConfigInstance.outputFolder,
keepDocker
})
);
}
Expand All @@ -114,7 +117,8 @@ export async function testWorkspaceFixtures({
taskContext: taskContextFactory.create(`${workspace.workspaceName}:${fixture}`),
outputDir: join(workspace.absolutePathToWorkspace, RelativeFilePath.of(fixture)),
outputMode: workspace.workspaceConfig.defaultOutputMode,
outputFolder: fixture
outputFolder: fixture,
keepDocker
})
);
}
Expand Down Expand Up @@ -175,7 +179,8 @@ export async function acquireLocksAndRunTest({
outputDir,
absolutePathToWorkspace,
outputMode,
outputFolder
outputFolder,
keepDocker
}: {
id: string;
lock: Semaphore;
Expand All @@ -191,6 +196,7 @@ export async function acquireLocksAndRunTest({
absolutePathToWorkspace: AbsoluteFilePath;
outputMode: OutputMode;
outputFolder: string;
keepDocker: boolean | undefined;
}): Promise<TestResult> {
taskContext.logger.debug("Acquiring lock...");
await lock.acquire();
Expand All @@ -208,7 +214,8 @@ export async function acquireLocksAndRunTest({
outputDir,
absolutePathToWorkspace,
outputMode,
outputFolder
outputFolder,
keepDocker
});
taskContext.logger.debug("Releasing lock...");
lock.release();
Expand All @@ -228,7 +235,8 @@ async function testWithWriteToDisk({
outputDir,
absolutePathToWorkspace,
outputMode,
outputFolder
outputFolder,
keepDocker
}: {
id: string;
fixture: string;
Expand All @@ -243,6 +251,7 @@ async function testWithWriteToDisk({
absolutePathToWorkspace: AbsoluteFilePath;
outputMode: OutputMode;
outputFolder: string;
keepDocker: boolean | undefined;
}): Promise<TestResult> {
try {
const workspace = await loadAPIWorkspace({
Expand Down Expand Up @@ -275,7 +284,8 @@ async function testWithWriteToDisk({
irVersion,
outputVersion,
outputMode,
fixtureName: fixture
fixtureName: fixture,
keepDocker
});
for (const script of scripts ?? []) {
taskContext.logger.info(`Running script on ${fixture}`);
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading