Skip to content

Commit 2caca1b

Browse files
committed
Use getComputedInput for getConfigFileInput
1 parent 465d6c7 commit 2caca1b

3 files changed

Lines changed: 24 additions & 73 deletions

File tree

lib/entry-points.js

Lines changed: 9 additions & 27 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/config/file.test.ts

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ test("getConfigFileInput returns input value", async (t) => {
4242
.returns(testInput);
4343
})
4444
.withArgs(repositoryProperties)
45-
.logs(t, "Using configuration file input from workflow")
45+
.logs(t, "Using config-file input from workflow")
4646
.passes(t.deepEqual, { value: testInput, source: InputSource.Workflow });
4747
});
4848

@@ -51,30 +51,22 @@ test("getConfigFileInput returns repository property value", async (t) => {
5151
await callee(getConfigFileInput)
5252
.withFeatures([Feature.ConfigFileRepositoryProperty])
5353
.withArgs(repositoryProperties)
54-
.logs(t, "Using configuration file input from repository property")
54+
.logs(t, "Using config-file input from repository property")
5555
.passes(t.deepEqual, {
5656
value: repositoryProperties[RepositoryPropertyName.CONFIG_FILE],
5757
source: InputSource.RepositoryProperty,
5858
});
5959
});
6060

61-
test("getConfigFileInput ignores empty repository property value", async (t) => {
62-
// Since the repository property value is an empty/whitespace string, we should ignore it.
63-
await callee(getConfigFileInput)
64-
.withFeatures([Feature.ConfigFileRepositoryProperty])
65-
.withArgs({ [RepositoryPropertyName.CONFIG_FILE]: " " })
66-
.passes(t.is, undefined);
67-
});
68-
6961
test("getConfigFileInput ignores repository property value when FF is off", async (t) => {
7062
// Since the FF is off, we should ignore the repository property value.
7163
await callee(getConfigFileInput)
7264
.withFeatures([])
7365
.withArgs(repositoryProperties)
74-
.notLogs(t, "Using configuration file input from repository property")
66+
.notLogs(t, "Using config-file input from repository property")
7567
.logs(
7668
t,
77-
"Ignoring configuration file input from repository property, because the corresponding feature flag is disabled.",
69+
"Ignoring config-file input from repository property, because the corresponding feature flag is disabled.",
7870
)
7971
.passes(t.is, undefined);
8072
});

src/config/file.ts

Lines changed: 11 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import {
99
import { ConfigurationError } from "../util";
1010

1111
import { parseUserConfig, UserConfig } from "./db-config";
12-
import { InputSource, type ComputedInput } from "./inputs";
12+
import { getComputedInput, InputName, type ComputedInput } from "./inputs";
1313
import { parseRemoteFileAddress } from "./remote-file";
1414

1515
/**
@@ -29,42 +29,19 @@ export const REMOTE_PATH_PREFIX = "remote=";
2929
* Gets the value that is configured for the configuration file, if any.
3030
*/
3131
export async function getConfigFileInput(
32-
{
33-
logger,
34-
actions,
35-
features,
36-
}: ActionState<["Logger", "Actions", "FeatureFlags"]>,
32+
action: ActionState<["Logger", "Actions", "FeatureFlags"]>,
3733
repositoryProperties: Partial<RepositoryProperties>,
3834
): Promise<ComputedInput | undefined> {
39-
const input = actions.getOptionalInput("config-file");
40-
41-
if (input !== undefined) {
42-
logger.info(`Using configuration file input from workflow: ${input}`);
43-
return { value: input, source: InputSource.Workflow };
44-
}
45-
46-
const propertyValue =
47-
repositoryProperties[RepositoryPropertyName.CONFIG_FILE];
48-
49-
if (propertyValue !== undefined && propertyValue.trim().length > 0) {
50-
// Only use the repository property value if the FF is enabled.
51-
const useRepositoryProperty = await features.getValue(
52-
Feature.ConfigFileRepositoryProperty,
53-
);
54-
55-
if (useRepositoryProperty) {
56-
logger.info(
57-
`Using configuration file input from repository property: ${propertyValue}`,
58-
);
59-
return { value: propertyValue, source: InputSource.RepositoryProperty };
60-
} else {
61-
logger.info(
62-
"Ignoring configuration file input from repository property, because the corresponding feature flag is disabled.",
63-
);
64-
}
65-
}
35+
// Only use the repository property value if the FF is enabled.
36+
const useRepositoryProperty = await action.features.getValue(
37+
Feature.ConfigFileRepositoryProperty,
38+
);
6639

67-
return undefined;
40+
return getComputedInput(action, repositoryProperties, InputName.ConfigFile, {
41+
repositoryPropertyFeatureEnabled: useRepositoryProperty,
42+
allowForcedRepositoryPropertyValue: false,
43+
repositoryPropertyName: RepositoryPropertyName.CONFIG_FILE,
44+
});
6845
}
6946

7047
/**

0 commit comments

Comments
 (0)