/
install.go
37 lines (32 loc) · 987 Bytes
/
install.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package composectl
import (
"fmt"
"github.com/containerd/containerd/platforms"
v1 "github.com/foundriesio/composeapp/pkg/compose/v1"
"github.com/spf13/cobra"
"path"
)
var (
installCmd = &cobra.Command{
Use: "install <ref>",
Short: "",
Long: ``,
Args: cobra.ExactArgs(1),
Run: installApp,
}
)
func init() {
rootCmd.AddCommand(installCmd)
}
func installApp(cmd *cobra.Command, args []string) {
cs, err := v1.NewAppStore(config.StoreRoot, config.Platform)
DieNotNil(err)
appRef := args[0]
fmt.Printf("Loading app metadata from the local store...")
app, _, err := v1.NewAppLoader().LoadAppTree(cmd.Context(), cs, platforms.OnlyStrict(config.Platform), appRef)
DieNotNil(err)
fmt.Println("ok")
fmt.Printf("Extracting app compose archive to %s and loading its images to docker %s\n", composeRoot, dockerHost)
err = v1.InstallApp(cmd.Context(), app, cs, path.Join(config.StoreRoot, "blobs/sha256"), config.ComposeRoot, config.DockerHost)
DieNotNil(err)
}