Skip to content

Commit

Permalink
Merge pull request #480 from h0x0er/jatin/cleanup
Browse files Browse the repository at this point in the history
chore: clean the code
  • Loading branch information
varunsh-coder authored Oct 26, 2024
2 parents 40401cf + 6c39b84 commit 556aae6
Show file tree
Hide file tree
Showing 6 changed files with 75 additions and 107 deletions.
17 changes: 3 additions & 14 deletions dist/post/index.js

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

2 changes: 1 addition & 1 deletion dist/post/index.js.map

Large diffs are not rendered by default.

128 changes: 67 additions & 61 deletions dist/pre/index.js

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

2 changes: 1 addition & 1 deletion dist/pre/index.js.map

Large diffs are not rendered by default.

11 changes: 0 additions & 11 deletions src/arc-runner.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,3 @@ it("should correctly recognize arc based runner", async () => {
let isArc: boolean = await isArcRunner();
expect(isArc).toBe(true);
});

it("should write endpoint files", () => {
process.env["isTest"] = "1";

let allowed_endpoints = [
"github.com:443",
"*.google.com:443",
"youtube.com",
].join(" ");
sendAllowedEndpoints(allowed_endpoints);
});
22 changes: 3 additions & 19 deletions src/arc-runner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,28 +21,14 @@ function isSecondaryPod(): boolean {
return fs.existsSync(workDir);
}

function getRunnerTempDir(): string {
const isTest = process.env["isTest"];

if (isTest === "1") {
return "/tmp";
}
return process.env["RUNNER_TEMP"] || "/tmp";
}

export function sendAllowedEndpoints(endpoints: string): void {
const allowedEndpoints = endpoints.split(" "); // endpoints are space separated

for (const endpoint of allowedEndpoints) {
if (endpoint) {
let encodedEndpoint = Buffer.from(endpoint).toString("base64");

let fileName = path.join(
getRunnerTempDir(),
`step_policy_endpoint_${encodedEndpoint}`
);

echo(fileName);
let endpointPolicyStr = `step_policy_endpoint_${encodedEndpoint}`;
echo(endpointPolicyStr);
}
}

Expand All @@ -53,9 +39,7 @@ export function sendAllowedEndpoints(endpoints: string): void {

function applyPolicy(count: number): void {
let applyPolicyStr = `step_policy_apply_${count}`;
let fileName = path.join(getRunnerTempDir(), applyPolicyStr);

echo(fileName);
echo(applyPolicyStr);
}

function echo(content: string) {
Expand Down

0 comments on commit 556aae6

Please sign in to comment.