Implement handling of new filters in typescript converter
This commit is contained in:
@@ -7,10 +7,12 @@ import {TokenType} from "../../templates/tokens/types";
|
|||||||
import {
|
import {
|
||||||
BranchFilterConfig,
|
BranchFilterConfig,
|
||||||
EventsConfig,
|
EventsConfig,
|
||||||
|
NamesFilterConfig,
|
||||||
PathFilterConfig,
|
PathFilterConfig,
|
||||||
ScheduleConfig,
|
ScheduleConfig,
|
||||||
TagFilterConfig,
|
TagFilterConfig,
|
||||||
TypesFilterConfig,
|
TypesFilterConfig,
|
||||||
|
VersionsFilterConfig,
|
||||||
WorkflowFilterConfig
|
WorkflowFilterConfig
|
||||||
} from "../workflow-template";
|
} from "../workflow-template";
|
||||||
import {isValidCron} from "./cron";
|
import {isValidCron} from "./cron";
|
||||||
@@ -76,10 +78,11 @@ export function convertOn(context: TemplateContext, token: TemplateToken): Event
|
|||||||
...convertPatternFilter("tags", eventToken),
|
...convertPatternFilter("tags", eventToken),
|
||||||
...convertPatternFilter("paths", eventToken),
|
...convertPatternFilter("paths", eventToken),
|
||||||
...convertFilter("types", eventToken),
|
...convertFilter("types", eventToken),
|
||||||
|
...convertFilter("versions", eventToken),
|
||||||
|
...convertFilter("names", eventToken),
|
||||||
...convertFilter("workflows", eventToken)
|
...convertFilter("workflows", eventToken)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -121,8 +124,8 @@ function convertPatternFilter<T extends BranchFilterConfig & TagFilterConfig & P
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
function convertFilter<T extends TypesFilterConfig & WorkflowFilterConfig>(
|
function convertFilter<T extends TypesFilterConfig & WorkflowFilterConfig & VersionsFilterConfig & NamesFilterConfig>(
|
||||||
name: "types" | "workflows",
|
name: "types" | "workflows" | "versions" | "names",
|
||||||
token: MappingToken
|
token: MappingToken
|
||||||
): T {
|
): T {
|
||||||
const result = {} as T;
|
const result = {} as T;
|
||||||
|
|||||||
@@ -129,6 +129,7 @@ export type EventsConfig = {
|
|||||||
repository_dispatch?: TypesFilterConfig;
|
repository_dispatch?: TypesFilterConfig;
|
||||||
release?: TypesFilterConfig;
|
release?: TypesFilterConfig;
|
||||||
watch?: TypesFilterConfig;
|
watch?: TypesFilterConfig;
|
||||||
|
image_versions?: TypesFilterConfig & VersionsFilterConfig & NamesFilterConfig;
|
||||||
|
|
||||||
// Index signature to allow easier lookup
|
// Index signature to allow easier lookup
|
||||||
[eventName: string]: unknown;
|
[eventName: string]: unknown;
|
||||||
@@ -138,6 +139,14 @@ export type TypesFilterConfig = {
|
|||||||
types?: string[];
|
types?: string[];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export type VersionsFilterConfig = {
|
||||||
|
versions?: string[];
|
||||||
|
};
|
||||||
|
|
||||||
|
export type NamesFilterConfig = {
|
||||||
|
names?: string[];
|
||||||
|
};
|
||||||
|
|
||||||
export type BranchFilterConfig = {
|
export type BranchFilterConfig = {
|
||||||
branches?: string[];
|
branches?: string[];
|
||||||
"branches-ignore"?: string[];
|
"branches-ignore"?: string[];
|
||||||
|
|||||||
+8
-1
@@ -15,7 +15,14 @@ jobs:
|
|||||||
---
|
---
|
||||||
{
|
{
|
||||||
"events": {
|
"events": {
|
||||||
"image_version": {}
|
"image_version": {
|
||||||
|
"versions": [
|
||||||
|
"1.*"
|
||||||
|
],
|
||||||
|
"names": [
|
||||||
|
"testing"
|
||||||
|
]
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"jobs": [
|
"jobs": [
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -21,6 +21,10 @@ jobs:
|
|||||||
"image_version": {
|
"image_version": {
|
||||||
"types": [
|
"types": [
|
||||||
"ready"
|
"ready"
|
||||||
|
],
|
||||||
|
"names": [
|
||||||
|
"one",
|
||||||
|
"two"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -21,6 +21,10 @@ jobs:
|
|||||||
"image_version": {
|
"image_version": {
|
||||||
"types": [
|
"types": [
|
||||||
"ready"
|
"ready"
|
||||||
|
],
|
||||||
|
"versions": [
|
||||||
|
"1.0.0",
|
||||||
|
"1.0.1"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user