stocky-france-59380
03/11/2021, 1:29 AMexport const ymml = new k8s.yaml.ConfigFile('yamlfile', {
file: 'foo.yaml',
});
and a test like this
describe('yaml', function () {
it('reads', function (done) {
pulumi.all([infra.ymml.urn, infra.ymml]).apply(([urn, thefile]) => {
console.log(urn);
var val = thefile.getResource('v1/Service', 'my-service');
console.log(val);
done();
});
});
});
in a unit test is there away to see the output of the file? At the moment I get this
yaml
urn:pulumi:stack::project::kubernetes:yaml:ConfigFile::yamlfile
OutputImpl {
__pulumiOutput: true,
resources: [Function (anonymous)],
allResources: [Function (anonymous)],
isKnown: Promise { <pending> },
isSecret: Promise { <pending> },
promise: [Function (anonymous)],
toString: [Function (anonymous)],
toJSON: [Function (anonymous)]
}
✓ reads
(node:58505) PromiseRejectionHandledWarning: Promise rejection was handled asynchronously (rejection id: 3)
(Use `node --trace-warnings ...` to show where the warning was created)
(node:58505) PromiseRejectionHandledWarning: Promise rejection was handled asynchronously (rejection id: 4)
I am trying to understand an error that looks like this when running that deploys a blackbox exporter. I can apply it using kubectl apply
but it's failing as below in pulumi
Error: invocation of kubernetes:yaml:decode returned an error: error converting YAML to JSON: yaml control characters are not allowed
little-cartoon-10569
03/11/2021, 2:01 AMapply()
blocks, and that's a bit tricky to synchonize properly.val.apply((contents) => console.log(contents));
stocky-france-59380
03/11/2021, 2:11 AMlittle-cartoon-10569
03/11/2021, 2:13 AMapply()
blocks.stocky-france-59380
03/11/2021, 2:23 AMlittle-cartoon-10569
03/11/2021, 2:25 AMstocky-france-59380
03/11/2021, 2:33 AM>
const yaml = require('js-yaml');
const fs = require('fs');
describe('js-yaml', function () {
it('read', function (done) {
let fileContent = fs.readFileSync('./foo.yml', 'utf-8');
let data = yaml.load(fileContent);
console.log(data);
done();
});
});
describe('yaml', function () {
it('reads', function (done) {
pulumi.all([infra.ymml.urn, infra.ymml]).apply(([urn, thefile]) => {
console.log(urn);
var val = thefile.getResource('v1/Service', 'my-service');
val.apply((content) => console.log(content.apiVersion));
done();
});
});
});
});
where foo.yaml
looks like this
apiVersion: v1
kind: Service
metadata:
name: my-service
spec:
selector:
app: MyApp
ports:
- protocol: TCP
port: 80
targetPort: 9376
the output is
yaml
urn:pulumi:stack::project::kubernetes:yaml:ConfigFile::yamlfile
✓ reads
(node:72056) PromiseRejectionHandledWarning: Promise rejection was handled asynchronously (rejection id: 3)
(Use `node --trace-warnings ...` to show where the warning was created)
(node:72056) PromiseRejectionHandledWarning: Promise rejection was handled asynchronously (rejection id: 4)
little-cartoon-10569
03/11/2021, 2:45 AMasync
to the function you pass to it