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

don't validate endpoint config with --secret #315

Merged
merged 2 commits into from
Oct 18, 2023
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
13 changes: 10 additions & 3 deletions src/lib/config/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -201,8 +201,6 @@ export class ShellConfig {
? ProjectConfig.fromConfig(new Config("config key", opts.projectConfig))
: undefined;

this.projectConfig?.validate(this.rootConfig);

const urlFlag = Endpoint.getURLFromFlags(this.flags);
if (urlFlag !== undefined) {
try {
Expand Down Expand Up @@ -250,7 +248,15 @@ export class ShellConfig {
);
}

if (endpointName === undefined) {
// There are 2 scenarios where we want to execute the first if block:
// 1. no endpoint name is set
// 2. In a CI/CD environment where a secret is set but there is no
// root config. In this scenario endpoints may be set by the project
// configuration but won't exist in their pipeline workspace.
if (
endpointName === undefined ||
(secretFlag !== undefined && this.rootConfig.isEmpty())
) {
// This is a dummy secret. `--secret` must be set in this case, which
// `validate` enforces.
this.endpoint = new Endpoint({
Expand All @@ -260,6 +266,7 @@ export class ShellConfig {
graphqlPort: this.flags.numberOpt("graphqlPort"),
});
} else {
this.projectConfig?.validate(this.rootConfig);
this.endpoint = this.rootConfig.endpoints[endpointName];
if (this.endpoint === undefined) {
throw new Error(`No such endpoint '${endpointName}'`);
Expand Down
4 changes: 4 additions & 0 deletions src/lib/config/root-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ export class RootConfig {
}
}

isEmpty(): boolean {
return Object.keys(this.endpoints).length === 0;
}

/**
* If there is an endpoint object in the config, and it has a
* object underneath it, we are saying that it uses the
Expand Down