diff --git a/.gitignore b/.gitignore index 744834753..f21498f14 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,4 @@ -_output +/cluster-storage-operator # Temporary Build Files build/_output diff --git a/Dockerfile b/Dockerfile index e09d10c10..ab0db6595 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,10 +1,15 @@ -FROM alpine:3.6 +FROM registry.svc.ci.openshift.org/openshift/release:golang-1.10 AS builder +WORKDIR /go/src/github.com/openshift/cluster-storage-operator +COPY . . +RUN make build -RUN adduser -D cluster-storage-operator +FROM registry.svc.ci.openshift.org/openshift/origin-v4.0:base +COPY --from=builder /go/src/github.com/openshift/cluster-storage-operator/cluster-storage-operator /usr/bin/ +COPY manifests /manifests +RUN useradd cluster-storage-operator USER cluster-storage-operator - -COPY deploy/deployment.yaml /manifests/deployment.yaml -COPY deploy/roles.yaml /manifests/roles.yaml -COPY deploy/image-references /manifests/image-references - -ADD build/_output/bin/cluster-storage-operator /usr/local/bin/cluster-storage-operator +ENTRYPOINT ["/usr/bin/cluster-storage-operator"] +LABEL io.openshift.release.operator true +LABEL io.k8s.display-name="OpenShift cluster-storage-operator" \ + io.k8s.description="This is a component of OpenShift Container Platform and manages the lifecycle of cluster storage components." \ + maintainer="Matthew Wong " diff --git a/Gopkg.lock b/Gopkg.lock index f5caf22d0..248a0902d 100644 --- a/Gopkg.lock +++ b/Gopkg.lock @@ -215,6 +215,13 @@ revision = "1624edc4454b8682399def8740d46db5e4362ba4" version = "v1.1.5" +[[projects]] + digest = "1:4a26d01840733b60e9af432d24df6104660a537bb756d4e05c24e097ab68d726" + name = "github.com/jteeuwen/go-bindata" + packages = ["."] + pruneopts = "NT" + revision = "6025e8de665b31fa74ab1a66f2cddd8c0abf887e" + [[projects]] branch = "master" digest = "1:84a5a2b67486d5d67060ac393aa255d05d24ed5ee41daecd5635ec22657b6492" @@ -750,6 +757,7 @@ analyzer-name = "dep" analyzer-version = 1 input-imports = [ + "github.com/jteeuwen/go-bindata", "github.com/openshift/installer/pkg/types", "github.com/openshift/library-go/pkg/operator/resource/resourceread", "github.com/operator-framework/operator-sdk/version", diff --git a/Gopkg.toml b/Gopkg.toml index 9abb4a906..e33e07c4c 100644 --- a/Gopkg.toml +++ b/Gopkg.toml @@ -8,6 +8,7 @@ required = [ "k8s.io/code-generator/cmd/informer-gen", "k8s.io/code-generator/cmd/openapi-gen", "k8s.io/gengo/args", + "github.com/jteeuwen/go-bindata", ] [[override]] @@ -45,6 +46,11 @@ required = [ branch = "master" #osdk_branch_annotation # version = "=v0.1.0" #osdk_version_annotation +[[constraint]] + name="github.com/jteeuwen/go-bindata" + # Current working master + revision = "6025e8de665b31fa74ab1a66f2cddd8c0abf887e" + [prune] go-tests = true non-go = true @@ -54,6 +60,10 @@ required = [ name = "k8s.io/code-generator" non-go = false + [[prune.project]] + name="github.com/jteeuwen/go-bindata" + unused-packages = false + [[constraint]] name = "github.com/openshift/installer" branch = "master" diff --git a/Makefile b/Makefile index a2db164f6..7636b63d8 100644 --- a/Makefile +++ b/Makefile @@ -1,16 +1,27 @@ +IMG ?= openshift/origin-cluster-storage-operator:latest + +PACKAGE=github.com/openshift/cluster-storage-operator +MAIN_PACKAGE=$(PACKAGE)/cmd/cluster-storage-operator + +BIN=$(lastword $(subst /, ,$(MAIN_PACKAGE))) + +ENVVAR=GOOS=linux CGO_ENABLED=0 +GOOS=linux +GO_BUILD_RECIPE=GOOS=$(GOOS) go build -o $(BIN) $(MAIN_PACKAGE) + BINDATA=pkg/generated/bindata.go GOBINDATA_BIN=$(GOPATH)/bin/go-bindata all: build build: generate - operator-sdk build quay.io/openshift/cluster-storage-operator + $(GO_BUILD_RECIPE) generate: $(GOBINDATA_BIN) - go-bindata -nometadata -pkg generated -o $(BINDATA) manifests/... + $(GOBINDATA_BIN) -nometadata -pkg generated -o $(BINDATA) assets/... $(GOBINDATA_BIN): - go get -u github.com/jteeuwen/go-bindata/... + go build -o $(GOBINDATA_BIN) ./vendor/github.com/jteeuwen/go-bindata/go-bindata test: go test ./pkg/... @@ -20,5 +31,9 @@ verify: hack/verify-gometalinter.sh hack/verify-govet.sh +container: build test verify + docker build . -t $(IMG) + clean: - rm -rf build/_output + go clean + rm -f $(BIN) diff --git a/manifests/aws.yaml b/assets/aws.yaml similarity index 100% rename from manifests/aws.yaml rename to assets/aws.yaml diff --git a/manifests/openstack.yaml b/assets/openstack.yaml similarity index 100% rename from manifests/openstack.yaml rename to assets/openstack.yaml diff --git a/cmd/manager/main.go b/cmd/cluster-storage-operator/main.go similarity index 100% rename from cmd/manager/main.go rename to cmd/cluster-storage-operator/main.go diff --git a/deploy/crds/cluster_v1alpha1_clusterstorage_crd.yaml b/deploy/crds/cluster_v1alpha1_clusterstorage_crd.yaml deleted file mode 100644 index 9c709aa13..000000000 --- a/deploy/crds/cluster_v1alpha1_clusterstorage_crd.yaml +++ /dev/null @@ -1,13 +0,0 @@ -apiVersion: apiextensions.k8s.io/v1beta1 -kind: CustomResourceDefinition -metadata: - name: clusterstorages.cluster.storage.openshift.io -spec: - group: cluster.storage.openshift.io - names: - kind: ClusterStorage - listKind: ClusterStorageList - plural: clusterstorages - singular: clusterstorage - scope: Namespaced - version: v1alpha1 diff --git a/deploy/crds/cluster_v1alpha1_clusterstorage_crd.yaml b/deploy/crds/cluster_v1alpha1_clusterstorage_crd.yaml new file mode 120000 index 000000000..a70ba4fa6 --- /dev/null +++ b/deploy/crds/cluster_v1alpha1_clusterstorage_crd.yaml @@ -0,0 +1 @@ +../../manifests/00-custom-resource-definition.yaml \ No newline at end of file diff --git a/deploy/operator.yaml b/deploy/operator.yaml deleted file mode 100644 index 487b6456b..000000000 --- a/deploy/operator.yaml +++ /dev/null @@ -1,36 +0,0 @@ -apiVersion: apps/v1 -kind: Deployment -metadata: - name: cluster-storage-operator -spec: - replicas: 1 - selector: - matchLabels: - name: cluster-storage-operator - template: - metadata: - labels: - name: cluster-storage-operator - spec: - serviceAccountName: cluster-storage-operator - containers: - - name: cluster-storage-operator - # Replace this with the built image name - image: REPLACE_IMAGE - ports: - - containerPort: 60000 - name: metrics - command: - - cluster-storage-operator - imagePullPolicy: Always - env: - - name: WATCH_NAMESPACE - valueFrom: - fieldRef: - fieldPath: metadata.namespace - - name: POD_NAME - valueFrom: - fieldRef: - fieldPath: metadata.name - - name: OPERATOR_NAME - value: "cluster-storage-operator" diff --git a/deploy/roles.yaml b/deploy/roles.yaml deleted file mode 100644 index 073f1a4d6..000000000 --- a/deploy/roles.yaml +++ /dev/null @@ -1,131 +0,0 @@ -apiVersion: v1 -kind: Namespace -metadata: - name: openshift-cluster-storage-operator - ---- - -apiVersion: v1 -kind: ServiceAccount -metadata: - name: cluster-storage-operator - namespace: openshift-cluster-storage-operator - ---- - -kind: Role -apiVersion: rbac.authorization.k8s.io/v1 -metadata: - name: cluster-storage-operator - namespace: openshift-cluster-storage-operator -rules: -- apiGroups: - - storage.openshift.io - resources: - - "*" - verbs: - - "*" -- apiGroups: - - "" - resources: - - pods - - services - - endpoints - - persistentvolumeclaims - - events - - configmaps - - secrets - verbs: - - "*" -- apiGroups: - - apps - resources: - - deployments - - daemonsets - - replicasets - - statefulsets - verbs: - - "*" - ---- - -kind: RoleBinding -apiVersion: rbac.authorization.k8s.io/v1 -metadata: - name: cluster-storage-operator - namespace: openshift-cluster-storage-operator -subjects: -- kind: ServiceAccount - name: cluster-storage-operator -roleRef: - kind: Role - name: cluster-storage-operator - apiGroup: rbac.authorization.k8s.io - ---- - -kind: Role -apiVersion: rbac.authorization.k8s.io/v1 -metadata: - name: cluster-storage-operator - namespace: kube-system -rules: -- apiGroups: - - "" - resources: - - configmaps - verbs: - - get - - watch - - list - ---- - -kind: RoleBinding -apiVersion: rbac.authorization.k8s.io/v1 -metadata: - name: cluster-storage-operator - namespace: kube-system -subjects: -- kind: ServiceAccount - name: cluster-storage-operator - namespace: openshift-cluster-storage-operator -roleRef: - kind: Role - name: cluster-storage-operator - apiGroup: rbac.authorization.k8s.io - ---- - -kind: ClusterRole -apiVersion: rbac.authorization.k8s.io/v1 -metadata: - name: cluster-storage-operator -rules: -- apiGroups: - - storage.k8s.io - resources: - - storageclasses - verbs: - - get - - watch - - list - - create - - delete - - patch - - update - ---- - -kind: ClusterRoleBinding -apiVersion: rbac.authorization.k8s.io/v1 -metadata: - name: cluster-storage-operator -subjects: -- kind: ServiceAccount - name: cluster-storage-operator - namespace: openshift-cluster-storage-operator -roleRef: - kind: ClusterRole - name: cluster-storage-operator - apiGroup: rbac.authorization.k8s.io diff --git a/manifests/00-namespace.yaml b/manifests/00-namespace.yaml new file mode 100644 index 000000000..d69230909 --- /dev/null +++ b/manifests/00-namespace.yaml @@ -0,0 +1,4 @@ +apiVersion: v1 +kind: Namespace +metadata: + name: openshift-cluster-storage-operator diff --git a/manifests/01-cluster-config-role-binding.yaml b/manifests/01-cluster-config-role-binding.yaml new file mode 100644 index 000000000..b7c8fadab --- /dev/null +++ b/manifests/01-cluster-config-role-binding.yaml @@ -0,0 +1,13 @@ +kind: RoleBinding +apiVersion: rbac.authorization.k8s.io/v1 +metadata: + name: cluster-storage-operator + namespace: kube-system +subjects: +- kind: ServiceAccount + name: cluster-storage-operator + namespace: openshift-cluster-storage-operator +roleRef: + kind: Role + name: cluster-storage-operator + apiGroup: rbac.authorization.k8s.io diff --git a/manifests/01-cluster-config-role.yaml b/manifests/01-cluster-config-role.yaml new file mode 100644 index 000000000..4a2312028 --- /dev/null +++ b/manifests/01-cluster-config-role.yaml @@ -0,0 +1,14 @@ +kind: Role +apiVersion: rbac.authorization.k8s.io/v1 +metadata: + name: cluster-storage-operator + namespace: kube-system +rules: +- apiGroups: + - "" + resources: + - configmaps + verbs: + - get + - watch + - list diff --git a/manifests/01-cluster-role-binding.yaml b/manifests/01-cluster-role-binding.yaml new file mode 100644 index 000000000..de79406b1 --- /dev/null +++ b/manifests/01-cluster-role-binding.yaml @@ -0,0 +1,12 @@ +kind: ClusterRoleBinding +apiVersion: rbac.authorization.k8s.io/v1 +metadata: + name: cluster-storage-operator +subjects: +- kind: ServiceAccount + name: cluster-storage-operator + namespace: openshift-cluster-storage-operator +roleRef: + kind: ClusterRole + name: cluster-storage-operator + apiGroup: rbac.authorization.k8s.io diff --git a/manifests/01-cluster-role.yaml b/manifests/01-cluster-role.yaml new file mode 100644 index 000000000..c04d5e2a4 --- /dev/null +++ b/manifests/01-cluster-role.yaml @@ -0,0 +1,17 @@ +kind: ClusterRole +apiVersion: rbac.authorization.k8s.io/v1 +metadata: + name: cluster-storage-operator +rules: +- apiGroups: + - storage.k8s.io + resources: + - storageclasses + verbs: + - get + - watch + - list + - create + - delete + - patch + - update diff --git a/deploy/role_binding.yaml b/manifests/01-role-binding.yaml similarity index 84% rename from deploy/role_binding.yaml rename to manifests/01-role-binding.yaml index be0660992..8d998579f 100644 --- a/deploy/role_binding.yaml +++ b/manifests/01-role-binding.yaml @@ -2,6 +2,7 @@ kind: RoleBinding apiVersion: rbac.authorization.k8s.io/v1 metadata: name: cluster-storage-operator + namespace: openshift-cluster-storage-operator subjects: - kind: ServiceAccount name: cluster-storage-operator diff --git a/deploy/role.yaml b/manifests/01-role.yaml similarity index 67% rename from deploy/role.yaml rename to manifests/01-role.yaml index 01fa22e58..a03bb88a6 100644 --- a/deploy/role.yaml +++ b/manifests/01-role.yaml @@ -1,9 +1,15 @@ -apiVersion: rbac.authorization.k8s.io/v1 kind: Role +apiVersion: rbac.authorization.k8s.io/v1 metadata: - creationTimestamp: null name: cluster-storage-operator + namespace: openshift-cluster-storage-operator rules: +- apiGroups: + - storage.openshift.io + resources: + - "*" + verbs: + - "*" - apiGroups: - "" resources: @@ -15,7 +21,7 @@ rules: - configmaps - secrets verbs: - - '*' + - "*" - apiGroups: - apps resources: @@ -24,17 +30,4 @@ rules: - replicasets - statefulsets verbs: - - '*' -- apiGroups: - - monitoring.coreos.com - resources: - - servicemonitors - verbs: - - get - - create -- apiGroups: - - cluster.storage.openshift.io - resources: - - '*' - verbs: - - '*' + - "*" diff --git a/deploy/service_account.yaml b/manifests/01-service-account.yaml similarity index 62% rename from deploy/service_account.yaml rename to manifests/01-service-account.yaml index 8c4f5b121..8844da15d 100644 --- a/deploy/service_account.yaml +++ b/manifests/01-service-account.yaml @@ -2,3 +2,4 @@ apiVersion: v1 kind: ServiceAccount metadata: name: cluster-storage-operator + namespace: openshift-cluster-storage-operator diff --git a/deploy/deployment.yaml b/manifests/02-deployment.yaml similarity index 93% rename from deploy/deployment.yaml rename to manifests/02-deployment.yaml index 576b21fed..bfb4e67c8 100644 --- a/deploy/deployment.yaml +++ b/manifests/02-deployment.yaml @@ -16,7 +16,7 @@ spec: serviceAccountName: cluster-storage-operator containers: - name: cluster-storage-operator - image: quay.io/openshift/cluster-storage-operator:latest + image: openshift/origin-cluster-storage-operator:latest ports: - containerPort: 60000 name: metrics diff --git a/deploy/image-references b/manifests/image-references similarity index 68% rename from deploy/image-references rename to manifests/image-references index 550f7bf09..1dc9e44af 100644 --- a/deploy/image-references +++ b/manifests/image-references @@ -5,4 +5,4 @@ spec: - name: cluster-storage-operator from: kind: DockerImage - name: quay.io/openshift/cluster-storage-operator + name: openshift/origin-cluster-storage-operator:latest diff --git a/pkg/controller/clusterstorage/clusterstorage_controller.go b/pkg/controller/clusterstorage/clusterstorage_controller.go index f20322462..24e0e88ed 100644 --- a/pkg/controller/clusterstorage/clusterstorage_controller.go +++ b/pkg/controller/clusterstorage/clusterstorage_controller.go @@ -28,8 +28,10 @@ import ( ) const ( + // OwnerLabelNamespace is the label key for the owner namespace OwnerLabelNamespace = "cluster.storage.openshift.io/owner-namespace" - OwnerLabelName = "cluster.storage.openshift.io/owner-name" + // OwnerLabelName is the label key for the owner name + OwnerLabelName = "cluster.storage.openshift.io/owner-name" ) // Add creates a new ClusterStorage Controller and adds it to the Manager. The Manager will set fields on the Controller diff --git a/pkg/generated/bindata.go b/pkg/generated/bindata.go index 2369252e0..45f602191 100644 --- a/pkg/generated/bindata.go +++ b/pkg/generated/bindata.go @@ -1,7 +1,7 @@ // Code generated by go-bindata. // sources: -// manifests/aws.yaml -// manifests/openstack.yaml +// assets/aws.yaml +// assets/openstack.yaml // DO NOT EDIT! package generated @@ -69,42 +69,42 @@ func (fi bindataFileInfo) Sys() interface{} { return nil } -var _manifestsAwsYaml = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\x54\x8e\x31\x8e\x83\x40\x0c\x45\xfb\x39\x85\x45\x0f\xab\xdd\x6a\x35\x6d\x8e\x10\x29\xbd\x09\x3f\xc8\x02\x3c\x23\xdb\x10\xe5\xf6\x11\x24\x29\xd2\xfa\xeb\x3d\x3f\xae\x72\x81\xb9\x14\xcd\xe4\x51\x8c\x47\x74\xd3\xbf\x77\x52\x7e\xb6\xdf\x34\x89\x0e\x99\xce\xaf\xfb\x69\x66\xf7\xb4\x20\x78\xe0\xe0\x9c\x88\x94\x17\x64\x1a\xeb\x5f\x22\x62\xd5\x12\x1c\x52\xd4\xf7\x89\x3e\xb6\xeb\x4e\x75\xd3\xda\xc3\x14\x81\xc3\x2c\xde\x0e\xb8\xf1\x3a\x47\x7b\xcc\x99\x9a\xb0\x15\x4d\xaa\x56\x36\xd9\x63\x60\x99\xbe\x19\xbe\x7b\x8b\xde\x53\x65\xe3\x05\x01\x3b\xde\xc4\xa3\xbe\x0b\x9e\x01\x00\x00\xff\xff\x7e\xdd\x79\x79\xc9\x00\x00\x00") +var _assetsAwsYaml = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\x54\x8e\x31\x8e\x83\x40\x0c\x45\xfb\x39\x85\x45\x0f\xab\xdd\x6a\x35\x6d\x8e\x10\x29\xbd\x09\x3f\xc8\x02\x3c\x23\xdb\x10\xe5\xf6\x11\x24\x29\xd2\xfa\xeb\x3d\x3f\xae\x72\x81\xb9\x14\xcd\xe4\x51\x8c\x47\x74\xd3\xbf\x77\x52\x7e\xb6\xdf\x34\x89\x0e\x99\xce\xaf\xfb\x69\x66\xf7\xb4\x20\x78\xe0\xe0\x9c\x88\x94\x17\x64\x1a\xeb\x5f\x22\x62\xd5\x12\x1c\x52\xd4\xf7\x89\x3e\xb6\xeb\x4e\x75\xd3\xda\xc3\x14\x81\xc3\x2c\xde\x0e\xb8\xf1\x3a\x47\x7b\xcc\x99\x9a\xb0\x15\x4d\xaa\x56\x36\xd9\x63\x60\x99\xbe\x19\xbe\x7b\x8b\xde\x53\x65\xe3\x05\x01\x3b\xde\xc4\xa3\xbe\x0b\x9e\x01\x00\x00\xff\xff\x7e\xdd\x79\x79\xc9\x00\x00\x00") -func manifestsAwsYamlBytes() ([]byte, error) { +func assetsAwsYamlBytes() ([]byte, error) { return bindataRead( - _manifestsAwsYaml, - "manifests/aws.yaml", + _assetsAwsYaml, + "assets/aws.yaml", ) } -func manifestsAwsYaml() (*asset, error) { - bytes, err := manifestsAwsYamlBytes() +func assetsAwsYaml() (*asset, error) { + bytes, err := assetsAwsYamlBytes() if err != nil { return nil, err } - info := bindataFileInfo{name: "manifests/aws.yaml", size: 0, mode: os.FileMode(0), modTime: time.Unix(0, 0)} + info := bindataFileInfo{name: "assets/aws.yaml", size: 0, mode: os.FileMode(0), modTime: time.Unix(0, 0)} a := &asset{bytes: bytes, info: info} return a, nil } -var _manifestsOpenstackYaml = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\x54\x8e\xb1\x8e\xc3\x30\x0c\x43\x77\x7f\x85\x90\x3d\x3e\xdc\x76\xf0\x7a\x9f\x50\xa0\x3b\x13\xab\x85\x90\x44\x0e\x24\x25\xdf\x5f\x38\x45\x87\xae\x24\x1f\x49\xec\x72\x67\x73\x69\x5a\xc8\xa3\x19\x9e\x9c\x97\x3f\xcf\xd2\x7e\xce\xdf\xb4\x88\xd6\x42\xb7\xb7\xfe\xbf\xc2\x3d\x6d\x1c\xa8\x08\x94\x44\xa4\xd8\xb8\x63\xd0\x0a\xab\x89\x08\xaa\x2d\x10\xd2\xd4\xbb\x4f\x9f\xca\xb9\xa3\x79\xe2\x40\x5e\x8e\x89\x4d\x39\xf8\xda\x10\x1f\x2b\x3f\x70\xac\x31\x5e\x99\x42\x43\xd8\xc1\x43\xda\xad\x9d\xd2\x6f\xb1\x15\xfa\x66\x66\xd1\xca\x96\x5e\x01\x00\x00\xff\xff\xf3\x03\x04\x7a\xba\x00\x00\x00") +var _assetsOpenstackYaml = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\x54\x8e\xb1\x8e\xc3\x30\x0c\x43\x77\x7f\x85\x90\x3d\x3e\xdc\x76\xf0\x7a\x9f\x50\xa0\x3b\x13\xab\x85\x90\x44\x0e\x24\x25\xdf\x5f\x38\x45\x87\xae\x24\x1f\x49\xec\x72\x67\x73\x69\x5a\xc8\xa3\x19\x9e\x9c\x97\x3f\xcf\xd2\x7e\xce\xdf\xb4\x88\xd6\x42\xb7\xb7\xfe\xbf\xc2\x3d\x6d\x1c\xa8\x08\x94\x44\xa4\xd8\xb8\x63\xd0\x0a\xab\x89\x08\xaa\x2d\x10\xd2\xd4\xbb\x4f\x9f\xca\xb9\xa3\x79\xe2\x40\x5e\x8e\x89\x4d\x39\xf8\xda\x10\x1f\x2b\x3f\x70\xac\x31\x5e\x99\x42\x43\xd8\xc1\x43\xda\xad\x9d\xd2\x6f\xb1\x15\xfa\x66\x66\xd1\xca\x96\x5e\x01\x00\x00\xff\xff\xf3\x03\x04\x7a\xba\x00\x00\x00") -func manifestsOpenstackYamlBytes() ([]byte, error) { +func assetsOpenstackYamlBytes() ([]byte, error) { return bindataRead( - _manifestsOpenstackYaml, - "manifests/openstack.yaml", + _assetsOpenstackYaml, + "assets/openstack.yaml", ) } -func manifestsOpenstackYaml() (*asset, error) { - bytes, err := manifestsOpenstackYamlBytes() +func assetsOpenstackYaml() (*asset, error) { + bytes, err := assetsOpenstackYamlBytes() if err != nil { return nil, err } - info := bindataFileInfo{name: "manifests/openstack.yaml", size: 0, mode: os.FileMode(0), modTime: time.Unix(0, 0)} + info := bindataFileInfo{name: "assets/openstack.yaml", size: 0, mode: os.FileMode(0), modTime: time.Unix(0, 0)} a := &asset{bytes: bytes, info: info} return a, nil } @@ -161,8 +161,8 @@ func AssetNames() []string { // _bindata is a table, holding each asset generator, mapped to its name. var _bindata = map[string]func() (*asset, error){ - "manifests/aws.yaml": manifestsAwsYaml, - "manifests/openstack.yaml": manifestsOpenstackYaml, + "assets/aws.yaml": assetsAwsYaml, + "assets/openstack.yaml": assetsOpenstackYaml, } // AssetDir returns the file names below a certain @@ -205,9 +205,9 @@ type bintree struct { Children map[string]*bintree } var _bintree = &bintree{nil, map[string]*bintree{ - "manifests": &bintree{nil, map[string]*bintree{ - "aws.yaml": &bintree{manifestsAwsYaml, map[string]*bintree{}}, - "openstack.yaml": &bintree{manifestsOpenstackYaml, map[string]*bintree{}}, + "assets": &bintree{nil, map[string]*bintree{ + "aws.yaml": &bintree{assetsAwsYaml, map[string]*bintree{}}, + "openstack.yaml": &bintree{assetsOpenstackYaml, map[string]*bintree{}}, }}, }} diff --git a/vendor/github.com/jteeuwen/go-bindata/LICENSE b/vendor/github.com/jteeuwen/go-bindata/LICENSE new file mode 100644 index 000000000..c07a9311f --- /dev/null +++ b/vendor/github.com/jteeuwen/go-bindata/LICENSE @@ -0,0 +1,3 @@ +This work is subject to the CC0 1.0 Universal (CC0 1.0) Public Domain Dedication +license. Its contents can be found at: +http://creativecommons.org/publicdomain/zero/1.0 diff --git a/vendor/github.com/jteeuwen/go-bindata/asset.go b/vendor/github.com/jteeuwen/go-bindata/asset.go new file mode 100644 index 000000000..95b6b94f3 --- /dev/null +++ b/vendor/github.com/jteeuwen/go-bindata/asset.go @@ -0,0 +1,12 @@ +// This work is subject to the CC0 1.0 Universal (CC0 1.0) Public Domain Dedication +// license. Its contents can be found at: +// http://creativecommons.org/publicdomain/zero/1.0/ + +package bindata + +// Asset holds information about a single asset to be processed. +type Asset struct { + Path string // Full file path. + Name string // Key used in TOC -- name by which asset is referenced. + Func string // Function name for the procedure returning the asset contents. +} diff --git a/vendor/github.com/jteeuwen/go-bindata/bytewriter.go b/vendor/github.com/jteeuwen/go-bindata/bytewriter.go new file mode 100644 index 000000000..05d6d6780 --- /dev/null +++ b/vendor/github.com/jteeuwen/go-bindata/bytewriter.go @@ -0,0 +1,44 @@ +// This work is subject to the CC0 1.0 Universal (CC0 1.0) Public Domain Dedication +// license. Its contents can be found at: +// http://creativecommons.org/publicdomain/zero/1.0/ + +package bindata + +import ( + "fmt" + "io" +) + +var ( + newline = []byte{'\n'} + dataindent = []byte{'\t', '\t'} + space = []byte{' '} +) + +type ByteWriter struct { + io.Writer + c int +} + +func (w *ByteWriter) Write(p []byte) (n int, err error) { + if len(p) == 0 { + return + } + + for n = range p { + if w.c%12 == 0 { + w.Writer.Write(newline) + w.Writer.Write(dataindent) + w.c = 0 + } else { + w.Writer.Write(space) + } + + fmt.Fprintf(w.Writer, "0x%02x,", p[n]) + w.c++ + } + + n++ + + return +} diff --git a/vendor/github.com/jteeuwen/go-bindata/config.go b/vendor/github.com/jteeuwen/go-bindata/config.go new file mode 100644 index 000000000..2bd0d56d8 --- /dev/null +++ b/vendor/github.com/jteeuwen/go-bindata/config.go @@ -0,0 +1,203 @@ +// This work is subject to the CC0 1.0 Universal (CC0 1.0) Public Domain Dedication +// license. Its contents can be found at: +// http://creativecommons.org/publicdomain/zero/1.0/ + +package bindata + +import ( + "fmt" + "os" + "path/filepath" + "regexp" +) + +// InputConfig defines options on a asset directory to be convert. +type InputConfig struct { + // Path defines a directory containing asset files to be included + // in the generated output. + Path string + + // Recusive defines whether subdirectories of Path + // should be recursively included in the conversion. + Recursive bool +} + +// Config defines a set of options for the asset conversion. +type Config struct { + // Name of the package to use. Defaults to 'main'. + Package string + + // Tags specify a set of optional build tags, which should be + // included in the generated output. The tags are appended to a + // `// +build` line in the beginning of the output file + // and must follow the build tags syntax specified by the go tool. + Tags string + + // Input defines the directory path, containing all asset files as + // well as whether to recursively process assets in any sub directories. + Input []InputConfig + + // Output defines the output file for the generated code. + // If left empty, this defaults to 'bindata.go' in the current + // working directory. + Output string + + // Prefix defines a path prefix which should be stripped from all + // file names when generating the keys in the table of contents. + // For example, running without the `-prefix` flag, we get: + // + // $ go-bindata /path/to/templates + // go_bindata["/path/to/templates/foo.html"] = _path_to_templates_foo_html + // + // Running with the `-prefix` flag, we get: + // + // $ go-bindata -prefix "/path/to/" /path/to/templates/foo.html + // go_bindata["templates/foo.html"] = templates_foo_html + Prefix string + + // NoMemCopy will alter the way the output file is generated. + // + // It will employ a hack that allows us to read the file data directly from + // the compiled program's `.rodata` section. This ensures that when we call + // call our generated function, we omit unnecessary mem copies. + // + // The downside of this, is that it requires dependencies on the `reflect` and + // `unsafe` packages. These may be restricted on platforms like AppEngine and + // thus prevent you from using this mode. + // + // Another disadvantage is that the byte slice we create, is strictly read-only. + // For most use-cases this is not a problem, but if you ever try to alter the + // returned byte slice, a runtime panic is thrown. Use this mode only on target + // platforms where memory constraints are an issue. + // + // The default behaviour is to use the old code generation method. This + // prevents the two previously mentioned issues, but will employ at least one + // extra memcopy and thus increase memory requirements. + // + // For instance, consider the following two examples: + // + // This would be the default mode, using an extra memcopy but gives a safe + // implementation without dependencies on `reflect` and `unsafe`: + // + // func myfile() []byte { + // return []byte{0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a} + // } + // + // Here is the same functionality, but uses the `.rodata` hack. + // The byte slice returned from this example can not be written to without + // generating a runtime error. + // + // var _myfile = "\x89\x50\x4e\x47\x0d\x0a\x1a" + // + // func myfile() []byte { + // var empty [0]byte + // sx := (*reflect.StringHeader)(unsafe.Pointer(&_myfile)) + // b := empty[:] + // bx := (*reflect.SliceHeader)(unsafe.Pointer(&b)) + // bx.Data = sx.Data + // bx.Len = len(_myfile) + // bx.Cap = bx.Len + // return b + // } + NoMemCopy bool + + // NoCompress means the assets are /not/ GZIP compressed before being turned + // into Go code. The generated function will automatically unzip + // the file data when called. Defaults to false. + NoCompress bool + + // Perform a debug build. This generates an asset file, which + // loads the asset contents directly from disk at their original + // location, instead of embedding the contents in the code. + // + // This is mostly useful if you anticipate that the assets are + // going to change during your development cycle. You will always + // want your code to access the latest version of the asset. + // Only in release mode, will the assets actually be embedded + // in the code. The default behaviour is Release mode. + Debug bool + + // Perform a dev build, which is nearly identical to the debug option. The + // only difference is that instead of absolute file paths in generated code, + // it expects a variable, `rootDir`, to be set in the generated code's + // package (the author needs to do this manually), which it then prepends to + // an asset's name to construct the file path on disk. + // + // This is mainly so you can push the generated code file to a shared + // repository. + Dev bool + + // When true, size, mode and modtime are not preserved from files + NoMetadata bool + // When nonzero, use this as mode for all files. + Mode uint + // When nonzero, use this as unix timestamp for all files. + ModTime int64 + + // Ignores any filenames matching the regex pattern specified, e.g. + // path/to/file.ext will ignore only that file, or \\.gitignore + // will match any .gitignore file. + // + // This parameter can be provided multiple times. + Ignore []*regexp.Regexp +} + +// NewConfig returns a default configuration struct. +func NewConfig() *Config { + c := new(Config) + c.Package = "main" + c.NoMemCopy = false + c.NoCompress = false + c.Debug = false + c.Output = "./bindata.go" + c.Ignore = make([]*regexp.Regexp, 0) + return c +} + +// validate ensures the config has sane values. +// Part of which means checking if certain file/directory paths exist. +func (c *Config) validate() error { + if len(c.Package) == 0 { + return fmt.Errorf("Missing package name") + } + + for _, input := range c.Input { + _, err := os.Lstat(input.Path) + if err != nil { + return fmt.Errorf("Failed to stat input path '%s': %v", input.Path, err) + } + } + + if len(c.Output) == 0 { + cwd, err := os.Getwd() + if err != nil { + return fmt.Errorf("Unable to determine current working directory.") + } + + c.Output = filepath.Join(cwd, "bindata.go") + } + + stat, err := os.Lstat(c.Output) + if err != nil { + if !os.IsNotExist(err) { + return fmt.Errorf("Output path: %v", err) + } + + // File does not exist. This is fine, just make + // sure the directory it is to be in exists. + dir, _ := filepath.Split(c.Output) + if dir != "" { + err = os.MkdirAll(dir, 0744) + + if err != nil { + return fmt.Errorf("Create output directory: %v", err) + } + } + } + + if stat != nil && stat.IsDir() { + return fmt.Errorf("Output path is a directory.") + } + + return nil +} diff --git a/vendor/github.com/jteeuwen/go-bindata/convert.go b/vendor/github.com/jteeuwen/go-bindata/convert.go new file mode 100644 index 000000000..cf0466edd --- /dev/null +++ b/vendor/github.com/jteeuwen/go-bindata/convert.go @@ -0,0 +1,261 @@ +// This work is subject to the CC0 1.0 Universal (CC0 1.0) Public Domain Dedication +// license. Its contents can be found at: +// http://creativecommons.org/publicdomain/zero/1.0/ + +package bindata + +import ( + "bufio" + "fmt" + "os" + "path/filepath" + "regexp" + "sort" + "strings" + "unicode" +) + +// Translate reads assets from an input directory, converts them +// to Go code and writes new files to the output specified +// in the given configuration. +func Translate(c *Config) error { + var toc []Asset + + // Ensure our configuration has sane values. + err := c.validate() + if err != nil { + return err + } + + var knownFuncs = make(map[string]int) + var visitedPaths = make(map[string]bool) + // Locate all the assets. + for _, input := range c.Input { + err = findFiles(input.Path, c.Prefix, input.Recursive, &toc, c.Ignore, knownFuncs, visitedPaths) + if err != nil { + return err + } + } + + // Create output file. + fd, err := os.Create(c.Output) + if err != nil { + return err + } + + defer fd.Close() + + // Create a buffered writer for better performance. + bfd := bufio.NewWriter(fd) + defer bfd.Flush() + + // Write the header. This makes e.g. Github ignore diffs in generated files. + if _, err = fmt.Fprint(bfd, "// Code generated by go-bindata.\n"); err != nil { + return err + } + if _, err = fmt.Fprint(bfd, "// sources:\n"); err != nil { + return err + } + + wd, err := os.Getwd() + if err != nil { + return err + } + + for _, asset := range toc { + relative, _ := filepath.Rel(wd, asset.Path) + if _, err = fmt.Fprintf(bfd, "// %s\n", filepath.ToSlash(relative)); err != nil { + return err + } + } + if _, err = fmt.Fprint(bfd, "// DO NOT EDIT!\n\n"); err != nil { + return err + } + + // Write build tags, if applicable. + if len(c.Tags) > 0 { + if _, err = fmt.Fprintf(bfd, "// +build %s\n\n", c.Tags); err != nil { + return err + } + } + + // Write package declaration. + _, err = fmt.Fprintf(bfd, "package %s\n\n", c.Package) + if err != nil { + return err + } + + // Write assets. + if c.Debug || c.Dev { + err = writeDebug(bfd, c, toc) + } else { + err = writeRelease(bfd, c, toc) + } + + if err != nil { + return err + } + + // Write table of contents + if err := writeTOC(bfd, toc); err != nil { + return err + } + // Write hierarchical tree of assets + if err := writeTOCTree(bfd, toc); err != nil { + return err + } + + // Write restore procedure + return writeRestore(bfd) +} + +// Implement sort.Interface for []os.FileInfo based on Name() +type ByName []os.FileInfo + +func (v ByName) Len() int { return len(v) } +func (v ByName) Swap(i, j int) { v[i], v[j] = v[j], v[i] } +func (v ByName) Less(i, j int) bool { return v[i].Name() < v[j].Name() } + +// findFiles recursively finds all the file paths in the given directory tree. +// They are added to the given map as keys. Values will be safe function names +// for each file, which will be used when generating the output code. +func findFiles(dir, prefix string, recursive bool, toc *[]Asset, ignore []*regexp.Regexp, knownFuncs map[string]int, visitedPaths map[string]bool) error { + dirpath := dir + if len(prefix) > 0 { + dirpath, _ = filepath.Abs(dirpath) + prefix, _ = filepath.Abs(prefix) + prefix = filepath.ToSlash(prefix) + } + + fi, err := os.Stat(dirpath) + if err != nil { + return err + } + + var list []os.FileInfo + + if !fi.IsDir() { + dirpath = filepath.Dir(dirpath) + list = []os.FileInfo{fi} + } else { + visitedPaths[dirpath] = true + fd, err := os.Open(dirpath) + if err != nil { + return err + } + + defer fd.Close() + + list, err = fd.Readdir(0) + if err != nil { + return err + } + + // Sort to make output stable between invocations + sort.Sort(ByName(list)) + } + + for _, file := range list { + var asset Asset + asset.Path = filepath.Join(dirpath, file.Name()) + asset.Name = filepath.ToSlash(asset.Path) + + ignoring := false + for _, re := range ignore { + if re.MatchString(asset.Path) { + ignoring = true + break + } + } + if ignoring { + continue + } + + if file.IsDir() { + if recursive { + recursivePath := filepath.Join(dir, file.Name()) + visitedPaths[asset.Path] = true + findFiles(recursivePath, prefix, recursive, toc, ignore, knownFuncs, visitedPaths) + } + continue + } else if file.Mode()&os.ModeSymlink == os.ModeSymlink { + var linkPath string + if linkPath, err = os.Readlink(asset.Path); err != nil { + return err + } + if !filepath.IsAbs(linkPath) { + if linkPath, err = filepath.Abs(dirpath + "/" + linkPath); err != nil { + return err + } + } + if _, ok := visitedPaths[linkPath]; !ok { + visitedPaths[linkPath] = true + findFiles(asset.Path, prefix, recursive, toc, ignore, knownFuncs, visitedPaths) + } + continue + } + + if strings.HasPrefix(asset.Name, prefix) { + asset.Name = asset.Name[len(prefix):] + } else { + asset.Name = filepath.Join(dir, file.Name()) + } + + // If we have a leading slash, get rid of it. + if len(asset.Name) > 0 && asset.Name[0] == '/' { + asset.Name = asset.Name[1:] + } + + // This shouldn't happen. + if len(asset.Name) == 0 { + return fmt.Errorf("Invalid file: %v", asset.Path) + } + + asset.Func = safeFunctionName(asset.Name, knownFuncs) + asset.Path, _ = filepath.Abs(asset.Path) + *toc = append(*toc, asset) + } + + return nil +} + +var regFuncName = regexp.MustCompile(`[^a-zA-Z0-9_]`) + +// safeFunctionName converts the given name into a name +// which qualifies as a valid function identifier. It +// also compares against a known list of functions to +// prevent conflict based on name translation. +func safeFunctionName(name string, knownFuncs map[string]int) string { + var inBytes, outBytes []byte + var toUpper bool + + name = strings.ToLower(name) + inBytes = []byte(name) + + for i := 0; i < len(inBytes); i++ { + if regFuncName.Match([]byte{inBytes[i]}) { + toUpper = true + } else if toUpper { + outBytes = append(outBytes, []byte(strings.ToUpper(string(inBytes[i])))...) + toUpper = false + } else { + outBytes = append(outBytes, inBytes[i]) + } + } + + name = string(outBytes) + + // Identifier can't start with a digit. + if unicode.IsDigit(rune(name[0])) { + name = "_" + name + } + + if num, ok := knownFuncs[name]; ok { + knownFuncs[name] = num + 1 + name = fmt.Sprintf("%s%d", name, num) + } else { + knownFuncs[name] = 2 + } + + return name +} diff --git a/vendor/github.com/jteeuwen/go-bindata/debug.go b/vendor/github.com/jteeuwen/go-bindata/debug.go new file mode 100644 index 000000000..09fee785d --- /dev/null +++ b/vendor/github.com/jteeuwen/go-bindata/debug.go @@ -0,0 +1,87 @@ +// This work is subject to the CC0 1.0 Universal (CC0 1.0) Public Domain Dedication +// license. Its contents can be found at: +// http://creativecommons.org/publicdomain/zero/1.0/ + +package bindata + +import ( + "fmt" + "io" +) + +// writeDebug writes the debug code file. +func writeDebug(w io.Writer, c *Config, toc []Asset) error { + err := writeDebugHeader(w) + if err != nil { + return err + } + + for i := range toc { + err = writeDebugAsset(w, c, &toc[i]) + if err != nil { + return err + } + } + + return nil +} + +// writeDebugHeader writes output file headers. +// This targets debug builds. +func writeDebugHeader(w io.Writer) error { + _, err := fmt.Fprintf(w, `import ( + "fmt" + "io/ioutil" + "os" + "path/filepath" + "strings" +) + +// bindataRead reads the given file from disk. It returns an error on failure. +func bindataRead(path, name string) ([]byte, error) { + buf, err := ioutil.ReadFile(path) + if err != nil { + err = fmt.Errorf("Error reading asset %%s at %%s: %%v", name, path, err) + } + return buf, err +} + +type asset struct { + bytes []byte + info os.FileInfo +} + +`) + return err +} + +// writeDebugAsset write a debug entry for the given asset. +// A debug entry is simply a function which reads the asset from +// the original file (e.g.: from disk). +func writeDebugAsset(w io.Writer, c *Config, asset *Asset) error { + pathExpr := fmt.Sprintf("%q", asset.Path) + if c.Dev { + pathExpr = fmt.Sprintf("filepath.Join(rootDir, %q)", asset.Name) + } + + _, err := fmt.Fprintf(w, `// %s reads file data from disk. It returns an error on failure. +func %s() (*asset, error) { + path := %s + name := %q + bytes, err := bindataRead(path, name) + if err != nil { + return nil, err + } + + fi, err := os.Stat(path) + if err != nil { + err = fmt.Errorf("Error reading asset info %%s at %%s: %%v", name, path, err) + } + + a := &asset{bytes: bytes, info: fi} + return a, err +} + +`, asset.Func, asset.Func, pathExpr, asset.Name) + return err +} diff --git a/vendor/github.com/jteeuwen/go-bindata/doc.go b/vendor/github.com/jteeuwen/go-bindata/doc.go new file mode 100644 index 000000000..09ead1e3b --- /dev/null +++ b/vendor/github.com/jteeuwen/go-bindata/doc.go @@ -0,0 +1,129 @@ +// This work is subject to the CC0 1.0 Universal (CC0 1.0) Public Domain Dedication +// license. Its contents can be found at: +// http://creativecommons.org/publicdomain/zero/1.0/ + +/* +bindata converts any file into managable Go source code. Useful for +embedding binary data into a go program. The file data is optionally gzip +compressed before being converted to a raw byte slice. + +The following paragraphs cover some of the customization options +which can be specified in the Config struct, which must be passed into +the Translate() call. + + +Debug vs Release builds + +When used with the `Debug` option, the generated code does not actually include +the asset data. Instead, it generates function stubs which load the data from +the original file on disk. The asset API remains identical between debug and +release builds, so your code will not have to change. + +This is useful during development when you expect the assets to change often. +The host application using these assets uses the same API in both cases and +will not have to care where the actual data comes from. + +An example is a Go webserver with some embedded, static web content like +HTML, JS and CSS files. While developing it, you do not want to rebuild the +whole server and restart it every time you make a change to a bit of +javascript. You just want to build and launch the server once. Then just press +refresh in the browser to see those changes. Embedding the assets with the +`debug` flag allows you to do just that. When you are finished developing and +ready for deployment, just re-invoke `go-bindata` without the `-debug` flag. +It will now embed the latest version of the assets. + + +Lower memory footprint + +The `NoMemCopy` option will alter the way the output file is generated. +It will employ a hack that allows us to read the file data directly from +the compiled program's `.rodata` section. This ensures that when we call +call our generated function, we omit unnecessary memcopies. + +The downside of this, is that it requires dependencies on the `reflect` and +`unsafe` packages. These may be restricted on platforms like AppEngine and +thus prevent you from using this mode. + +Another disadvantage is that the byte slice we create, is strictly read-only. +For most use-cases this is not a problem, but if you ever try to alter the +returned byte slice, a runtime panic is thrown. Use this mode only on target +platforms where memory constraints are an issue. + +The default behaviour is to use the old code generation method. This +prevents the two previously mentioned issues, but will employ at least one +extra memcopy and thus increase memory requirements. + +For instance, consider the following two examples: + +This would be the default mode, using an extra memcopy but gives a safe +implementation without dependencies on `reflect` and `unsafe`: + + func myfile() []byte { + return []byte{0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a} + } + +Here is the same functionality, but uses the `.rodata` hack. +The byte slice returned from this example can not be written to without +generating a runtime error. + + var _myfile = "\x89\x50\x4e\x47\x0d\x0a\x1a" + + func myfile() []byte { + var empty [0]byte + sx := (*reflect.StringHeader)(unsafe.Pointer(&_myfile)) + b := empty[:] + bx := (*reflect.SliceHeader)(unsafe.Pointer(&b)) + bx.Data = sx.Data + bx.Len = len(_myfile) + bx.Cap = bx.Len + return b + } + + +Optional compression + +The NoCompress option indicates that the supplied assets are *not* GZIP +compressed before being turned into Go code. The data should still be accessed +through a function call, so nothing changes in the API. + +This feature is useful if you do not care for compression, or the supplied +resource is already compressed. Doing it again would not add any value and may +even increase the size of the data. + +The default behaviour of the program is to use compression. + + +Path prefix stripping + +The keys used in the `_bindata` map are the same as the input file name +passed to `go-bindata`. This includes the path. In most cases, this is not +desireable, as it puts potentially sensitive information in your code base. +For this purpose, the tool supplies another command line flag `-prefix`. +This accepts a portion of a path name, which should be stripped off from +the map keys and function names. + +For example, running without the `-prefix` flag, we get: + + $ go-bindata /path/to/templates/ + + _bindata["/path/to/templates/foo.html"] = path_to_templates_foo_html + +Running with the `-prefix` flag, we get: + + $ go-bindata -prefix "/path/to/" /path/to/templates/ + + _bindata["templates/foo.html"] = templates_foo_html + + +Build tags + +With the optional Tags field, you can specify any go build tags that +must be fulfilled for the output file to be included in a build. This +is useful when including binary data in multiple formats, where the desired +format is specified at build time with the appropriate tags. + +The tags are appended to a `// +build` line in the beginning of the output file +and must follow the build tags syntax specified by the go tool. + +*/ +package bindata diff --git a/vendor/github.com/jteeuwen/go-bindata/go-bindata/AppendSliceValue.go b/vendor/github.com/jteeuwen/go-bindata/go-bindata/AppendSliceValue.go new file mode 100644 index 000000000..f5da49596 --- /dev/null +++ b/vendor/github.com/jteeuwen/go-bindata/go-bindata/AppendSliceValue.go @@ -0,0 +1,22 @@ +package main + +import "strings" + +// borrowed from https://github.com/hashicorp/serf/blob/master/command/agent/flag_slice_value.go + +// AppendSliceValue implements the flag.Value interface and allows multiple +// calls to the same variable to append a list. +type AppendSliceValue []string + +func (s *AppendSliceValue) String() string { + return strings.Join(*s, ",") +} + +func (s *AppendSliceValue) Set(value string) error { + if *s == nil { + *s = make([]string, 0, 1) + } + + *s = append(*s, value) + return nil +} diff --git a/vendor/github.com/jteeuwen/go-bindata/go-bindata/main.go b/vendor/github.com/jteeuwen/go-bindata/go-bindata/main.go new file mode 100644 index 000000000..503a059e6 --- /dev/null +++ b/vendor/github.com/jteeuwen/go-bindata/go-bindata/main.go @@ -0,0 +1,107 @@ +// This work is subject to the CC0 1.0 Universal (CC0 1.0) Public Domain Dedication +// license. Its contents can be found at: +// http://creativecommons.org/publicdomain/zero/1.0/ + +package main + +import ( + "flag" + "fmt" + "os" + "path/filepath" + "regexp" + "strings" + + "github.com/jteeuwen/go-bindata" +) + +func main() { + cfg := parseArgs() + err := bindata.Translate(cfg) + + if err != nil { + fmt.Fprintf(os.Stderr, "bindata: %v\n", err) + os.Exit(1) + } +} + +// parseArgs create s a new, filled configuration instance +// by reading and parsing command line options. +// +// This function exits the program with an error, if +// any of the command line options are incorrect. +func parseArgs() *bindata.Config { + var version bool + + c := bindata.NewConfig() + + flag.Usage = func() { + fmt.Printf("Usage: %s [options] \n\n", os.Args[0]) + flag.PrintDefaults() + } + + flag.BoolVar(&c.Debug, "debug", c.Debug, "Do not embed the assets, but provide the embedding API. Contents will still be loaded from disk.") + flag.BoolVar(&c.Dev, "dev", c.Dev, "Similar to debug, but does not emit absolute paths. Expects a rootDir variable to already exist in the generated code's package.") + flag.StringVar(&c.Tags, "tags", c.Tags, "Optional set of build tags to include.") + flag.StringVar(&c.Prefix, "prefix", c.Prefix, "Optional path prefix to strip off asset names.") + flag.StringVar(&c.Package, "pkg", c.Package, "Package name to use in the generated code.") + flag.BoolVar(&c.NoMemCopy, "nomemcopy", c.NoMemCopy, "Use a .rodata hack to get rid of unnecessary memcopies. Refer to the documentation to see what implications this carries.") + flag.BoolVar(&c.NoCompress, "nocompress", c.NoCompress, "Assets will *not* be GZIP compressed when this flag is specified.") + flag.BoolVar(&c.NoMetadata, "nometadata", c.NoMetadata, "Assets will not preserve size, mode, and modtime info.") + flag.UintVar(&c.Mode, "mode", c.Mode, "Optional file mode override for all files.") + flag.Int64Var(&c.ModTime, "modtime", c.ModTime, "Optional modification unix timestamp override for all files.") + flag.StringVar(&c.Output, "o", c.Output, "Optional name of the output file to be generated.") + flag.BoolVar(&version, "version", false, "Displays version information.") + + ignore := make([]string, 0) + flag.Var((*AppendSliceValue)(&ignore), "ignore", "Regex pattern to ignore") + + flag.Parse() + + patterns := make([]*regexp.Regexp, 0) + for _, pattern := range ignore { + patterns = append(patterns, regexp.MustCompile(pattern)) + } + c.Ignore = patterns + + if version { + fmt.Printf("%s\n", Version()) + os.Exit(0) + } + + // Make sure we have input paths. + if flag.NArg() == 0 { + fmt.Fprintf(os.Stderr, "Missing \n\n") + flag.Usage() + os.Exit(1) + } + + // Create input configurations. + c.Input = make([]bindata.InputConfig, flag.NArg()) + for i := range c.Input { + c.Input[i] = parseInput(flag.Arg(i)) + } + + return c +} + +// parseRecursive determines whether the given path has a recrusive indicator and +// returns a new path with the recursive indicator chopped off if it does. +// +// ex: +// /path/to/foo/... -> (/path/to/foo, true) +// /path/to/bar -> (/path/to/bar, false) +func parseInput(path string) bindata.InputConfig { + if strings.HasSuffix(path, "/...") { + return bindata.InputConfig{ + Path: filepath.Clean(path[:len(path)-4]), + Recursive: true, + } + } else { + return bindata.InputConfig{ + Path: filepath.Clean(path), + Recursive: false, + } + } + +} diff --git a/vendor/github.com/jteeuwen/go-bindata/go-bindata/version.go b/vendor/github.com/jteeuwen/go-bindata/go-bindata/version.go new file mode 100644 index 000000000..a12508ede --- /dev/null +++ b/vendor/github.com/jteeuwen/go-bindata/go-bindata/version.go @@ -0,0 +1,31 @@ +// This work is subject to the CC0 1.0 Universal (CC0 1.0) Public Domain Dedication +// license. Its contents can be found at: +// http://creativecommons.org/publicdomain/zero/1.0/ + +package main + +import ( + "fmt" + "runtime" +) + +const ( + AppName = "go-bindata" + AppVersionMajor = 3 + AppVersionMinor = 1 +) + +// revision part of the program version. +// This will be set automatically at build time like so: +// +// go build -ldflags "-X main.AppVersionRev `date -u +%s`" +var AppVersionRev string + +func Version() string { + if len(AppVersionRev) == 0 { + AppVersionRev = "0" + } + + return fmt.Sprintf("%s %d.%d.%s (Go runtime %s).\nCopyright (c) 2010-2013, Jim Teeuwen.", + AppName, AppVersionMajor, AppVersionMinor, AppVersionRev, runtime.Version()) +} diff --git a/vendor/github.com/jteeuwen/go-bindata/release.go b/vendor/github.com/jteeuwen/go-bindata/release.go new file mode 100644 index 000000000..6aefeb28a --- /dev/null +++ b/vendor/github.com/jteeuwen/go-bindata/release.go @@ -0,0 +1,387 @@ +// This work is subject to the CC0 1.0 Universal (CC0 1.0) Public Domain Dedication +// license. Its contents can be found at: +// http://creativecommons.org/publicdomain/zero/1.0/ + +package bindata + +import ( + "bytes" + "compress/gzip" + "fmt" + "io" + "io/ioutil" + "os" + "unicode/utf8" +) + +// writeRelease writes the release code file. +func writeRelease(w io.Writer, c *Config, toc []Asset) error { + err := writeReleaseHeader(w, c) + if err != nil { + return err + } + + for i := range toc { + err = writeReleaseAsset(w, c, &toc[i]) + if err != nil { + return err + } + } + + return nil +} + +// writeReleaseHeader writes output file headers. +// This targets release builds. +func writeReleaseHeader(w io.Writer, c *Config) error { + var err error + if c.NoCompress { + if c.NoMemCopy { + err = header_uncompressed_nomemcopy(w) + } else { + err = header_uncompressed_memcopy(w) + } + } else { + if c.NoMemCopy { + err = header_compressed_nomemcopy(w) + } else { + err = header_compressed_memcopy(w) + } + } + if err != nil { + return err + } + return header_release_common(w) +} + +// writeReleaseAsset write a release entry for the given asset. +// A release entry is a function which embeds and returns +// the file's byte content. +func writeReleaseAsset(w io.Writer, c *Config, asset *Asset) error { + fd, err := os.Open(asset.Path) + if err != nil { + return err + } + + defer fd.Close() + + if c.NoCompress { + if c.NoMemCopy { + err = uncompressed_nomemcopy(w, asset, fd) + } else { + err = uncompressed_memcopy(w, asset, fd) + } + } else { + if c.NoMemCopy { + err = compressed_nomemcopy(w, asset, fd) + } else { + err = compressed_memcopy(w, asset, fd) + } + } + if err != nil { + return err + } + return asset_release_common(w, c, asset) +} + +// sanitize prepares a valid UTF-8 string as a raw string constant. +// Based on https://code.google.com/p/go/source/browse/godoc/static/makestatic.go?repo=tools +func sanitize(b []byte) []byte { + // Replace ` with `+"`"+` + b = bytes.Replace(b, []byte("`"), []byte("`+\"`\"+`"), -1) + + // Replace BOM with `+"\xEF\xBB\xBF"+` + // (A BOM is valid UTF-8 but not permitted in Go source files. + // I wouldn't bother handling this, but for some insane reason + // jquery.js has a BOM somewhere in the middle.) + return bytes.Replace(b, []byte("\xEF\xBB\xBF"), []byte("`+\"\\xEF\\xBB\\xBF\"+`"), -1) +} + +func header_compressed_nomemcopy(w io.Writer) error { + _, err := fmt.Fprintf(w, `import ( + "bytes" + "compress/gzip" + "fmt" + "io" + "io/ioutil" + "os" + "path/filepath" + "strings" + "time" +) + +func bindataRead(data, name string) ([]byte, error) { + gz, err := gzip.NewReader(strings.NewReader(data)) + if err != nil { + return nil, fmt.Errorf("Read %%q: %%v", name, err) + } + + var buf bytes.Buffer + _, err = io.Copy(&buf, gz) + clErr := gz.Close() + + if err != nil { + return nil, fmt.Errorf("Read %%q: %%v", name, err) + } + if clErr != nil { + return nil, err + } + + return buf.Bytes(), nil +} + +`) + return err +} + +func header_compressed_memcopy(w io.Writer) error { + _, err := fmt.Fprintf(w, `import ( + "bytes" + "compress/gzip" + "fmt" + "io" + "io/ioutil" + "os" + "path/filepath" + "strings" + "time" +) + +func bindataRead(data []byte, name string) ([]byte, error) { + gz, err := gzip.NewReader(bytes.NewBuffer(data)) + if err != nil { + return nil, fmt.Errorf("Read %%q: %%v", name, err) + } + + var buf bytes.Buffer + _, err = io.Copy(&buf, gz) + clErr := gz.Close() + + if err != nil { + return nil, fmt.Errorf("Read %%q: %%v", name, err) + } + if clErr != nil { + return nil, err + } + + return buf.Bytes(), nil +} + +`) + return err +} + +func header_uncompressed_nomemcopy(w io.Writer) error { + _, err := fmt.Fprintf(w, `import ( + "fmt" + "io/ioutil" + "os" + "path/filepath" + "reflect" + "strings" + "time" + "unsafe" +) + +func bindataRead(data, name string) ([]byte, error) { + var empty [0]byte + sx := (*reflect.StringHeader)(unsafe.Pointer(&data)) + b := empty[:] + bx := (*reflect.SliceHeader)(unsafe.Pointer(&b)) + bx.Data = sx.Data + bx.Len = len(data) + bx.Cap = bx.Len + return b, nil +} + +`) + return err +} + +func header_uncompressed_memcopy(w io.Writer) error { + _, err := fmt.Fprintf(w, `import ( + "fmt" + "io/ioutil" + "os" + "path/filepath" + "strings" + "time" +) +`) + return err +} + +func header_release_common(w io.Writer) error { + _, err := fmt.Fprintf(w, `type asset struct { + bytes []byte + info os.FileInfo +} + +type bindataFileInfo struct { + name string + size int64 + mode os.FileMode + modTime time.Time +} + +func (fi bindataFileInfo) Name() string { + return fi.name +} +func (fi bindataFileInfo) Size() int64 { + return fi.size +} +func (fi bindataFileInfo) Mode() os.FileMode { + return fi.mode +} +func (fi bindataFileInfo) ModTime() time.Time { + return fi.modTime +} +func (fi bindataFileInfo) IsDir() bool { + return false +} +func (fi bindataFileInfo) Sys() interface{} { + return nil +} + +`) + return err +} + +func compressed_nomemcopy(w io.Writer, asset *Asset, r io.Reader) error { + _, err := fmt.Fprintf(w, `var _%s = "`, asset.Func) + if err != nil { + return err + } + + gz := gzip.NewWriter(&StringWriter{Writer: w}) + _, err = io.Copy(gz, r) + gz.Close() + + if err != nil { + return err + } + + _, err = fmt.Fprintf(w, `" + +func %sBytes() ([]byte, error) { + return bindataRead( + _%s, + %q, + ) +} + +`, asset.Func, asset.Func, asset.Name) + return err +} + +func compressed_memcopy(w io.Writer, asset *Asset, r io.Reader) error { + _, err := fmt.Fprintf(w, `var _%s = []byte("`, asset.Func) + if err != nil { + return err + } + + gz := gzip.NewWriter(&StringWriter{Writer: w}) + _, err = io.Copy(gz, r) + gz.Close() + + if err != nil { + return err + } + + _, err = fmt.Fprintf(w, `") + +func %sBytes() ([]byte, error) { + return bindataRead( + _%s, + %q, + ) +} + +`, asset.Func, asset.Func, asset.Name) + return err +} + +func uncompressed_nomemcopy(w io.Writer, asset *Asset, r io.Reader) error { + _, err := fmt.Fprintf(w, `var _%s = "`, asset.Func) + if err != nil { + return err + } + + _, err = io.Copy(&StringWriter{Writer: w}, r) + if err != nil { + return err + } + + _, err = fmt.Fprintf(w, `" + +func %sBytes() ([]byte, error) { + return bindataRead( + _%s, + %q, + ) +} + +`, asset.Func, asset.Func, asset.Name) + return err +} + +func uncompressed_memcopy(w io.Writer, asset *Asset, r io.Reader) error { + _, err := fmt.Fprintf(w, `var _%s = []byte(`, asset.Func) + if err != nil { + return err + } + + b, err := ioutil.ReadAll(r) + if err != nil { + return err + } + if utf8.Valid(b) && !bytes.Contains(b, []byte{0}) { + fmt.Fprintf(w, "`%s`", sanitize(b)) + } else { + fmt.Fprintf(w, "%+q", b) + } + + _, err = fmt.Fprintf(w, `) + +func %sBytes() ([]byte, error) { + return _%s, nil +} + +`, asset.Func, asset.Func) + return err +} + +func asset_release_common(w io.Writer, c *Config, asset *Asset) error { + fi, err := os.Stat(asset.Path) + if err != nil { + return err + } + + mode := uint(fi.Mode()) + modTime := fi.ModTime().Unix() + size := fi.Size() + if c.NoMetadata { + mode = 0 + modTime = 0 + size = 0 + } + if c.Mode > 0 { + mode = uint(os.ModePerm) & c.Mode + } + if c.ModTime > 0 { + modTime = c.ModTime + } + _, err = fmt.Fprintf(w, `func %s() (*asset, error) { + bytes, err := %sBytes() + if err != nil { + return nil, err + } + + info := bindataFileInfo{name: %q, size: %d, mode: os.FileMode(%d), modTime: time.Unix(%d, 0)} + a := &asset{bytes: bytes, info: info} + return a, nil +} + +`, asset.Func, asset.Func, asset.Name, size, mode, modTime) + return err +} diff --git a/vendor/github.com/jteeuwen/go-bindata/restore.go b/vendor/github.com/jteeuwen/go-bindata/restore.go new file mode 100644 index 000000000..65db0e8f9 --- /dev/null +++ b/vendor/github.com/jteeuwen/go-bindata/restore.go @@ -0,0 +1,63 @@ +// This work is subject to the CC0 1.0 Universal (CC0 1.0) Public Domain Dedication +// license. Its contents can be found at: +// http://creativecommons.org/publicdomain/zero/1.0/ + +package bindata + +import ( + "fmt" + "io" +) + +func writeRestore(w io.Writer) error { + _, err := fmt.Fprintf(w, ` +// RestoreAsset restores an asset under the given directory +func RestoreAsset(dir, name string) error { + data, err := Asset(name) + if err != nil { + return err + } + info, err := AssetInfo(name) + if err != nil { + return err + } + err = os.MkdirAll(_filePath(dir, filepath.Dir(name)), os.FileMode(0755)) + if err != nil { + return err + } + err = ioutil.WriteFile(_filePath(dir, name), data, info.Mode()) + if err != nil { + return err + } + err = os.Chtimes(_filePath(dir, name), info.ModTime(), info.ModTime()) + if err != nil { + return err + } + return nil +} + +// RestoreAssets restores an asset under the given directory recursively +func RestoreAssets(dir, name string) error { + children, err := AssetDir(name) + // File + if err != nil { + return RestoreAsset(dir, name) + } + // Dir + for _, child := range children { + err = RestoreAssets(dir, filepath.Join(name, child)) + if err != nil { + return err + } + } + return nil +} + +func _filePath(dir, name string) string { + cannonicalName := strings.Replace(name, "\\", "/", -1) + return filepath.Join(append([]string{dir}, strings.Split(cannonicalName, "/")...)...) +} + +`) + return err +} diff --git a/vendor/github.com/jteeuwen/go-bindata/stringwriter.go b/vendor/github.com/jteeuwen/go-bindata/stringwriter.go new file mode 100644 index 000000000..77daa04cb --- /dev/null +++ b/vendor/github.com/jteeuwen/go-bindata/stringwriter.go @@ -0,0 +1,36 @@ +// This work is subject to the CC0 1.0 Universal (CC0 1.0) Public Domain Dedication +// license. Its contents can be found at: +// http://creativecommons.org/publicdomain/zero/1.0/ + +package bindata + +import ( + "io" +) + +const lowerHex = "0123456789abcdef" + +type StringWriter struct { + io.Writer + c int +} + +func (w *StringWriter) Write(p []byte) (n int, err error) { + if len(p) == 0 { + return + } + + buf := []byte(`\x00`) + var b byte + + for n, b = range p { + buf[2] = lowerHex[b/16] + buf[3] = lowerHex[b%16] + w.Writer.Write(buf) + w.c++ + } + + n++ + + return +} diff --git a/vendor/github.com/jteeuwen/go-bindata/testdata/out/compress-memcopy.go b/vendor/github.com/jteeuwen/go-bindata/testdata/out/compress-memcopy.go new file mode 100644 index 000000000..099f6f612 --- /dev/null +++ b/vendor/github.com/jteeuwen/go-bindata/testdata/out/compress-memcopy.go @@ -0,0 +1,312 @@ +// Code generated by go-bindata. +// sources: +// in/a/test.asset +// in/b/test.asset +// in/c/test.asset +// in/test.asset +// DO NOT EDIT! + +package main + +import ( + "bytes" + "compress/gzip" + "fmt" + "io" + "io/ioutil" + "os" + "path/filepath" + "strings" + "time" +) + +func bindataRead(data []byte, name string) ([]byte, error) { + gz, err := gzip.NewReader(bytes.NewBuffer(data)) + if err != nil { + return nil, fmt.Errorf("Read %q: %v", name, err) + } + + var buf bytes.Buffer + _, err = io.Copy(&buf, gz) + clErr := gz.Close() + + if err != nil { + return nil, fmt.Errorf("Read %q: %v", name, err) + } + if clErr != nil { + return nil, err + } + + return buf.Bytes(), nil +} + +type asset struct { + bytes []byte + info os.FileInfo +} + +type bindataFileInfo struct { + name string + size int64 + mode os.FileMode + modTime time.Time +} + +func (fi bindataFileInfo) Name() string { + return fi.name +} +func (fi bindataFileInfo) Size() int64 { + return fi.size +} +func (fi bindataFileInfo) Mode() os.FileMode { + return fi.mode +} +func (fi bindataFileInfo) ModTime() time.Time { + return fi.modTime +} +func (fi bindataFileInfo) IsDir() bool { + return false +} +func (fi bindataFileInfo) Sys() interface{} { + return nil +} + +var _inATestAsset = []byte("\x1f\x8b\x08\x00\x00\x09\x6e\x88\x00\xff\xd2\xd7\x57\x28\x4e\xcc\x2d\xc8\x49\x55\x48\xcb\xcc\x49\xe5\x02\x04\x00\x00\xff\xff\x8a\x82\x8c\x85\x0f\x00\x00\x00") + +func inATestAssetBytes() ([]byte, error) { + return bindataRead( + _inATestAsset, + "in/a/test.asset", + ) +} + +func inATestAsset() (*asset, error) { + bytes, err := inATestAssetBytes() + if err != nil { + return nil, err + } + + info := bindataFileInfo{name: "in/a/test.asset", size: 15, mode: os.FileMode(436), modTime: time.Unix(1445582844, 0)} + a := &asset{bytes: bytes, info: info} + return a, nil +} + +var _inBTestAsset = []byte("\x1f\x8b\x08\x00\x00\x09\x6e\x88\x00\xff\xd2\xd7\x57\x28\x4e\xcc\x2d\xc8\x49\x55\x48\xcb\xcc\x49\xe5\x02\x04\x00\x00\xff\xff\x8a\x82\x8c\x85\x0f\x00\x00\x00") + +func inBTestAssetBytes() ([]byte, error) { + return bindataRead( + _inBTestAsset, + "in/b/test.asset", + ) +} + +func inBTestAsset() (*asset, error) { + bytes, err := inBTestAssetBytes() + if err != nil { + return nil, err + } + + info := bindataFileInfo{name: "in/b/test.asset", size: 15, mode: os.FileMode(436), modTime: time.Unix(1445582844, 0)} + a := &asset{bytes: bytes, info: info} + return a, nil +} + +var _inCTestAsset = []byte("\x1f\x8b\x08\x00\x00\x09\x6e\x88\x00\xff\xd2\xd7\x57\x28\x4e\xcc\x2d\xc8\x49\x55\x48\xcb\xcc\x49\xe5\x02\x04\x00\x00\xff\xff\x8a\x82\x8c\x85\x0f\x00\x00\x00") + +func inCTestAssetBytes() ([]byte, error) { + return bindataRead( + _inCTestAsset, + "in/c/test.asset", + ) +} + +func inCTestAsset() (*asset, error) { + bytes, err := inCTestAssetBytes() + if err != nil { + return nil, err + } + + info := bindataFileInfo{name: "in/c/test.asset", size: 15, mode: os.FileMode(436), modTime: time.Unix(1445582844, 0)} + a := &asset{bytes: bytes, info: info} + return a, nil +} + +var _inTestAsset = []byte("\x1f\x8b\x08\x00\x00\x09\x6e\x88\x00\xff\xd2\xd7\x57\x28\x4e\xcc\x2d\xc8\x49\x55\x48\xcb\xcc\x49\xe5\x02\x04\x00\x00\xff\xff\x8a\x82\x8c\x85\x0f\x00\x00\x00") + +func inTestAssetBytes() ([]byte, error) { + return bindataRead( + _inTestAsset, + "in/test.asset", + ) +} + +func inTestAsset() (*asset, error) { + bytes, err := inTestAssetBytes() + if err != nil { + return nil, err + } + + info := bindataFileInfo{name: "in/test.asset", size: 15, mode: os.FileMode(436), modTime: time.Unix(1445582844, 0)} + a := &asset{bytes: bytes, info: info} + return a, nil +} + +// Asset loads and returns the asset for the given name. +// It returns an error if the asset could not be found or +// could not be loaded. +func Asset(name string) ([]byte, error) { + cannonicalName := strings.Replace(name, "\\", "/", -1) + if f, ok := _bindata[cannonicalName]; ok { + a, err := f() + if err != nil { + return nil, fmt.Errorf("Asset %s can't read by error: %v", name, err) + } + return a.bytes, nil + } + return nil, fmt.Errorf("Asset %s not found", name) +} + +// MustAsset is like Asset but panics when Asset would return an error. +// It simplifies safe initialization of global variables. +func MustAsset(name string) []byte { + a, err := Asset(name) + if err != nil { + panic("asset: Asset(" + name + "): " + err.Error()) + } + + return a +} + +// AssetInfo loads and returns the asset info for the given name. +// It returns an error if the asset could not be found or +// could not be loaded. +func AssetInfo(name string) (os.FileInfo, error) { + cannonicalName := strings.Replace(name, "\\", "/", -1) + if f, ok := _bindata[cannonicalName]; ok { + a, err := f() + if err != nil { + return nil, fmt.Errorf("AssetInfo %s can't read by error: %v", name, err) + } + return a.info, nil + } + return nil, fmt.Errorf("AssetInfo %s not found", name) +} + +// AssetNames returns the names of the assets. +func AssetNames() []string { + names := make([]string, 0, len(_bindata)) + for name := range _bindata { + names = append(names, name) + } + return names +} + +// _bindata is a table, holding each asset generator, mapped to its name. +var _bindata = map[string]func() (*asset, error){ + "in/a/test.asset": inATestAsset, + "in/b/test.asset": inBTestAsset, + "in/c/test.asset": inCTestAsset, + "in/test.asset": inTestAsset, +} + +// AssetDir returns the file names below a certain +// directory embedded in the file by go-bindata. +// For example if you run go-bindata on data/... and data contains the +// following hierarchy: +// data/ +// foo.txt +// img/ +// a.png +// b.png +// then AssetDir("data") would return []string{"foo.txt", "img"} +// AssetDir("data/img") would return []string{"a.png", "b.png"} +// AssetDir("foo.txt") and AssetDir("notexist") would return an error +// AssetDir("") will return []string{"data"}. +func AssetDir(name string) ([]string, error) { + node := _bintree + if len(name) != 0 { + cannonicalName := strings.Replace(name, "\\", "/", -1) + pathList := strings.Split(cannonicalName, "/") + for _, p := range pathList { + node = node.Children[p] + if node == nil { + return nil, fmt.Errorf("Asset %s not found", name) + } + } + } + if node.Func != nil { + return nil, fmt.Errorf("Asset %s not found", name) + } + rv := make([]string, 0, len(node.Children)) + for childName := range node.Children { + rv = append(rv, childName) + } + return rv, nil +} + +type bintree struct { + Func func() (*asset, error) + Children map[string]*bintree +} +var _bintree = &bintree{nil, map[string]*bintree{ + "in": &bintree{nil, map[string]*bintree{ + "a": &bintree{nil, map[string]*bintree{ + "test.asset": &bintree{inATestAsset, map[string]*bintree{}}, + }}, + "b": &bintree{nil, map[string]*bintree{ + "test.asset": &bintree{inBTestAsset, map[string]*bintree{}}, + }}, + "c": &bintree{nil, map[string]*bintree{ + "test.asset": &bintree{inCTestAsset, map[string]*bintree{}}, + }}, + "test.asset": &bintree{inTestAsset, map[string]*bintree{}}, + }}, +}} + +// RestoreAsset restores an asset under the given directory +func RestoreAsset(dir, name string) error { + data, err := Asset(name) + if err != nil { + return err + } + info, err := AssetInfo(name) + if err != nil { + return err + } + err = os.MkdirAll(_filePath(dir, filepath.Dir(name)), os.FileMode(0755)) + if err != nil { + return err + } + err = ioutil.WriteFile(_filePath(dir, name), data, info.Mode()) + if err != nil { + return err + } + err = os.Chtimes(_filePath(dir, name), info.ModTime(), info.ModTime()) + if err != nil { + return err + } + return nil +} + +// RestoreAssets restores an asset under the given directory recursively +func RestoreAssets(dir, name string) error { + children, err := AssetDir(name) + // File + if err != nil { + return RestoreAsset(dir, name) + } + // Dir + for _, child := range children { + err = RestoreAssets(dir, filepath.Join(name, child)) + if err != nil { + return err + } + } + return nil +} + +func _filePath(dir, name string) string { + cannonicalName := strings.Replace(name, "\\", "/", -1) + return filepath.Join(append([]string{dir}, strings.Split(cannonicalName, "/")...)...) +} + diff --git a/vendor/github.com/jteeuwen/go-bindata/testdata/out/compress-nomemcopy.go b/vendor/github.com/jteeuwen/go-bindata/testdata/out/compress-nomemcopy.go new file mode 100644 index 000000000..f52422141 --- /dev/null +++ b/vendor/github.com/jteeuwen/go-bindata/testdata/out/compress-nomemcopy.go @@ -0,0 +1,312 @@ +// Code generated by go-bindata. +// sources: +// in/a/test.asset +// in/b/test.asset +// in/c/test.asset +// in/test.asset +// DO NOT EDIT! + +package main + +import ( + "bytes" + "compress/gzip" + "fmt" + "io" + "io/ioutil" + "os" + "path/filepath" + "strings" + "time" +) + +func bindataRead(data, name string) ([]byte, error) { + gz, err := gzip.NewReader(strings.NewReader(data)) + if err != nil { + return nil, fmt.Errorf("Read %q: %v", name, err) + } + + var buf bytes.Buffer + _, err = io.Copy(&buf, gz) + clErr := gz.Close() + + if err != nil { + return nil, fmt.Errorf("Read %q: %v", name, err) + } + if clErr != nil { + return nil, err + } + + return buf.Bytes(), nil +} + +type asset struct { + bytes []byte + info os.FileInfo +} + +type bindataFileInfo struct { + name string + size int64 + mode os.FileMode + modTime time.Time +} + +func (fi bindataFileInfo) Name() string { + return fi.name +} +func (fi bindataFileInfo) Size() int64 { + return fi.size +} +func (fi bindataFileInfo) Mode() os.FileMode { + return fi.mode +} +func (fi bindataFileInfo) ModTime() time.Time { + return fi.modTime +} +func (fi bindataFileInfo) IsDir() bool { + return false +} +func (fi bindataFileInfo) Sys() interface{} { + return nil +} + +var _inATestAsset = "\x1f\x8b\x08\x00\x00\x09\x6e\x88\x00\xff\xd2\xd7\x57\x28\x4e\xcc\x2d\xc8\x49\x55\x48\xcb\xcc\x49\xe5\x02\x04\x00\x00\xff\xff\x8a\x82\x8c\x85\x0f\x00\x00\x00" + +func inATestAssetBytes() ([]byte, error) { + return bindataRead( + _inATestAsset, + "in/a/test.asset", + ) +} + +func inATestAsset() (*asset, error) { + bytes, err := inATestAssetBytes() + if err != nil { + return nil, err + } + + info := bindataFileInfo{name: "in/a/test.asset", size: 15, mode: os.FileMode(436), modTime: time.Unix(1445582844, 0)} + a := &asset{bytes: bytes, info: info} + return a, nil +} + +var _inBTestAsset = "\x1f\x8b\x08\x00\x00\x09\x6e\x88\x00\xff\xd2\xd7\x57\x28\x4e\xcc\x2d\xc8\x49\x55\x48\xcb\xcc\x49\xe5\x02\x04\x00\x00\xff\xff\x8a\x82\x8c\x85\x0f\x00\x00\x00" + +func inBTestAssetBytes() ([]byte, error) { + return bindataRead( + _inBTestAsset, + "in/b/test.asset", + ) +} + +func inBTestAsset() (*asset, error) { + bytes, err := inBTestAssetBytes() + if err != nil { + return nil, err + } + + info := bindataFileInfo{name: "in/b/test.asset", size: 15, mode: os.FileMode(436), modTime: time.Unix(1445582844, 0)} + a := &asset{bytes: bytes, info: info} + return a, nil +} + +var _inCTestAsset = "\x1f\x8b\x08\x00\x00\x09\x6e\x88\x00\xff\xd2\xd7\x57\x28\x4e\xcc\x2d\xc8\x49\x55\x48\xcb\xcc\x49\xe5\x02\x04\x00\x00\xff\xff\x8a\x82\x8c\x85\x0f\x00\x00\x00" + +func inCTestAssetBytes() ([]byte, error) { + return bindataRead( + _inCTestAsset, + "in/c/test.asset", + ) +} + +func inCTestAsset() (*asset, error) { + bytes, err := inCTestAssetBytes() + if err != nil { + return nil, err + } + + info := bindataFileInfo{name: "in/c/test.asset", size: 15, mode: os.FileMode(436), modTime: time.Unix(1445582844, 0)} + a := &asset{bytes: bytes, info: info} + return a, nil +} + +var _inTestAsset = "\x1f\x8b\x08\x00\x00\x09\x6e\x88\x00\xff\xd2\xd7\x57\x28\x4e\xcc\x2d\xc8\x49\x55\x48\xcb\xcc\x49\xe5\x02\x04\x00\x00\xff\xff\x8a\x82\x8c\x85\x0f\x00\x00\x00" + +func inTestAssetBytes() ([]byte, error) { + return bindataRead( + _inTestAsset, + "in/test.asset", + ) +} + +func inTestAsset() (*asset, error) { + bytes, err := inTestAssetBytes() + if err != nil { + return nil, err + } + + info := bindataFileInfo{name: "in/test.asset", size: 15, mode: os.FileMode(436), modTime: time.Unix(1445582844, 0)} + a := &asset{bytes: bytes, info: info} + return a, nil +} + +// Asset loads and returns the asset for the given name. +// It returns an error if the asset could not be found or +// could not be loaded. +func Asset(name string) ([]byte, error) { + cannonicalName := strings.Replace(name, "\\", "/", -1) + if f, ok := _bindata[cannonicalName]; ok { + a, err := f() + if err != nil { + return nil, fmt.Errorf("Asset %s can't read by error: %v", name, err) + } + return a.bytes, nil + } + return nil, fmt.Errorf("Asset %s not found", name) +} + +// MustAsset is like Asset but panics when Asset would return an error. +// It simplifies safe initialization of global variables. +func MustAsset(name string) []byte { + a, err := Asset(name) + if err != nil { + panic("asset: Asset(" + name + "): " + err.Error()) + } + + return a +} + +// AssetInfo loads and returns the asset info for the given name. +// It returns an error if the asset could not be found or +// could not be loaded. +func AssetInfo(name string) (os.FileInfo, error) { + cannonicalName := strings.Replace(name, "\\", "/", -1) + if f, ok := _bindata[cannonicalName]; ok { + a, err := f() + if err != nil { + return nil, fmt.Errorf("AssetInfo %s can't read by error: %v", name, err) + } + return a.info, nil + } + return nil, fmt.Errorf("AssetInfo %s not found", name) +} + +// AssetNames returns the names of the assets. +func AssetNames() []string { + names := make([]string, 0, len(_bindata)) + for name := range _bindata { + names = append(names, name) + } + return names +} + +// _bindata is a table, holding each asset generator, mapped to its name. +var _bindata = map[string]func() (*asset, error){ + "in/a/test.asset": inATestAsset, + "in/b/test.asset": inBTestAsset, + "in/c/test.asset": inCTestAsset, + "in/test.asset": inTestAsset, +} + +// AssetDir returns the file names below a certain +// directory embedded in the file by go-bindata. +// For example if you run go-bindata on data/... and data contains the +// following hierarchy: +// data/ +// foo.txt +// img/ +// a.png +// b.png +// then AssetDir("data") would return []string{"foo.txt", "img"} +// AssetDir("data/img") would return []string{"a.png", "b.png"} +// AssetDir("foo.txt") and AssetDir("notexist") would return an error +// AssetDir("") will return []string{"data"}. +func AssetDir(name string) ([]string, error) { + node := _bintree + if len(name) != 0 { + cannonicalName := strings.Replace(name, "\\", "/", -1) + pathList := strings.Split(cannonicalName, "/") + for _, p := range pathList { + node = node.Children[p] + if node == nil { + return nil, fmt.Errorf("Asset %s not found", name) + } + } + } + if node.Func != nil { + return nil, fmt.Errorf("Asset %s not found", name) + } + rv := make([]string, 0, len(node.Children)) + for childName := range node.Children { + rv = append(rv, childName) + } + return rv, nil +} + +type bintree struct { + Func func() (*asset, error) + Children map[string]*bintree +} +var _bintree = &bintree{nil, map[string]*bintree{ + "in": &bintree{nil, map[string]*bintree{ + "a": &bintree{nil, map[string]*bintree{ + "test.asset": &bintree{inATestAsset, map[string]*bintree{}}, + }}, + "b": &bintree{nil, map[string]*bintree{ + "test.asset": &bintree{inBTestAsset, map[string]*bintree{}}, + }}, + "c": &bintree{nil, map[string]*bintree{ + "test.asset": &bintree{inCTestAsset, map[string]*bintree{}}, + }}, + "test.asset": &bintree{inTestAsset, map[string]*bintree{}}, + }}, +}} + +// RestoreAsset restores an asset under the given directory +func RestoreAsset(dir, name string) error { + data, err := Asset(name) + if err != nil { + return err + } + info, err := AssetInfo(name) + if err != nil { + return err + } + err = os.MkdirAll(_filePath(dir, filepath.Dir(name)), os.FileMode(0755)) + if err != nil { + return err + } + err = ioutil.WriteFile(_filePath(dir, name), data, info.Mode()) + if err != nil { + return err + } + err = os.Chtimes(_filePath(dir, name), info.ModTime(), info.ModTime()) + if err != nil { + return err + } + return nil +} + +// RestoreAssets restores an asset under the given directory recursively +func RestoreAssets(dir, name string) error { + children, err := AssetDir(name) + // File + if err != nil { + return RestoreAsset(dir, name) + } + // Dir + for _, child := range children { + err = RestoreAssets(dir, filepath.Join(name, child)) + if err != nil { + return err + } + } + return nil +} + +func _filePath(dir, name string) string { + cannonicalName := strings.Replace(name, "\\", "/", -1) + return filepath.Join(append([]string{dir}, strings.Split(cannonicalName, "/")...)...) +} + diff --git a/vendor/github.com/jteeuwen/go-bindata/testdata/out/debug.go b/vendor/github.com/jteeuwen/go-bindata/testdata/out/debug.go new file mode 100644 index 000000000..62ac6bf71 --- /dev/null +++ b/vendor/github.com/jteeuwen/go-bindata/testdata/out/debug.go @@ -0,0 +1,263 @@ +// Code generated by go-bindata. +// sources: +// in/a/test.asset +// in/b/test.asset +// in/c/test.asset +// in/test.asset +// DO NOT EDIT! + +package main + +import ( + "fmt" + "io/ioutil" + "os" + "path/filepath" + "strings" +) + +// bindataRead reads the given file from disk. It returns an error on failure. +func bindataRead(path, name string) ([]byte, error) { + buf, err := ioutil.ReadFile(path) + if err != nil { + err = fmt.Errorf("Error reading asset %s at %s: %v", name, path, err) + } + return buf, err +} + +type asset struct { + bytes []byte + info os.FileInfo +} + +// inATestAsset reads file data from disk. It returns an error on failure. +func inATestAsset() (*asset, error) { + path := "/home/ts/code/go/src/github.com/jteeuwen/go-bindata/testdata/in/a/test.asset" + name := "in/a/test.asset" + bytes, err := bindataRead(path, name) + if err != nil { + return nil, err + } + + fi, err := os.Stat(path) + if err != nil { + err = fmt.Errorf("Error reading asset info %s at %s: %v", name, path, err) + } + + a := &asset{bytes: bytes, info: fi} + return a, err +} + +// inBTestAsset reads file data from disk. It returns an error on failure. +func inBTestAsset() (*asset, error) { + path := "/home/ts/code/go/src/github.com/jteeuwen/go-bindata/testdata/in/b/test.asset" + name := "in/b/test.asset" + bytes, err := bindataRead(path, name) + if err != nil { + return nil, err + } + + fi, err := os.Stat(path) + if err != nil { + err = fmt.Errorf("Error reading asset info %s at %s: %v", name, path, err) + } + + a := &asset{bytes: bytes, info: fi} + return a, err +} + +// inCTestAsset reads file data from disk. It returns an error on failure. +func inCTestAsset() (*asset, error) { + path := "/home/ts/code/go/src/github.com/jteeuwen/go-bindata/testdata/in/c/test.asset" + name := "in/c/test.asset" + bytes, err := bindataRead(path, name) + if err != nil { + return nil, err + } + + fi, err := os.Stat(path) + if err != nil { + err = fmt.Errorf("Error reading asset info %s at %s: %v", name, path, err) + } + + a := &asset{bytes: bytes, info: fi} + return a, err +} + +// inTestAsset reads file data from disk. It returns an error on failure. +func inTestAsset() (*asset, error) { + path := "/home/ts/code/go/src/github.com/jteeuwen/go-bindata/testdata/in/test.asset" + name := "in/test.asset" + bytes, err := bindataRead(path, name) + if err != nil { + return nil, err + } + + fi, err := os.Stat(path) + if err != nil { + err = fmt.Errorf("Error reading asset info %s at %s: %v", name, path, err) + } + + a := &asset{bytes: bytes, info: fi} + return a, err +} + +// Asset loads and returns the asset for the given name. +// It returns an error if the asset could not be found or +// could not be loaded. +func Asset(name string) ([]byte, error) { + cannonicalName := strings.Replace(name, "\\", "/", -1) + if f, ok := _bindata[cannonicalName]; ok { + a, err := f() + if err != nil { + return nil, fmt.Errorf("Asset %s can't read by error: %v", name, err) + } + return a.bytes, nil + } + return nil, fmt.Errorf("Asset %s not found", name) +} + +// MustAsset is like Asset but panics when Asset would return an error. +// It simplifies safe initialization of global variables. +func MustAsset(name string) []byte { + a, err := Asset(name) + if err != nil { + panic("asset: Asset(" + name + "): " + err.Error()) + } + + return a +} + +// AssetInfo loads and returns the asset info for the given name. +// It returns an error if the asset could not be found or +// could not be loaded. +func AssetInfo(name string) (os.FileInfo, error) { + cannonicalName := strings.Replace(name, "\\", "/", -1) + if f, ok := _bindata[cannonicalName]; ok { + a, err := f() + if err != nil { + return nil, fmt.Errorf("AssetInfo %s can't read by error: %v", name, err) + } + return a.info, nil + } + return nil, fmt.Errorf("AssetInfo %s not found", name) +} + +// AssetNames returns the names of the assets. +func AssetNames() []string { + names := make([]string, 0, len(_bindata)) + for name := range _bindata { + names = append(names, name) + } + return names +} + +// _bindata is a table, holding each asset generator, mapped to its name. +var _bindata = map[string]func() (*asset, error){ + "in/a/test.asset": inATestAsset, + "in/b/test.asset": inBTestAsset, + "in/c/test.asset": inCTestAsset, + "in/test.asset": inTestAsset, +} + +// AssetDir returns the file names below a certain +// directory embedded in the file by go-bindata. +// For example if you run go-bindata on data/... and data contains the +// following hierarchy: +// data/ +// foo.txt +// img/ +// a.png +// b.png +// then AssetDir("data") would return []string{"foo.txt", "img"} +// AssetDir("data/img") would return []string{"a.png", "b.png"} +// AssetDir("foo.txt") and AssetDir("notexist") would return an error +// AssetDir("") will return []string{"data"}. +func AssetDir(name string) ([]string, error) { + node := _bintree + if len(name) != 0 { + cannonicalName := strings.Replace(name, "\\", "/", -1) + pathList := strings.Split(cannonicalName, "/") + for _, p := range pathList { + node = node.Children[p] + if node == nil { + return nil, fmt.Errorf("Asset %s not found", name) + } + } + } + if node.Func != nil { + return nil, fmt.Errorf("Asset %s not found", name) + } + rv := make([]string, 0, len(node.Children)) + for childName := range node.Children { + rv = append(rv, childName) + } + return rv, nil +} + +type bintree struct { + Func func() (*asset, error) + Children map[string]*bintree +} +var _bintree = &bintree{nil, map[string]*bintree{ + "in": &bintree{nil, map[string]*bintree{ + "a": &bintree{nil, map[string]*bintree{ + "test.asset": &bintree{inATestAsset, map[string]*bintree{}}, + }}, + "b": &bintree{nil, map[string]*bintree{ + "test.asset": &bintree{inBTestAsset, map[string]*bintree{}}, + }}, + "c": &bintree{nil, map[string]*bintree{ + "test.asset": &bintree{inCTestAsset, map[string]*bintree{}}, + }}, + "test.asset": &bintree{inTestAsset, map[string]*bintree{}}, + }}, +}} + +// RestoreAsset restores an asset under the given directory +func RestoreAsset(dir, name string) error { + data, err := Asset(name) + if err != nil { + return err + } + info, err := AssetInfo(name) + if err != nil { + return err + } + err = os.MkdirAll(_filePath(dir, filepath.Dir(name)), os.FileMode(0755)) + if err != nil { + return err + } + err = ioutil.WriteFile(_filePath(dir, name), data, info.Mode()) + if err != nil { + return err + } + err = os.Chtimes(_filePath(dir, name), info.ModTime(), info.ModTime()) + if err != nil { + return err + } + return nil +} + +// RestoreAssets restores an asset under the given directory recursively +func RestoreAssets(dir, name string) error { + children, err := AssetDir(name) + // File + if err != nil { + return RestoreAsset(dir, name) + } + // Dir + for _, child := range children { + err = RestoreAssets(dir, filepath.Join(name, child)) + if err != nil { + return err + } + } + return nil +} + +func _filePath(dir, name string) string { + cannonicalName := strings.Replace(name, "\\", "/", -1) + return filepath.Join(append([]string{dir}, strings.Split(cannonicalName, "/")...)...) +} + diff --git a/vendor/github.com/jteeuwen/go-bindata/testdata/out/nocompress-memcopy.go b/vendor/github.com/jteeuwen/go-bindata/testdata/out/nocompress-memcopy.go new file mode 100644 index 000000000..fc4c49415 --- /dev/null +++ b/vendor/github.com/jteeuwen/go-bindata/testdata/out/nocompress-memcopy.go @@ -0,0 +1,280 @@ +// Code generated by go-bindata. +// sources: +// in/a/test.asset +// in/b/test.asset +// in/c/test.asset +// in/test.asset +// DO NOT EDIT! + +package main + +import ( + "fmt" + "io/ioutil" + "os" + "path/filepath" + "strings" + "time" +) +type asset struct { + bytes []byte + info os.FileInfo +} + +type bindataFileInfo struct { + name string + size int64 + mode os.FileMode + modTime time.Time +} + +func (fi bindataFileInfo) Name() string { + return fi.name +} +func (fi bindataFileInfo) Size() int64 { + return fi.size +} +func (fi bindataFileInfo) Mode() os.FileMode { + return fi.mode +} +func (fi bindataFileInfo) ModTime() time.Time { + return fi.modTime +} +func (fi bindataFileInfo) IsDir() bool { + return false +} +func (fi bindataFileInfo) Sys() interface{} { + return nil +} + +var _inATestAsset = []byte(`// sample file +`) + +func inATestAssetBytes() ([]byte, error) { + return _inATestAsset, nil +} + +func inATestAsset() (*asset, error) { + bytes, err := inATestAssetBytes() + if err != nil { + return nil, err + } + + info := bindataFileInfo{name: "in/a/test.asset", size: 15, mode: os.FileMode(436), modTime: time.Unix(1445582844, 0)} + a := &asset{bytes: bytes, info: info} + return a, nil +} + +var _inBTestAsset = []byte(`// sample file +`) + +func inBTestAssetBytes() ([]byte, error) { + return _inBTestAsset, nil +} + +func inBTestAsset() (*asset, error) { + bytes, err := inBTestAssetBytes() + if err != nil { + return nil, err + } + + info := bindataFileInfo{name: "in/b/test.asset", size: 15, mode: os.FileMode(436), modTime: time.Unix(1445582844, 0)} + a := &asset{bytes: bytes, info: info} + return a, nil +} + +var _inCTestAsset = []byte(`// sample file +`) + +func inCTestAssetBytes() ([]byte, error) { + return _inCTestAsset, nil +} + +func inCTestAsset() (*asset, error) { + bytes, err := inCTestAssetBytes() + if err != nil { + return nil, err + } + + info := bindataFileInfo{name: "in/c/test.asset", size: 15, mode: os.FileMode(436), modTime: time.Unix(1445582844, 0)} + a := &asset{bytes: bytes, info: info} + return a, nil +} + +var _inTestAsset = []byte(`// sample file +`) + +func inTestAssetBytes() ([]byte, error) { + return _inTestAsset, nil +} + +func inTestAsset() (*asset, error) { + bytes, err := inTestAssetBytes() + if err != nil { + return nil, err + } + + info := bindataFileInfo{name: "in/test.asset", size: 15, mode: os.FileMode(436), modTime: time.Unix(1445582844, 0)} + a := &asset{bytes: bytes, info: info} + return a, nil +} + +// Asset loads and returns the asset for the given name. +// It returns an error if the asset could not be found or +// could not be loaded. +func Asset(name string) ([]byte, error) { + cannonicalName := strings.Replace(name, "\\", "/", -1) + if f, ok := _bindata[cannonicalName]; ok { + a, err := f() + if err != nil { + return nil, fmt.Errorf("Asset %s can't read by error: %v", name, err) + } + return a.bytes, nil + } + return nil, fmt.Errorf("Asset %s not found", name) +} + +// MustAsset is like Asset but panics when Asset would return an error. +// It simplifies safe initialization of global variables. +func MustAsset(name string) []byte { + a, err := Asset(name) + if err != nil { + panic("asset: Asset(" + name + "): " + err.Error()) + } + + return a +} + +// AssetInfo loads and returns the asset info for the given name. +// It returns an error if the asset could not be found or +// could not be loaded. +func AssetInfo(name string) (os.FileInfo, error) { + cannonicalName := strings.Replace(name, "\\", "/", -1) + if f, ok := _bindata[cannonicalName]; ok { + a, err := f() + if err != nil { + return nil, fmt.Errorf("AssetInfo %s can't read by error: %v", name, err) + } + return a.info, nil + } + return nil, fmt.Errorf("AssetInfo %s not found", name) +} + +// AssetNames returns the names of the assets. +func AssetNames() []string { + names := make([]string, 0, len(_bindata)) + for name := range _bindata { + names = append(names, name) + } + return names +} + +// _bindata is a table, holding each asset generator, mapped to its name. +var _bindata = map[string]func() (*asset, error){ + "in/a/test.asset": inATestAsset, + "in/b/test.asset": inBTestAsset, + "in/c/test.asset": inCTestAsset, + "in/test.asset": inTestAsset, +} + +// AssetDir returns the file names below a certain +// directory embedded in the file by go-bindata. +// For example if you run go-bindata on data/... and data contains the +// following hierarchy: +// data/ +// foo.txt +// img/ +// a.png +// b.png +// then AssetDir("data") would return []string{"foo.txt", "img"} +// AssetDir("data/img") would return []string{"a.png", "b.png"} +// AssetDir("foo.txt") and AssetDir("notexist") would return an error +// AssetDir("") will return []string{"data"}. +func AssetDir(name string) ([]string, error) { + node := _bintree + if len(name) != 0 { + cannonicalName := strings.Replace(name, "\\", "/", -1) + pathList := strings.Split(cannonicalName, "/") + for _, p := range pathList { + node = node.Children[p] + if node == nil { + return nil, fmt.Errorf("Asset %s not found", name) + } + } + } + if node.Func != nil { + return nil, fmt.Errorf("Asset %s not found", name) + } + rv := make([]string, 0, len(node.Children)) + for childName := range node.Children { + rv = append(rv, childName) + } + return rv, nil +} + +type bintree struct { + Func func() (*asset, error) + Children map[string]*bintree +} +var _bintree = &bintree{nil, map[string]*bintree{ + "in": &bintree{nil, map[string]*bintree{ + "a": &bintree{nil, map[string]*bintree{ + "test.asset": &bintree{inATestAsset, map[string]*bintree{}}, + }}, + "b": &bintree{nil, map[string]*bintree{ + "test.asset": &bintree{inBTestAsset, map[string]*bintree{}}, + }}, + "c": &bintree{nil, map[string]*bintree{ + "test.asset": &bintree{inCTestAsset, map[string]*bintree{}}, + }}, + "test.asset": &bintree{inTestAsset, map[string]*bintree{}}, + }}, +}} + +// RestoreAsset restores an asset under the given directory +func RestoreAsset(dir, name string) error { + data, err := Asset(name) + if err != nil { + return err + } + info, err := AssetInfo(name) + if err != nil { + return err + } + err = os.MkdirAll(_filePath(dir, filepath.Dir(name)), os.FileMode(0755)) + if err != nil { + return err + } + err = ioutil.WriteFile(_filePath(dir, name), data, info.Mode()) + if err != nil { + return err + } + err = os.Chtimes(_filePath(dir, name), info.ModTime(), info.ModTime()) + if err != nil { + return err + } + return nil +} + +// RestoreAssets restores an asset under the given directory recursively +func RestoreAssets(dir, name string) error { + children, err := AssetDir(name) + // File + if err != nil { + return RestoreAsset(dir, name) + } + // Dir + for _, child := range children { + err = RestoreAssets(dir, filepath.Join(name, child)) + if err != nil { + return err + } + } + return nil +} + +func _filePath(dir, name string) string { + cannonicalName := strings.Replace(name, "\\", "/", -1) + return filepath.Join(append([]string{dir}, strings.Split(cannonicalName, "/")...)...) +} + diff --git a/vendor/github.com/jteeuwen/go-bindata/testdata/out/nocompress-nomemcopy.go b/vendor/github.com/jteeuwen/go-bindata/testdata/out/nocompress-nomemcopy.go new file mode 100644 index 000000000..9504f0a64 --- /dev/null +++ b/vendor/github.com/jteeuwen/go-bindata/testdata/out/nocompress-nomemcopy.go @@ -0,0 +1,302 @@ +// Code generated by go-bindata. +// sources: +// in/a/test.asset +// in/b/test.asset +// in/c/test.asset +// in/test.asset +// DO NOT EDIT! + +package main + +import ( + "fmt" + "io/ioutil" + "os" + "path/filepath" + "reflect" + "strings" + "time" + "unsafe" +) + +func bindataRead(data, name string) ([]byte, error) { + var empty [0]byte + sx := (*reflect.StringHeader)(unsafe.Pointer(&data)) + b := empty[:] + bx := (*reflect.SliceHeader)(unsafe.Pointer(&b)) + bx.Data = sx.Data + bx.Len = len(data) + bx.Cap = bx.Len + return b, nil +} + +type asset struct { + bytes []byte + info os.FileInfo +} + +type bindataFileInfo struct { + name string + size int64 + mode os.FileMode + modTime time.Time +} + +func (fi bindataFileInfo) Name() string { + return fi.name +} +func (fi bindataFileInfo) Size() int64 { + return fi.size +} +func (fi bindataFileInfo) Mode() os.FileMode { + return fi.mode +} +func (fi bindataFileInfo) ModTime() time.Time { + return fi.modTime +} +func (fi bindataFileInfo) IsDir() bool { + return false +} +func (fi bindataFileInfo) Sys() interface{} { + return nil +} + +var _inATestAsset = "\x2f\x2f\x20\x73\x61\x6d\x70\x6c\x65\x20\x66\x69\x6c\x65\x0a" + +func inATestAssetBytes() ([]byte, error) { + return bindataRead( + _inATestAsset, + "in/a/test.asset", + ) +} + +func inATestAsset() (*asset, error) { + bytes, err := inATestAssetBytes() + if err != nil { + return nil, err + } + + info := bindataFileInfo{name: "in/a/test.asset", size: 15, mode: os.FileMode(436), modTime: time.Unix(1445582844, 0)} + a := &asset{bytes: bytes, info: info} + return a, nil +} + +var _inBTestAsset = "\x2f\x2f\x20\x73\x61\x6d\x70\x6c\x65\x20\x66\x69\x6c\x65\x0a" + +func inBTestAssetBytes() ([]byte, error) { + return bindataRead( + _inBTestAsset, + "in/b/test.asset", + ) +} + +func inBTestAsset() (*asset, error) { + bytes, err := inBTestAssetBytes() + if err != nil { + return nil, err + } + + info := bindataFileInfo{name: "in/b/test.asset", size: 15, mode: os.FileMode(436), modTime: time.Unix(1445582844, 0)} + a := &asset{bytes: bytes, info: info} + return a, nil +} + +var _inCTestAsset = "\x2f\x2f\x20\x73\x61\x6d\x70\x6c\x65\x20\x66\x69\x6c\x65\x0a" + +func inCTestAssetBytes() ([]byte, error) { + return bindataRead( + _inCTestAsset, + "in/c/test.asset", + ) +} + +func inCTestAsset() (*asset, error) { + bytes, err := inCTestAssetBytes() + if err != nil { + return nil, err + } + + info := bindataFileInfo{name: "in/c/test.asset", size: 15, mode: os.FileMode(436), modTime: time.Unix(1445582844, 0)} + a := &asset{bytes: bytes, info: info} + return a, nil +} + +var _inTestAsset = "\x2f\x2f\x20\x73\x61\x6d\x70\x6c\x65\x20\x66\x69\x6c\x65\x0a" + +func inTestAssetBytes() ([]byte, error) { + return bindataRead( + _inTestAsset, + "in/test.asset", + ) +} + +func inTestAsset() (*asset, error) { + bytes, err := inTestAssetBytes() + if err != nil { + return nil, err + } + + info := bindataFileInfo{name: "in/test.asset", size: 15, mode: os.FileMode(436), modTime: time.Unix(1445582844, 0)} + a := &asset{bytes: bytes, info: info} + return a, nil +} + +// Asset loads and returns the asset for the given name. +// It returns an error if the asset could not be found or +// could not be loaded. +func Asset(name string) ([]byte, error) { + cannonicalName := strings.Replace(name, "\\", "/", -1) + if f, ok := _bindata[cannonicalName]; ok { + a, err := f() + if err != nil { + return nil, fmt.Errorf("Asset %s can't read by error: %v", name, err) + } + return a.bytes, nil + } + return nil, fmt.Errorf("Asset %s not found", name) +} + +// MustAsset is like Asset but panics when Asset would return an error. +// It simplifies safe initialization of global variables. +func MustAsset(name string) []byte { + a, err := Asset(name) + if err != nil { + panic("asset: Asset(" + name + "): " + err.Error()) + } + + return a +} + +// AssetInfo loads and returns the asset info for the given name. +// It returns an error if the asset could not be found or +// could not be loaded. +func AssetInfo(name string) (os.FileInfo, error) { + cannonicalName := strings.Replace(name, "\\", "/", -1) + if f, ok := _bindata[cannonicalName]; ok { + a, err := f() + if err != nil { + return nil, fmt.Errorf("AssetInfo %s can't read by error: %v", name, err) + } + return a.info, nil + } + return nil, fmt.Errorf("AssetInfo %s not found", name) +} + +// AssetNames returns the names of the assets. +func AssetNames() []string { + names := make([]string, 0, len(_bindata)) + for name := range _bindata { + names = append(names, name) + } + return names +} + +// _bindata is a table, holding each asset generator, mapped to its name. +var _bindata = map[string]func() (*asset, error){ + "in/a/test.asset": inATestAsset, + "in/b/test.asset": inBTestAsset, + "in/c/test.asset": inCTestAsset, + "in/test.asset": inTestAsset, +} + +// AssetDir returns the file names below a certain +// directory embedded in the file by go-bindata. +// For example if you run go-bindata on data/... and data contains the +// following hierarchy: +// data/ +// foo.txt +// img/ +// a.png +// b.png +// then AssetDir("data") would return []string{"foo.txt", "img"} +// AssetDir("data/img") would return []string{"a.png", "b.png"} +// AssetDir("foo.txt") and AssetDir("notexist") would return an error +// AssetDir("") will return []string{"data"}. +func AssetDir(name string) ([]string, error) { + node := _bintree + if len(name) != 0 { + cannonicalName := strings.Replace(name, "\\", "/", -1) + pathList := strings.Split(cannonicalName, "/") + for _, p := range pathList { + node = node.Children[p] + if node == nil { + return nil, fmt.Errorf("Asset %s not found", name) + } + } + } + if node.Func != nil { + return nil, fmt.Errorf("Asset %s not found", name) + } + rv := make([]string, 0, len(node.Children)) + for childName := range node.Children { + rv = append(rv, childName) + } + return rv, nil +} + +type bintree struct { + Func func() (*asset, error) + Children map[string]*bintree +} +var _bintree = &bintree{nil, map[string]*bintree{ + "in": &bintree{nil, map[string]*bintree{ + "a": &bintree{nil, map[string]*bintree{ + "test.asset": &bintree{inATestAsset, map[string]*bintree{}}, + }}, + "b": &bintree{nil, map[string]*bintree{ + "test.asset": &bintree{inBTestAsset, map[string]*bintree{}}, + }}, + "c": &bintree{nil, map[string]*bintree{ + "test.asset": &bintree{inCTestAsset, map[string]*bintree{}}, + }}, + "test.asset": &bintree{inTestAsset, map[string]*bintree{}}, + }}, +}} + +// RestoreAsset restores an asset under the given directory +func RestoreAsset(dir, name string) error { + data, err := Asset(name) + if err != nil { + return err + } + info, err := AssetInfo(name) + if err != nil { + return err + } + err = os.MkdirAll(_filePath(dir, filepath.Dir(name)), os.FileMode(0755)) + if err != nil { + return err + } + err = ioutil.WriteFile(_filePath(dir, name), data, info.Mode()) + if err != nil { + return err + } + err = os.Chtimes(_filePath(dir, name), info.ModTime(), info.ModTime()) + if err != nil { + return err + } + return nil +} + +// RestoreAssets restores an asset under the given directory recursively +func RestoreAssets(dir, name string) error { + children, err := AssetDir(name) + // File + if err != nil { + return RestoreAsset(dir, name) + } + // Dir + for _, child := range children { + err = RestoreAssets(dir, filepath.Join(name, child)) + if err != nil { + return err + } + } + return nil +} + +func _filePath(dir, name string) string { + cannonicalName := strings.Replace(name, "\\", "/", -1) + return filepath.Join(append([]string{dir}, strings.Split(cannonicalName, "/")...)...) +} + diff --git a/vendor/github.com/jteeuwen/go-bindata/testdata/symlinkFile/file1 b/vendor/github.com/jteeuwen/go-bindata/testdata/symlinkFile/file1 new file mode 120000 index 000000000..6e09272b6 --- /dev/null +++ b/vendor/github.com/jteeuwen/go-bindata/testdata/symlinkFile/file1 @@ -0,0 +1 @@ +../symlinkSrc/file1 \ No newline at end of file diff --git a/vendor/github.com/jteeuwen/go-bindata/testdata/symlinkParent/symlinkTarget b/vendor/github.com/jteeuwen/go-bindata/testdata/symlinkParent/symlinkTarget new file mode 120000 index 000000000..ccb1f73af --- /dev/null +++ b/vendor/github.com/jteeuwen/go-bindata/testdata/symlinkParent/symlinkTarget @@ -0,0 +1 @@ +../symlinkSrc/ \ No newline at end of file diff --git a/vendor/github.com/jteeuwen/go-bindata/testdata/symlinkRecursiveParent/symlinkTarget b/vendor/github.com/jteeuwen/go-bindata/testdata/symlinkRecursiveParent/symlinkTarget new file mode 120000 index 000000000..2ee9371dc --- /dev/null +++ b/vendor/github.com/jteeuwen/go-bindata/testdata/symlinkRecursiveParent/symlinkTarget @@ -0,0 +1 @@ +../symlinkRecursiveParent/ \ No newline at end of file diff --git a/vendor/github.com/jteeuwen/go-bindata/toc.go b/vendor/github.com/jteeuwen/go-bindata/toc.go new file mode 100644 index 000000000..9ec410b25 --- /dev/null +++ b/vendor/github.com/jteeuwen/go-bindata/toc.go @@ -0,0 +1,230 @@ +// This work is subject to the CC0 1.0 Universal (CC0 1.0) Public Domain Dedication +// license. Its contents can be found at: +// http://creativecommons.org/publicdomain/zero/1.0/ + +package bindata + +import ( + "fmt" + "io" + "sort" + "strings" +) + +type assetTree struct { + Asset Asset + Children map[string]*assetTree +} + +func newAssetTree() *assetTree { + tree := &assetTree{} + tree.Children = make(map[string]*assetTree) + return tree +} + +func (node *assetTree) child(name string) *assetTree { + rv, ok := node.Children[name] + if !ok { + rv = newAssetTree() + node.Children[name] = rv + } + return rv +} + +func (root *assetTree) Add(route []string, asset Asset) { + for _, name := range route { + root = root.child(name) + } + root.Asset = asset +} + +func ident(w io.Writer, n int) { + for i := 0; i < n; i++ { + w.Write([]byte{'\t'}) + } +} + +func (root *assetTree) funcOrNil() string { + if root.Asset.Func == "" { + return "nil" + } else { + return root.Asset.Func + } +} + +func (root *assetTree) writeGoMap(w io.Writer, nident int) { + fmt.Fprintf(w, "&bintree{%s, map[string]*bintree{", root.funcOrNil()) + + if len(root.Children) > 0 { + io.WriteString(w, "\n") + + // Sort to make output stable between invocations + filenames := make([]string, len(root.Children)) + i := 0 + for filename, _ := range root.Children { + filenames[i] = filename + i++ + } + sort.Strings(filenames) + + for _, p := range filenames { + ident(w, nident+1) + fmt.Fprintf(w, `"%s": `, p) + root.Children[p].writeGoMap(w, nident+1) + } + ident(w, nident) + } + + io.WriteString(w, "}}") + if nident > 0 { + io.WriteString(w, ",") + } + io.WriteString(w, "\n") +} + +func (root *assetTree) WriteAsGoMap(w io.Writer) error { + _, err := fmt.Fprint(w, `type bintree struct { + Func func() (*asset, error) + Children map[string]*bintree +} +var _bintree = `) + root.writeGoMap(w, 0) + return err +} + +func writeTOCTree(w io.Writer, toc []Asset) error { + _, err := fmt.Fprintf(w, `// AssetDir returns the file names below a certain +// directory embedded in the file by go-bindata. +// For example if you run go-bindata on data/... and data contains the +// following hierarchy: +// data/ +// foo.txt +// img/ +// a.png +// b.png +// then AssetDir("data") would return []string{"foo.txt", "img"} +// AssetDir("data/img") would return []string{"a.png", "b.png"} +// AssetDir("foo.txt") and AssetDir("notexist") would return an error +// AssetDir("") will return []string{"data"}. +func AssetDir(name string) ([]string, error) { + node := _bintree + if len(name) != 0 { + cannonicalName := strings.Replace(name, "\\", "/", -1) + pathList := strings.Split(cannonicalName, "/") + for _, p := range pathList { + node = node.Children[p] + if node == nil { + return nil, fmt.Errorf("Asset %%s not found", name) + } + } + } + if node.Func != nil { + return nil, fmt.Errorf("Asset %%s not found", name) + } + rv := make([]string, 0, len(node.Children)) + for childName := range node.Children { + rv = append(rv, childName) + } + return rv, nil +} + +`) + if err != nil { + return err + } + tree := newAssetTree() + for i := range toc { + pathList := strings.Split(toc[i].Name, "/") + tree.Add(pathList, toc[i]) + } + return tree.WriteAsGoMap(w) +} + +// writeTOC writes the table of contents file. +func writeTOC(w io.Writer, toc []Asset) error { + err := writeTOCHeader(w) + if err != nil { + return err + } + + for i := range toc { + err = writeTOCAsset(w, &toc[i]) + if err != nil { + return err + } + } + + return writeTOCFooter(w) +} + +// writeTOCHeader writes the table of contents file header. +func writeTOCHeader(w io.Writer) error { + _, err := fmt.Fprintf(w, `// Asset loads and returns the asset for the given name. +// It returns an error if the asset could not be found or +// could not be loaded. +func Asset(name string) ([]byte, error) { + cannonicalName := strings.Replace(name, "\\", "/", -1) + if f, ok := _bindata[cannonicalName]; ok { + a, err := f() + if err != nil { + return nil, fmt.Errorf("Asset %%s can't read by error: %%v", name, err) + } + return a.bytes, nil + } + return nil, fmt.Errorf("Asset %%s not found", name) +} + +// MustAsset is like Asset but panics when Asset would return an error. +// It simplifies safe initialization of global variables. +func MustAsset(name string) []byte { + a, err := Asset(name) + if err != nil { + panic("asset: Asset(" + name + "): " + err.Error()) + } + + return a +} + +// AssetInfo loads and returns the asset info for the given name. +// It returns an error if the asset could not be found or +// could not be loaded. +func AssetInfo(name string) (os.FileInfo, error) { + cannonicalName := strings.Replace(name, "\\", "/", -1) + if f, ok := _bindata[cannonicalName]; ok { + a, err := f() + if err != nil { + return nil, fmt.Errorf("AssetInfo %%s can't read by error: %%v", name, err) + } + return a.info, nil + } + return nil, fmt.Errorf("AssetInfo %%s not found", name) +} + +// AssetNames returns the names of the assets. +func AssetNames() []string { + names := make([]string, 0, len(_bindata)) + for name := range _bindata { + names = append(names, name) + } + return names +} + +// _bindata is a table, holding each asset generator, mapped to its name. +var _bindata = map[string]func() (*asset, error){ +`) + return err +} + +// writeTOCAsset write a TOC entry for the given asset. +func writeTOCAsset(w io.Writer, asset *Asset) error { + _, err := fmt.Fprintf(w, "\t%q: %s,\n", asset.Name, asset.Func) + return err +} + +// writeTOCFooter writes the table of contents file footer. +func writeTOCFooter(w io.Writer) error { + _, err := fmt.Fprintf(w, `} + +`) + return err +} diff --git a/version/version.go b/version/version.go index e3e130bf9..10a766d94 100644 --- a/version/version.go +++ b/version/version.go @@ -1,5 +1,6 @@ package version var ( + // Version is the version of cluster-storage-operator Version = "0.0.1" )