Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/product-os/transformer-runtime
https://github.com/product-os/transformer-runtime
Last synced: 6 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/product-os/transformer-runtime
- Owner: product-os
- Created: 2021-07-18T16:51:04.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2022-12-13T02:20:48.000Z (almost 2 years ago)
- Last Synced: 2024-03-15T04:09:16.120Z (8 months ago)
- Language: TypeScript
- Size: 328 KB
- Stars: 1
- Watchers: 13
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
Awesome Lists containing this project
README
# ProductOS Transformer Runtime Package
This package encodes the basic rules for running transformers. This package allows you to obtain the minimal functionality to run a transformer by providing input, artifact, and output targets.
## Example Usage
Run a transformer of image `example-image:latest` which has been pulled before:
```js
import TransformerRuntime from '../src';
import * as yaml from 'js-yaml';
import * as fs from 'fs';
import * as path from 'path';
import { Contract } from '@balena/jellyfish-types/build/core';
import testTransformer from './test-transformer';const runtime = new TransformerRuntime();
const img = 'example-image';
const version = 'latest';const artifactDir = path.join(__dirname, 'artifactDir');
const workingDir = path.join(__dirname, 'in');
const transformerImage = `${img}:${version}`;
const outputDir = path.join(__dirname, 'out');
const runPrivileged = true;
const content = fs
.readFileSync(path.join(artifactDir, '/balena.yml'))
.toString();
const contract = yaml.load(content) as Contract;async function main() {
const result = await runtime.runTransformer(
artifactDir,
contract,
testTransformer,
transformerImage,
workingDir,
outputDir,
runPrivileged
);
}main().catch(err => {
console.log("error executing your transformer:", err);
process.exit(1);
});
```## Create your own transformer
You can follow the tutorial [here](https://docs.google.com/document/d/1iPsyXBjnvzG25hNHztIFsUcLDM1gSAIhNTHJDY8pZJ0/) to create your own transformer