Skip to content
Snippets Groups Projects
Unverified Commit 652ac2ac authored by David May's avatar David May Committed by GitHub
Browse files

feat: add velaci manager (#14803)

parent e4fe08f1
No related branches found
No related tags found
No related merge requests found
...@@ -67,6 +67,7 @@ import * as terragrunt from './terragrunt'; ...@@ -67,6 +67,7 @@ import * as terragrunt from './terragrunt';
import * as terragruntVersion from './terragrunt-version'; import * as terragruntVersion from './terragrunt-version';
import * as travis from './travis'; import * as travis from './travis';
import type { ManagerApi } from './types'; import type { ManagerApi } from './types';
import * as velaci from './velaci';
const api = new Map<string, ManagerApi>(); const api = new Map<string, ManagerApi>();
export default api; export default api;
...@@ -139,3 +140,4 @@ api.set('terraform-version', terraformVersion); ...@@ -139,3 +140,4 @@ api.set('terraform-version', terraformVersion);
api.set('terragrunt', terragrunt); api.set('terragrunt', terragrunt);
api.set('terragrunt-version', terragruntVersion); api.set('terragrunt-version', terragruntVersion);
api.set('travis', travis); api.set('travis', travis);
api.set('velaci', velaci);
version: "1"
steps:
- name: node
image: amd64/node:10.0.0@sha256:5082d4db78ee2d24f72b25eb75537f2e19c49f04a595378d1ae8814d6f2fbf28
commands:
- npm install
- npm test
secrets:
# Implicit secret definition.
- name: vault_token
- origin:
name: private vault
image: target/secret-vault:v0.1.0
secrets: [ vault_token ]
parameters:
addr: vault.example.com
auth_method: token
username: octocat
items:
- source: secret/docker
path: docker
version: "1"
services:
- name: mysql
image: mysql:5.7.24
- name: redis
image: redis:alpine
steps:
- name: node
image: amd64/node:10.0.0@sha256:5082d4db78ee2d24f72b25eb75537f2e19c49f04a595378d1ae8814d6f2fbf28
commands:
- npm install
- npm test
version: "1"
stages:
go:
steps:
- name: go
image: golang:1.13
environment:
CGO_ENABLED: '0'
GOOS: linux
commands:
- go get ./...
- go test ./...
node:
steps:
- name: node
image: amd64/node:10.0.0@sha256:5082d4db78ee2d24f72b25eb75537f2e19c49f04a595378d1ae8814d6f2fbf28
commands:
- npm install
- npm test
version: "1"
steps:
- name: go
image: golang:1.13
environment:
CGO_ENABLED: '0'
GOOS: linux
commands:
- go get ./...
- go test ./...
- name: node
image: amd64/node:10.0.0@sha256:5082d4db78ee2d24f72b25eb75537f2e19c49f04a595378d1ae8814d6f2fbf28
commands:
- npm install
- npm test
import { Fixtures } from '../../../../test/fixtures';
import { extractPackageFile } from '.';
describe('modules/manager/velaci/extract', () => {
describe('extractPackageFile()', () => {
it('should handle invalid YAML', () => {
const res = extractPackageFile('foo: bar: invalid');
expect(res).toBeNull();
});
it('should handle YAML without pipeline/images', () => {
const res = extractPackageFile('no: pipeline');
expect(res).toBeNull();
});
it('extracts multiple step pipeline image lines', () => {
const res = extractPackageFile(Fixtures.get('.vela-steps.yml'));
expect(res.deps).toMatchObject([
{
currentValue: '1.13',
depName: 'golang',
},
{
currentValue: '10.0.0',
depName: 'node',
},
]);
});
it('extracts multiple services pipeline image lines', () => {
const res = extractPackageFile(Fixtures.get('.vela-services.yml'));
expect(res.deps).toMatchObject([
{
currentValue: '10.0.0',
depName: 'node',
},
{
currentValue: '5.7.24',
depName: 'mysql',
},
{
currentValue: 'alpine',
depName: 'redis',
},
]);
});
it('extracts multiple stages pipeline image lines', () => {
const res = extractPackageFile(Fixtures.get('.vela-stages.yaml'));
expect(res.deps).toMatchObject([
{
currentValue: '1.13',
depName: 'golang',
},
{
currentValue: '10.0.0',
depName: 'node',
},
]);
});
it('extracts multiple secrets pipeline image lines', () => {
const res = extractPackageFile(Fixtures.get('.vela-secrets.yml'));
expect(res.deps).toMatchObject([
{
currentValue: '10.0.0',
depName: 'node',
},
{
currentValue: 'v0.1.0',
depName: 'target/secret-vault',
},
]);
});
});
});
import { load } from 'js-yaml';
import { logger } from '../../../logger';
import { getDep } from '../dockerfile/extract';
import type { PackageDependency, PackageFile } from '../types';
import type { VelaPipelineConfiguration } from './types';
export function extractPackageFile(file: string): PackageFile | null {
let doc: VelaPipelineConfiguration | undefined;
try {
doc = load(file, { json: true }) as VelaPipelineConfiguration;
} catch (err) {
logger.debug({ err, file }, 'Failed to parse Vela file.');
return null;
}
const deps: PackageDependency[] = [];
// iterate over steps
for (const step of doc.steps ?? []) {
const dep = getDep(step.image);
deps.push(dep);
}
// iterate over services
for (const service of doc.services ?? []) {
const dep = getDep(service.image);
deps.push(dep);
}
// iterate over stages
for (const stage of Object.values(doc.stages ?? {})) {
for (const step of stage.steps ?? []) {
const dep = getDep(step.image);
deps.push(dep);
}
}
// check secrets
for (const secret of Object.values(doc.secrets ?? {})) {
if (secret.origin) {
const dep = getDep(secret.origin.image);
deps.push(dep);
}
}
if (!deps.length) {
return null;
}
return { deps };
}
import { DockerDatasource } from '../../datasource/docker';
export { extractPackageFile } from './extract';
export const defaultConfig = {
fileMatch: ['(^|/).vela.ya?ml$'],
};
export const supportedDatasources = [DockerDatasource.id];
Extracts Docker-type dependencies from VelaCI config files.
If you need to change the versioning format, read the [versioning](https://docs.renovatebot.com/modules/versioning/) documentation to learn more.
/**
* VelaPipelineConfiguration
*
* Spec: https://github.com/go-vela/types/releases/latest/download/schema.json
* Docs: https://go-vela.github.io/docs/reference/yaml/
*/
export interface VelaPipelineConfiguration {
secrets?: {
origin?: ObjectWithImageProp;
}[];
services?: ObjectWithImageProp[];
stages?: Record<string, Stage>;
steps?: ObjectWithImageProp[];
}
export interface ObjectWithImageProp {
image: string;
}
export interface Stage {
steps: ObjectWithImageProp[];
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment