Skip to content
This repository has been archived by the owner on Jun 21, 2022. It is now read-only.

Commit

Permalink
inits filter strategy; fixes stats bug; v0.3.16
Browse files Browse the repository at this point in the history
  • Loading branch information
mhausenblas committed Jul 20, 2017
1 parent 3913d22 commit 8f88592
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
reshifter_version := 0.3.15
reshifter_version := 0.3.16
git_version := `git rev-parse HEAD`
app_name := reshifter-app
main_dir := `pwd`
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,13 @@ If you want to use the ReShifter app, that is the Web UI, you need to use the Do
For example, to launch the ReShifter app locally, do:

```
$ docker run --rm -p 8080:8080 quay.io/mhausenblas/reshifter:0.3.15
$ docker run --rm -p 8080:8080 quay.io/mhausenblas/reshifter:0.3.16
```

If you want to use the ReShifter API, for example as a head-less service, you can simply use the binary, no other dependencies required:

```
$ curl -s -L https://github.com/mhausenblas/reshifter/releases/download/v0.3.15-alpha/reshifter -o reshifter
$ curl -s -L https://github.com/mhausenblas/reshifter/releases/download/v0.3.16-alpha/reshifter -o reshifter
$ chmod +x reshifter
$ ./reshifter
```
Expand Down Expand Up @@ -84,7 +84,7 @@ yourself.
## CLI tool

ReShifter also provides for a CLI tool called `rcli`.
Get binary releases for Linux and macOS via the [GitHub release page](https://github.com/mhausenblas/reshifter/releases/tag/v0.3.15-alpha).
Get binary releases for Linux and macOS via the [GitHub release page](https://github.com/mhausenblas/reshifter/releases/tag/v0.3.16-alpha).

```
$ rcli -h
Expand Down
2 changes: 2 additions & 0 deletions pkg/backup/backup.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,8 @@ func pickStrategy() (string, types.Reap) {
return types.ReapFunctionRaw, raw
case "render":
return types.ReapFunctionRender, render
case "filter":
return types.ReapFunctionFilter, filter
default:
return types.ReapFunctionRaw, raw
}
Expand Down
16 changes: 16 additions & 0 deletions pkg/backup/strategy.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,22 @@ func render(path, val string, writer interface{}) error {
return nil
}

// filter is a reap strategy that stores val in a path in directory target,
// if a certain condition is met (set of white-listed paths).
func filter(path, val string, target interface{}) error {
t, ok := target.(string)
if !ok {
return fmt.Errorf("Can't use target %v, it should be a string!", target)
}
if strings.Contains(path, "deployments") {
_, err := store(t, path, val)
if err != nil {
return fmt.Errorf("Can't store %s%s in %s: %s", t, path, val, err)
}
}
return nil
}

// store creates a file at based+path with val as its content.
// based is the output directory to use and path can be
// any valid etcd key (with ':'' characters being escaped automatically).
Expand Down
2 changes: 2 additions & 0 deletions pkg/types/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ const (
ReapFunctionRaw = "raw"
// ReapFunctionRender represents the reap function that dumps the values of all keys to stdout.
ReapFunctionRender = "render"
// ReapFunctionFilter represents the reap function that dumps the values of certain keys to disk.
ReapFunctionFilter = "filter"
// NotADistro represents the fact that no Kubernetes distro-related prefixes exit in etcd
NotADistro KubernetesDistro = iota
// Vanilla represents the vanilla, upstream Kubernetes distribution.
Expand Down
2 changes: 1 addition & 1 deletion rcli/cmd/stats.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func docollectstats(endpoint string) {
log.Info("Didn't find legacy keys, trying modern keys now …")
}
vk, vs, err := discovery.CountKeysFor(endpoint, types.KubernetesPrefix, types.KubernetesPrefixLast)
if err != nil {
if err != nil && derr != nil {
log.Error(fmt.Sprintf("Having problems calculating stats: %s", err))
return
}
Expand Down

0 comments on commit 8f88592

Please sign in to comment.