Skip to content

Commit

Permalink
Various code cleanup (#47)
Browse files Browse the repository at this point in the history
  • Loading branch information
tamalsaha authored Jun 20, 2017
1 parent 7a3e1fc commit 7e496f2
Show file tree
Hide file tree
Showing 36 changed files with 467 additions and 462 deletions.
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[![Go Report Card](https://goreportcard.com/badge/github.com/appscode/restik)](https://goreportcard.com/report/github.com/appscode/restik)
[![Go Report Card](https://goreportcard.com/badge/github.com/appscode/stash)](https://goreportcard.com/report/github.com/appscode/stash)

## Restik
Restik provides support to backup your Kubernetes Volumes
## Stash
Stash provides support to backup your Kubernetes Volumes

**Feautures**
- Support backup for any kubernetes [volumes](https://kubernetes.io/docs/concepts/storage/volumes/).
Expand All @@ -10,7 +10,7 @@
Kubernetes 1.5+

## Supported Workloads
Restik supports backup of following Workloads
Stash supports backup of following Workloads

* Replication Controller
* Replica Set
Expand All @@ -27,7 +27,7 @@ One can start the backup process by following this [guide](docs/user-guide/backu

## How to recover

The recover process will be left to users for now. It can be done by running `$ /restic -r <restik_repo> restore snapshot_id --target <target_dir>` inside the restic-sidecar container.
The recover process will be left to users for now. It can be done by running `$ /restic -r <stash_repo> restore snapshot_id --target <target_dir>` inside the restic-sidecar container.
You can find the details [here](https://restic.readthedocs.io/en/stable/Manual/#restore-a-snapshot)

## Developer Guide
Expand All @@ -38,17 +38,17 @@ If you want to know how Backup Controller is working, read this [doc](docs/devel

## Versioning Policy
There are 2 parts to versioning policy:
- Operator version: Restik __does not follow semver__, rather the _major_ version of operator points to the
- Operator version: Stash __does not follow semver__, rather the _major_ version of operator points to the
Kubernetes [client-go](https://github.com/kubernetes/client-go#branches-and-tags) version.
You can verify this from the `glide.yaml` file. This means there might be breaking changes
between point releases of the operator. This generally manifests as changed annotation keys or their meaning.
Please always check the release notes for upgrade instructions.
- TPR version: backup.appscode.com/v1alpha1 is considered in alpha. This means breaking changes to the YAML format
- TPR version: stash.appscode.com/v1alpha1 is considered in alpha. This means breaking changes to the YAML format
might happen among different releases of the operator.

---

**The restik operator collects anonymous usage statistics to help us learn how the software is being used and how we can improve it. To disable stats collection, run the operator with the flag** `--analytics=false`.
**The stash operator collects anonymous usage statistics to help us learn how the software is being used and how we can improve it. To disable stats collection, run the operator with the flag** `--analytics=false`.

---

Expand Down
7 changes: 0 additions & 7 deletions api/extensions/restik.yaml

This file was deleted.

7 changes: 7 additions & 0 deletions api/extensions/stash.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
apiVersion: extensions/v1beta1
kind: ThirdPartyResource
metadata:
name: restic.stash.appscode.com
description: "Stash by AppsCode - Backup Kubernetes persistent volumes"
versions:
- name: v1alpha1
4 changes: 2 additions & 2 deletions api/install/install.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package install

import (
rapi "github.com/appscode/restik/api"
rapi "github.com/appscode/stash/api"
"k8s.io/apimachinery/pkg/apimachinery/announced"
"k8s.io/apimachinery/pkg/util/sets"
"k8s.io/client-go/pkg/api"
Expand All @@ -12,7 +12,7 @@ func init() {
&announced.GroupMetaFactoryArgs{
GroupName: rapi.GroupName,
VersionPreferenceOrder: []string{rapi.V1alpha1SchemeGroupVersion.Version},
ImportPrefix: "github.com/appscode/restik/api",
ImportPrefix: "github.com/appscode/stash/api",
RootScopedKinds: sets.NewString("ThirdPartyResource"),
AddInternalObjectsToScheme: rapi.AddToScheme,
},
Expand Down
8 changes: 4 additions & 4 deletions api/register.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@ var (
// Adds the list of known types to apiv1.Scheme.
func addKnownTypes(scheme *runtime.Scheme) error {
scheme.AddKnownTypes(SchemeGroupVersion,
&Restik{},
&RestikList{},
&Restic{},
&ResticList{},

&metav1.ListOptions{},
)
return nil
}

func (obj *Restik) GetObjectKind() schema.ObjectKind { return &obj.TypeMeta }
func (obj *RestikList) GetObjectKind() schema.ObjectKind { return &obj.TypeMeta }
func (obj *Restic) GetObjectKind() schema.ObjectKind { return &obj.TypeMeta }
func (obj *ResticList) GetObjectKind() schema.ObjectKind { return &obj.TypeMeta }
4 changes: 2 additions & 2 deletions api/register_v1alpha1.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ var (
// Adds the list of known types to api.Scheme.
func v1addKnownTypes(scheme *runtime.Scheme) error {
scheme.AddKnownTypes(V1alpha1SchemeGroupVersion,
&Restik{},
&RestikList{},
&Restic{},
&ResticList{},

&metav1.ListOptions{},
)
Expand Down
14 changes: 7 additions & 7 deletions api/restik_types.go → api/restic_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ const (
KeepYearly RetentionStrategy = "keep-yearly"
)

type Restik struct {
type Restic struct {
metav1.TypeMeta `json:",inline,omitempty"`
metav1.ObjectMeta `json:"metadata,omitempty"`
Spec RestikSpec `json:"spec,omitempty"`
Status RestikStatus `json:"status,omitempty"`
Spec ResticSpec `json:"spec,omitempty"`
Status ResticStatus `json:"status,omitempty"`
}

type RestikSpec struct {
type ResticSpec struct {
// Source of the backup volumeName:path
Source Source `json:"source"`
// Destination of the backup
Expand All @@ -36,18 +36,18 @@ type RestikSpec struct {
RetentionPolicy RetentionPolicy `json:"retentionPolicy,omitempty"`
}

type RestikStatus struct {
type ResticStatus struct {
FirstBackupTime *metav1.Time `json:"firstBackupTime,omitempty"`
LastBackupTime *metav1.Time `json:"lastBackupTime,omitempty"`
LastSuccessfulBackupTime *metav1.Time `json:"lastSuccessfulBackupTime,omitempty"`
LastBackupDuration string `json:"lastBackupDuration,omitempty"`
BackupCount int64 `json:"backupCount,omitempty"`
}

type RestikList struct {
type ResticList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []Restik `json:"items,omitempty"`
Items []Restic `json:"items,omitempty"`
}

type Source struct {
Expand Down
10 changes: 5 additions & 5 deletions chart/restik/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
apiVersion: v1
description: Restik provides controller that takes backup of kubernetes volume.
icon: https://cdn.appscode.com/images/icon/restik.png
name: restik
description: Stash provides controller that takes backup of kubernetes volume.
icon: https://cdn.appscode.com/images/icon/stash.png
name: stash
version: 0.1.0
sources:
- https://github.com/appscode/restik
- https://github.com/appscode/stash
maintainers:
- name: 'AppsCode Inc.'
- name: appscode
email: [email protected]
16 changes: 8 additions & 8 deletions chart/restik/README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
# Restik
[Restik](https://github.com/appscode/restik) provides support to backup your Kubernetes Volumes
# Stash
[Stash](https://github.com/appscode/stash) provides support to backup your Kubernetes Volumes
## TL;DR;

```bash
$ helm install hack/chart/restik
$ helm install chart/stash
```

## Introduction

This chart bootstraps a [Restik controller](https://github.com/appscode/restik) deployment on a [Kubernetes](http://kubernetes.io) cluster using the [Helm](https://helm.sh) package manager.
This chart bootstraps a [Stash controller](https://github.com/appscode/stash) deployment on a [Kubernetes](http://kubernetes.io) cluster using the [Helm](https://helm.sh) package manager.

## Prerequisites

Expand All @@ -17,9 +17,9 @@ This chart bootstraps a [Restik controller](https://github.com/appscode/restik)
## Installing the Chart
To install the chart with the release name `my-release`:
```bash
$ helm install --name my-release hack/chart/restik
$ helm install --name my-release chart/stash
```
The command deploys Restik Controller on the Kubernetes cluster in the default configuration. The [configuration](#configuration) section lists the parameters that can be configured during installation.
The command deploys Stash Controller on the Kubernetes cluster in the default configuration. The [configuration](#configuration) section lists the parameters that can be configured during installation.

> **Tip**: List all releases using `helm list`
Expand All @@ -35,10 +35,10 @@ The command removes all the Kubernetes components associated with the chart and

## Configuration

The following tables lists the configurable parameters of the Restik chart and their default values.
The following tables lists the configurable parameters of the Stash chart and their default values.


| Parameter | Description | Default |
| ----------------------- | ---------------------- | ------------------- |
| `image` | Container image to run | `appscode/restik` |
| `image` | Container image to run | `appscode/stash` |
| `imageTag` | Image tag of container | `latest` |
2 changes: 1 addition & 1 deletion chart/restik/templates/NOTES.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
To verify that Restik has started, run:
To verify that Stash has started, run:

kubectl --namespace={{ .Release.Namespace }} get deployments -l "release={{ .Release.Name }}, app={{ template "fullname" . }}"
6 changes: 3 additions & 3 deletions chart/restik/values.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
##
## Restik chart configuration
## Stash chart configuration
##

## Image that will be used in Restik controller and in Restik sidecar container
## Image that will be used in Stash controller and in Stash sidecar container

image: appscode/restik
image: appscode/stash
imageTag: latest
6 changes: 3 additions & 3 deletions client/clientset/codec.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"strings"

"github.com/appscode/log"
rapi "github.com/appscode/restik/api"
sapi "github.com/appscode/stash/api"
"github.com/ghodss/yaml"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
Expand Down Expand Up @@ -149,8 +149,8 @@ func (c *extendedCodec) EncodeParameters(obj runtime.Object, to schema.GroupVers
func setDefaultVersionKind(obj runtime.Object) {
// Check the values can are In type Extended Ingress
defaultGVK := schema.GroupVersionKind{
Group: rapi.V1alpha1SchemeGroupVersion.Group,
Version: rapi.V1alpha1SchemeGroupVersion.Version,
Group: sapi.V1alpha1SchemeGroupVersion.Group,
Version: sapi.V1alpha1SchemeGroupVersion.Version,
}

fullyQualifiedKind := reflect.ValueOf(obj).Type().String()
Expand Down
17 changes: 9 additions & 8 deletions client/clientset/extensions.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package clientset
import (
"fmt"

sapi "github.com/appscode/stash/api"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/client-go/pkg/api"
"k8s.io/client-go/rest"
Expand All @@ -14,7 +15,7 @@ const (

type ExtensionInterface interface {
RESTClient() rest.Interface
RestikNamespacer
ResticGetter
}

// ExtensionsClient is used to interact with experimental Kubernetes features.
Expand All @@ -26,8 +27,8 @@ type ExtensionClient struct {

var _ ExtensionInterface = &ExtensionClient{}

func (a *ExtensionClient) Restiks(namespace string) RestikInterface {
return newRestik(a, namespace)
func (c *ExtensionClient) Restics(namespace string) ResticInterface {
return newRestic(c, namespace)
}

// NewForConfig creates a new ExtensionClient for the given config. This client
Expand Down Expand Up @@ -64,21 +65,21 @@ func New(c rest.Interface) *ExtensionClient {
}

func setExtensionsDefaults(config *rest.Config) error {
gv, err := schema.ParseGroupVersion("backup.appscode.com/v1alpha1")
gv, err := schema.ParseGroupVersion(sapi.GroupName + "/v1alpha1")
if err != nil {
return err
}
// if backup.appscode.com/v1alpha1 is not enabled, return an error
// if stash.appscode.com/v1alpha1 is not enabled, return an error
if !api.Registry.IsEnabledVersion(gv) {
return fmt.Errorf("backup.appscode.com/v1alpha1 is not enabled")
return fmt.Errorf(sapi.GroupName + "/v1alpha1 is not enabled")
}
config.APIPath = defaultAPIPath
if config.UserAgent == "" {
config.UserAgent = rest.DefaultKubernetesUserAgent()
}

if config.GroupVersion == nil || config.GroupVersion.Group != "backup.appscode.com" {
g, err := api.Registry.Group("backup.appscode.com")
if config.GroupVersion == nil || config.GroupVersion.Group != sapi.GroupName {
g, err := api.Registry.Group(sapi.GroupName)
if err != nil {
return err
}
Expand Down
11 changes: 6 additions & 5 deletions client/clientset/fake/extensions.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
package fake

import (
"github.com/appscode/restik/client/clientset"
sapi "github.com/appscode/stash/api"
"github.com/appscode/stash/client/clientset"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/watch"
"k8s.io/client-go/pkg/api"
Expand All @@ -15,10 +16,10 @@ type FakeExtensionClient struct {

var _ clientset.ExtensionInterface = &FakeExtensionClient{}

func NewFakeRestikClient(objects ...runtime.Object) *FakeExtensionClient {
func NewFakeStashClient(objects ...runtime.Object) *FakeExtensionClient {
o := testing.NewObjectTracker(api.Registry, api.Scheme, api.Codecs.UniversalDecoder())
for _, obj := range objects {
if obj.GetObjectKind().GroupVersionKind().Group == "backup.appscode.com" {
if obj.GetObjectKind().GroupVersionKind().Group == sapi.GroupName {
if err := o.Add(obj); err != nil {
panic(err)
}
Expand All @@ -33,8 +34,8 @@ func NewFakeRestikClient(objects ...runtime.Object) *FakeExtensionClient {
return &FakeExtensionClient{&fakePtr}
}

func (m *FakeExtensionClient) Restiks(ns string) clientset.RestikInterface {
return &FakeRestik{m.Fake, ns}
func (m *FakeExtensionClient) Restics(ns string) clientset.ResticInterface {
return &FakeStash{m.Fake, ns}
}

// RESTClient returns a RESTClient that is used to communicate
Expand Down
Loading

0 comments on commit 7e496f2

Please sign in to comment.