~mclehman/guestctl

ab2029ecd02a372553ba9b85019ef6a22e8a5367 — Max Lehman 5 years ago 5103f0c
Implement guest connect functionality.
M META6.json => META6.json +2 -1
@@ 9,9 9,10 @@
    "resources" : [
        "templates/dockerfile.tmpl",
        "templates/docker-compose.tmpl",
        "templates/user.tmpl",
        "templates/sshd_config.tmpl"
    ],
    "version" : "0.1.0",
    "version" : "0.1.1",
    "production" : false,
    "perl" : "v6.*",
    "authors" : [

M bin/guestctl => bin/guestctl +7 -0
@@ 60,6 60,13 @@ multi MAIN($guest, GuestAction $action, *@args) {
            transparent-run <<docker-compose up -d --force-recreate>>, cwd => $guest-dir;
        }

        when (Connect, Running) {
            my $container-id = run(<<docker-compose ps -q $guest>>, :out, cwd => $guest-dir).out.slurp.chomp;
            my $user = "$guest-dir/user".IO.slurp.chomp;
            my $home-dir = "/home/$user";
            run <<docker exec -it -u $user -w $home-dir $container-id bash>>;
        }

        when (Commit, Running) {
            my $container-id = run(<<docker-compose ps -q $guest>>, :out, cwd => $guest-dir).out.slurp.chomp;
            my $commit-epoch-time = now.to-posix.head.Int;

M lib/App/Guestctl/Common.pm6 => lib/App/Guestctl/Common.pm6 +2 -1
@@ 15,7 15,8 @@ enum GuestCommand is export
     Status    => "status",
	 Commit    => "commit",
     Snapshots => "snapshots",
     Rollback  => "rollback");
     Rollback  => "rollback",
     Connect   => "connect");

enum ManageCommand is export
    (Update  => "update",

M lib/App/Guestctl/Templates.pm6 => lib/App/Guestctl/Templates.pm6 +1 -0
@@ 38,6 38,7 @@ sub gen-template-vars(@prompt-entries, $guest) is export {
sub load-template-files($template-dir) is export {
    return ("Dockerfile"         => %?RESOURCES<templates/dockerfile.tmpl>.slurp,
            "docker-compose.yml" => %?RESOURCES<templates/docker-compose.tmpl>.slurp,
            "user"               => %?RESOURCES<templates/user.tmpl>.slurp,
            "ssh/sshd_config"    => %?RESOURCES<templates/sshd_config.tmpl>.slurp);
}


A resources/templates/user.tmpl => resources/templates/user.tmpl +1 -0
@@ 0,0 1,1 @@
{{ user }}