"Missing manifest" error at $ rkt run - rkt

I have the following shell script which creates a Debian base aci container for rkt / appC:
#!/bin/sh
set -e
# $ zcat debian.aci | tree | head
# $ rkt run debian.aci --insecure-options=image
export MY_CHROOT=/var/lib/container/aci/debian
mkdir -p $MY_CHROOT
debootstrap --verbose --arch=amd64 --include=iputils-ping,iproute --variant=minbase stable $MY_CHROOT/rootfs http://httpredir.debian.org/debian
cat > $MY_CHROOT/manifest <<EOF
{
"acKind": "ImageManifest",
"acVersion": "0.8.9",
"name": "debian",
"labels": [
{"name": "arch", "value": "amd64"},
{"name": "os", "value": "linux"},
{"name": "version", "value": "1.0.0"}
],
"app": {
"exec": [
"/bin/sh",
"echo",
"Hello, World from $MY_ENV_VAR!"
],
"user": "0",
"group": "0",
"environment": [
{
"name": "MY_ENV_VAR",
"value": "$(whoami)"
}
],
},
"annotations": {
"authors": "Istvan Lantos <email#addess.com>"
}
}
EOF
# use gpg to create a sig, but we'll skip that for now
tar cvvf - $MY_CHROOT/manifest $MY_CHROOT/rootfs | gzip -c > $MY_CHROOT/debian.aci
To verify that manifest file is present:
root#debian:/var/lib/container/aci/debian# zcat debian.aci | tree | head
.
├── debian.aci
├── manifest
└── rootfs
├── bin
│   ├── bash
│   ├── cat
│   ├── chacl
│   ├── chgrp
│   ├── chmod
When I try to run this container with $ rkt run debian.aci --insecure-options=image command, I got the following error:
run: missing manifest
I followed these guides for file structure:
https://github.com/appc/spec
https://github.com/appc/spec/blob/master/spec/aci.md#image-layout
https://github.com/appc/spec/blob/master/examples/image.json
Why not working?
Thank You for your help!

Actually, the error is caused by tar which includes absolute paths in the archive.
So solution is to cd in the directory and not use absolute paths prefixed by $MY_CHROOT.
Source: https://unix.stackexchange.com/a/59246/120771

Related

use a `task` to export a workspace-specific environment variable: $PATH?

I have several workspaces that have unique environments.
When I load a workspace, I would like to update the linux $PATH accordingly, however, I tried the following:
### workspace.code-workspace
{
"folders": [
{
"path": "."
}
],
"settings": {},
"tasks": [
{
"command": "export $PATH=${workspaceFolder}/bin:$PATH"
}
]
}
Which fails according to:
me#pc:~/Containers/cuda_devcon/project$ ls -alvh ./bin/julia
lrwxrwxrwx 1 me me 21 Jan 29 17:38 ./bin/julia -> julia-1.6.7/bin/julia
me#pc:~/Containers/cuda_devcon/project$ which julia
me#pc:~/Containers/cuda_devcon/project$ julia
Command 'julia' not found, but can be installed with:
sudo snap install julia # version 1.8.5, or
sudo apt install julia # version 1.4.1+dfsg-1
See 'snap info julia' for additional versions.

vs-code extension doesn't Activate on startup

I'm developing a vs-code extension, I wrote a code for cron-jobs (runs extension at a certain time) and it works well. the problem is my extension doesn't lunch at startup I've read the docs and I did what I must do like I saw in docs and still doesn't work at startup.
extension.ts:
import * as vscode from "vscode";
import axios from "axios";
// dotenv
import "dotenv/config";
export async function activate(context: vscode.ExtensionContext) {
var cron = require("node-cron");
// API Call Goes Here...
// *** Visual Studio Code ***
let disposable = vscode.commands.registerCommand(
"myExtenstionIdAndNameNotForPublicXD",
async () => {
if (Content || Reference) {
vscode.window.showInformationMessage(
`"${Content}" - ${Reference} 💥`
);
} else {
vscode.window.showInformationMessage(
`Network Error! 💥`
);
}
// *** Autostart ***
{
/*
# ┌────────────── second (optional)
# │ ┌──────────── minute
# │ │ ┌────────── hour
# │ │ │ ┌──────── day of month
# │ │ │ │ ┌────── month
# │ │ │ │ │ ┌──── day of week
# │ │ │ │ │ │
# │ │ │ │ │ │
# * * * * * *
*/
}
cron.schedule(
// S M H D M W
"5 * * * * *",
async () => {
if (Content || Reference) {
vscode.window.showInformationMessage(
`"${Content}" - ${Reference} 💥`
);
} else {
vscode.window.showInformationMessage(
`Network Error! 💥`
);
}
},
{
scheduled: true,
}
);
}
);
context.subscriptions.push(disposable);
}
// this method is called when your extension is deactivated
export function deactivate() {}
and here is my package.json
{
"name": "name",
"displayName": "name",
"description": "name",
"version": "0.0.1",
"engines": {
"vscode": "^1.70.0"
},
"categories": [
"Other"
],
"activationEvents": ["*"],
"main": "./dist/extension.js",
"contributes": {
"commands": [
{
"command": "name.name",
"title": "name.name"
}
]
},
"scripts": {
"vscode:prepublish": "npm run package",
"compile": "webpack",
"watch": "webpack --watch",
"package": "webpack --mode production --devtool hidden-source-map",
"compile-tests": "tsc -p . --outDir out",
"watch-tests": "tsc -p . -w --outDir out",
"pretest": "npm run compile-tests && npm run compile && npm run lint",
"lint": "eslint src --ext ts",
"test": "node ./out/test/runTest.js"
},
"devDependencies": {
"#types/glob": "^7.2.0",
"#types/mocha": "^9.1.1",
"#types/node": "^16.11.56",
"#types/vscode": "^1.70.0",
"#typescript-eslint/eslint-plugin": "^5.31.0",
"#typescript-eslint/parser": "^5.31.0",
"#vscode/test-electron": "^2.1.5",
"eslint": "^8.20.0",
"glob": "^8.0.3",
"mocha": "^10.0.0",
"ts-loader": "^9.3.1",
"typescript": "^4.7.4",
"webpack": "^5.74.0",
"webpack-cli": "^4.10.0"
},
"dependencies": {
"axios": "^0.27.2",
"cron": "^2.1.0",
"dotenv": "^16.0.1",
"node-cron": "^3.0.2"
}
}
I need to auto-lunch the extension when the user opens vs code.
then it shows a notification
last, the cron-job code work well and push notifications daily (i know it will push every 15 sec .. just for test)
note: I get this error on my debug console
Error: Unexpected SIGPIPE at process.<anonymous> (/usr/share/code/resources/app/out/out-vscode/bootstrap.js:35:18) at process.emit (/home/kareem/Desktop/VerseOfTheDay-vscode/lib/events.js:390:28) at Signal.callbackTrampoline (node:internal/async_hooks:130:17) {stack: 'Error: Unexpected SIGPIPE at process.<ano…Trampoline (node:internal/async_hooks:130:17)', message: 'Unexpected SIGPIPE'}
that's it! im sorry for hiding the extension name and details :)
I found a solution that was not mentioned on DOCS,
You must do this next like this:
extension.ts or extension.js
context.subscriptions.push(disposable);
// Solution is the next line after your context
vscode.commands.executeCommand("identifier.yourExtensionName");
Also, make sure you have one of the following options on your Package.json
"activationEvents": ["onStartupFinished"], // or "*"
Ref: https://medium.com/secarmalabs/using-visual-studio-code-extensions-for-persistence-a65c940b7ea6
and
https://code.visualstudio.com/api/references/activation-events
I hope it helps you ^-^

Swiftc arguments in Swift Package

I hava a Swift Package with an executable target, the project structure looks like this:
MySwiftPackage
├── Package.swift
├── Sources
│   └── MySwiftPackage
│   ├── SwiftBridgeCore.swift
│   ├── main.swift
│   └── my_rust_lib.swift
├── bridging-header.h
├── file.json
├── generated
│   ├── SwiftBridgeCore.h
│   └── my_rust_lib
│   └── my_rust_lib.h
└── lib_mac
   └── libmy_rust_lib.a
This package needs to link to the static library lib_mac/libmy_rust_lib.a and links with the bridging-header.h.
The bridging-header.h just has some #include to the headers in generated.
To build this project, I run
swiftc -L lib_mac -lmy_rust_lib \
-import-objc-header bridging-header.h \
Sources/LinuxSwiftPackage/*.swift
This will build an executable I can run. I now want to accomplish the same this using swift build, so that I can add dependencies.
I have tried the following:
1. In my Package.swift, I added the following:
let package = Package(
name: "MySwiftPackage",
dependencies: [],
targets: [
.executableTarget(
name: "MySwiftPackage",
dependencies: [],
cSettings: [
.headerSearchPath(".")
],
linkerSettings: [
.linkedLibrary(":lib_mac/libmy_rust_lib.a")
]
)
]
)
This did not link the library however, as I got a lot of cannot find type <SomeType defined in the header> in scope
2. I have added the following to Package.swift:
let package = Package(
name: "MySwiftPackage",
dependencies: [],
targets: [
.executableTarget(
name: "MySwiftPackage",
dependencies: [],
linkerSettings: [
.unsafeFlags(["-L lib_mac", "-lmy_rust_lib", "-import-objc-header bridging-header.h"])
]
)
]
)
This would yield the same errors.
I also tried swiftSettings instead of linkerSettings, this would give me the following error: ld: symbol(s) not found for architecture x86_64
3. I have tried the following:
file.json
{
"version": 1,
"sdk": "/Library/Developer/Toolchains/swift-latest.xctoolchain/usr/bin/swift",
"toolchain-bin-dir": "/Library/Developer/Toolchains/swift-latest.xctoolchain/usr/bin",
"target": "x86_64-apple-macosx",
"dynamic-library-extension": "lib",
"extra-cc-flags": [
],
"extra-swiftc-flags": [
"-L",
"lib_mac",
"-lmy_rust_lib",
"-import-objc-header",
"bridging-header.h"
],
"extra-cpp-flags": []
}
with a Package.swift that looks like this:
let package = Package(
name: "MySwiftPackage",
dependencies: [],
targets: [
.executableTarget(
name: "MySwiftPackage",
dependencies: []
)
]
)
I then ran swift build --destination file.json, with would give me the following error:
error: no such module 'Foundation'
import Foundation
Will any of these approaches work with some changes? Or is there another approach that should work?
Thanks in advance,Jonas
P.S. I'm using macOS (12)

TypeOrm Error: No connection options were found in any orm configuration files

I'm working on a Typescript/nodeJS personal project. I want to create a connection to my postgres database using typeOrm but I ran into this issue:
here is the full error:
$ ts-node src/index.ts
Version 9 of Highlight.js has reached EOL and is no longer supported. Please upgrade to version 10.
Server listening at http://localhost:3002
(node:36885) UnhandledPromiseRejectionWarning: Error: No connection options were found in any orm configuration files.
at connexion_1.createConnection.error (/home/maxime/Dev/JeuxDuPlacard/packages/server/src/index.ts:7:36)
at typeorm_1.getConnectionOptions.then.catch.error (/home/maxime/Dev/JeuxDuPlacard/packages/server/src/technical/typeorm/connexion.ts:17:5)
at process._tickCallback (internal/process/next_tick.js:68:7)
at Function.Module.runMain (internal/modules/cjs/loader.js:834:11)
at Object.<anonymous> (/home/maxime/Dev/JeuxDuPlacard/packages/server/node_modules/ts-node/src/_bin.ts:182:12)
at Module._compile (internal/modules/cjs/loader.js:778:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
at Module.load (internal/modules/cjs/loader.js:653:32)
at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
at Function.Module._load (internal/modules/cjs/loader.js:585:3)
(node:36885) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:36885) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code
my project structure
.
├── docker
│   ├── database.env
│   └── docker-compose.yml
├── ormconfig.ts
├── package.json
├── package-lock.json
├── src
│   ├── app.ts
│   ├── business
│   ├── index.ts
│   └── technical
│   ├── controller
│   ├── typeorm
│   │   ├── connexion.ts
│   │   └── repository
│   ├── user
│   └── validation
├── tsconfig.json
├── yarn-error.log
└── yarn.lock
./package.json
{
"name": "server",
"version": "1.0.0",
"main": "index.js",
"license": "MIT",
"type": "commonjs",
"workspaces": [
"packages/*"
],
"private": true,
"scripts": {
"dev": "tsc --watch",
"test": "echo testing server",
"start": "ts-node src/index.ts"
},
"dependencies": {
"#types/jsonwebtoken": "^8.5.0",
"bcrypt": "^5.0.0",
"body-parser": "^1.19.0",
"express": "^4.17.1",
"jsonwebtoken": "^8.5.1",
"pg": "^8.4.0",
"reflect-metadata": "^0.1.10",
"typeorm": "0.2.29",
"validate.js": "^0.13.1"
},
"devDependencies": {
"#types/bcrypt": "^3.0.0",
"#types/express": "^4.17.9",
"#types/node": "^14.14.8",
"ts-node": "3.3.0",
"ts-node-dev": "^1.0.0",
"typescript": "^4.0.5"
}
}
src/index.ts
import "reflect-metadata";
import { createConnection } from "./technical/typeorm/connexion";
import app from './app';
const port = 3002;
createConnection( error => { throw new Error(error.message) });
app.listen(port, () => console.log(`Server listening at http://localhost:${port}`))
src/technical/typeorm/connection.ts
import { PostgresConnectionOptions } from 'typeorm/driver/postgres/PostgresConnectionOptions';
import { getConnectionOptions, createConnection as TypeOrmCreateConnexion, Connection } from 'typeorm';
export async function createConnection(handleError: (error: Error) => unknown): Promise<Connection>{
return getConnectionOptions()
.then(connectionOptions => {
console.log(connectionOptions)
return TypeOrmCreateConnexion({
...(connectionOptions as PostgresConnectionOptions),
poolErrorHandler: handleError,
extra: {
max: 1
},
})
})
.catch(error => {
handleError(error);
throw error;
})
}
ormConfig.ts
import {ConnectionOptions} from "typeorm";
import path from "path";
const isCompiled = path.extname(__filename).includes('js');
const fileExtension = isCompiled ? "js" : "ts";
export default {
type: "postgres",
host: process.env.DB_HOST || "localhost",
port: Number(process.env.DB_PORT) || 5432,
username: process.env.DB_USERNAME || "test",
password: process.env.DB_PASSWORD || "test",
database: process.env.DB_NAME || "test",
synchronize: true,
logging: false,
entities: [
`src/business/**/*.entity.${fileExtension}`
],
migrations: [
`src/migration/**/*.${fileExtension}`
],
subscribers: [
`src/subscriber/**/*.${fileExtension}`
]
} as ConnectionOptions;
Apparently, typeOrm cannot find the ormConfig.ts file. This project is part of a larger monorepo which also contains the front-end connected with workspaces and lerna (I can provide more information if needed)
Any help coming from someone who can help me to find the solution about why typeORM can't find this ormConfig file will be greatly appreciated.
If you would like to use TypeORM configuration file from the root of the project, then it should be one of the next formats: .js, .json, .xml, .env, .yml, .xml (doc) (also suggest to use ormconfig without capital C).

How can I print an Ansible vaulted variable that includes a Kubernetes secret from the CLI?

I have a Ansible group_vars directory with the following file within it:
$ cat inventory/group_vars/env1
...
...
ldap_config: !vault |
$ANSIBLE_VAULT;1.1;AES256
31636161623166323039356163363432336566356165633232643932623133643764343134613064
6563346430393264643432636434356334313065653537300a353431376264333463333238383833
31633664303532356635303336383361386165613431346565373239643431303235323132633331
3561343765383538340a373436653232326632316133623935333739323165303532353830386532
39616232633436333238396139323631633966333635393431373565643339313031393031313836
61306163333539616264353163353535366537356662333833653634393963663838303230386362
31396431636630393439306663313762313531633130326633383164393938363165333866626438
...
...
This Ansible encrypted string has a Kubernetes secret encapsulated within it. A base64 blob that looks something like this:
IyMKIyBIb3N0IERhdGFiYXNlCiMKIyBsb2NhbGhvc3QgaXMgdXNlZCB0byBjb25maWd1cmUgdGhlIGxvb3BiYWNrIGludGVyZmFjZQojIHdoZW4gdGhlIHN5c3RlbSBpcyBib290aW5nLiAgRG8gbm90IGNoYW5nZSB0aGlzIGVudHJ5LgojIwoxMjcuMC4wLjEJbG9jYWxob3N0CjI1NS4yNTUuMjU1LjI1NQlicm9hZGNhc3Rob3N0Cjo6MSAgICAgICAgICAgICBsb2NhbGhvc3QKIyBBZGRlZCBieSBEb2NrZXIgRGVza3RvcAojIFRvIGFsbG93IHRoZSBzYW1lIGt1YmUgY29udGV4dCB0byB3b3JrIG9uIHRoZSBob3N0IGFuZCB0aGUgY29udGFpbmVyOgoxMjcuMC4wLjEga3ViZXJuZXRlcy5kb2NrZXIuaW50ZXJuYWwKIyBFbmQgb2Ygc2VjdGlvbgo=
How can I decrypt this in a single CLI?
We can use an Ansible adhoc command to retrieve the variable of interest, ldap_config. To start we're going to use this adhoc to retrieve the Ansible encrypted vault string:
$ ansible -i "localhost," all \
-m debug \
-a 'msg="{{ ldap_config }}"' \
--vault-password-file=~/.vault_pass.txt \
-e#inventory/group_vars/env1
localhost | SUCCESS => {
"msg": "ABCD......."
Make note that we're:
using the debug module and having it print the variable, msg={{ ldap_config }}
giving ansible the path to the secret to decrypt encrypted strings
using the notation -e#< ...path to file...> to pass the file with the encrypted vault variables
Now we can use Jinja2 filters to do the rest of the parsing:
$ ansible -i "localhost," all \
-m debug \
-a 'msg="{{ ldap_config | b64decode | from_yaml }}"' \
--vault-password-file=~/.vault_pass.txt \
-e#inventory/group_vars/env1
localhost | SUCCESS => {
"msg": {
"apiVersion": "v1",
"bindDN": "uid=readonly,cn=users,cn=accounts,dc=mydom,dc=com",
"bindPassword": "my secret password to ldap",
"ca": "",
"insecure": true,
"kind": "LDAPSyncConfig",
"rfc2307": {
"groupMembershipAttributes": [
"member"
],
"groupNameAttributes": [
"cn"
],
"groupUIDAttribute": "dn",
"groupsQuery": {
"baseDN": "cn=groups,cn=accounts,dc=mydom,dc=com",
"derefAliases": "never",
"filter": "(objectclass=groupOfNames)",
"scope": "sub"
},
"tolerateMemberNotFoundErrors": false,
"tolerateMemberOutOfScopeErrors": false,
"userNameAttributes": [
"uid"
],
"userUIDAttribute": "dn",
"usersQuery": {
"baseDN": "cn=users,cn=accounts,dc=mydom,dc=com",
"derefAliases": "never",
"scope": "sub"
}
},
"url": "ldap://192.168.1.10:389"
}
}
NOTE: The above section -a 'msg="{{ ldap_config | b64decode | from_yaml }}" is what's doing the heavy lifting in terms of converting from Base64 to YAML.
References
How to run Ansible without hosts file
https://docs.ansible.com/ansible/latest/user_guide/playbooks_filters.html#filters-for-formatting-data
Base64 Decode String in jinja
How to decrypt string with ansible-vault 2.3.0
If you need a one liner that works with any yaml file (not only in inventory) containing inlined vault vars, and if you are ready to install a pip package for that, there is a solution using yq, a yaml processor built on top of jq
prerequesite: Install yq
pip install yq
Usage
You can get your result with the following command:
yq -r .ldapconfig inventory/group_vars/env1 | ansible_vault decrypt
If you need to type your vault pass interactively, don't forget to add the relevant option
yq -r .ldapconfig inventory/group_vars/env1 | ansible_vault --ask-vault-pass decrypt
Note: the -r option to yq is mandatory to get a raw result without the quotation marks around the value.