-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(incus-runner): container state detection
- Loading branch information
Showing
3 changed files
with
34 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,17 @@ | ||
export default async function({config}) { | ||
export default async function ({ config }) { | ||
// Note, using `incus shell` would be nice but `cwd` doesn't seem right | ||
// `incus shell --cwd /nikita/packages/$pkg` then `pwd` return `/root` | ||
// `incus shell --cwd /nikita/packages/$pkg -- pkg` prints: | ||
// `pwd: ignoring non-option arguments` | ||
// `/nikita/packages/$pkg` | ||
await this.execute({ | ||
$header: 'Container enter', | ||
$header: "Container enter", | ||
// To be tested | ||
// command: `incus shell --cwd ${config.cwd} ${config.container}`, | ||
command: `incus exec --cwd ${config.cwd} ${config.container} -- bash`, | ||
stdio: ['inherit', 'inherit', 'inherit'], | ||
stdio: ["inherit", "inherit", "inherit"], | ||
stdin: process.stdin, | ||
stdout: process.stdout, | ||
stderr: process.stderr | ||
stderr: process.stderr, | ||
}); | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,18 @@ | ||
export default async function({config}) { | ||
const {config: state} = await this.incus.state({ | ||
$header: 'Container state', | ||
container: `${config.container}` | ||
export default async function ({ config }) { | ||
let state = ""; | ||
const { exists } = await this.incus.exists({ | ||
$header: "Container exists", | ||
container: `${config.container}`, | ||
}); | ||
process.stdout.write(JSON.stringify(state, null, 2)); | ||
}; | ||
if (!exists) { | ||
state = "NOT_CREATED"; | ||
} else { | ||
({ config: state } = await this.incus.state({ | ||
$if: exists, | ||
$header: "Container state", | ||
container: `${config.container}`, | ||
})); | ||
} | ||
// process.stdout.write(JSON.stringify(state, null, 2)); | ||
return { state: state }; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters