Skip to content

Commit

Permalink
Set hostname based on resource type (#198)
Browse files Browse the repository at this point in the history
  • Loading branch information
tamalsaha authored Oct 10, 2017
1 parent e530116 commit 4f376ad
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 5 additions & 0 deletions schedule.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{})
Expand All @@ -72,27 +73,31 @@ 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)
}
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)
}
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)
}
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)
Expand Down
2 changes: 1 addition & 1 deletion snapshot_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{})
Expand Down

0 comments on commit 4f376ad

Please sign in to comment.