Skip to content

Commit

Permalink
Merge branch 'templates-providers' of https://github.com/red-kite-sol…
Browse files Browse the repository at this point in the history
…utions/stalker into templates-providers
  • Loading branch information
Aboisier committed Nov 17, 2024
2 parents cece74f + 4c1c60e commit 2325da9
Show file tree
Hide file tree
Showing 13 changed files with 20 additions and 23 deletions.
2 changes: 1 addition & 1 deletion devspace.base.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ vars:
JM_JWT_SECRET: "123456" # The secret used to sign JWT for users
JM_REFRESH_SECRET: "123456" # The secret used to sign JWT refresh token for users
JM_MONGO_ADDRESS: mongodb://${MONGO_JM_USER}:${MONGO_JM_PASSWORD}@mongo-mongodb-headless:27017/ # The address of the FM's mongo database
JM_DATA_SOURCES: '[{"type": "git", "url": "https://github.com/red-kite-solutions/stalker-templates-community"}]'
JM_DATA_SOURCES: '[{"type": "git", "url": "https://github.com/red-kite-solutions/stalker-templates-community", "branch": "main"}]'

# Cron
CRON_VERSION: latest
Expand Down
2 changes: 1 addition & 1 deletion devspace.tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ vars:
JM_CERTIFICATES_KAFKA_CLIENT_KEY: LS0tLS1CRUdJTiBFTkNSWVBURUQgUFJJVkFURSBLRVktLS0tLQpNSUlKbkRCT0Jna3Foa2lHOXcwQkJRMHdRVEFwQmdrcWhraUc5dzBCQlF3d0hBUUlLZUEwajVzSFVSRUNBZ2dBCk1Bd0dDQ3FHU0liM0RRSUpCUUF3RkFZSUtvWklodmNOQXdjRUNNVENMc3BjUWxCOEJJSUpTT0FRall5eHl3OUUKVnZITElBS1I2Ly9MQjJXQ3d0aVBWTUwxckc2VkhSb3ZObENRZ3VOL3BPcjBHNGpkdmJrcGcyV3V2WExmaFBsYwpuaVY0WmhQaHEyWnU0bTFGRVNtVlhXRWFNMWFwc2l6Q1NLU1FDTkhrZEZCYktxZFlmbTVMTXpiUldpTHBERTdLCmdwSTBFTE05VVNaaVlGMjBrdUJXN0M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red-kite-solutions/stalker-templates-community"}]'
JM_DATA_SOURCES: '[{"type": "git", "url": "https://github.com/red-kite-solutions/stalker-templates-community", "branch": "main"}]'

# Cron
CRON_CERTIFICATES_CA_PEM: LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSURaVENDQWsyZ0F3SUJBZ0lVUUxZaERvdE9idXZRQnhGMGRrYnI2SmZSOTVNd0RRWUpLb1pJaHZjTkFRRUwKQlFBd1FqRUxNQWtHQTFVRUF3d0NRMEV4RmpBVUJnTlZCQXNNRFZOMFlXeHJaWElnVFc5dVoyOHhHekFaQmdOVgpCQW9NRWxKbFpDQkxhWFJsSUZOdmJIVjBhVzl1Y3pBZUZ3MHlOREF5TVRreU1UQXlOVE5hRncwek5EQXlNVFl5Ck1UQXlOVE5hTUVJeEN6QUpCZ05WQkFNTUFrTkJNUll3RkFZRFZRUUxEQTFUZEdGc2EyVnlJRTF2Ym1kdk1Sc3cKR1FZRFZRUUtEQkpTWldRZ1MybDBaU0JUYjJ4MWRHbHZibk13Z2dFaU1BMEdDU3FHU0liM0RRRUJBUVVBQTRJQgpEd0F3Z2dFS0FvSUJBUUM3NGFjRTZhWkNVS2YrcXBkZlJQdEU4di9odGZNdzhkb2ZrUjZiUUwwWmtDMTBQb0VBCkFIeTRCTWtmMW9HR09GWTdVNkxOZEpackVUaVIrSDdkM2ptNUg0QndMQ1grcjRTRUFvc0N3SDVDUHVVSndwZk4KMS9JRTFIbjVxRXcrOFBqUzZqUTBtNHY5NW1lbUpDMTFUWEszMTMySk5VMFUxVm0yaHorMnZwSGpveTc5b1pSdwphNmJ1d1dTV1NwL2lMN2M0Y2dBQmtRTFdHYXhDcW9FWUpqbXJpTnhwQy9FTzk4V2FJeTl2WGdmaUxTSkkzUG5ECjFXc1BTbHgrOFplSEZXdlZqSllhU2dEZUowbXFXUS9aMTI5SVdidmtMelhkV2VYYXIwdDdaYzlOWWVuOVhPQkUKNGdlY3BTWjJTMG1SRFVadnRyNW4rbzM0RTRCRjlqYldRRzVuQWdNQkFBR2pVekJSTUIwR0ExVWREZ1FXQkJSUgpXaHBhREI4eVVPVGhaU1hyMm1rRzV5RnlYVEFmQmdOVkhTTUVHREFXZ0JSUldocGFEQjh5VU9UaFpTWHIybWtHCjV5RnlYVEFQQmdOVkhSTUJBZjhFQlRBREFRSC9NQTBHQ1NxR1NJYjNEUUVCQ3dVQUE0SUJBUUF2c1N3bVJSN2QKSzZSRmtoVTZHOFp1VnFIMldSTDdCd0VHM0UrbE5xWHEzMVBLcjVyd3dGb3VIUHlBdDhFRk13dlZBd2prc0s5TwpoMzJDWmorZE1MN3NtVFliTE90T0xIbWkvUmxEeVdES1hNQ3dqcXh4aS9LdnVVTkhLVEV0c2pMVW5zNWxVUWpzCmI5MUVBNGlvdFM1UDE2ZEMzM2NqVUwwY1p5TkdsTGoyVzB2UjRuM3gwYjZrRkl0QXlHZnpxZ0NHbFpNY29wUDcKNENpeUNWZ0xhcDduTFdrNTdOV294Z2F2L3VnczZ0YXVrQ3dZcm5aT28xVkNqL3R1L0wwNUp3dTNTVWhXWHlJbApobENRMjNNYVRRK1hqVEk5TXNueEtSOWlOTWI3MWNkT2V4K0M3bHhMcm41K2xDSW9yVzJyWHRPY003VlI5TlJnClBGT2w5SE5zMU01egotLS0tLUVORCBDRVJUSUZJQ0FURS0tLS0t
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export class CustomJobTemplateSource {
type: 'git';
repoUrl: string;
avatarUrl: string;
branch: string;
}

@Schema()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,7 @@ export class JobSourceDto {

@IsString()
avatarUrl: string;

@IsString()
branch: string;
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export class CustomJobSource {
type: 'git';
repoUrl: string;
avatarUrl: string;
branch: string;
}

@Schema()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,24 +24,6 @@ async function exists(fs: FsPromisesApi, path: string) {
export class JobReader {
private logger = new Logger(JobReader.name);

public async validatePath(
path: string,
fileName: string,
fs?: FsPromisesApi,
): Promise<boolean> {
fs ??= realFs.promises;

const fileSplit = fileName.split('.');
if (fileSplit.length <= 1) return false;

const ext = fileSplit[fileSplit.length - 1].toLowerCase();
if (ext !== 'yml' && ext !== 'yaml') return false;

if (!(await exists(fs, path + fileName))) return false;

return true;
}

/** Reads a job configuration using the given file system. */
public async readJob(
jobsPath: string,
Expand Down Expand Up @@ -122,10 +104,11 @@ export class JobReader {
type: dataSource.type,
avatarUrl: dataSource.avatarUrl,
repoUrl: dataSource.repoUrl,
branch: dataSource.branch,
},
};

if (await exists(fs, handlerPath)) {
if (handlerPath && (await exists(fs, handlerPath))) {
job.findingHandler = (await fs.readFile(handlerPath)).toString();
job.findingHandlerEnabled = true;
job.findingHandlerLanguage = jobMetadata.findingHandlerLanguage;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export interface JobSourceConfig {
username: string;
password: string;
};
branch: string;
}

export interface JobSource {
Expand All @@ -30,6 +31,7 @@ export class GitJobSource implements JobSource {
includeTemplates: boolean = false,
): Promise<CustomJobEntry[]> {
const jobs = await this.listJobs('/jobs');

if (includeTemplates) {
jobs.push(...(await this.listJobs('/job-templates')));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export class CronSubscriptionSource {
type: 'git';
url: string;
avatarUrl: string;
branch: string;
}

@Schema()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export class EventSubscriptionSource {
type: 'git';
url: string;
avatarUrl: string;
branch: string;
}

@Schema()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -427,6 +427,7 @@ export class SubscriptionsUtils {
type: dataSource.type,
avatarUrl: dataSource.avatarUrl,
url: dataSource.repoUrl,
branch: dataSource.branch,
};

switch (yaml.triggerType) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export interface DataSourceConfig {
username: string;
password: string;
};
branch?: string;
}

export interface DataSource {
Expand All @@ -29,7 +30,7 @@ export class GitDataSource implements DataSource {
url: this.config.url,
dir: '/',
onAuth: () => this.config.auth,
ref: 'main',
ref: this.config.branch ?? 'main',
singleBranch: true,
depth: 1,
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export interface DataSource {
repoUrl: string;
avatarUrl: string;
fs: FsPromisesApi;
branch: string;
}

interface DataSourceCacheEntry extends DataSource {
Expand Down Expand Up @@ -53,6 +54,7 @@ export class DataSources {
fs,
avatarUrl: this.inferAvatar(config.url),
repoUrl: config.url,
branch: config.branch,
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export interface GitDataSourceConfig {
username: string;
password: string;
};
branch: string;
}

export class GitDataSource implements DataSource {
Expand All @@ -26,7 +27,7 @@ export class GitDataSource implements DataSource {
url: this.config.url,
dir: '/',
onAuth: () => this.config.auth,
ref: 'main',
ref: this.config.branch,
singleBranch: true,
depth: 1,
});
Expand Down

0 comments on commit 2325da9

Please sign in to comment.