From 4f376ada348c9c064b88dccb182faf0ecc5cc817 Mon Sep 17 00:00:00 2001 From: Tamal Saha Date: Tue, 10 Oct 2017 08:09:10 -0700 Subject: [PATCH] Set hostname based on resource type (#198) --- schedule.go | 5 +++++ snapshot_handler.go | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/schedule.go b/schedule.go index 8b9f53a46..49b256273 100644 --- a/schedule.go +++ b/schedule.go @@ -62,6 +62,7 @@ func NewCmdSchedule() *cobra.Command { case "Deployments", "Deployment", "deployments", "deployment": opt.AppKind = "Deployment" opt.SmartPrefix = "" + opt.SnapshotHostname = opt.AppName _, err := kubeClient.AppsV1beta1().Deployments(opt.Namespace).Get(opt.AppName, metav1.GetOptions{}) if err != nil { _, err := kubeClient.ExtensionsV1beta1().Deployments(opt.Namespace).Get(opt.AppName, metav1.GetOptions{}) @@ -72,6 +73,7 @@ func NewCmdSchedule() *cobra.Command { case "ReplicaSets", "ReplicaSet", "replicasets", "replicaset", "rs": opt.AppKind = "ReplicaSet" opt.SmartPrefix = "" + opt.SnapshotHostname = opt.AppName _, err := kubeClient.ExtensionsV1beta1().ReplicaSets(opt.Namespace).Get(opt.AppName, metav1.GetOptions{}) if err != nil { log.Fatalf(`Unknown ReplicaSet %s/%s`, opt.Namespace, opt.AppName) @@ -79,6 +81,7 @@ func NewCmdSchedule() *cobra.Command { case "ReplicationControllers", "ReplicationController", "replicationcontrollers", "replicationcontroller", "rc": opt.AppKind = "ReplicationController" opt.SmartPrefix = "" + opt.SnapshotHostname = opt.AppName _, err := kubeClient.CoreV1().ReplicationControllers(opt.Namespace).Get(opt.AppName, metav1.GetOptions{}) if err != nil { log.Fatalf(`Unknown ReplicationController %s/%s`, opt.Namespace, opt.AppName) @@ -86,6 +89,7 @@ func NewCmdSchedule() *cobra.Command { case "StatefulSets", "StatefulSet": opt.AppKind = "StatefulSet" opt.SmartPrefix = opt.PodName + opt.SnapshotHostname = opt.PodName _, err := kubeClient.AppsV1beta1().StatefulSets(opt.Namespace).Get(opt.AppName, metav1.GetOptions{}) if err != nil { log.Fatalf(`Unknown StatefulSet %s/%s`, opt.Namespace, opt.AppName) @@ -93,6 +97,7 @@ func NewCmdSchedule() *cobra.Command { case "DaemonSets", "DaemonSet", "daemonsets", "daemonset": opt.AppKind = "DaemonSet" opt.SmartPrefix = opt.NodeName + opt.SnapshotHostname = opt.NodeName _, err := kubeClient.ExtensionsV1beta1().DaemonSets(opt.Namespace).Get(opt.AppName, metav1.GetOptions{}) if err != nil { log.Fatalf(`Unknown DaemonSet %s/%s`, opt.Namespace, opt.AppName) diff --git a/snapshot_handler.go b/snapshot_handler.go index f1e93e414..dc0aca2d7 100644 --- a/snapshot_handler.go +++ b/snapshot_handler.go @@ -35,7 +35,7 @@ func ExportSnapshots(w http.ResponseWriter, r *http.Request) { http.Error(w, "Missing parameter:"+PathParamName, http.StatusBadRequest) return } - resticCLI := cli.New(scratchDir) + resticCLI := cli.New(scratchDir, "") var resource *api.Restic resource, err := stashClient.Restics(namespace).Get(name, metav1.GetOptions{})