-
Notifications
You must be signed in to change notification settings - Fork 6
/
upload.go
61 lines (50 loc) · 1.64 KB
/
upload.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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
// SPDX-License-Identifier: GPL-3.0
package main
import (
"fmt"
"path/filepath"
"github.com/comrade-coop/apocryph/pkg/ipcr"
tpipfs "github.com/comrade-coop/apocryph/pkg/ipfs"
"github.com/comrade-coop/apocryph/pkg/publisher"
"github.com/spf13/cobra"
)
var uploadPodCmd = &cobra.Command{
Use: fmt.Sprintf("upload [%s] [deployment.yaml]", publisher.DefaultPodFile),
Short: "Upload a pod from a local manifest",
Long: "Upload a pod from a local manifest. Note that this command does not send anything to the provider and is meant to be used only together with the rest of the low-level commands.",
GroupID: "lowlevel",
Args: cobra.MaximumNArgs(2),
RunE: func(cmd *cobra.Command, args []string) error {
podFile, deploymentFile, pod, deployment, err := publisher.ReadPodAndDeployment(args, manifestFormat, deploymentFormat)
if err != nil {
return err
}
configureDeployment(deployment)
ipfs, _, err := tpipfs.GetIpfsClient(ipfsApi)
if err != nil {
return fmt.Errorf("Failed connecting to IPFS: %w", err)
}
ctrdClient, err := ipcr.GetContainerdClient("k8s.io")
if err != nil {
return err
}
if uploadSecrets {
err = publisher.UploadSecrets(cmd.Context(), ipfs, filepath.Dir(podFile), pod, deployment)
if err != nil {
return err
}
}
if uploadImages {
err = publisher.UploadImages(cmd.Context(), ctrdClient, ipfsApi, pod, deployment)
if err != nil {
return err
}
}
return publisher.SaveDeployment(deploymentFile, deploymentFormat, deployment)
},
}
func init() {
podCmd.AddCommand(uploadPodCmd)
uploadPodCmd.Flags().AddFlagSet(deploymentFlags)
uploadPodCmd.Flags().AddFlagSet(uploadFlags)
}