Skip to content

Commit 196a3e5

Browse files
authored
Merge pull request #3188 from github/mbg/telemetry/partial-config
Allow `Partial<Config>` for `createStatusReportBase`
2 parents 8301b8b + bdd2cdf commit 196a3e5

12 files changed

+91
-30
lines changed

lib/analyze-action.js

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

lib/autobuild-action.js

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

lib/init-action-post.js

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

lib/init-action.js

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

lib/resolve-environment-action.js

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

lib/start-proxy-action.js

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

lib/upload-sarif-action.js

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

src/start-proxy-action.ts

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,14 @@ import { pki } from "node-forge";
77

88
import * as actionsUtil from "./actions-util";
99
import { getApiDetails, getAuthorizationHeaderFor } from "./api-client";
10+
import { Config } from "./config-utils";
11+
import { KnownLanguage } from "./languages";
1012
import { getActionsLogger, Logger } from "./logging";
1113
import {
1214
Credential,
1315
getCredentials,
1416
getDownloadUrl,
17+
parseLanguage,
1518
UPDATEJOB_PROXY,
1619
} from "./start-proxy";
1720
import {
@@ -98,14 +101,15 @@ interface StartProxyStatus extends StatusReportBase {
98101

99102
async function sendSuccessStatusReport(
100103
startedAt: Date,
104+
config: Partial<Config>,
101105
registry_types: string[],
102106
logger: Logger,
103107
) {
104108
const statusReportBase = await createStatusReportBase(
105109
ActionName.StartProxy,
106110
"success",
107111
startedAt,
108-
undefined,
112+
config,
109113
await util.checkDiskUsage(logger),
110114
logger,
111115
);
@@ -125,6 +129,7 @@ async function runWrapper() {
125129
actionsUtil.persistInputs();
126130

127131
const logger = getActionsLogger();
132+
let language: KnownLanguage | undefined;
128133

129134
try {
130135
// Setup logging for the proxy
@@ -133,11 +138,13 @@ async function runWrapper() {
133138
core.saveState("proxy-log-file", proxyLogFilePath);
134139

135140
// Get the configuration options
141+
const languageInput = actionsUtil.getOptionalInput("language");
142+
language = languageInput ? parseLanguage(languageInput) : undefined;
136143
const credentials = getCredentials(
137144
logger,
138145
actionsUtil.getOptionalInput("registry_secrets"),
139146
actionsUtil.getOptionalInput("registries_credentials"),
140-
actionsUtil.getOptionalInput("language"),
147+
language,
141148
);
142149

143150
if (credentials.length === 0) {
@@ -165,6 +172,9 @@ async function runWrapper() {
165172
// Report success if we have reached this point.
166173
await sendSuccessStatusReport(
167174
startedAt,
175+
{
176+
languages: language && [language],
177+
},
168178
proxyConfig.all_credentials.map((c) => c.type),
169179
logger,
170180
);
@@ -178,7 +188,9 @@ async function runWrapper() {
178188
ActionName.StartProxy,
179189
getActionsStatus(error),
180190
startedAt,
181-
undefined,
191+
{
192+
languages: language && [language],
193+
},
182194
await util.checkDiskUsage(logger),
183195
logger,
184196
);

src/start-proxy.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ test("getCredentials filters by language when specified", async (t) => {
109109
getRunnerLogger(true),
110110
undefined,
111111
toEncodedJSON(mixedCredentials),
112-
"java",
112+
KnownLanguage.java,
113113
);
114114
t.is(credentials.length, 1);
115115
t.is(credentials[0].type, "maven_repository");
@@ -120,7 +120,7 @@ test("getCredentials returns all for a language when specified", async (t) => {
120120
getRunnerLogger(true),
121121
undefined,
122122
toEncodedJSON(mixedCredentials),
123-
"go",
123+
KnownLanguage.go,
124124
);
125125
t.is(credentials.length, 2);
126126

src/start-proxy.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,8 @@ export function getCredentials(
7979
logger: Logger,
8080
registrySecrets: string | undefined,
8181
registriesCredentials: string | undefined,
82-
languageString: string | undefined,
82+
language: KnownLanguage | undefined,
8383
): Credential[] {
84-
const language = languageString ? parseLanguage(languageString) : undefined;
8584
const registryTypeForLanguage = language
8685
? LANGUAGE_TO_REGISTRY_TYPE[language]
8786
: undefined;

0 commit comments

Comments
 (0)