Add a context provider for secrets

This commit is contained in:
Josh Gross
2022-11-29 16:56:20 -05:00
parent a67069da17
commit 72c7fbd032
10 changed files with 105 additions and 9 deletions
@@ -4,13 +4,18 @@ import {ContextProviderConfig} from "./context-providers/config";
import {getPositionFromCursor} from "./test-utils/cursor-position";
const contextProviderConfig: ContextProviderConfig = {
getContext: (context: string) => {
getContext: async (context: string) => {
switch (context) {
case "github":
return new data.Dictionary({
key: "event",
value: new data.StringData("push")
});
case "secrets":
return new data.Dictionary({
key: "DEPLOY_KEY",
value: new data.StringData("DEPLOY_KEY")
});
}
return undefined;
@@ -125,4 +130,22 @@ jobs:
expect(result.map(x => x.label)).toEqual(["event"]);
});
});
it("context inherited from parent", async () => {
// The token definition is just a `string` and
// the parent `step-with` holds the allowed context
const input = `
on: push
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/deploy@v100
with:
deploy-key: \${{ secrets.|
`;
const result = await complete(...getPositionFromCursor(input), undefined, contextProviderConfig);
expect(result.map(x => x.label)).toEqual(["DEPLOY_KEY"]);
});
});