Merge f731cdcb2b
into bc6e5840b6
This commit is contained in:
commit
e3432a021b
1255 changed files with 186047 additions and 303152 deletions
1092
Godeps/Godeps.json
generated
1092
Godeps/Godeps.json
generated
File diff suppressed because it is too large
Load diff
|
@ -26,10 +26,10 @@ import (
|
||||||
"github.com/golang/glog"
|
"github.com/golang/glog"
|
||||||
|
|
||||||
compute "google.golang.org/api/compute/v1"
|
compute "google.golang.org/api/compute/v1"
|
||||||
|
api_v1 "k8s.io/api/core/v1"
|
||||||
"k8s.io/apimachinery/pkg/types"
|
"k8s.io/apimachinery/pkg/types"
|
||||||
"k8s.io/apimachinery/pkg/util/intstr"
|
"k8s.io/apimachinery/pkg/util/intstr"
|
||||||
"k8s.io/apimachinery/pkg/util/sets"
|
"k8s.io/apimachinery/pkg/util/sets"
|
||||||
api_v1 "k8s.io/client-go/pkg/api/v1"
|
|
||||||
|
|
||||||
"k8s.io/ingress/controllers/gce/healthchecks"
|
"k8s.io/ingress/controllers/gce/healthchecks"
|
||||||
"k8s.io/ingress/controllers/gce/instances"
|
"k8s.io/ingress/controllers/gce/instances"
|
||||||
|
|
|
@ -23,9 +23,9 @@ import (
|
||||||
|
|
||||||
compute "google.golang.org/api/compute/v1"
|
compute "google.golang.org/api/compute/v1"
|
||||||
"google.golang.org/api/googleapi"
|
"google.golang.org/api/googleapi"
|
||||||
|
api_v1 "k8s.io/api/core/v1"
|
||||||
"k8s.io/apimachinery/pkg/util/intstr"
|
"k8s.io/apimachinery/pkg/util/intstr"
|
||||||
"k8s.io/apimachinery/pkg/util/sets"
|
"k8s.io/apimachinery/pkg/util/sets"
|
||||||
api_v1 "k8s.io/client-go/pkg/api/v1"
|
|
||||||
|
|
||||||
"k8s.io/ingress/controllers/gce/healthchecks"
|
"k8s.io/ingress/controllers/gce/healthchecks"
|
||||||
"k8s.io/ingress/controllers/gce/instances"
|
"k8s.io/ingress/controllers/gce/instances"
|
||||||
|
|
|
@ -20,7 +20,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
compute "google.golang.org/api/compute/v1"
|
compute "google.golang.org/api/compute/v1"
|
||||||
api_v1 "k8s.io/client-go/pkg/api/v1"
|
api_v1 "k8s.io/api/core/v1"
|
||||||
"k8s.io/client-go/tools/cache"
|
"k8s.io/client-go/tools/cache"
|
||||||
|
|
||||||
"k8s.io/ingress/controllers/gce/utils"
|
"k8s.io/ingress/controllers/gce/utils"
|
||||||
|
|
|
@ -18,7 +18,7 @@ package backends
|
||||||
|
|
||||||
import (
|
import (
|
||||||
compute "google.golang.org/api/compute/v1"
|
compute "google.golang.org/api/compute/v1"
|
||||||
api_v1 "k8s.io/client-go/pkg/api/v1"
|
api_v1 "k8s.io/api/core/v1"
|
||||||
)
|
)
|
||||||
|
|
||||||
// ProbeProvider retrieves a probe struct given a nodePort
|
// ProbeProvider retrieves a probe struct given a nodePort
|
||||||
|
|
|
@ -24,14 +24,14 @@ import (
|
||||||
|
|
||||||
"github.com/golang/glog"
|
"github.com/golang/glog"
|
||||||
|
|
||||||
|
api_v1 "k8s.io/api/core/v1"
|
||||||
|
extensions "k8s.io/api/extensions/v1beta1"
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
"k8s.io/apimachinery/pkg/fields"
|
"k8s.io/apimachinery/pkg/fields"
|
||||||
"k8s.io/client-go/kubernetes"
|
"k8s.io/client-go/kubernetes"
|
||||||
scheme "k8s.io/client-go/kubernetes/scheme"
|
scheme "k8s.io/client-go/kubernetes/scheme"
|
||||||
unversionedcore "k8s.io/client-go/kubernetes/typed/core/v1"
|
unversionedcore "k8s.io/client-go/kubernetes/typed/core/v1"
|
||||||
listers "k8s.io/client-go/listers/core/v1"
|
listers "k8s.io/client-go/listers/core/v1"
|
||||||
api_v1 "k8s.io/client-go/pkg/api/v1"
|
|
||||||
extensions "k8s.io/client-go/pkg/apis/extensions/v1beta1"
|
|
||||||
"k8s.io/client-go/tools/cache"
|
"k8s.io/client-go/tools/cache"
|
||||||
"k8s.io/client-go/tools/record"
|
"k8s.io/client-go/tools/record"
|
||||||
|
|
||||||
|
|
|
@ -24,14 +24,14 @@ import (
|
||||||
|
|
||||||
compute "google.golang.org/api/compute/v1"
|
compute "google.golang.org/api/compute/v1"
|
||||||
|
|
||||||
|
api_v1 "k8s.io/api/core/v1"
|
||||||
|
extensions "k8s.io/api/extensions/v1beta1"
|
||||||
meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
"k8s.io/apimachinery/pkg/util/intstr"
|
"k8s.io/apimachinery/pkg/util/intstr"
|
||||||
"k8s.io/apimachinery/pkg/util/sets"
|
"k8s.io/apimachinery/pkg/util/sets"
|
||||||
"k8s.io/apimachinery/pkg/util/uuid"
|
"k8s.io/apimachinery/pkg/util/uuid"
|
||||||
"k8s.io/client-go/kubernetes/fake"
|
"k8s.io/client-go/kubernetes/fake"
|
||||||
"k8s.io/client-go/pkg/api"
|
"k8s.io/kubernetes/pkg/api"
|
||||||
api_v1 "k8s.io/client-go/pkg/api/v1"
|
|
||||||
extensions "k8s.io/client-go/pkg/apis/extensions/v1beta1"
|
|
||||||
|
|
||||||
"k8s.io/ingress/controllers/gce/firewalls"
|
"k8s.io/ingress/controllers/gce/firewalls"
|
||||||
"k8s.io/ingress/controllers/gce/loadbalancers"
|
"k8s.io/ingress/controllers/gce/loadbalancers"
|
||||||
|
|
|
@ -21,10 +21,10 @@ import (
|
||||||
|
|
||||||
"github.com/golang/glog"
|
"github.com/golang/glog"
|
||||||
|
|
||||||
|
api_v1 "k8s.io/api/core/v1"
|
||||||
|
extensions "k8s.io/api/extensions/v1beta1"
|
||||||
meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
"k8s.io/client-go/kubernetes"
|
"k8s.io/client-go/kubernetes"
|
||||||
api_v1 "k8s.io/client-go/pkg/api/v1"
|
|
||||||
extensions "k8s.io/client-go/pkg/apis/extensions/v1beta1"
|
|
||||||
|
|
||||||
"k8s.io/ingress/controllers/gce/loadbalancers"
|
"k8s.io/ingress/controllers/gce/loadbalancers"
|
||||||
)
|
)
|
||||||
|
|
|
@ -21,10 +21,10 @@ import (
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
api_v1 "k8s.io/api/core/v1"
|
||||||
meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
"k8s.io/apimachinery/pkg/util/intstr"
|
"k8s.io/apimachinery/pkg/util/intstr"
|
||||||
"k8s.io/apimachinery/pkg/util/sets"
|
"k8s.io/apimachinery/pkg/util/sets"
|
||||||
api_v1 "k8s.io/client-go/pkg/api/v1"
|
|
||||||
"k8s.io/ingress/controllers/gce/backends"
|
"k8s.io/ingress/controllers/gce/backends"
|
||||||
"k8s.io/ingress/controllers/gce/utils"
|
"k8s.io/ingress/controllers/gce/utils"
|
||||||
)
|
)
|
||||||
|
|
|
@ -26,6 +26,8 @@ import (
|
||||||
"github.com/golang/glog"
|
"github.com/golang/glog"
|
||||||
|
|
||||||
compute "google.golang.org/api/compute/v1"
|
compute "google.golang.org/api/compute/v1"
|
||||||
|
api_v1 "k8s.io/api/core/v1"
|
||||||
|
extensions "k8s.io/api/extensions/v1beta1"
|
||||||
"k8s.io/apimachinery/pkg/api/meta"
|
"k8s.io/apimachinery/pkg/api/meta"
|
||||||
meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
"k8s.io/apimachinery/pkg/labels"
|
"k8s.io/apimachinery/pkg/labels"
|
||||||
|
@ -34,8 +36,6 @@ import (
|
||||||
"k8s.io/apimachinery/pkg/util/sets"
|
"k8s.io/apimachinery/pkg/util/sets"
|
||||||
"k8s.io/apimachinery/pkg/util/wait"
|
"k8s.io/apimachinery/pkg/util/wait"
|
||||||
listers "k8s.io/client-go/listers/core/v1"
|
listers "k8s.io/client-go/listers/core/v1"
|
||||||
api_v1 "k8s.io/client-go/pkg/api/v1"
|
|
||||||
extensions "k8s.io/client-go/pkg/apis/extensions/v1beta1"
|
|
||||||
"k8s.io/client-go/tools/cache"
|
"k8s.io/client-go/tools/cache"
|
||||||
"k8s.io/client-go/util/workqueue"
|
"k8s.io/client-go/util/workqueue"
|
||||||
|
|
||||||
|
|
|
@ -26,13 +26,13 @@ import (
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"log"
|
"log"
|
||||||
|
|
||||||
|
api_v1 "k8s.io/api/core/v1"
|
||||||
registered "k8s.io/apimachinery/pkg/apimachinery/registered"
|
registered "k8s.io/apimachinery/pkg/apimachinery/registered"
|
||||||
meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
"k8s.io/apimachinery/pkg/runtime"
|
"k8s.io/apimachinery/pkg/runtime"
|
||||||
"k8s.io/client-go/pkg/api"
|
|
||||||
api_v1 "k8s.io/client-go/pkg/api/v1"
|
|
||||||
|
|
||||||
// This installs the legacy v1 API
|
// This installs the legacy v1 API
|
||||||
|
"k8s.io/kubernetes/pkg/api"
|
||||||
_ "k8s.io/kubernetes/pkg/api/install"
|
_ "k8s.io/kubernetes/pkg/api/install"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -36,8 +36,8 @@ import (
|
||||||
"k8s.io/apimachinery/pkg/util/intstr"
|
"k8s.io/apimachinery/pkg/util/intstr"
|
||||||
"k8s.io/apimachinery/pkg/util/wait"
|
"k8s.io/apimachinery/pkg/util/wait"
|
||||||
"k8s.io/client-go/kubernetes"
|
"k8s.io/client-go/kubernetes"
|
||||||
"k8s.io/client-go/pkg/api"
|
"k8s.io/api/core/v1"
|
||||||
api_v1 "k8s.io/client-go/pkg/api/v1"
|
api_v1 "k8s.io/api/core/v1"
|
||||||
"k8s.io/client-go/rest"
|
"k8s.io/client-go/rest"
|
||||||
"k8s.io/client-go/tools/clientcmd"
|
"k8s.io/client-go/tools/clientcmd"
|
||||||
clientcmdapi "k8s.io/client-go/tools/clientcmd/api"
|
clientcmdapi "k8s.io/client-go/tools/clientcmd/api"
|
||||||
|
|
|
@ -23,10 +23,10 @@ import (
|
||||||
|
|
||||||
"github.com/golang/glog"
|
"github.com/golang/glog"
|
||||||
|
|
||||||
|
api_v1 "k8s.io/api/core/v1"
|
||||||
"k8s.io/apimachinery/pkg/api/errors"
|
"k8s.io/apimachinery/pkg/api/errors"
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
"k8s.io/client-go/kubernetes"
|
"k8s.io/client-go/kubernetes"
|
||||||
api_v1 "k8s.io/client-go/pkg/api/v1"
|
|
||||||
"k8s.io/client-go/tools/cache"
|
"k8s.io/client-go/tools/cache"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,7 @@ package storage
|
||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"k8s.io/client-go/pkg/api"
|
api "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestConfigMapUID(t *testing.T) {
|
func TestConfigMapUID(t *testing.T) {
|
||||||
|
|
|
@ -34,7 +34,7 @@ import (
|
||||||
"github.com/spf13/pflag"
|
"github.com/spf13/pflag"
|
||||||
|
|
||||||
proxyproto "github.com/armon/go-proxyproto"
|
proxyproto "github.com/armon/go-proxyproto"
|
||||||
api_v1 "k8s.io/client-go/pkg/api/v1"
|
api_v1 "k8s.io/api/core/v1"
|
||||||
|
|
||||||
"k8s.io/ingress/controllers/nginx/pkg/config"
|
"k8s.io/ingress/controllers/nginx/pkg/config"
|
||||||
ngx_template "k8s.io/ingress/controllers/nginx/pkg/template"
|
ngx_template "k8s.io/ingress/controllers/nginx/pkg/template"
|
||||||
|
|
|
@ -24,8 +24,8 @@ import (
|
||||||
"regexp"
|
"regexp"
|
||||||
|
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
api "k8s.io/client-go/pkg/api/v1"
|
api "k8s.io/api/core/v1"
|
||||||
extensions "k8s.io/client-go/pkg/apis/extensions/v1beta1"
|
extensions "k8s.io/api/extensions/v1beta1"
|
||||||
|
|
||||||
"k8s.io/ingress/core/pkg/ingress/annotations/parser"
|
"k8s.io/ingress/core/pkg/ingress/annotations/parser"
|
||||||
ing_errors "k8s.io/ingress/core/pkg/ingress/errors"
|
ing_errors "k8s.io/ingress/core/pkg/ingress/errors"
|
||||||
|
|
|
@ -25,10 +25,10 @@ import (
|
||||||
|
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
|
|
||||||
|
api "k8s.io/api/core/v1"
|
||||||
|
extensions "k8s.io/api/extensions/v1beta1"
|
||||||
meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
"k8s.io/apimachinery/pkg/util/intstr"
|
"k8s.io/apimachinery/pkg/util/intstr"
|
||||||
api "k8s.io/client-go/pkg/api/v1"
|
|
||||||
extensions "k8s.io/client-go/pkg/apis/extensions/v1beta1"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func buildIngress() *extensions.Ingress {
|
func buildIngress() *extensions.Ingress {
|
||||||
|
|
|
@ -21,7 +21,7 @@ import (
|
||||||
"regexp"
|
"regexp"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
extensions "k8s.io/client-go/pkg/apis/extensions/v1beta1"
|
extensions "k8s.io/api/extensions/v1beta1"
|
||||||
|
|
||||||
"k8s.io/ingress/core/pkg/ingress/annotations/parser"
|
"k8s.io/ingress/core/pkg/ingress/annotations/parser"
|
||||||
ing_errors "k8s.io/ingress/core/pkg/ingress/errors"
|
ing_errors "k8s.io/ingress/core/pkg/ingress/errors"
|
||||||
|
|
|
@ -21,9 +21,9 @@ import (
|
||||||
"reflect"
|
"reflect"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
api "k8s.io/api/core/v1"
|
||||||
|
extensions "k8s.io/api/extensions/v1beta1"
|
||||||
meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
api "k8s.io/client-go/pkg/api/v1"
|
|
||||||
extensions "k8s.io/client-go/pkg/apis/extensions/v1beta1"
|
|
||||||
|
|
||||||
"k8s.io/apimachinery/pkg/util/intstr"
|
"k8s.io/apimachinery/pkg/util/intstr"
|
||||||
)
|
)
|
||||||
|
|
|
@ -18,7 +18,7 @@ package authtls
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
extensions "k8s.io/client-go/pkg/apis/extensions/v1beta1"
|
extensions "k8s.io/api/extensions/v1beta1"
|
||||||
|
|
||||||
"k8s.io/ingress/core/pkg/ingress/annotations/parser"
|
"k8s.io/ingress/core/pkg/ingress/annotations/parser"
|
||||||
ing_errors "k8s.io/ingress/core/pkg/ingress/errors"
|
ing_errors "k8s.io/ingress/core/pkg/ingress/errors"
|
||||||
|
|
|
@ -19,10 +19,10 @@ package authtls
|
||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
api "k8s.io/api/core/v1"
|
||||||
|
extensions "k8s.io/api/extensions/v1beta1"
|
||||||
meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
"k8s.io/apimachinery/pkg/util/intstr"
|
"k8s.io/apimachinery/pkg/util/intstr"
|
||||||
api "k8s.io/client-go/pkg/api/v1"
|
|
||||||
extensions "k8s.io/client-go/pkg/apis/extensions/v1beta1"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func buildIngress() *extensions.Ingress {
|
func buildIngress() *extensions.Ingress {
|
||||||
|
|
|
@ -18,7 +18,7 @@ package class
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/golang/glog"
|
"github.com/golang/glog"
|
||||||
extensions "k8s.io/client-go/pkg/apis/extensions/v1beta1"
|
extensions "k8s.io/api/extensions/v1beta1"
|
||||||
|
|
||||||
"k8s.io/ingress/core/pkg/ingress/annotations/parser"
|
"k8s.io/ingress/core/pkg/ingress/annotations/parser"
|
||||||
"k8s.io/ingress/core/pkg/ingress/errors"
|
"k8s.io/ingress/core/pkg/ingress/errors"
|
||||||
|
|
|
@ -19,9 +19,9 @@ package class
|
||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
api "k8s.io/api/core/v1"
|
||||||
|
extensions "k8s.io/api/extensions/v1beta1"
|
||||||
meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
api "k8s.io/client-go/pkg/api/v1"
|
|
||||||
extensions "k8s.io/client-go/pkg/apis/extensions/v1beta1"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestIsValidClass(t *testing.T) {
|
func TestIsValidClass(t *testing.T) {
|
||||||
|
|
|
@ -17,7 +17,7 @@ limitations under the License.
|
||||||
package cors
|
package cors
|
||||||
|
|
||||||
import (
|
import (
|
||||||
extensions "k8s.io/client-go/pkg/apis/extensions/v1beta1"
|
extensions "k8s.io/api/extensions/v1beta1"
|
||||||
|
|
||||||
"k8s.io/ingress/core/pkg/ingress/annotations/parser"
|
"k8s.io/ingress/core/pkg/ingress/annotations/parser"
|
||||||
)
|
)
|
||||||
|
|
|
@ -19,9 +19,9 @@ package cors
|
||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
api "k8s.io/api/core/v1"
|
||||||
|
extensions "k8s.io/api/extensions/v1beta1"
|
||||||
meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
api "k8s.io/client-go/pkg/api/v1"
|
|
||||||
extensions "k8s.io/client-go/pkg/apis/extensions/v1beta1"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
|
|
@ -17,7 +17,7 @@ limitations under the License.
|
||||||
package healthcheck
|
package healthcheck
|
||||||
|
|
||||||
import (
|
import (
|
||||||
extensions "k8s.io/client-go/pkg/apis/extensions/v1beta1"
|
extensions "k8s.io/api/extensions/v1beta1"
|
||||||
|
|
||||||
"k8s.io/ingress/core/pkg/ingress/annotations/parser"
|
"k8s.io/ingress/core/pkg/ingress/annotations/parser"
|
||||||
"k8s.io/ingress/core/pkg/ingress/resolver"
|
"k8s.io/ingress/core/pkg/ingress/resolver"
|
||||||
|
|
|
@ -19,10 +19,10 @@ package healthcheck
|
||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
api "k8s.io/api/core/v1"
|
||||||
|
extensions "k8s.io/api/extensions/v1beta1"
|
||||||
meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
"k8s.io/apimachinery/pkg/util/intstr"
|
"k8s.io/apimachinery/pkg/util/intstr"
|
||||||
api "k8s.io/client-go/pkg/api/v1"
|
|
||||||
extensions "k8s.io/client-go/pkg/apis/extensions/v1beta1"
|
|
||||||
|
|
||||||
"k8s.io/ingress/core/pkg/ingress/defaults"
|
"k8s.io/ingress/core/pkg/ingress/defaults"
|
||||||
)
|
)
|
||||||
|
|
|
@ -22,7 +22,7 @@ import (
|
||||||
|
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
|
|
||||||
extensions "k8s.io/client-go/pkg/apis/extensions/v1beta1"
|
extensions "k8s.io/api/extensions/v1beta1"
|
||||||
"k8s.io/kubernetes/pkg/util/net/sets"
|
"k8s.io/kubernetes/pkg/util/net/sets"
|
||||||
|
|
||||||
"k8s.io/ingress/core/pkg/ingress/annotations/parser"
|
"k8s.io/ingress/core/pkg/ingress/annotations/parser"
|
||||||
|
|
|
@ -20,10 +20,10 @@ import (
|
||||||
"reflect"
|
"reflect"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
api "k8s.io/api/core/v1"
|
||||||
|
extensions "k8s.io/api/extensions/v1beta1"
|
||||||
meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
"k8s.io/apimachinery/pkg/util/intstr"
|
"k8s.io/apimachinery/pkg/util/intstr"
|
||||||
api "k8s.io/client-go/pkg/api/v1"
|
|
||||||
extensions "k8s.io/client-go/pkg/apis/extensions/v1beta1"
|
|
||||||
|
|
||||||
"k8s.io/ingress/core/pkg/ingress/defaults"
|
"k8s.io/ingress/core/pkg/ingress/defaults"
|
||||||
"k8s.io/ingress/core/pkg/ingress/errors"
|
"k8s.io/ingress/core/pkg/ingress/errors"
|
||||||
|
|
|
@ -19,7 +19,7 @@ package parser
|
||||||
import (
|
import (
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
extensions "k8s.io/client-go/pkg/apis/extensions/v1beta1"
|
extensions "k8s.io/api/extensions/v1beta1"
|
||||||
|
|
||||||
"k8s.io/ingress/core/pkg/ingress/errors"
|
"k8s.io/ingress/core/pkg/ingress/errors"
|
||||||
)
|
)
|
||||||
|
|
|
@ -19,9 +19,9 @@ package parser
|
||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
api "k8s.io/api/core/v1"
|
||||||
|
extensions "k8s.io/api/extensions/v1beta1"
|
||||||
meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
api "k8s.io/client-go/pkg/api/v1"
|
|
||||||
extensions "k8s.io/client-go/pkg/apis/extensions/v1beta1"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func buildIngress() *extensions.Ingress {
|
func buildIngress() *extensions.Ingress {
|
||||||
|
|
|
@ -17,7 +17,7 @@ limitations under the License.
|
||||||
package portinredirect
|
package portinredirect
|
||||||
|
|
||||||
import (
|
import (
|
||||||
extensions "k8s.io/client-go/pkg/apis/extensions/v1beta1"
|
extensions "k8s.io/api/extensions/v1beta1"
|
||||||
|
|
||||||
"k8s.io/ingress/core/pkg/ingress/annotations/parser"
|
"k8s.io/ingress/core/pkg/ingress/annotations/parser"
|
||||||
"k8s.io/ingress/core/pkg/ingress/resolver"
|
"k8s.io/ingress/core/pkg/ingress/resolver"
|
||||||
|
|
|
@ -19,10 +19,10 @@ package portinredirect
|
||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
api "k8s.io/api/core/v1"
|
||||||
|
extensions "k8s.io/api/extensions/v1beta1"
|
||||||
meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
"k8s.io/apimachinery/pkg/util/intstr"
|
"k8s.io/apimachinery/pkg/util/intstr"
|
||||||
api "k8s.io/client-go/pkg/api/v1"
|
|
||||||
extensions "k8s.io/client-go/pkg/apis/extensions/v1beta1"
|
|
||||||
|
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,7 @@ limitations under the License.
|
||||||
package proxy
|
package proxy
|
||||||
|
|
||||||
import (
|
import (
|
||||||
extensions "k8s.io/client-go/pkg/apis/extensions/v1beta1"
|
extensions "k8s.io/api/extensions/v1beta1"
|
||||||
|
|
||||||
"k8s.io/ingress/core/pkg/ingress/annotations/parser"
|
"k8s.io/ingress/core/pkg/ingress/annotations/parser"
|
||||||
"k8s.io/ingress/core/pkg/ingress/resolver"
|
"k8s.io/ingress/core/pkg/ingress/resolver"
|
||||||
|
|
|
@ -19,10 +19,10 @@ package proxy
|
||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
api "k8s.io/api/core/v1"
|
||||||
|
extensions "k8s.io/api/extensions/v1beta1"
|
||||||
meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
"k8s.io/apimachinery/pkg/util/intstr"
|
"k8s.io/apimachinery/pkg/util/intstr"
|
||||||
api "k8s.io/client-go/pkg/api/v1"
|
|
||||||
extensions "k8s.io/client-go/pkg/apis/extensions/v1beta1"
|
|
||||||
|
|
||||||
"k8s.io/ingress/core/pkg/ingress/defaults"
|
"k8s.io/ingress/core/pkg/ingress/defaults"
|
||||||
)
|
)
|
||||||
|
|
|
@ -19,7 +19,7 @@ package ratelimit
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
extensions "k8s.io/client-go/pkg/apis/extensions/v1beta1"
|
extensions "k8s.io/api/extensions/v1beta1"
|
||||||
|
|
||||||
"k8s.io/ingress/core/pkg/ingress/annotations/parser"
|
"k8s.io/ingress/core/pkg/ingress/annotations/parser"
|
||||||
)
|
)
|
||||||
|
|
|
@ -19,9 +19,9 @@ package ratelimit
|
||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
api "k8s.io/api/core/v1"
|
||||||
|
extensions "k8s.io/api/extensions/v1beta1"
|
||||||
meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
api "k8s.io/client-go/pkg/api/v1"
|
|
||||||
extensions "k8s.io/client-go/pkg/apis/extensions/v1beta1"
|
|
||||||
|
|
||||||
"k8s.io/apimachinery/pkg/util/intstr"
|
"k8s.io/apimachinery/pkg/util/intstr"
|
||||||
)
|
)
|
||||||
|
|
|
@ -17,7 +17,7 @@ limitations under the License.
|
||||||
package rewrite
|
package rewrite
|
||||||
|
|
||||||
import (
|
import (
|
||||||
extensions "k8s.io/client-go/pkg/apis/extensions/v1beta1"
|
extensions "k8s.io/api/extensions/v1beta1"
|
||||||
|
|
||||||
"k8s.io/ingress/core/pkg/ingress/annotations/parser"
|
"k8s.io/ingress/core/pkg/ingress/annotations/parser"
|
||||||
"k8s.io/ingress/core/pkg/ingress/resolver"
|
"k8s.io/ingress/core/pkg/ingress/resolver"
|
||||||
|
|
|
@ -19,10 +19,10 @@ package rewrite
|
||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
api "k8s.io/api/core/v1"
|
||||||
|
extensions "k8s.io/api/extensions/v1beta1"
|
||||||
meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
"k8s.io/apimachinery/pkg/util/intstr"
|
"k8s.io/apimachinery/pkg/util/intstr"
|
||||||
api "k8s.io/client-go/pkg/api/v1"
|
|
||||||
extensions "k8s.io/client-go/pkg/apis/extensions/v1beta1"
|
|
||||||
|
|
||||||
"k8s.io/ingress/core/pkg/ingress/defaults"
|
"k8s.io/ingress/core/pkg/ingress/defaults"
|
||||||
)
|
)
|
||||||
|
|
|
@ -20,7 +20,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
extensions "k8s.io/client-go/pkg/apis/extensions/v1beta1"
|
extensions "k8s.io/api/extensions/v1beta1"
|
||||||
|
|
||||||
"k8s.io/ingress/core/pkg/ingress/annotations/parser"
|
"k8s.io/ingress/core/pkg/ingress/annotations/parser"
|
||||||
"k8s.io/ingress/core/pkg/ingress/resolver"
|
"k8s.io/ingress/core/pkg/ingress/resolver"
|
||||||
|
|
|
@ -19,9 +19,9 @@ package secureupstream
|
||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
api "k8s.io/api/core/v1"
|
||||||
|
extensions "k8s.io/api/extensions/v1beta1"
|
||||||
meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
api "k8s.io/client-go/pkg/api/v1"
|
|
||||||
extensions "k8s.io/client-go/pkg/apis/extensions/v1beta1"
|
|
||||||
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"k8s.io/apimachinery/pkg/util/intstr"
|
"k8s.io/apimachinery/pkg/util/intstr"
|
||||||
|
|
|
@ -21,7 +21,7 @@ import (
|
||||||
|
|
||||||
"github.com/golang/glog"
|
"github.com/golang/glog"
|
||||||
|
|
||||||
extensions "k8s.io/client-go/pkg/apis/extensions/v1beta1"
|
extensions "k8s.io/api/extensions/v1beta1"
|
||||||
|
|
||||||
"k8s.io/ingress/core/pkg/ingress/annotations/parser"
|
"k8s.io/ingress/core/pkg/ingress/annotations/parser"
|
||||||
)
|
)
|
||||||
|
|
|
@ -19,10 +19,10 @@ package sessionaffinity
|
||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
api "k8s.io/api/core/v1"
|
||||||
|
extensions "k8s.io/api/extensions/v1beta1"
|
||||||
meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
"k8s.io/apimachinery/pkg/util/intstr"
|
"k8s.io/apimachinery/pkg/util/intstr"
|
||||||
api "k8s.io/client-go/pkg/api/v1"
|
|
||||||
extensions "k8s.io/client-go/pkg/apis/extensions/v1beta1"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func buildIngress() *extensions.Ingress {
|
func buildIngress() *extensions.Ingress {
|
||||||
|
|
|
@ -17,7 +17,7 @@ limitations under the License.
|
||||||
package snippet
|
package snippet
|
||||||
|
|
||||||
import (
|
import (
|
||||||
extensions "k8s.io/client-go/pkg/apis/extensions/v1beta1"
|
extensions "k8s.io/api/extensions/v1beta1"
|
||||||
|
|
||||||
"k8s.io/ingress/core/pkg/ingress/annotations/parser"
|
"k8s.io/ingress/core/pkg/ingress/annotations/parser"
|
||||||
)
|
)
|
||||||
|
|
|
@ -19,9 +19,9 @@ package snippet
|
||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
api "k8s.io/api/core/v1"
|
||||||
|
extensions "k8s.io/api/extensions/v1beta1"
|
||||||
meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
api "k8s.io/client-go/pkg/api/v1"
|
|
||||||
extensions "k8s.io/client-go/pkg/apis/extensions/v1beta1"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestParse(t *testing.T) {
|
func TestParse(t *testing.T) {
|
||||||
|
|
|
@ -17,7 +17,7 @@ limitations under the License.
|
||||||
package sslpassthrough
|
package sslpassthrough
|
||||||
|
|
||||||
import (
|
import (
|
||||||
extensions "k8s.io/client-go/pkg/apis/extensions/v1beta1"
|
extensions "k8s.io/api/extensions/v1beta1"
|
||||||
|
|
||||||
"k8s.io/ingress/core/pkg/ingress/annotations/parser"
|
"k8s.io/ingress/core/pkg/ingress/annotations/parser"
|
||||||
ing_errors "k8s.io/ingress/core/pkg/ingress/errors"
|
ing_errors "k8s.io/ingress/core/pkg/ingress/errors"
|
||||||
|
|
|
@ -19,9 +19,9 @@ package sslpassthrough
|
||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
api "k8s.io/api/core/v1"
|
||||||
|
extensions "k8s.io/api/extensions/v1beta1"
|
||||||
meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
api "k8s.io/client-go/pkg/api/v1"
|
|
||||||
extensions "k8s.io/client-go/pkg/apis/extensions/v1beta1"
|
|
||||||
|
|
||||||
"k8s.io/apimachinery/pkg/util/intstr"
|
"k8s.io/apimachinery/pkg/util/intstr"
|
||||||
)
|
)
|
||||||
|
|
|
@ -18,7 +18,7 @@ package controller
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/golang/glog"
|
"github.com/golang/glog"
|
||||||
extensions "k8s.io/client-go/pkg/apis/extensions/v1beta1"
|
extensions "k8s.io/api/extensions/v1beta1"
|
||||||
"k8s.io/ingress/core/pkg/ingress/annotations/auth"
|
"k8s.io/ingress/core/pkg/ingress/annotations/auth"
|
||||||
"k8s.io/ingress/core/pkg/ingress/annotations/authreq"
|
"k8s.io/ingress/core/pkg/ingress/annotations/authreq"
|
||||||
"k8s.io/ingress/core/pkg/ingress/annotations/authtls"
|
"k8s.io/ingress/core/pkg/ingress/annotations/authtls"
|
||||||
|
|
|
@ -19,10 +19,10 @@ package controller
|
||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
api "k8s.io/api/core/v1"
|
||||||
|
extensions "k8s.io/api/extensions/v1beta1"
|
||||||
meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
"k8s.io/apimachinery/pkg/util/intstr"
|
"k8s.io/apimachinery/pkg/util/intstr"
|
||||||
api "k8s.io/client-go/pkg/api/v1"
|
|
||||||
extensions "k8s.io/client-go/pkg/apis/extensions/v1beta1"
|
|
||||||
|
|
||||||
"k8s.io/ingress/core/pkg/ingress/defaults"
|
"k8s.io/ingress/core/pkg/ingress/defaults"
|
||||||
"k8s.io/ingress/core/pkg/ingress/resolver"
|
"k8s.io/ingress/core/pkg/ingress/resolver"
|
||||||
|
|
|
@ -23,7 +23,7 @@ import (
|
||||||
|
|
||||||
"github.com/golang/glog"
|
"github.com/golang/glog"
|
||||||
|
|
||||||
api "k8s.io/client-go/pkg/api/v1"
|
api "k8s.io/api/core/v1"
|
||||||
"k8s.io/client-go/tools/cache"
|
"k8s.io/client-go/tools/cache"
|
||||||
|
|
||||||
"k8s.io/ingress/core/pkg/ingress"
|
"k8s.io/ingress/core/pkg/ingress"
|
||||||
|
|
|
@ -23,9 +23,9 @@ import (
|
||||||
|
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
|
api_v1 "k8s.io/api/core/v1"
|
||||||
meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
testclient "k8s.io/client-go/kubernetes/fake"
|
testclient "k8s.io/client-go/kubernetes/fake"
|
||||||
api_v1 "k8s.io/client-go/pkg/api/v1"
|
|
||||||
cache_client "k8s.io/client-go/tools/cache"
|
cache_client "k8s.io/client-go/tools/cache"
|
||||||
"k8s.io/ingress/core/pkg/ingress"
|
"k8s.io/ingress/core/pkg/ingress"
|
||||||
"k8s.io/ingress/core/pkg/ingress/store"
|
"k8s.io/ingress/core/pkg/ingress/store"
|
||||||
|
|
|
@ -29,6 +29,8 @@ import (
|
||||||
|
|
||||||
"github.com/golang/glog"
|
"github.com/golang/glog"
|
||||||
|
|
||||||
|
api "k8s.io/api/core/v1"
|
||||||
|
extensions "k8s.io/api/extensions/v1beta1"
|
||||||
"k8s.io/apimachinery/pkg/fields"
|
"k8s.io/apimachinery/pkg/fields"
|
||||||
"k8s.io/apimachinery/pkg/util/intstr"
|
"k8s.io/apimachinery/pkg/util/intstr"
|
||||||
"k8s.io/apimachinery/pkg/util/runtime"
|
"k8s.io/apimachinery/pkg/util/runtime"
|
||||||
|
@ -36,8 +38,6 @@ import (
|
||||||
clientset "k8s.io/client-go/kubernetes"
|
clientset "k8s.io/client-go/kubernetes"
|
||||||
"k8s.io/client-go/kubernetes/scheme"
|
"k8s.io/client-go/kubernetes/scheme"
|
||||||
unversionedcore "k8s.io/client-go/kubernetes/typed/core/v1"
|
unversionedcore "k8s.io/client-go/kubernetes/typed/core/v1"
|
||||||
api "k8s.io/client-go/pkg/api/v1"
|
|
||||||
extensions "k8s.io/client-go/pkg/apis/extensions/v1beta1"
|
|
||||||
"k8s.io/client-go/tools/cache"
|
"k8s.io/client-go/tools/cache"
|
||||||
"k8s.io/client-go/tools/record"
|
"k8s.io/client-go/tools/record"
|
||||||
"k8s.io/client-go/util/flowcontrol"
|
"k8s.io/client-go/util/flowcontrol"
|
||||||
|
@ -51,7 +51,6 @@ import (
|
||||||
"k8s.io/ingress/core/pkg/ingress/defaults"
|
"k8s.io/ingress/core/pkg/ingress/defaults"
|
||||||
"k8s.io/ingress/core/pkg/ingress/resolver"
|
"k8s.io/ingress/core/pkg/ingress/resolver"
|
||||||
"k8s.io/ingress/core/pkg/ingress/status"
|
"k8s.io/ingress/core/pkg/ingress/status"
|
||||||
"k8s.io/ingress/core/pkg/ingress/status/leaderelection/resourcelock"
|
|
||||||
"k8s.io/ingress/core/pkg/ingress/store"
|
"k8s.io/ingress/core/pkg/ingress/store"
|
||||||
"k8s.io/ingress/core/pkg/k8s"
|
"k8s.io/ingress/core/pkg/k8s"
|
||||||
"k8s.io/ingress/core/pkg/net/ssl"
|
"k8s.io/ingress/core/pkg/net/ssl"
|
||||||
|
@ -234,11 +233,6 @@ func newIngressController(config *Configuration) *GenericController {
|
||||||
|
|
||||||
eventHandler := cache.ResourceEventHandlerFuncs{
|
eventHandler := cache.ResourceEventHandlerFuncs{
|
||||||
AddFunc: func(obj interface{}) {
|
AddFunc: func(obj interface{}) {
|
||||||
ep := obj.(*api.Endpoints)
|
|
||||||
_, found := ep.Annotations[resourcelock.LeaderElectionRecordAnnotationKey]
|
|
||||||
if found {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
ic.syncQueue.Enqueue(obj)
|
ic.syncQueue.Enqueue(obj)
|
||||||
},
|
},
|
||||||
DeleteFunc: func(obj interface{}) {
|
DeleteFunc: func(obj interface{}) {
|
||||||
|
@ -246,12 +240,6 @@ func newIngressController(config *Configuration) *GenericController {
|
||||||
},
|
},
|
||||||
UpdateFunc: func(old, cur interface{}) {
|
UpdateFunc: func(old, cur interface{}) {
|
||||||
if !reflect.DeepEqual(old, cur) {
|
if !reflect.DeepEqual(old, cur) {
|
||||||
ep := cur.(*api.Endpoints)
|
|
||||||
_, found := ep.Annotations[resourcelock.LeaderElectionRecordAnnotationKey]
|
|
||||||
if found {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
ic.syncQueue.Enqueue(cur)
|
ic.syncQueue.Enqueue(cur)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
@ -14,9 +14,9 @@ import (
|
||||||
"github.com/prometheus/client_golang/prometheus/promhttp"
|
"github.com/prometheus/client_golang/prometheus/promhttp"
|
||||||
"github.com/spf13/pflag"
|
"github.com/spf13/pflag"
|
||||||
|
|
||||||
|
api "k8s.io/api/core/v1"
|
||||||
"k8s.io/apiserver/pkg/server/healthz"
|
"k8s.io/apiserver/pkg/server/healthz"
|
||||||
"k8s.io/client-go/kubernetes"
|
"k8s.io/client-go/kubernetes"
|
||||||
api "k8s.io/client-go/pkg/api/v1"
|
|
||||||
"k8s.io/client-go/rest"
|
"k8s.io/client-go/rest"
|
||||||
"k8s.io/client-go/tools/clientcmd"
|
"k8s.io/client-go/tools/clientcmd"
|
||||||
clientcmd_api "k8s.io/client-go/tools/clientcmd/api"
|
clientcmd_api "k8s.io/client-go/tools/clientcmd/api"
|
||||||
|
|
|
@ -17,7 +17,7 @@ limitations under the License.
|
||||||
package resolver
|
package resolver
|
||||||
|
|
||||||
import (
|
import (
|
||||||
api "k8s.io/client-go/pkg/api/v1"
|
api "k8s.io/api/core/v1"
|
||||||
|
|
||||||
"k8s.io/ingress/core/pkg/ingress/defaults"
|
"k8s.io/ingress/core/pkg/ingress/defaults"
|
||||||
)
|
)
|
||||||
|
|
|
@ -1,122 +0,0 @@
|
||||||
/*
|
|
||||||
Copyright 2015 The Kubernetes Authors.
|
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
you may not use this file except in compliance with the License.
|
|
||||||
You may obtain a copy of the License at
|
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
See the License for the specific language governing permissions and
|
|
||||||
limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package status
|
|
||||||
|
|
||||||
import (
|
|
||||||
"encoding/json"
|
|
||||||
"os"
|
|
||||||
"time"
|
|
||||||
|
|
||||||
"github.com/golang/glog"
|
|
||||||
|
|
||||||
"k8s.io/apimachinery/pkg/api/errors"
|
|
||||||
meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
|
||||||
client "k8s.io/client-go/kubernetes"
|
|
||||||
"k8s.io/client-go/kubernetes/scheme"
|
|
||||||
api "k8s.io/client-go/pkg/api/v1"
|
|
||||||
"k8s.io/client-go/tools/record"
|
|
||||||
|
|
||||||
"k8s.io/ingress/core/pkg/ingress/status/leaderelection"
|
|
||||||
"k8s.io/ingress/core/pkg/ingress/status/leaderelection/resourcelock"
|
|
||||||
)
|
|
||||||
|
|
||||||
func getCurrentLeader(electionID, namespace string, c client.Interface) (string, *api.Endpoints, error) {
|
|
||||||
endpoints, err := c.Core().Endpoints(namespace).Get(electionID, meta_v1.GetOptions{})
|
|
||||||
if err != nil {
|
|
||||||
return "", nil, err
|
|
||||||
}
|
|
||||||
val, found := endpoints.Annotations[resourcelock.LeaderElectionRecordAnnotationKey]
|
|
||||||
if !found {
|
|
||||||
return "", endpoints, nil
|
|
||||||
}
|
|
||||||
electionRecord := resourcelock.LeaderElectionRecord{}
|
|
||||||
if err = json.Unmarshal([]byte(val), &electionRecord); err != nil {
|
|
||||||
return "", nil, err
|
|
||||||
}
|
|
||||||
return electionRecord.HolderIdentity, endpoints, err
|
|
||||||
}
|
|
||||||
|
|
||||||
// NewElection creates an election. 'namespace'/'election' should be an existing Kubernetes Service
|
|
||||||
// 'id' is the id if this leader, should be unique.
|
|
||||||
func NewElection(electionID,
|
|
||||||
id,
|
|
||||||
namespace string,
|
|
||||||
ttl time.Duration,
|
|
||||||
callback func(leader string),
|
|
||||||
c client.Interface) (*leaderelection.LeaderElector, error) {
|
|
||||||
|
|
||||||
_, err := c.Core().Endpoints(namespace).Get(electionID, meta_v1.GetOptions{})
|
|
||||||
if err != nil {
|
|
||||||
if errors.IsNotFound(err) {
|
|
||||||
_, err = c.Core().Endpoints(namespace).Create(&api.Endpoints{
|
|
||||||
ObjectMeta: meta_v1.ObjectMeta{
|
|
||||||
Name: electionID,
|
|
||||||
},
|
|
||||||
})
|
|
||||||
if err != nil && !errors.IsConflict(err) {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
callbacks := leaderelection.LeaderCallbacks{
|
|
||||||
OnStartedLeading: func(stop <-chan struct{}) {
|
|
||||||
callback(id)
|
|
||||||
},
|
|
||||||
OnStoppedLeading: func() {
|
|
||||||
leader, _, err := getCurrentLeader(electionID, namespace, c)
|
|
||||||
if err != nil {
|
|
||||||
glog.Errorf("failed to get leader: %v", err)
|
|
||||||
// empty string means leader is unknown
|
|
||||||
callback("")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
callback(leader)
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
broadcaster := record.NewBroadcaster()
|
|
||||||
hostname, err := os.Hostname()
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
recorder := broadcaster.NewRecorder(scheme.Scheme, api.EventSource{
|
|
||||||
Component: "ingress-leader-elector",
|
|
||||||
Host: hostname,
|
|
||||||
})
|
|
||||||
|
|
||||||
lock := resourcelock.ConfigMapLock{
|
|
||||||
ConfigMapMeta: meta_v1.ObjectMeta{Namespace: namespace, Name: electionID},
|
|
||||||
Client: c,
|
|
||||||
LockConfig: resourcelock.ResourceLockConfig{
|
|
||||||
Identity: id,
|
|
||||||
EventRecorder: recorder,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
config := leaderelection.LeaderElectionConfig{
|
|
||||||
Lock: &lock,
|
|
||||||
LeaseDuration: ttl,
|
|
||||||
RenewDeadline: ttl / 2,
|
|
||||||
RetryPeriod: ttl / 4,
|
|
||||||
Callbacks: callbacks,
|
|
||||||
}
|
|
||||||
|
|
||||||
return leaderelection.NewLeaderElector(config)
|
|
||||||
}
|
|
|
@ -1,132 +0,0 @@
|
||||||
/*
|
|
||||||
Copyright 2017 The Kubernetes Authors.
|
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
you may not use this file except in compliance with the License.
|
|
||||||
You may obtain a copy of the License at
|
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
See the License for the specific language governing permissions and
|
|
||||||
limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package status
|
|
||||||
|
|
||||||
import (
|
|
||||||
"encoding/json"
|
|
||||||
"testing"
|
|
||||||
"time"
|
|
||||||
|
|
||||||
meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
|
||||||
"k8s.io/client-go/kubernetes/fake"
|
|
||||||
"k8s.io/client-go/pkg/api"
|
|
||||||
api_v1 "k8s.io/client-go/pkg/api/v1"
|
|
||||||
|
|
||||||
"k8s.io/ingress/core/pkg/ingress/status/leaderelection/resourcelock"
|
|
||||||
)
|
|
||||||
|
|
||||||
func TestGetCurrentLeaderLeaderExist(t *testing.T) {
|
|
||||||
fkER := resourcelock.LeaderElectionRecord{
|
|
||||||
HolderIdentity: "currentLeader",
|
|
||||||
LeaseDurationSeconds: 30,
|
|
||||||
AcquireTime: meta_v1.NewTime(time.Now()),
|
|
||||||
RenewTime: meta_v1.NewTime(time.Now()),
|
|
||||||
LeaderTransitions: 3,
|
|
||||||
}
|
|
||||||
leaderInfo, _ := json.Marshal(fkER)
|
|
||||||
fkEndpoints := api_v1.Endpoints{
|
|
||||||
ObjectMeta: meta_v1.ObjectMeta{
|
|
||||||
Name: "ingress-controller-test",
|
|
||||||
Namespace: api.NamespaceSystem,
|
|
||||||
Annotations: map[string]string{
|
|
||||||
resourcelock.LeaderElectionRecordAnnotationKey: string(leaderInfo),
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
|
||||||
fk := fake.NewSimpleClientset(&api_v1.EndpointsList{Items: []api_v1.Endpoints{fkEndpoints}})
|
|
||||||
identity, endpoints, err := getCurrentLeader("ingress-controller-test", api.NamespaceSystem, fk)
|
|
||||||
if err != nil {
|
|
||||||
t.Fatalf("expected identitiy and endpoints but returned error %s", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
if endpoints == nil {
|
|
||||||
t.Fatalf("returned nil but expected an endpoints")
|
|
||||||
}
|
|
||||||
|
|
||||||
if identity != "currentLeader" {
|
|
||||||
t.Fatalf("returned %v but expected %v", identity, "currentLeader")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestGetCurrentLeaderLeaderNotExist(t *testing.T) {
|
|
||||||
fkEndpoints := api_v1.Endpoints{
|
|
||||||
ObjectMeta: meta_v1.ObjectMeta{
|
|
||||||
Name: "ingress-controller-test",
|
|
||||||
Namespace: api.NamespaceSystem,
|
|
||||||
Annotations: map[string]string{},
|
|
||||||
},
|
|
||||||
}
|
|
||||||
fk := fake.NewSimpleClientset(&api_v1.EndpointsList{Items: []api_v1.Endpoints{fkEndpoints}})
|
|
||||||
identity, endpoints, err := getCurrentLeader("ingress-controller-test", api.NamespaceSystem, fk)
|
|
||||||
if err != nil {
|
|
||||||
t.Fatalf("unexpeted error: %v", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
if endpoints == nil {
|
|
||||||
t.Fatalf("returned nil but expected an endpoints")
|
|
||||||
}
|
|
||||||
|
|
||||||
if identity != "" {
|
|
||||||
t.Fatalf("returned %s but expected %s", identity, "")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestGetCurrentLeaderAnnotationError(t *testing.T) {
|
|
||||||
fkEndpoints := api_v1.Endpoints{
|
|
||||||
ObjectMeta: meta_v1.ObjectMeta{
|
|
||||||
Name: "ingress-controller-test",
|
|
||||||
Namespace: api.NamespaceSystem,
|
|
||||||
Annotations: map[string]string{
|
|
||||||
resourcelock.LeaderElectionRecordAnnotationKey: "just-test-error-leader-annotation",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
|
||||||
fk := fake.NewSimpleClientset(&api_v1.EndpointsList{Items: []api_v1.Endpoints{fkEndpoints}})
|
|
||||||
_, _, err := getCurrentLeader("ingress-controller-test", api.NamespaceSystem, fk)
|
|
||||||
if err == nil {
|
|
||||||
t.Errorf("expected error")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestNewElection(t *testing.T) {
|
|
||||||
fk := fake.NewSimpleClientset(&api_v1.EndpointsList{Items: []api_v1.Endpoints{
|
|
||||||
{
|
|
||||||
ObjectMeta: meta_v1.ObjectMeta{
|
|
||||||
Name: "ingress-controller-test",
|
|
||||||
Namespace: api.NamespaceSystem,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
ObjectMeta: meta_v1.ObjectMeta{
|
|
||||||
Name: "ingress-controller-test-020",
|
|
||||||
Namespace: api.NamespaceSystem,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}})
|
|
||||||
|
|
||||||
ne, err := NewElection("ingress-controller-test", "startLeader", api.NamespaceSystem, 4*time.Second, func(leader string) {
|
|
||||||
// do nothing
|
|
||||||
go t.Logf("execute callback fun, leader is: %s", leader)
|
|
||||||
}, fk)
|
|
||||||
if err != nil {
|
|
||||||
t.Fatalf("unexpected error %v", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
if ne == nil {
|
|
||||||
t.Fatalf("unexpected nil")
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -19,21 +19,25 @@ package status
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"net"
|
"net"
|
||||||
|
"os"
|
||||||
"sort"
|
"sort"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/golang/glog"
|
"github.com/golang/glog"
|
||||||
|
|
||||||
|
api "k8s.io/api/core/v1"
|
||||||
|
extensions "k8s.io/api/extensions/v1beta1"
|
||||||
meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
"k8s.io/apimachinery/pkg/labels"
|
"k8s.io/apimachinery/pkg/labels"
|
||||||
"k8s.io/apimachinery/pkg/util/wait"
|
"k8s.io/apimachinery/pkg/util/wait"
|
||||||
clientset "k8s.io/client-go/kubernetes"
|
clientset "k8s.io/client-go/kubernetes"
|
||||||
api_v1 "k8s.io/client-go/pkg/api/v1"
|
"k8s.io/client-go/kubernetes/scheme"
|
||||||
extensions "k8s.io/client-go/pkg/apis/extensions/v1beta1"
|
"k8s.io/client-go/tools/leaderelection"
|
||||||
|
"k8s.io/client-go/tools/leaderelection/resourcelock"
|
||||||
|
"k8s.io/client-go/tools/record"
|
||||||
|
|
||||||
"k8s.io/ingress/core/pkg/ingress/annotations/class"
|
"k8s.io/ingress/core/pkg/ingress/annotations/class"
|
||||||
"k8s.io/ingress/core/pkg/ingress/status/leaderelection"
|
|
||||||
"k8s.io/ingress/core/pkg/ingress/store"
|
"k8s.io/ingress/core/pkg/ingress/store"
|
||||||
"k8s.io/ingress/core/pkg/k8s"
|
"k8s.io/ingress/core/pkg/k8s"
|
||||||
"k8s.io/ingress/core/pkg/strings"
|
"k8s.io/ingress/core/pkg/strings"
|
||||||
|
@ -126,7 +130,7 @@ func (s statusSync) Shutdown() {
|
||||||
}
|
}
|
||||||
|
|
||||||
glog.Infof("removing address from ingress status (%v)", addrs)
|
glog.Infof("removing address from ingress status (%v)", addrs)
|
||||||
s.updateStatus([]api_v1.LoadBalancerIngress{})
|
s.updateStatus([]api.LoadBalancerIngress{})
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *statusSync) run() {
|
func (s *statusSync) run() {
|
||||||
|
@ -198,17 +202,49 @@ func NewStatusSyncer(config Config) Sync {
|
||||||
|
|
||||||
// we need to use the defined ingress class to allow multiple leaders
|
// we need to use the defined ingress class to allow multiple leaders
|
||||||
// in order to update information about ingress status
|
// in order to update information about ingress status
|
||||||
id := fmt.Sprintf("%v-%v", config.ElectionID, config.DefaultIngressClass)
|
electionID := fmt.Sprintf("%v-%v", config.ElectionID, config.DefaultIngressClass)
|
||||||
if config.IngressClass != "" {
|
if config.IngressClass != "" {
|
||||||
id = fmt.Sprintf("%v-%v", config.ElectionID, config.IngressClass)
|
electionID = fmt.Sprintf("%v-%v", config.ElectionID, config.IngressClass)
|
||||||
}
|
}
|
||||||
|
|
||||||
le, err := NewElection(id,
|
callbacks := leaderelection.LeaderCallbacks{
|
||||||
pod.Name, pod.Namespace, 30*time.Second,
|
OnStartedLeading: func(stop <-chan struct{}) {
|
||||||
st.callback, config.Client)
|
st.callback(pod.Name)
|
||||||
|
},
|
||||||
|
OnStoppedLeading: func() {
|
||||||
|
st.callback("")
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
broadcaster := record.NewBroadcaster()
|
||||||
|
hostname, _ := os.Hostname()
|
||||||
|
|
||||||
|
recorder := broadcaster.NewRecorder(scheme.Scheme, api.EventSource{
|
||||||
|
Component: "ingress-leader-elector",
|
||||||
|
Host: hostname,
|
||||||
|
})
|
||||||
|
|
||||||
|
lock := resourcelock.ConfigMapLock{
|
||||||
|
ConfigMapMeta: meta_v1.ObjectMeta{Namespace: pod.Namespace, Name: electionID},
|
||||||
|
Client: config.Client.Core(),
|
||||||
|
LockConfig: resourcelock.ResourceLockConfig{
|
||||||
|
Identity: electionID,
|
||||||
|
EventRecorder: recorder,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
le, err := leaderelection.NewLeaderElector(leaderelection.LeaderElectionConfig{
|
||||||
|
Lock: &lock,
|
||||||
|
LeaseDuration: 30 * time.Second,
|
||||||
|
RenewDeadline: 15 * time.Second,
|
||||||
|
RetryPeriod: 5 * time.Second,
|
||||||
|
Callbacks: callbacks,
|
||||||
|
})
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
glog.Fatalf("unexpected error starting leader election: %v", err)
|
glog.Fatalf("unexpected error starting leader election: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
st.elector = le
|
st.elector = le
|
||||||
return st
|
return st
|
||||||
}
|
}
|
||||||
|
@ -265,13 +301,13 @@ func (s *statusSync) isRunningMultiplePods() bool {
|
||||||
}
|
}
|
||||||
|
|
||||||
// sliceToStatus converts a slice of IP and/or hostnames to LoadBalancerIngress
|
// sliceToStatus converts a slice of IP and/or hostnames to LoadBalancerIngress
|
||||||
func sliceToStatus(endpoints []string) []api_v1.LoadBalancerIngress {
|
func sliceToStatus(endpoints []string) []api.LoadBalancerIngress {
|
||||||
lbi := []api_v1.LoadBalancerIngress{}
|
lbi := []api.LoadBalancerIngress{}
|
||||||
for _, ep := range endpoints {
|
for _, ep := range endpoints {
|
||||||
if net.ParseIP(ep) == nil {
|
if net.ParseIP(ep) == nil {
|
||||||
lbi = append(lbi, api_v1.LoadBalancerIngress{Hostname: ep})
|
lbi = append(lbi, api.LoadBalancerIngress{Hostname: ep})
|
||||||
} else {
|
} else {
|
||||||
lbi = append(lbi, api_v1.LoadBalancerIngress{IP: ep})
|
lbi = append(lbi, api.LoadBalancerIngress{IP: ep})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -279,7 +315,7 @@ func sliceToStatus(endpoints []string) []api_v1.LoadBalancerIngress {
|
||||||
return lbi
|
return lbi
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *statusSync) updateStatus(newIPs []api_v1.LoadBalancerIngress) {
|
func (s *statusSync) updateStatus(newIPs []api.LoadBalancerIngress) {
|
||||||
ings := s.IngressLister.List()
|
ings := s.IngressLister.List()
|
||||||
var wg sync.WaitGroup
|
var wg sync.WaitGroup
|
||||||
wg.Add(len(ings))
|
wg.Add(len(ings))
|
||||||
|
@ -319,7 +355,7 @@ func (s *statusSync) updateStatus(newIPs []api_v1.LoadBalancerIngress) {
|
||||||
wg.Wait()
|
wg.Wait()
|
||||||
}
|
}
|
||||||
|
|
||||||
func ingressSliceEqual(lhs, rhs []api_v1.LoadBalancerIngress) bool {
|
func ingressSliceEqual(lhs, rhs []api.LoadBalancerIngress) bool {
|
||||||
if len(lhs) != len(rhs) {
|
if len(lhs) != len(rhs) {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
@ -336,7 +372,7 @@ func ingressSliceEqual(lhs, rhs []api_v1.LoadBalancerIngress) bool {
|
||||||
}
|
}
|
||||||
|
|
||||||
// loadBalancerIngressByIP sorts LoadBalancerIngress using the field IP
|
// loadBalancerIngressByIP sorts LoadBalancerIngress using the field IP
|
||||||
type loadBalancerIngressByIP []api_v1.LoadBalancerIngress
|
type loadBalancerIngressByIP []api.LoadBalancerIngress
|
||||||
|
|
||||||
func (c loadBalancerIngressByIP) Len() int { return len(c) }
|
func (c loadBalancerIngressByIP) Len() int { return len(c) }
|
||||||
func (c loadBalancerIngressByIP) Swap(i, j int) { c[i], c[j] = c[j], c[i] }
|
func (c loadBalancerIngressByIP) Swap(i, j int) { c[i], c[j] = c[j], c[i] }
|
||||||
|
|
|
@ -23,12 +23,12 @@ import (
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
api_v1 "k8s.io/api/core/v1"
|
||||||
|
extensions "k8s.io/api/extensions/v1beta1"
|
||||||
meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
testclient "k8s.io/client-go/kubernetes/fake"
|
testclient "k8s.io/client-go/kubernetes/fake"
|
||||||
"k8s.io/client-go/pkg/api"
|
|
||||||
api_v1 "k8s.io/client-go/pkg/api/v1"
|
|
||||||
extensions "k8s.io/client-go/pkg/apis/extensions/v1beta1"
|
|
||||||
"k8s.io/client-go/tools/cache"
|
"k8s.io/client-go/tools/cache"
|
||||||
|
"k8s.io/kubernetes/pkg/api"
|
||||||
|
|
||||||
"k8s.io/ingress/core/pkg/ingress/annotations/class"
|
"k8s.io/ingress/core/pkg/ingress/annotations/class"
|
||||||
cache_store "k8s.io/ingress/core/pkg/ingress/store"
|
cache_store "k8s.io/ingress/core/pkg/ingress/store"
|
||||||
|
|
|
@ -19,7 +19,7 @@ package store
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
api "k8s.io/client-go/pkg/api/v1"
|
api "k8s.io/api/core/v1"
|
||||||
"k8s.io/client-go/tools/cache"
|
"k8s.io/client-go/tools/cache"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -21,9 +21,9 @@ import (
|
||||||
|
|
||||||
"github.com/spf13/pflag"
|
"github.com/spf13/pflag"
|
||||||
|
|
||||||
|
api "k8s.io/api/core/v1"
|
||||||
"k8s.io/apimachinery/pkg/util/intstr"
|
"k8s.io/apimachinery/pkg/util/intstr"
|
||||||
"k8s.io/apiserver/pkg/server/healthz"
|
"k8s.io/apiserver/pkg/server/healthz"
|
||||||
api "k8s.io/client-go/pkg/api/v1"
|
|
||||||
|
|
||||||
"k8s.io/ingress/core/pkg/ingress/annotations/auth"
|
"k8s.io/ingress/core/pkg/ingress/annotations/auth"
|
||||||
"k8s.io/ingress/core/pkg/ingress/annotations/authreq"
|
"k8s.io/ingress/core/pkg/ingress/annotations/authreq"
|
||||||
|
|
|
@ -21,9 +21,9 @@ import (
|
||||||
"os"
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
api "k8s.io/api/core/v1"
|
||||||
meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
clientset "k8s.io/client-go/kubernetes"
|
clientset "k8s.io/client-go/kubernetes"
|
||||||
api "k8s.io/client-go/pkg/api/v1"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// IsValidService checks if exists a service with the specified name
|
// IsValidService checks if exists a service with the specified name
|
||||||
|
|
|
@ -20,9 +20,9 @@ import (
|
||||||
"os"
|
"os"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
api "k8s.io/api/core/v1"
|
||||||
meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
testclient "k8s.io/client-go/kubernetes/fake"
|
testclient "k8s.io/client-go/kubernetes/fake"
|
||||||
api "k8s.io/client-go/pkg/api/v1"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestParseNameNS(t *testing.T) {
|
func TestParseNameNS(t *testing.T) {
|
||||||
|
|
|
@ -24,7 +24,7 @@ import (
|
||||||
|
|
||||||
"github.com/spf13/pflag"
|
"github.com/spf13/pflag"
|
||||||
|
|
||||||
api "k8s.io/client-go/pkg/api/v1"
|
api "k8s.io/api/core/v1"
|
||||||
|
|
||||||
nginxconfig "k8s.io/ingress/controllers/nginx/pkg/config"
|
nginxconfig "k8s.io/ingress/controllers/nginx/pkg/config"
|
||||||
"k8s.io/ingress/core/pkg/ingress"
|
"k8s.io/ingress/core/pkg/ingress"
|
||||||
|
|
13
vendor/bitbucket.org/ww/goautoneg/Makefile
generated
vendored
13
vendor/bitbucket.org/ww/goautoneg/Makefile
generated
vendored
|
@ -1,13 +0,0 @@
|
||||||
include $(GOROOT)/src/Make.inc
|
|
||||||
|
|
||||||
TARG=bitbucket.org/ww/goautoneg
|
|
||||||
GOFILES=autoneg.go
|
|
||||||
|
|
||||||
include $(GOROOT)/src/Make.pkg
|
|
||||||
|
|
||||||
format:
|
|
||||||
gofmt -w *.go
|
|
||||||
|
|
||||||
docs:
|
|
||||||
gomake clean
|
|
||||||
godoc ${TARG} > README.txt
|
|
67
vendor/bitbucket.org/ww/goautoneg/README.txt
generated
vendored
67
vendor/bitbucket.org/ww/goautoneg/README.txt
generated
vendored
|
@ -1,67 +0,0 @@
|
||||||
PACKAGE
|
|
||||||
|
|
||||||
package goautoneg
|
|
||||||
import "bitbucket.org/ww/goautoneg"
|
|
||||||
|
|
||||||
HTTP Content-Type Autonegotiation.
|
|
||||||
|
|
||||||
The functions in this package implement the behaviour specified in
|
|
||||||
http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html
|
|
||||||
|
|
||||||
Copyright (c) 2011, Open Knowledge Foundation Ltd.
|
|
||||||
All rights reserved.
|
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without
|
|
||||||
modification, are permitted provided that the following conditions are
|
|
||||||
met:
|
|
||||||
|
|
||||||
Redistributions of source code must retain the above copyright
|
|
||||||
notice, this list of conditions and the following disclaimer.
|
|
||||||
|
|
||||||
Redistributions in binary form must reproduce the above copyright
|
|
||||||
notice, this list of conditions and the following disclaimer in
|
|
||||||
the documentation and/or other materials provided with the
|
|
||||||
distribution.
|
|
||||||
|
|
||||||
Neither the name of the Open Knowledge Foundation Ltd. nor the
|
|
||||||
names of its contributors may be used to endorse or promote
|
|
||||||
products derived from this software without specific prior written
|
|
||||||
permission.
|
|
||||||
|
|
||||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
||||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
||||||
HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
||||||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
||||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
||||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
|
|
||||||
|
|
||||||
FUNCTIONS
|
|
||||||
|
|
||||||
func Negotiate(header string, alternatives []string) (content_type string)
|
|
||||||
Negotiate the most appropriate content_type given the accept header
|
|
||||||
and a list of alternatives.
|
|
||||||
|
|
||||||
func ParseAccept(header string) (accept []Accept)
|
|
||||||
Parse an Accept Header string returning a sorted list
|
|
||||||
of clauses
|
|
||||||
|
|
||||||
|
|
||||||
TYPES
|
|
||||||
|
|
||||||
type Accept struct {
|
|
||||||
Type, SubType string
|
|
||||||
Q float32
|
|
||||||
Params map[string]string
|
|
||||||
}
|
|
||||||
Structure to represent a clause in an HTTP Accept Header
|
|
||||||
|
|
||||||
|
|
||||||
SUBDIRECTORIES
|
|
||||||
|
|
||||||
.hg
|
|
162
vendor/bitbucket.org/ww/goautoneg/autoneg.go
generated
vendored
162
vendor/bitbucket.org/ww/goautoneg/autoneg.go
generated
vendored
|
@ -1,162 +0,0 @@
|
||||||
/*
|
|
||||||
HTTP Content-Type Autonegotiation.
|
|
||||||
|
|
||||||
The functions in this package implement the behaviour specified in
|
|
||||||
http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html
|
|
||||||
|
|
||||||
Copyright (c) 2011, Open Knowledge Foundation Ltd.
|
|
||||||
All rights reserved.
|
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without
|
|
||||||
modification, are permitted provided that the following conditions are
|
|
||||||
met:
|
|
||||||
|
|
||||||
Redistributions of source code must retain the above copyright
|
|
||||||
notice, this list of conditions and the following disclaimer.
|
|
||||||
|
|
||||||
Redistributions in binary form must reproduce the above copyright
|
|
||||||
notice, this list of conditions and the following disclaimer in
|
|
||||||
the documentation and/or other materials provided with the
|
|
||||||
distribution.
|
|
||||||
|
|
||||||
Neither the name of the Open Knowledge Foundation Ltd. nor the
|
|
||||||
names of its contributors may be used to endorse or promote
|
|
||||||
products derived from this software without specific prior written
|
|
||||||
permission.
|
|
||||||
|
|
||||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
||||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
||||||
HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
||||||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
||||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
||||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
|
|
||||||
|
|
||||||
*/
|
|
||||||
package goautoneg
|
|
||||||
|
|
||||||
import (
|
|
||||||
"sort"
|
|
||||||
"strconv"
|
|
||||||
"strings"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Structure to represent a clause in an HTTP Accept Header
|
|
||||||
type Accept struct {
|
|
||||||
Type, SubType string
|
|
||||||
Q float64
|
|
||||||
Params map[string]string
|
|
||||||
}
|
|
||||||
|
|
||||||
// For internal use, so that we can use the sort interface
|
|
||||||
type accept_slice []Accept
|
|
||||||
|
|
||||||
func (accept accept_slice) Len() int {
|
|
||||||
slice := []Accept(accept)
|
|
||||||
return len(slice)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (accept accept_slice) Less(i, j int) bool {
|
|
||||||
slice := []Accept(accept)
|
|
||||||
ai, aj := slice[i], slice[j]
|
|
||||||
if ai.Q > aj.Q {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
if ai.Type != "*" && aj.Type == "*" {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
if ai.SubType != "*" && aj.SubType == "*" {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
func (accept accept_slice) Swap(i, j int) {
|
|
||||||
slice := []Accept(accept)
|
|
||||||
slice[i], slice[j] = slice[j], slice[i]
|
|
||||||
}
|
|
||||||
|
|
||||||
// Parse an Accept Header string returning a sorted list
|
|
||||||
// of clauses
|
|
||||||
func ParseAccept(header string) (accept []Accept) {
|
|
||||||
parts := strings.Split(header, ",")
|
|
||||||
accept = make([]Accept, 0, len(parts))
|
|
||||||
for _, part := range parts {
|
|
||||||
part := strings.Trim(part, " ")
|
|
||||||
|
|
||||||
a := Accept{}
|
|
||||||
a.Params = make(map[string]string)
|
|
||||||
a.Q = 1.0
|
|
||||||
|
|
||||||
mrp := strings.Split(part, ";")
|
|
||||||
|
|
||||||
media_range := mrp[0]
|
|
||||||
sp := strings.Split(media_range, "/")
|
|
||||||
a.Type = strings.Trim(sp[0], " ")
|
|
||||||
|
|
||||||
switch {
|
|
||||||
case len(sp) == 1 && a.Type == "*":
|
|
||||||
a.SubType = "*"
|
|
||||||
case len(sp) == 2:
|
|
||||||
a.SubType = strings.Trim(sp[1], " ")
|
|
||||||
default:
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
if len(mrp) == 1 {
|
|
||||||
accept = append(accept, a)
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
for _, param := range mrp[1:] {
|
|
||||||
sp := strings.SplitN(param, "=", 2)
|
|
||||||
if len(sp) != 2 {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
token := strings.Trim(sp[0], " ")
|
|
||||||
if token == "q" {
|
|
||||||
a.Q, _ = strconv.ParseFloat(sp[1], 32)
|
|
||||||
} else {
|
|
||||||
a.Params[token] = strings.Trim(sp[1], " ")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
accept = append(accept, a)
|
|
||||||
}
|
|
||||||
|
|
||||||
slice := accept_slice(accept)
|
|
||||||
sort.Sort(slice)
|
|
||||||
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// Negotiate the most appropriate content_type given the accept header
|
|
||||||
// and a list of alternatives.
|
|
||||||
func Negotiate(header string, alternatives []string) (content_type string) {
|
|
||||||
asp := make([][]string, 0, len(alternatives))
|
|
||||||
for _, ctype := range alternatives {
|
|
||||||
asp = append(asp, strings.SplitN(ctype, "/", 2))
|
|
||||||
}
|
|
||||||
for _, clause := range ParseAccept(header) {
|
|
||||||
for i, ctsp := range asp {
|
|
||||||
if clause.Type == ctsp[0] && clause.SubType == ctsp[1] {
|
|
||||||
content_type = alternatives[i]
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if clause.Type == ctsp[0] && clause.SubType == "*" {
|
|
||||||
content_type = alternatives[i]
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if clause.Type == "*" && clause.SubType == "*" {
|
|
||||||
content_type = alternatives[i]
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
36
vendor/github.com/go-openapi/analysis/.drone.yml
generated
vendored
36
vendor/github.com/go-openapi/analysis/.drone.yml
generated
vendored
|
@ -1,36 +0,0 @@
|
||||||
clone:
|
|
||||||
path: github.com/go-openapi/analysis
|
|
||||||
|
|
||||||
matrix:
|
|
||||||
GO_VERSION:
|
|
||||||
- "1.6"
|
|
||||||
|
|
||||||
build:
|
|
||||||
integration:
|
|
||||||
image: golang:$$GO_VERSION
|
|
||||||
pull: true
|
|
||||||
commands:
|
|
||||||
- go get -u github.com/stretchr/testify/assert
|
|
||||||
- go get -u gopkg.in/yaml.v2
|
|
||||||
- go get -u github.com/go-openapi/swag
|
|
||||||
- go get -u github.com/go-openapi/jsonpointer
|
|
||||||
- go get -u github.com/go-openapi/spec
|
|
||||||
- go get -u github.com/go-openapi/loads/fmts
|
|
||||||
- go test -race ./...
|
|
||||||
- go test -v -cover -coverprofile=coverage.out -covermode=count ./...
|
|
||||||
|
|
||||||
notify:
|
|
||||||
slack:
|
|
||||||
channel: bots
|
|
||||||
webhook_url: $$SLACK_URL
|
|
||||||
username: drone
|
|
||||||
|
|
||||||
publish:
|
|
||||||
coverage:
|
|
||||||
server: https://coverage.vmware.run
|
|
||||||
token: $$GITHUB_TOKEN
|
|
||||||
# threshold: 70
|
|
||||||
# must_increase: true
|
|
||||||
when:
|
|
||||||
matrix:
|
|
||||||
GO_VERSION: "1.6"
|
|
2
vendor/github.com/go-openapi/analysis/.gitignore
generated
vendored
2
vendor/github.com/go-openapi/analysis/.gitignore
generated
vendored
|
@ -1,2 +0,0 @@
|
||||||
secrets.yml
|
|
||||||
coverage.out
|
|
12
vendor/github.com/go-openapi/analysis/.pullapprove.yml
generated
vendored
12
vendor/github.com/go-openapi/analysis/.pullapprove.yml
generated
vendored
|
@ -1,12 +0,0 @@
|
||||||
approve_by_comment: true
|
|
||||||
approve_regex: '^(:shipit:|:\+1:|\+1|LGTM|lgtm|Approved)'
|
|
||||||
reject_regex: ^[Rr]ejected
|
|
||||||
reset_on_push: false
|
|
||||||
reviewers:
|
|
||||||
members:
|
|
||||||
- casualjim
|
|
||||||
- frapposelli
|
|
||||||
- vburenin
|
|
||||||
- pytlesk4
|
|
||||||
name: pullapprove
|
|
||||||
required: 1
|
|
74
vendor/github.com/go-openapi/analysis/CODE_OF_CONDUCT.md
generated
vendored
74
vendor/github.com/go-openapi/analysis/CODE_OF_CONDUCT.md
generated
vendored
|
@ -1,74 +0,0 @@
|
||||||
# Contributor Covenant Code of Conduct
|
|
||||||
|
|
||||||
## Our Pledge
|
|
||||||
|
|
||||||
In the interest of fostering an open and welcoming environment, we as
|
|
||||||
contributors and maintainers pledge to making participation in our project and
|
|
||||||
our community a harassment-free experience for everyone, regardless of age, body
|
|
||||||
size, disability, ethnicity, gender identity and expression, level of experience,
|
|
||||||
nationality, personal appearance, race, religion, or sexual identity and
|
|
||||||
orientation.
|
|
||||||
|
|
||||||
## Our Standards
|
|
||||||
|
|
||||||
Examples of behavior that contributes to creating a positive environment
|
|
||||||
include:
|
|
||||||
|
|
||||||
* Using welcoming and inclusive language
|
|
||||||
* Being respectful of differing viewpoints and experiences
|
|
||||||
* Gracefully accepting constructive criticism
|
|
||||||
* Focusing on what is best for the community
|
|
||||||
* Showing empathy towards other community members
|
|
||||||
|
|
||||||
Examples of unacceptable behavior by participants include:
|
|
||||||
|
|
||||||
* The use of sexualized language or imagery and unwelcome sexual attention or
|
|
||||||
advances
|
|
||||||
* Trolling, insulting/derogatory comments, and personal or political attacks
|
|
||||||
* Public or private harassment
|
|
||||||
* Publishing others' private information, such as a physical or electronic
|
|
||||||
address, without explicit permission
|
|
||||||
* Other conduct which could reasonably be considered inappropriate in a
|
|
||||||
professional setting
|
|
||||||
|
|
||||||
## Our Responsibilities
|
|
||||||
|
|
||||||
Project maintainers are responsible for clarifying the standards of acceptable
|
|
||||||
behavior and are expected to take appropriate and fair corrective action in
|
|
||||||
response to any instances of unacceptable behavior.
|
|
||||||
|
|
||||||
Project maintainers have the right and responsibility to remove, edit, or
|
|
||||||
reject comments, commits, code, wiki edits, issues, and other contributions
|
|
||||||
that are not aligned to this Code of Conduct, or to ban temporarily or
|
|
||||||
permanently any contributor for other behaviors that they deem inappropriate,
|
|
||||||
threatening, offensive, or harmful.
|
|
||||||
|
|
||||||
## Scope
|
|
||||||
|
|
||||||
This Code of Conduct applies both within project spaces and in public spaces
|
|
||||||
when an individual is representing the project or its community. Examples of
|
|
||||||
representing a project or community include using an official project e-mail
|
|
||||||
address, posting via an official social media account, or acting as an appointed
|
|
||||||
representative at an online or offline event. Representation of a project may be
|
|
||||||
further defined and clarified by project maintainers.
|
|
||||||
|
|
||||||
## Enforcement
|
|
||||||
|
|
||||||
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
|
||||||
reported by contacting the project team at ivan+abuse@flanders.co.nz. All
|
|
||||||
complaints will be reviewed and investigated and will result in a response that
|
|
||||||
is deemed necessary and appropriate to the circumstances. The project team is
|
|
||||||
obligated to maintain confidentiality with regard to the reporter of an incident.
|
|
||||||
Further details of specific enforcement policies may be posted separately.
|
|
||||||
|
|
||||||
Project maintainers who do not follow or enforce the Code of Conduct in good
|
|
||||||
faith may face temporary or permanent repercussions as determined by other
|
|
||||||
members of the project's leadership.
|
|
||||||
|
|
||||||
## Attribution
|
|
||||||
|
|
||||||
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
|
||||||
available at [http://contributor-covenant.org/version/1/4][version]
|
|
||||||
|
|
||||||
[homepage]: http://contributor-covenant.org
|
|
||||||
[version]: http://contributor-covenant.org/version/1/4/
|
|
6
vendor/github.com/go-openapi/analysis/README.md
generated
vendored
6
vendor/github.com/go-openapi/analysis/README.md
generated
vendored
|
@ -1,6 +0,0 @@
|
||||||
# OpenAPI initiative analysis [](https://ci.vmware.run/go-openapi/analysis) [](https://coverage.vmware.run/go-openapi/analysis) [](https://slackin.goswagger.io)
|
|
||||||
|
|
||||||
[](https://raw.githubusercontent.com/go-openapi/analysis/master/LICENSE) [](http://godoc.org/github.com/go-openapi/analysis)
|
|
||||||
|
|
||||||
|
|
||||||
A foundational library to analyze an OAI specification document for easier reasoning about the content.
|
|
614
vendor/github.com/go-openapi/analysis/analyzer.go
generated
vendored
614
vendor/github.com/go-openapi/analysis/analyzer.go
generated
vendored
|
@ -1,614 +0,0 @@
|
||||||
// Copyright 2015 go-swagger maintainers
|
|
||||||
//
|
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
// you may not use this file except in compliance with the License.
|
|
||||||
// You may obtain a copy of the License at
|
|
||||||
//
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
//
|
|
||||||
// Unless required by applicable law or agreed to in writing, software
|
|
||||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
// See the License for the specific language governing permissions and
|
|
||||||
// limitations under the License.
|
|
||||||
|
|
||||||
package analysis
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
slashpath "path"
|
|
||||||
"strconv"
|
|
||||||
"strings"
|
|
||||||
|
|
||||||
"github.com/go-openapi/jsonpointer"
|
|
||||||
"github.com/go-openapi/spec"
|
|
||||||
"github.com/go-openapi/swag"
|
|
||||||
)
|
|
||||||
|
|
||||||
type referenceAnalysis struct {
|
|
||||||
schemas map[string]spec.Ref
|
|
||||||
responses map[string]spec.Ref
|
|
||||||
parameters map[string]spec.Ref
|
|
||||||
items map[string]spec.Ref
|
|
||||||
allRefs map[string]spec.Ref
|
|
||||||
referenced struct {
|
|
||||||
schemas map[string]SchemaRef
|
|
||||||
responses map[string]*spec.Response
|
|
||||||
parameters map[string]*spec.Parameter
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (r *referenceAnalysis) addRef(key string, ref spec.Ref) {
|
|
||||||
r.allRefs["#"+key] = ref
|
|
||||||
}
|
|
||||||
|
|
||||||
func (r *referenceAnalysis) addItemsRef(key string, items *spec.Items) {
|
|
||||||
r.items["#"+key] = items.Ref
|
|
||||||
r.addRef(key, items.Ref)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (r *referenceAnalysis) addSchemaRef(key string, ref SchemaRef) {
|
|
||||||
r.schemas["#"+key] = ref.Schema.Ref
|
|
||||||
r.addRef(key, ref.Schema.Ref)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (r *referenceAnalysis) addResponseRef(key string, resp *spec.Response) {
|
|
||||||
r.responses["#"+key] = resp.Ref
|
|
||||||
r.addRef(key, resp.Ref)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (r *referenceAnalysis) addParamRef(key string, param *spec.Parameter) {
|
|
||||||
r.parameters["#"+key] = param.Ref
|
|
||||||
r.addRef(key, param.Ref)
|
|
||||||
}
|
|
||||||
|
|
||||||
// New takes a swagger spec object and returns an analyzed spec document.
|
|
||||||
// The analyzed document contains a number of indices that make it easier to
|
|
||||||
// reason about semantics of a swagger specification for use in code generation
|
|
||||||
// or validation etc.
|
|
||||||
func New(doc *spec.Swagger) *Spec {
|
|
||||||
a := &Spec{
|
|
||||||
spec: doc,
|
|
||||||
consumes: make(map[string]struct{}, 150),
|
|
||||||
produces: make(map[string]struct{}, 150),
|
|
||||||
authSchemes: make(map[string]struct{}, 150),
|
|
||||||
operations: make(map[string]map[string]*spec.Operation, 150),
|
|
||||||
allSchemas: make(map[string]SchemaRef, 150),
|
|
||||||
allOfs: make(map[string]SchemaRef, 150),
|
|
||||||
references: referenceAnalysis{
|
|
||||||
schemas: make(map[string]spec.Ref, 150),
|
|
||||||
responses: make(map[string]spec.Ref, 150),
|
|
||||||
parameters: make(map[string]spec.Ref, 150),
|
|
||||||
items: make(map[string]spec.Ref, 150),
|
|
||||||
allRefs: make(map[string]spec.Ref, 150),
|
|
||||||
},
|
|
||||||
}
|
|
||||||
a.references.referenced.schemas = make(map[string]SchemaRef, 150)
|
|
||||||
a.references.referenced.responses = make(map[string]*spec.Response, 150)
|
|
||||||
a.references.referenced.parameters = make(map[string]*spec.Parameter, 150)
|
|
||||||
a.initialize()
|
|
||||||
return a
|
|
||||||
}
|
|
||||||
|
|
||||||
// Spec takes a swagger spec object and turns it into a registry
|
|
||||||
// with a bunch of utility methods to act on the information in the spec
|
|
||||||
type Spec struct {
|
|
||||||
spec *spec.Swagger
|
|
||||||
consumes map[string]struct{}
|
|
||||||
produces map[string]struct{}
|
|
||||||
authSchemes map[string]struct{}
|
|
||||||
operations map[string]map[string]*spec.Operation
|
|
||||||
references referenceAnalysis
|
|
||||||
allSchemas map[string]SchemaRef
|
|
||||||
allOfs map[string]SchemaRef
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *Spec) initialize() {
|
|
||||||
for _, c := range s.spec.Consumes {
|
|
||||||
s.consumes[c] = struct{}{}
|
|
||||||
}
|
|
||||||
for _, c := range s.spec.Produces {
|
|
||||||
s.produces[c] = struct{}{}
|
|
||||||
}
|
|
||||||
for _, ss := range s.spec.Security {
|
|
||||||
for k := range ss {
|
|
||||||
s.authSchemes[k] = struct{}{}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for path, pathItem := range s.AllPaths() {
|
|
||||||
s.analyzeOperations(path, &pathItem)
|
|
||||||
}
|
|
||||||
|
|
||||||
for name, parameter := range s.spec.Parameters {
|
|
||||||
refPref := slashpath.Join("/parameters", jsonpointer.Escape(name))
|
|
||||||
if parameter.Items != nil {
|
|
||||||
s.analyzeItems("items", parameter.Items, refPref)
|
|
||||||
}
|
|
||||||
if parameter.In == "body" && parameter.Schema != nil {
|
|
||||||
s.analyzeSchema("schema", *parameter.Schema, refPref)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for name, response := range s.spec.Responses {
|
|
||||||
refPref := slashpath.Join("/responses", jsonpointer.Escape(name))
|
|
||||||
for _, v := range response.Headers {
|
|
||||||
if v.Items != nil {
|
|
||||||
s.analyzeItems("items", v.Items, refPref)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if response.Schema != nil {
|
|
||||||
s.analyzeSchema("schema", *response.Schema, refPref)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for name, schema := range s.spec.Definitions {
|
|
||||||
s.analyzeSchema(name, schema, "/definitions")
|
|
||||||
}
|
|
||||||
// TODO: after analyzing all things and flattening schemas etc
|
|
||||||
// resolve all the collected references to their final representations
|
|
||||||
// best put in a separate method because this could get expensive
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *Spec) analyzeOperations(path string, pi *spec.PathItem) {
|
|
||||||
// TODO: resolve refs here?
|
|
||||||
op := pi
|
|
||||||
s.analyzeOperation("GET", path, op.Get)
|
|
||||||
s.analyzeOperation("PUT", path, op.Put)
|
|
||||||
s.analyzeOperation("POST", path, op.Post)
|
|
||||||
s.analyzeOperation("PATCH", path, op.Patch)
|
|
||||||
s.analyzeOperation("DELETE", path, op.Delete)
|
|
||||||
s.analyzeOperation("HEAD", path, op.Head)
|
|
||||||
s.analyzeOperation("OPTIONS", path, op.Options)
|
|
||||||
for i, param := range op.Parameters {
|
|
||||||
refPref := slashpath.Join("/paths", jsonpointer.Escape(path), "parameters", strconv.Itoa(i))
|
|
||||||
if param.Ref.String() != "" {
|
|
||||||
s.references.addParamRef(refPref, ¶m)
|
|
||||||
}
|
|
||||||
if param.Items != nil {
|
|
||||||
s.analyzeItems("items", param.Items, refPref)
|
|
||||||
}
|
|
||||||
if param.Schema != nil {
|
|
||||||
s.analyzeSchema("schema", *param.Schema, refPref)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *Spec) analyzeItems(name string, items *spec.Items, prefix string) {
|
|
||||||
if items == nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
refPref := slashpath.Join(prefix, name)
|
|
||||||
s.analyzeItems(name, items.Items, refPref)
|
|
||||||
if items.Ref.String() != "" {
|
|
||||||
s.references.addItemsRef(refPref, items)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *Spec) analyzeOperation(method, path string, op *spec.Operation) {
|
|
||||||
if op == nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
for _, c := range op.Consumes {
|
|
||||||
s.consumes[c] = struct{}{}
|
|
||||||
}
|
|
||||||
for _, c := range op.Produces {
|
|
||||||
s.produces[c] = struct{}{}
|
|
||||||
}
|
|
||||||
for _, ss := range op.Security {
|
|
||||||
for k := range ss {
|
|
||||||
s.authSchemes[k] = struct{}{}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if _, ok := s.operations[method]; !ok {
|
|
||||||
s.operations[method] = make(map[string]*spec.Operation)
|
|
||||||
}
|
|
||||||
s.operations[method][path] = op
|
|
||||||
prefix := slashpath.Join("/paths", jsonpointer.Escape(path), strings.ToLower(method))
|
|
||||||
for i, param := range op.Parameters {
|
|
||||||
refPref := slashpath.Join(prefix, "parameters", strconv.Itoa(i))
|
|
||||||
if param.Ref.String() != "" {
|
|
||||||
s.references.addParamRef(refPref, ¶m)
|
|
||||||
}
|
|
||||||
s.analyzeItems("items", param.Items, refPref)
|
|
||||||
if param.In == "body" && param.Schema != nil {
|
|
||||||
s.analyzeSchema("schema", *param.Schema, refPref)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if op.Responses != nil {
|
|
||||||
if op.Responses.Default != nil {
|
|
||||||
refPref := slashpath.Join(prefix, "responses", "default")
|
|
||||||
if op.Responses.Default.Ref.String() != "" {
|
|
||||||
s.references.addResponseRef(refPref, op.Responses.Default)
|
|
||||||
}
|
|
||||||
for _, v := range op.Responses.Default.Headers {
|
|
||||||
s.analyzeItems("items", v.Items, refPref)
|
|
||||||
}
|
|
||||||
if op.Responses.Default.Schema != nil {
|
|
||||||
s.analyzeSchema("schema", *op.Responses.Default.Schema, refPref)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for k, res := range op.Responses.StatusCodeResponses {
|
|
||||||
refPref := slashpath.Join(prefix, "responses", strconv.Itoa(k))
|
|
||||||
if res.Ref.String() != "" {
|
|
||||||
s.references.addResponseRef(refPref, &res)
|
|
||||||
}
|
|
||||||
for _, v := range res.Headers {
|
|
||||||
s.analyzeItems("items", v.Items, refPref)
|
|
||||||
}
|
|
||||||
if res.Schema != nil {
|
|
||||||
s.analyzeSchema("schema", *res.Schema, refPref)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *Spec) analyzeSchema(name string, schema spec.Schema, prefix string) {
|
|
||||||
refURI := slashpath.Join(prefix, jsonpointer.Escape(name))
|
|
||||||
schRef := SchemaRef{
|
|
||||||
Name: name,
|
|
||||||
Schema: &schema,
|
|
||||||
Ref: spec.MustCreateRef("#" + refURI),
|
|
||||||
}
|
|
||||||
s.allSchemas["#"+refURI] = schRef
|
|
||||||
if schema.Ref.String() != "" {
|
|
||||||
s.references.addSchemaRef(refURI, schRef)
|
|
||||||
}
|
|
||||||
for k, v := range schema.Definitions {
|
|
||||||
s.analyzeSchema(k, v, slashpath.Join(refURI, "definitions"))
|
|
||||||
}
|
|
||||||
for k, v := range schema.Properties {
|
|
||||||
s.analyzeSchema(k, v, slashpath.Join(refURI, "properties"))
|
|
||||||
}
|
|
||||||
for k, v := range schema.PatternProperties {
|
|
||||||
s.analyzeSchema(k, v, slashpath.Join(refURI, "patternProperties"))
|
|
||||||
}
|
|
||||||
for i, v := range schema.AllOf {
|
|
||||||
s.analyzeSchema(strconv.Itoa(i), v, slashpath.Join(refURI, "allOf"))
|
|
||||||
}
|
|
||||||
if len(schema.AllOf) > 0 {
|
|
||||||
s.allOfs["#"+refURI] = SchemaRef{Name: name, Schema: &schema, Ref: spec.MustCreateRef("#" + refURI)}
|
|
||||||
}
|
|
||||||
for i, v := range schema.AnyOf {
|
|
||||||
s.analyzeSchema(strconv.Itoa(i), v, slashpath.Join(refURI, "anyOf"))
|
|
||||||
}
|
|
||||||
for i, v := range schema.OneOf {
|
|
||||||
s.analyzeSchema(strconv.Itoa(i), v, slashpath.Join(refURI, "oneOf"))
|
|
||||||
}
|
|
||||||
if schema.Not != nil {
|
|
||||||
s.analyzeSchema("not", *schema.Not, refURI)
|
|
||||||
}
|
|
||||||
if schema.AdditionalProperties != nil && schema.AdditionalProperties.Schema != nil {
|
|
||||||
s.analyzeSchema("additionalProperties", *schema.AdditionalProperties.Schema, refURI)
|
|
||||||
}
|
|
||||||
if schema.AdditionalItems != nil && schema.AdditionalItems.Schema != nil {
|
|
||||||
s.analyzeSchema("additionalItems", *schema.AdditionalItems.Schema, refURI)
|
|
||||||
}
|
|
||||||
if schema.Items != nil {
|
|
||||||
if schema.Items.Schema != nil {
|
|
||||||
s.analyzeSchema("items", *schema.Items.Schema, refURI)
|
|
||||||
}
|
|
||||||
for i, sch := range schema.Items.Schemas {
|
|
||||||
s.analyzeSchema(strconv.Itoa(i), sch, slashpath.Join(refURI, "items"))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// SecurityRequirement is a representation of a security requirement for an operation
|
|
||||||
type SecurityRequirement struct {
|
|
||||||
Name string
|
|
||||||
Scopes []string
|
|
||||||
}
|
|
||||||
|
|
||||||
// SecurityRequirementsFor gets the security requirements for the operation
|
|
||||||
func (s *Spec) SecurityRequirementsFor(operation *spec.Operation) []SecurityRequirement {
|
|
||||||
if s.spec.Security == nil && operation.Security == nil {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
schemes := s.spec.Security
|
|
||||||
if operation.Security != nil {
|
|
||||||
schemes = operation.Security
|
|
||||||
}
|
|
||||||
|
|
||||||
unique := make(map[string]SecurityRequirement)
|
|
||||||
for _, scheme := range schemes {
|
|
||||||
for k, v := range scheme {
|
|
||||||
if _, ok := unique[k]; !ok {
|
|
||||||
unique[k] = SecurityRequirement{Name: k, Scopes: v}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
var result []SecurityRequirement
|
|
||||||
for _, v := range unique {
|
|
||||||
result = append(result, v)
|
|
||||||
}
|
|
||||||
return result
|
|
||||||
}
|
|
||||||
|
|
||||||
// SecurityDefinitionsFor gets the matching security definitions for a set of requirements
|
|
||||||
func (s *Spec) SecurityDefinitionsFor(operation *spec.Operation) map[string]spec.SecurityScheme {
|
|
||||||
requirements := s.SecurityRequirementsFor(operation)
|
|
||||||
if len(requirements) == 0 {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
result := make(map[string]spec.SecurityScheme)
|
|
||||||
for _, v := range requirements {
|
|
||||||
if definition, ok := s.spec.SecurityDefinitions[v.Name]; ok {
|
|
||||||
if definition != nil {
|
|
||||||
result[v.Name] = *definition
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return result
|
|
||||||
}
|
|
||||||
|
|
||||||
// ConsumesFor gets the mediatypes for the operation
|
|
||||||
func (s *Spec) ConsumesFor(operation *spec.Operation) []string {
|
|
||||||
|
|
||||||
if len(operation.Consumes) == 0 {
|
|
||||||
cons := make(map[string]struct{}, len(s.spec.Consumes))
|
|
||||||
for _, k := range s.spec.Consumes {
|
|
||||||
cons[k] = struct{}{}
|
|
||||||
}
|
|
||||||
return s.structMapKeys(cons)
|
|
||||||
}
|
|
||||||
|
|
||||||
cons := make(map[string]struct{}, len(operation.Consumes))
|
|
||||||
for _, c := range operation.Consumes {
|
|
||||||
cons[c] = struct{}{}
|
|
||||||
}
|
|
||||||
return s.structMapKeys(cons)
|
|
||||||
}
|
|
||||||
|
|
||||||
// ProducesFor gets the mediatypes for the operation
|
|
||||||
func (s *Spec) ProducesFor(operation *spec.Operation) []string {
|
|
||||||
if len(operation.Produces) == 0 {
|
|
||||||
prod := make(map[string]struct{}, len(s.spec.Produces))
|
|
||||||
for _, k := range s.spec.Produces {
|
|
||||||
prod[k] = struct{}{}
|
|
||||||
}
|
|
||||||
return s.structMapKeys(prod)
|
|
||||||
}
|
|
||||||
|
|
||||||
prod := make(map[string]struct{}, len(operation.Produces))
|
|
||||||
for _, c := range operation.Produces {
|
|
||||||
prod[c] = struct{}{}
|
|
||||||
}
|
|
||||||
return s.structMapKeys(prod)
|
|
||||||
}
|
|
||||||
|
|
||||||
func mapKeyFromParam(param *spec.Parameter) string {
|
|
||||||
return fmt.Sprintf("%s#%s", param.In, fieldNameFromParam(param))
|
|
||||||
}
|
|
||||||
|
|
||||||
func fieldNameFromParam(param *spec.Parameter) string {
|
|
||||||
if nm, ok := param.Extensions.GetString("go-name"); ok {
|
|
||||||
return nm
|
|
||||||
}
|
|
||||||
return swag.ToGoName(param.Name)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *Spec) paramsAsMap(parameters []spec.Parameter, res map[string]spec.Parameter) {
|
|
||||||
for _, param := range parameters {
|
|
||||||
pr := param
|
|
||||||
if pr.Ref.String() != "" {
|
|
||||||
obj, _, err := pr.Ref.GetPointer().Get(s.spec)
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
pr = obj.(spec.Parameter)
|
|
||||||
}
|
|
||||||
res[mapKeyFromParam(&pr)] = pr
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// ParametersFor the specified operation id
|
|
||||||
func (s *Spec) ParametersFor(operationID string) []spec.Parameter {
|
|
||||||
gatherParams := func(pi *spec.PathItem, op *spec.Operation) []spec.Parameter {
|
|
||||||
bag := make(map[string]spec.Parameter)
|
|
||||||
s.paramsAsMap(pi.Parameters, bag)
|
|
||||||
s.paramsAsMap(op.Parameters, bag)
|
|
||||||
|
|
||||||
var res []spec.Parameter
|
|
||||||
for _, v := range bag {
|
|
||||||
res = append(res, v)
|
|
||||||
}
|
|
||||||
return res
|
|
||||||
}
|
|
||||||
for _, pi := range s.spec.Paths.Paths {
|
|
||||||
if pi.Get != nil && pi.Get.ID == operationID {
|
|
||||||
return gatherParams(&pi, pi.Get)
|
|
||||||
}
|
|
||||||
if pi.Head != nil && pi.Head.ID == operationID {
|
|
||||||
return gatherParams(&pi, pi.Head)
|
|
||||||
}
|
|
||||||
if pi.Options != nil && pi.Options.ID == operationID {
|
|
||||||
return gatherParams(&pi, pi.Options)
|
|
||||||
}
|
|
||||||
if pi.Post != nil && pi.Post.ID == operationID {
|
|
||||||
return gatherParams(&pi, pi.Post)
|
|
||||||
}
|
|
||||||
if pi.Patch != nil && pi.Patch.ID == operationID {
|
|
||||||
return gatherParams(&pi, pi.Patch)
|
|
||||||
}
|
|
||||||
if pi.Put != nil && pi.Put.ID == operationID {
|
|
||||||
return gatherParams(&pi, pi.Put)
|
|
||||||
}
|
|
||||||
if pi.Delete != nil && pi.Delete.ID == operationID {
|
|
||||||
return gatherParams(&pi, pi.Delete)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// ParamsFor the specified method and path. Aggregates them with the defaults etc, so it's all the params that
|
|
||||||
// apply for the method and path.
|
|
||||||
func (s *Spec) ParamsFor(method, path string) map[string]spec.Parameter {
|
|
||||||
res := make(map[string]spec.Parameter)
|
|
||||||
if pi, ok := s.spec.Paths.Paths[path]; ok {
|
|
||||||
s.paramsAsMap(pi.Parameters, res)
|
|
||||||
s.paramsAsMap(s.operations[strings.ToUpper(method)][path].Parameters, res)
|
|
||||||
}
|
|
||||||
return res
|
|
||||||
}
|
|
||||||
|
|
||||||
// OperationForName gets the operation for the given id
|
|
||||||
func (s *Spec) OperationForName(operationID string) (string, string, *spec.Operation, bool) {
|
|
||||||
for method, pathItem := range s.operations {
|
|
||||||
for path, op := range pathItem {
|
|
||||||
if operationID == op.ID {
|
|
||||||
return method, path, op, true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return "", "", nil, false
|
|
||||||
}
|
|
||||||
|
|
||||||
// OperationFor the given method and path
|
|
||||||
func (s *Spec) OperationFor(method, path string) (*spec.Operation, bool) {
|
|
||||||
if mp, ok := s.operations[strings.ToUpper(method)]; ok {
|
|
||||||
op, fn := mp[path]
|
|
||||||
return op, fn
|
|
||||||
}
|
|
||||||
return nil, false
|
|
||||||
}
|
|
||||||
|
|
||||||
// Operations gathers all the operations specified in the spec document
|
|
||||||
func (s *Spec) Operations() map[string]map[string]*spec.Operation {
|
|
||||||
return s.operations
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *Spec) structMapKeys(mp map[string]struct{}) []string {
|
|
||||||
if len(mp) == 0 {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
result := make([]string, 0, len(mp))
|
|
||||||
for k := range mp {
|
|
||||||
result = append(result, k)
|
|
||||||
}
|
|
||||||
return result
|
|
||||||
}
|
|
||||||
|
|
||||||
// AllPaths returns all the paths in the swagger spec
|
|
||||||
func (s *Spec) AllPaths() map[string]spec.PathItem {
|
|
||||||
if s.spec == nil || s.spec.Paths == nil {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
return s.spec.Paths.Paths
|
|
||||||
}
|
|
||||||
|
|
||||||
// OperationIDs gets all the operation ids based on method an dpath
|
|
||||||
func (s *Spec) OperationIDs() []string {
|
|
||||||
if len(s.operations) == 0 {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
result := make([]string, 0, len(s.operations))
|
|
||||||
for method, v := range s.operations {
|
|
||||||
for p, o := range v {
|
|
||||||
if o.ID != "" {
|
|
||||||
result = append(result, o.ID)
|
|
||||||
} else {
|
|
||||||
result = append(result, fmt.Sprintf("%s %s", strings.ToUpper(method), p))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return result
|
|
||||||
}
|
|
||||||
|
|
||||||
// RequiredConsumes gets all the distinct consumes that are specified in the specification document
|
|
||||||
func (s *Spec) RequiredConsumes() []string {
|
|
||||||
return s.structMapKeys(s.consumes)
|
|
||||||
}
|
|
||||||
|
|
||||||
// RequiredProduces gets all the distinct produces that are specified in the specification document
|
|
||||||
func (s *Spec) RequiredProduces() []string {
|
|
||||||
return s.structMapKeys(s.produces)
|
|
||||||
}
|
|
||||||
|
|
||||||
// RequiredSecuritySchemes gets all the distinct security schemes that are specified in the swagger spec
|
|
||||||
func (s *Spec) RequiredSecuritySchemes() []string {
|
|
||||||
return s.structMapKeys(s.authSchemes)
|
|
||||||
}
|
|
||||||
|
|
||||||
// SchemaRef is a reference to a schema
|
|
||||||
type SchemaRef struct {
|
|
||||||
Name string
|
|
||||||
Ref spec.Ref
|
|
||||||
Schema *spec.Schema
|
|
||||||
}
|
|
||||||
|
|
||||||
// SchemasWithAllOf returns schema references to all schemas that are defined
|
|
||||||
// with an allOf key
|
|
||||||
func (s *Spec) SchemasWithAllOf() (result []SchemaRef) {
|
|
||||||
for _, v := range s.allOfs {
|
|
||||||
result = append(result, v)
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// AllDefinitions returns schema references for all the definitions that were discovered
|
|
||||||
func (s *Spec) AllDefinitions() (result []SchemaRef) {
|
|
||||||
for _, v := range s.allSchemas {
|
|
||||||
result = append(result, v)
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// AllDefinitionReferences returns json refs for all the discovered schemas
|
|
||||||
func (s *Spec) AllDefinitionReferences() (result []string) {
|
|
||||||
for _, v := range s.references.schemas {
|
|
||||||
result = append(result, v.String())
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// AllParameterReferences returns json refs for all the discovered parameters
|
|
||||||
func (s *Spec) AllParameterReferences() (result []string) {
|
|
||||||
for _, v := range s.references.parameters {
|
|
||||||
result = append(result, v.String())
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// AllResponseReferences returns json refs for all the discovered responses
|
|
||||||
func (s *Spec) AllResponseReferences() (result []string) {
|
|
||||||
for _, v := range s.references.responses {
|
|
||||||
result = append(result, v.String())
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// AllItemsReferences returns the references for all the items
|
|
||||||
func (s *Spec) AllItemsReferences() (result []string) {
|
|
||||||
for _, v := range s.references.items {
|
|
||||||
result = append(result, v.String())
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// AllReferences returns all the references found in the document
|
|
||||||
func (s *Spec) AllReferences() (result []string) {
|
|
||||||
for _, v := range s.references.allRefs {
|
|
||||||
result = append(result, v.String())
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// AllRefs returns all the unique references found in the document
|
|
||||||
func (s *Spec) AllRefs() (result []spec.Ref) {
|
|
||||||
set := make(map[string]struct{})
|
|
||||||
for _, v := range s.references.allRefs {
|
|
||||||
a := v.String()
|
|
||||||
if a == "" {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
if _, ok := set[a]; !ok {
|
|
||||||
set[a] = struct{}{}
|
|
||||||
result = append(result, v)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
39
vendor/github.com/go-openapi/loads/.drone.yml
generated
vendored
39
vendor/github.com/go-openapi/loads/.drone.yml
generated
vendored
|
@ -1,39 +0,0 @@
|
||||||
clone:
|
|
||||||
path: github.com/go-openapi/loads
|
|
||||||
|
|
||||||
matrix:
|
|
||||||
GO_VERSION:
|
|
||||||
- "1.6"
|
|
||||||
|
|
||||||
build:
|
|
||||||
integration:
|
|
||||||
image: golang:$$GO_VERSION
|
|
||||||
pull: true
|
|
||||||
environment:
|
|
||||||
GOCOVMODE: "count"
|
|
||||||
commands:
|
|
||||||
- go get -u github.com/axw/gocov/gocov
|
|
||||||
- go get -u gopkg.in/matm/v1/gocov-html
|
|
||||||
- go get -u github.com/cee-dub/go-junit-report
|
|
||||||
- go get -u github.com/stretchr/testify/assert
|
|
||||||
- go get -u gopkg.in/yaml.v2
|
|
||||||
- go get -u github.com/go-openapi/swag
|
|
||||||
- go get -u github.com/go-openapi/analysis
|
|
||||||
- go get -u github.com/go-openapi/spec
|
|
||||||
- ./hack/build-drone.sh
|
|
||||||
|
|
||||||
notify:
|
|
||||||
slack:
|
|
||||||
channel: bots
|
|
||||||
webhook_url: $$SLACK_URL
|
|
||||||
username: drone
|
|
||||||
|
|
||||||
publish:
|
|
||||||
coverage:
|
|
||||||
server: https://coverage.vmware.run
|
|
||||||
token: $$GITHUB_TOKEN
|
|
||||||
# threshold: 70
|
|
||||||
# must_increase: true
|
|
||||||
when:
|
|
||||||
matrix:
|
|
||||||
GO_VERSION: "1.6"
|
|
4
vendor/github.com/go-openapi/loads/.gitignore
generated
vendored
4
vendor/github.com/go-openapi/loads/.gitignore
generated
vendored
|
@ -1,4 +0,0 @@
|
||||||
secrets.yml
|
|
||||||
coverage.out
|
|
||||||
profile.cov
|
|
||||||
profile.out
|
|
13
vendor/github.com/go-openapi/loads/.pullapprove.yml
generated
vendored
13
vendor/github.com/go-openapi/loads/.pullapprove.yml
generated
vendored
|
@ -1,13 +0,0 @@
|
||||||
approve_by_comment: true
|
|
||||||
approve_regex: '^(:shipit:|:\+1:|\+1|LGTM|lgtm|Approved)'
|
|
||||||
reject_regex: ^[Rr]ejected
|
|
||||||
reset_on_push: false
|
|
||||||
reviewers:
|
|
||||||
members:
|
|
||||||
- casualjim
|
|
||||||
- chancez
|
|
||||||
- frapposelli
|
|
||||||
- vburenin
|
|
||||||
- pytlesk4
|
|
||||||
name: pullapprove
|
|
||||||
required: 1
|
|
74
vendor/github.com/go-openapi/loads/CODE_OF_CONDUCT.md
generated
vendored
74
vendor/github.com/go-openapi/loads/CODE_OF_CONDUCT.md
generated
vendored
|
@ -1,74 +0,0 @@
|
||||||
# Contributor Covenant Code of Conduct
|
|
||||||
|
|
||||||
## Our Pledge
|
|
||||||
|
|
||||||
In the interest of fostering an open and welcoming environment, we as
|
|
||||||
contributors and maintainers pledge to making participation in our project and
|
|
||||||
our community a harassment-free experience for everyone, regardless of age, body
|
|
||||||
size, disability, ethnicity, gender identity and expression, level of experience,
|
|
||||||
nationality, personal appearance, race, religion, or sexual identity and
|
|
||||||
orientation.
|
|
||||||
|
|
||||||
## Our Standards
|
|
||||||
|
|
||||||
Examples of behavior that contributes to creating a positive environment
|
|
||||||
include:
|
|
||||||
|
|
||||||
* Using welcoming and inclusive language
|
|
||||||
* Being respectful of differing viewpoints and experiences
|
|
||||||
* Gracefully accepting constructive criticism
|
|
||||||
* Focusing on what is best for the community
|
|
||||||
* Showing empathy towards other community members
|
|
||||||
|
|
||||||
Examples of unacceptable behavior by participants include:
|
|
||||||
|
|
||||||
* The use of sexualized language or imagery and unwelcome sexual attention or
|
|
||||||
advances
|
|
||||||
* Trolling, insulting/derogatory comments, and personal or political attacks
|
|
||||||
* Public or private harassment
|
|
||||||
* Publishing others' private information, such as a physical or electronic
|
|
||||||
address, without explicit permission
|
|
||||||
* Other conduct which could reasonably be considered inappropriate in a
|
|
||||||
professional setting
|
|
||||||
|
|
||||||
## Our Responsibilities
|
|
||||||
|
|
||||||
Project maintainers are responsible for clarifying the standards of acceptable
|
|
||||||
behavior and are expected to take appropriate and fair corrective action in
|
|
||||||
response to any instances of unacceptable behavior.
|
|
||||||
|
|
||||||
Project maintainers have the right and responsibility to remove, edit, or
|
|
||||||
reject comments, commits, code, wiki edits, issues, and other contributions
|
|
||||||
that are not aligned to this Code of Conduct, or to ban temporarily or
|
|
||||||
permanently any contributor for other behaviors that they deem inappropriate,
|
|
||||||
threatening, offensive, or harmful.
|
|
||||||
|
|
||||||
## Scope
|
|
||||||
|
|
||||||
This Code of Conduct applies both within project spaces and in public spaces
|
|
||||||
when an individual is representing the project or its community. Examples of
|
|
||||||
representing a project or community include using an official project e-mail
|
|
||||||
address, posting via an official social media account, or acting as an appointed
|
|
||||||
representative at an online or offline event. Representation of a project may be
|
|
||||||
further defined and clarified by project maintainers.
|
|
||||||
|
|
||||||
## Enforcement
|
|
||||||
|
|
||||||
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
|
||||||
reported by contacting the project team at ivan+abuse@flanders.co.nz. All
|
|
||||||
complaints will be reviewed and investigated and will result in a response that
|
|
||||||
is deemed necessary and appropriate to the circumstances. The project team is
|
|
||||||
obligated to maintain confidentiality with regard to the reporter of an incident.
|
|
||||||
Further details of specific enforcement policies may be posted separately.
|
|
||||||
|
|
||||||
Project maintainers who do not follow or enforce the Code of Conduct in good
|
|
||||||
faith may face temporary or permanent repercussions as determined by other
|
|
||||||
members of the project's leadership.
|
|
||||||
|
|
||||||
## Attribution
|
|
||||||
|
|
||||||
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
|
||||||
available at [http://contributor-covenant.org/version/1/4][version]
|
|
||||||
|
|
||||||
[homepage]: http://contributor-covenant.org
|
|
||||||
[version]: http://contributor-covenant.org/version/1/4/
|
|
5
vendor/github.com/go-openapi/loads/README.md
generated
vendored
5
vendor/github.com/go-openapi/loads/README.md
generated
vendored
|
@ -1,5 +0,0 @@
|
||||||
# Loads OAI specs [](https://ci.vmware.run/go-openapi/loads) [](https://coverage.vmware.run/go-openapi/loads) [](https://slackin.goswagger.io)
|
|
||||||
|
|
||||||
[](https://raw.githubusercontent.com/go-openapi/loads/master/LICENSE) [](http://godoc.org/github.com/go-openapi/loads)
|
|
||||||
|
|
||||||
Loading of OAI specification documents from local or remote locations.
|
|
203
vendor/github.com/go-openapi/loads/spec.go
generated
vendored
203
vendor/github.com/go-openapi/loads/spec.go
generated
vendored
|
@ -1,203 +0,0 @@
|
||||||
// Copyright 2015 go-swagger maintainers
|
|
||||||
//
|
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
// you may not use this file except in compliance with the License.
|
|
||||||
// You may obtain a copy of the License at
|
|
||||||
//
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
//
|
|
||||||
// Unless required by applicable law or agreed to in writing, software
|
|
||||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
// See the License for the specific language governing permissions and
|
|
||||||
// limitations under the License.
|
|
||||||
|
|
||||||
package loads
|
|
||||||
|
|
||||||
import (
|
|
||||||
"encoding/json"
|
|
||||||
"fmt"
|
|
||||||
"net/url"
|
|
||||||
|
|
||||||
"github.com/go-openapi/analysis"
|
|
||||||
"github.com/go-openapi/spec"
|
|
||||||
"github.com/go-openapi/swag"
|
|
||||||
)
|
|
||||||
|
|
||||||
// JSONDoc loads a json document from either a file or a remote url
|
|
||||||
func JSONDoc(path string) (json.RawMessage, error) {
|
|
||||||
data, err := swag.LoadFromFileOrHTTP(path)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return json.RawMessage(data), nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// DocLoader represents a doc loader type
|
|
||||||
type DocLoader func(string) (json.RawMessage, error)
|
|
||||||
|
|
||||||
// DocMatcher represents a predicate to check if a loader matches
|
|
||||||
type DocMatcher func(string) bool
|
|
||||||
|
|
||||||
var loaders = &loader{Match: func(_ string) bool { return true }, Fn: JSONDoc}
|
|
||||||
|
|
||||||
// AddLoader for a document
|
|
||||||
func AddLoader(predicate DocMatcher, load DocLoader) {
|
|
||||||
prev := loaders
|
|
||||||
loaders = &loader{
|
|
||||||
Match: predicate,
|
|
||||||
Fn: load,
|
|
||||||
Next: prev,
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
type loader struct {
|
|
||||||
Fn DocLoader
|
|
||||||
Match DocMatcher
|
|
||||||
Next *loader
|
|
||||||
}
|
|
||||||
|
|
||||||
// JSONSpec loads a spec from a json document
|
|
||||||
func JSONSpec(path string) (*Document, error) {
|
|
||||||
data, err := JSONDoc(path)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
// convert to json
|
|
||||||
return Analyzed(json.RawMessage(data), "")
|
|
||||||
}
|
|
||||||
|
|
||||||
// Document represents a swagger spec document
|
|
||||||
type Document struct {
|
|
||||||
// specAnalyzer
|
|
||||||
Analyzer *analysis.Spec
|
|
||||||
spec *spec.Swagger
|
|
||||||
origSpec *spec.Swagger
|
|
||||||
schema *spec.Schema
|
|
||||||
raw json.RawMessage
|
|
||||||
}
|
|
||||||
|
|
||||||
// Spec loads a new spec document
|
|
||||||
func Spec(path string) (*Document, error) {
|
|
||||||
specURL, err := url.Parse(path)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
for l := loaders.Next; l != nil; l = l.Next {
|
|
||||||
if loaders.Match(specURL.Path) {
|
|
||||||
b, err2 := loaders.Fn(path)
|
|
||||||
if err2 != nil {
|
|
||||||
return nil, err2
|
|
||||||
}
|
|
||||||
return Analyzed(b, "")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
b, err := loaders.Fn(path)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return Analyzed(b, "")
|
|
||||||
}
|
|
||||||
|
|
||||||
var swag20Schema = spec.MustLoadSwagger20Schema()
|
|
||||||
|
|
||||||
// Analyzed creates a new analyzed spec document
|
|
||||||
func Analyzed(data json.RawMessage, version string) (*Document, error) {
|
|
||||||
if version == "" {
|
|
||||||
version = "2.0"
|
|
||||||
}
|
|
||||||
if version != "2.0" {
|
|
||||||
return nil, fmt.Errorf("spec version %q is not supported", version)
|
|
||||||
}
|
|
||||||
|
|
||||||
swspec := new(spec.Swagger)
|
|
||||||
if err := json.Unmarshal(data, swspec); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
origsqspec := new(spec.Swagger)
|
|
||||||
if err := json.Unmarshal(data, origsqspec); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
d := &Document{
|
|
||||||
Analyzer: analysis.New(swspec),
|
|
||||||
schema: swag20Schema,
|
|
||||||
spec: swspec,
|
|
||||||
raw: data,
|
|
||||||
origSpec: origsqspec,
|
|
||||||
}
|
|
||||||
return d, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// Expanded expands the ref fields in the spec document and returns a new spec document
|
|
||||||
func (d *Document) Expanded() (*Document, error) {
|
|
||||||
swspec := new(spec.Swagger)
|
|
||||||
if err := json.Unmarshal(d.raw, swspec); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
if err := spec.ExpandSpec(swspec); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
dd := &Document{
|
|
||||||
Analyzer: analysis.New(swspec),
|
|
||||||
spec: swspec,
|
|
||||||
schema: swag20Schema,
|
|
||||||
raw: d.raw,
|
|
||||||
origSpec: d.origSpec,
|
|
||||||
}
|
|
||||||
return dd, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// BasePath the base path for this spec
|
|
||||||
func (d *Document) BasePath() string {
|
|
||||||
return d.spec.BasePath
|
|
||||||
}
|
|
||||||
|
|
||||||
// Version returns the version of this spec
|
|
||||||
func (d *Document) Version() string {
|
|
||||||
return d.spec.Swagger
|
|
||||||
}
|
|
||||||
|
|
||||||
// Schema returns the swagger 2.0 schema
|
|
||||||
func (d *Document) Schema() *spec.Schema {
|
|
||||||
return d.schema
|
|
||||||
}
|
|
||||||
|
|
||||||
// Spec returns the swagger spec object model
|
|
||||||
func (d *Document) Spec() *spec.Swagger {
|
|
||||||
return d.spec
|
|
||||||
}
|
|
||||||
|
|
||||||
// Host returns the host for the API
|
|
||||||
func (d *Document) Host() string {
|
|
||||||
return d.spec.Host
|
|
||||||
}
|
|
||||||
|
|
||||||
// Raw returns the raw swagger spec as json bytes
|
|
||||||
func (d *Document) Raw() json.RawMessage {
|
|
||||||
return d.raw
|
|
||||||
}
|
|
||||||
|
|
||||||
func (d *Document) OrigSpec() *spec.Swagger {
|
|
||||||
return d.origSpec
|
|
||||||
}
|
|
||||||
|
|
||||||
// ResetDefinitions gives a shallow copy with the models reset
|
|
||||||
func (d *Document) ResetDefinitions() *Document {
|
|
||||||
defs := make(map[string]spec.Schema, len(d.origSpec.Definitions))
|
|
||||||
for k, v := range d.origSpec.Definitions {
|
|
||||||
defs[k] = v
|
|
||||||
}
|
|
||||||
|
|
||||||
d.spec.Definitions = defs
|
|
||||||
return d
|
|
||||||
}
|
|
||||||
|
|
||||||
// Pristine creates a new pristine document instance based on the input data
|
|
||||||
func (d *Document) Pristine() *Document {
|
|
||||||
dd, _ := Analyzed(d.Raw(), d.Version())
|
|
||||||
return dd
|
|
||||||
}
|
|
136
vendor/github.com/golang/protobuf/ptypes/any.go
generated
vendored
Normal file
136
vendor/github.com/golang/protobuf/ptypes/any.go
generated
vendored
Normal file
|
@ -0,0 +1,136 @@
|
||||||
|
// Go support for Protocol Buffers - Google's data interchange format
|
||||||
|
//
|
||||||
|
// Copyright 2016 The Go Authors. All rights reserved.
|
||||||
|
// https://github.com/golang/protobuf
|
||||||
|
//
|
||||||
|
// Redistribution and use in source and binary forms, with or without
|
||||||
|
// modification, are permitted provided that the following conditions are
|
||||||
|
// met:
|
||||||
|
//
|
||||||
|
// * Redistributions of source code must retain the above copyright
|
||||||
|
// notice, this list of conditions and the following disclaimer.
|
||||||
|
// * Redistributions in binary form must reproduce the above
|
||||||
|
// copyright notice, this list of conditions and the following disclaimer
|
||||||
|
// in the documentation and/or other materials provided with the
|
||||||
|
// distribution.
|
||||||
|
// * Neither the name of Google Inc. nor the names of its
|
||||||
|
// contributors may be used to endorse or promote products derived from
|
||||||
|
// this software without specific prior written permission.
|
||||||
|
//
|
||||||
|
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
package ptypes
|
||||||
|
|
||||||
|
// This file implements functions to marshal proto.Message to/from
|
||||||
|
// google.protobuf.Any message.
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"reflect"
|
||||||
|
"strings"
|
||||||
|
|
||||||
|
"github.com/golang/protobuf/proto"
|
||||||
|
"github.com/golang/protobuf/ptypes/any"
|
||||||
|
)
|
||||||
|
|
||||||
|
const googleApis = "type.googleapis.com/"
|
||||||
|
|
||||||
|
// AnyMessageName returns the name of the message contained in a google.protobuf.Any message.
|
||||||
|
//
|
||||||
|
// Note that regular type assertions should be done using the Is
|
||||||
|
// function. AnyMessageName is provided for less common use cases like filtering a
|
||||||
|
// sequence of Any messages based on a set of allowed message type names.
|
||||||
|
func AnyMessageName(any *any.Any) (string, error) {
|
||||||
|
slash := strings.LastIndex(any.TypeUrl, "/")
|
||||||
|
if slash < 0 {
|
||||||
|
return "", fmt.Errorf("message type url %q is invalid", any.TypeUrl)
|
||||||
|
}
|
||||||
|
return any.TypeUrl[slash+1:], nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// MarshalAny takes the protocol buffer and encodes it into google.protobuf.Any.
|
||||||
|
func MarshalAny(pb proto.Message) (*any.Any, error) {
|
||||||
|
value, err := proto.Marshal(pb)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return &any.Any{TypeUrl: googleApis + proto.MessageName(pb), Value: value}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// DynamicAny is a value that can be passed to UnmarshalAny to automatically
|
||||||
|
// allocate a proto.Message for the type specified in a google.protobuf.Any
|
||||||
|
// message. The allocated message is stored in the embedded proto.Message.
|
||||||
|
//
|
||||||
|
// Example:
|
||||||
|
//
|
||||||
|
// var x ptypes.DynamicAny
|
||||||
|
// if err := ptypes.UnmarshalAny(a, &x); err != nil { ... }
|
||||||
|
// fmt.Printf("unmarshaled message: %v", x.Message)
|
||||||
|
type DynamicAny struct {
|
||||||
|
proto.Message
|
||||||
|
}
|
||||||
|
|
||||||
|
// Empty returns a new proto.Message of the type specified in a
|
||||||
|
// google.protobuf.Any message. It returns an error if corresponding message
|
||||||
|
// type isn't linked in.
|
||||||
|
func Empty(any *any.Any) (proto.Message, error) {
|
||||||
|
aname, err := AnyMessageName(any)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
t := proto.MessageType(aname)
|
||||||
|
if t == nil {
|
||||||
|
return nil, fmt.Errorf("any: message type %q isn't linked in", aname)
|
||||||
|
}
|
||||||
|
return reflect.New(t.Elem()).Interface().(proto.Message), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// UnmarshalAny parses the protocol buffer representation in a google.protobuf.Any
|
||||||
|
// message and places the decoded result in pb. It returns an error if type of
|
||||||
|
// contents of Any message does not match type of pb message.
|
||||||
|
//
|
||||||
|
// pb can be a proto.Message, or a *DynamicAny.
|
||||||
|
func UnmarshalAny(any *any.Any, pb proto.Message) error {
|
||||||
|
if d, ok := pb.(*DynamicAny); ok {
|
||||||
|
if d.Message == nil {
|
||||||
|
var err error
|
||||||
|
d.Message, err = Empty(any)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return UnmarshalAny(any, d.Message)
|
||||||
|
}
|
||||||
|
|
||||||
|
aname, err := AnyMessageName(any)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
mname := proto.MessageName(pb)
|
||||||
|
if aname != mname {
|
||||||
|
return fmt.Errorf("mismatched message type: got %q want %q", aname, mname)
|
||||||
|
}
|
||||||
|
return proto.Unmarshal(any.Value, pb)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Is returns true if any value contains a given message type.
|
||||||
|
func Is(any *any.Any, pb proto.Message) bool {
|
||||||
|
aname, err := AnyMessageName(any)
|
||||||
|
if err != nil {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
return aname == proto.MessageName(pb)
|
||||||
|
}
|
155
vendor/github.com/golang/protobuf/ptypes/any/any.pb.go
generated
vendored
Normal file
155
vendor/github.com/golang/protobuf/ptypes/any/any.pb.go
generated
vendored
Normal file
|
@ -0,0 +1,155 @@
|
||||||
|
// Code generated by protoc-gen-go.
|
||||||
|
// source: github.com/golang/protobuf/ptypes/any/any.proto
|
||||||
|
// DO NOT EDIT!
|
||||||
|
|
||||||
|
/*
|
||||||
|
Package any is a generated protocol buffer package.
|
||||||
|
|
||||||
|
It is generated from these files:
|
||||||
|
github.com/golang/protobuf/ptypes/any/any.proto
|
||||||
|
|
||||||
|
It has these top-level messages:
|
||||||
|
Any
|
||||||
|
*/
|
||||||
|
package any
|
||||||
|
|
||||||
|
import proto "github.com/golang/protobuf/proto"
|
||||||
|
import fmt "fmt"
|
||||||
|
import math "math"
|
||||||
|
|
||||||
|
// Reference imports to suppress errors if they are not otherwise used.
|
||||||
|
var _ = proto.Marshal
|
||||||
|
var _ = fmt.Errorf
|
||||||
|
var _ = math.Inf
|
||||||
|
|
||||||
|
// This is a compile-time assertion to ensure that this generated file
|
||||||
|
// is compatible with the proto package it is being compiled against.
|
||||||
|
// A compilation error at this line likely means your copy of the
|
||||||
|
// proto package needs to be updated.
|
||||||
|
const _ = proto.ProtoPackageIsVersion2 // please upgrade the proto package
|
||||||
|
|
||||||
|
// `Any` contains an arbitrary serialized protocol buffer message along with a
|
||||||
|
// URL that describes the type of the serialized message.
|
||||||
|
//
|
||||||
|
// Protobuf library provides support to pack/unpack Any values in the form
|
||||||
|
// of utility functions or additional generated methods of the Any type.
|
||||||
|
//
|
||||||
|
// Example 1: Pack and unpack a message in C++.
|
||||||
|
//
|
||||||
|
// Foo foo = ...;
|
||||||
|
// Any any;
|
||||||
|
// any.PackFrom(foo);
|
||||||
|
// ...
|
||||||
|
// if (any.UnpackTo(&foo)) {
|
||||||
|
// ...
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// Example 2: Pack and unpack a message in Java.
|
||||||
|
//
|
||||||
|
// Foo foo = ...;
|
||||||
|
// Any any = Any.pack(foo);
|
||||||
|
// ...
|
||||||
|
// if (any.is(Foo.class)) {
|
||||||
|
// foo = any.unpack(Foo.class);
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// Example 3: Pack and unpack a message in Python.
|
||||||
|
//
|
||||||
|
// foo = Foo(...)
|
||||||
|
// any = Any()
|
||||||
|
// any.Pack(foo)
|
||||||
|
// ...
|
||||||
|
// if any.Is(Foo.DESCRIPTOR):
|
||||||
|
// any.Unpack(foo)
|
||||||
|
// ...
|
||||||
|
//
|
||||||
|
// The pack methods provided by protobuf library will by default use
|
||||||
|
// 'type.googleapis.com/full.type.name' as the type URL and the unpack
|
||||||
|
// methods only use the fully qualified type name after the last '/'
|
||||||
|
// in the type URL, for example "foo.bar.com/x/y.z" will yield type
|
||||||
|
// name "y.z".
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// JSON
|
||||||
|
// ====
|
||||||
|
// The JSON representation of an `Any` value uses the regular
|
||||||
|
// representation of the deserialized, embedded message, with an
|
||||||
|
// additional field `@type` which contains the type URL. Example:
|
||||||
|
//
|
||||||
|
// package google.profile;
|
||||||
|
// message Person {
|
||||||
|
// string first_name = 1;
|
||||||
|
// string last_name = 2;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// {
|
||||||
|
// "@type": "type.googleapis.com/google.profile.Person",
|
||||||
|
// "firstName": <string>,
|
||||||
|
// "lastName": <string>
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// If the embedded message type is well-known and has a custom JSON
|
||||||
|
// representation, that representation will be embedded adding a field
|
||||||
|
// `value` which holds the custom JSON in addition to the `@type`
|
||||||
|
// field. Example (for message [google.protobuf.Duration][]):
|
||||||
|
//
|
||||||
|
// {
|
||||||
|
// "@type": "type.googleapis.com/google.protobuf.Duration",
|
||||||
|
// "value": "1.212s"
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
type Any struct {
|
||||||
|
// A URL/resource name whose content describes the type of the
|
||||||
|
// serialized protocol buffer message.
|
||||||
|
//
|
||||||
|
// For URLs which use the scheme `http`, `https`, or no scheme, the
|
||||||
|
// following restrictions and interpretations apply:
|
||||||
|
//
|
||||||
|
// * If no scheme is provided, `https` is assumed.
|
||||||
|
// * The last segment of the URL's path must represent the fully
|
||||||
|
// qualified name of the type (as in `path/google.protobuf.Duration`).
|
||||||
|
// The name should be in a canonical form (e.g., leading "." is
|
||||||
|
// not accepted).
|
||||||
|
// * An HTTP GET on the URL must yield a [google.protobuf.Type][]
|
||||||
|
// value in binary format, or produce an error.
|
||||||
|
// * Applications are allowed to cache lookup results based on the
|
||||||
|
// URL, or have them precompiled into a binary to avoid any
|
||||||
|
// lookup. Therefore, binary compatibility needs to be preserved
|
||||||
|
// on changes to types. (Use versioned type names to manage
|
||||||
|
// breaking changes.)
|
||||||
|
//
|
||||||
|
// Schemes other than `http`, `https` (or the empty scheme) might be
|
||||||
|
// used with implementation specific semantics.
|
||||||
|
//
|
||||||
|
TypeUrl string `protobuf:"bytes,1,opt,name=type_url,json=typeUrl" json:"type_url,omitempty"`
|
||||||
|
// Must be a valid serialized protocol buffer of the above specified type.
|
||||||
|
Value []byte `protobuf:"bytes,2,opt,name=value,proto3" json:"value,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *Any) Reset() { *m = Any{} }
|
||||||
|
func (m *Any) String() string { return proto.CompactTextString(m) }
|
||||||
|
func (*Any) ProtoMessage() {}
|
||||||
|
func (*Any) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{0} }
|
||||||
|
func (*Any) XXX_WellKnownType() string { return "Any" }
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
proto.RegisterType((*Any)(nil), "google.protobuf.Any")
|
||||||
|
}
|
||||||
|
|
||||||
|
func init() { proto.RegisterFile("github.com/golang/protobuf/ptypes/any/any.proto", fileDescriptor0) }
|
||||||
|
|
||||||
|
var fileDescriptor0 = []byte{
|
||||||
|
// 187 bytes of a gzipped FileDescriptorProto
|
||||||
|
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0xe2, 0xd2, 0x4f, 0xcf, 0x2c, 0xc9,
|
||||||
|
0x28, 0x4d, 0xd2, 0x4b, 0xce, 0xcf, 0xd5, 0x4f, 0xcf, 0xcf, 0x49, 0xcc, 0x4b, 0xd7, 0x2f, 0x28,
|
||||||
|
0xca, 0x2f, 0xc9, 0x4f, 0x2a, 0x4d, 0xd3, 0x2f, 0x28, 0xa9, 0x2c, 0x48, 0x2d, 0xd6, 0x4f, 0xcc,
|
||||||
|
0xab, 0x04, 0x61, 0x3d, 0xb0, 0xb8, 0x10, 0x7f, 0x7a, 0x7e, 0x7e, 0x7a, 0x4e, 0xaa, 0x1e, 0x4c,
|
||||||
|
0x95, 0x92, 0x19, 0x17, 0xb3, 0x63, 0x5e, 0xa5, 0x90, 0x24, 0x17, 0x07, 0x48, 0x79, 0x7c, 0x69,
|
||||||
|
0x51, 0x8e, 0x04, 0xa3, 0x02, 0xa3, 0x06, 0x67, 0x10, 0x3b, 0x88, 0x1f, 0x5a, 0x94, 0x23, 0x24,
|
||||||
|
0xc2, 0xc5, 0x5a, 0x96, 0x98, 0x53, 0x9a, 0x2a, 0xc1, 0xa4, 0xc0, 0xa8, 0xc1, 0x13, 0x04, 0xe1,
|
||||||
|
0x38, 0x15, 0x71, 0x09, 0x27, 0xe7, 0xe7, 0xea, 0xa1, 0x19, 0xe7, 0xc4, 0xe1, 0x98, 0x57, 0x19,
|
||||||
|
0x00, 0xe2, 0x04, 0x30, 0x46, 0xa9, 0x12, 0xe5, 0xb8, 0x05, 0x8c, 0x8c, 0x8b, 0x98, 0x98, 0xdd,
|
||||||
|
0x03, 0x9c, 0x56, 0x31, 0xc9, 0xb9, 0x43, 0x4c, 0x0b, 0x80, 0xaa, 0xd2, 0x0b, 0x4f, 0xcd, 0xc9,
|
||||||
|
0xf1, 0xce, 0xcb, 0x2f, 0xcf, 0x0b, 0x01, 0xa9, 0x4e, 0x62, 0x03, 0x6b, 0x37, 0x06, 0x04, 0x00,
|
||||||
|
0x00, 0xff, 0xff, 0xc6, 0x4d, 0x03, 0x23, 0xf6, 0x00, 0x00, 0x00,
|
||||||
|
}
|
140
vendor/github.com/golang/protobuf/ptypes/any/any.proto
generated
vendored
Normal file
140
vendor/github.com/golang/protobuf/ptypes/any/any.proto
generated
vendored
Normal file
|
@ -0,0 +1,140 @@
|
||||||
|
// Protocol Buffers - Google's data interchange format
|
||||||
|
// Copyright 2008 Google Inc. All rights reserved.
|
||||||
|
// https://developers.google.com/protocol-buffers/
|
||||||
|
//
|
||||||
|
// Redistribution and use in source and binary forms, with or without
|
||||||
|
// modification, are permitted provided that the following conditions are
|
||||||
|
// met:
|
||||||
|
//
|
||||||
|
// * Redistributions of source code must retain the above copyright
|
||||||
|
// notice, this list of conditions and the following disclaimer.
|
||||||
|
// * Redistributions in binary form must reproduce the above
|
||||||
|
// copyright notice, this list of conditions and the following disclaimer
|
||||||
|
// in the documentation and/or other materials provided with the
|
||||||
|
// distribution.
|
||||||
|
// * Neither the name of Google Inc. nor the names of its
|
||||||
|
// contributors may be used to endorse or promote products derived from
|
||||||
|
// this software without specific prior written permission.
|
||||||
|
//
|
||||||
|
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
syntax = "proto3";
|
||||||
|
|
||||||
|
package google.protobuf;
|
||||||
|
|
||||||
|
option csharp_namespace = "Google.Protobuf.WellKnownTypes";
|
||||||
|
option go_package = "github.com/golang/protobuf/ptypes/any";
|
||||||
|
option java_package = "com.google.protobuf";
|
||||||
|
option java_outer_classname = "AnyProto";
|
||||||
|
option java_multiple_files = true;
|
||||||
|
option java_generate_equals_and_hash = true;
|
||||||
|
option objc_class_prefix = "GPB";
|
||||||
|
|
||||||
|
// `Any` contains an arbitrary serialized protocol buffer message along with a
|
||||||
|
// URL that describes the type of the serialized message.
|
||||||
|
//
|
||||||
|
// Protobuf library provides support to pack/unpack Any values in the form
|
||||||
|
// of utility functions or additional generated methods of the Any type.
|
||||||
|
//
|
||||||
|
// Example 1: Pack and unpack a message in C++.
|
||||||
|
//
|
||||||
|
// Foo foo = ...;
|
||||||
|
// Any any;
|
||||||
|
// any.PackFrom(foo);
|
||||||
|
// ...
|
||||||
|
// if (any.UnpackTo(&foo)) {
|
||||||
|
// ...
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// Example 2: Pack and unpack a message in Java.
|
||||||
|
//
|
||||||
|
// Foo foo = ...;
|
||||||
|
// Any any = Any.pack(foo);
|
||||||
|
// ...
|
||||||
|
// if (any.is(Foo.class)) {
|
||||||
|
// foo = any.unpack(Foo.class);
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// Example 3: Pack and unpack a message in Python.
|
||||||
|
//
|
||||||
|
// foo = Foo(...)
|
||||||
|
// any = Any()
|
||||||
|
// any.Pack(foo)
|
||||||
|
// ...
|
||||||
|
// if any.Is(Foo.DESCRIPTOR):
|
||||||
|
// any.Unpack(foo)
|
||||||
|
// ...
|
||||||
|
//
|
||||||
|
// The pack methods provided by protobuf library will by default use
|
||||||
|
// 'type.googleapis.com/full.type.name' as the type URL and the unpack
|
||||||
|
// methods only use the fully qualified type name after the last '/'
|
||||||
|
// in the type URL, for example "foo.bar.com/x/y.z" will yield type
|
||||||
|
// name "y.z".
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// JSON
|
||||||
|
// ====
|
||||||
|
// The JSON representation of an `Any` value uses the regular
|
||||||
|
// representation of the deserialized, embedded message, with an
|
||||||
|
// additional field `@type` which contains the type URL. Example:
|
||||||
|
//
|
||||||
|
// package google.profile;
|
||||||
|
// message Person {
|
||||||
|
// string first_name = 1;
|
||||||
|
// string last_name = 2;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// {
|
||||||
|
// "@type": "type.googleapis.com/google.profile.Person",
|
||||||
|
// "firstName": <string>,
|
||||||
|
// "lastName": <string>
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// If the embedded message type is well-known and has a custom JSON
|
||||||
|
// representation, that representation will be embedded adding a field
|
||||||
|
// `value` which holds the custom JSON in addition to the `@type`
|
||||||
|
// field. Example (for message [google.protobuf.Duration][]):
|
||||||
|
//
|
||||||
|
// {
|
||||||
|
// "@type": "type.googleapis.com/google.protobuf.Duration",
|
||||||
|
// "value": "1.212s"
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
message Any {
|
||||||
|
// A URL/resource name whose content describes the type of the
|
||||||
|
// serialized protocol buffer message.
|
||||||
|
//
|
||||||
|
// For URLs which use the scheme `http`, `https`, or no scheme, the
|
||||||
|
// following restrictions and interpretations apply:
|
||||||
|
//
|
||||||
|
// * If no scheme is provided, `https` is assumed.
|
||||||
|
// * The last segment of the URL's path must represent the fully
|
||||||
|
// qualified name of the type (as in `path/google.protobuf.Duration`).
|
||||||
|
// The name should be in a canonical form (e.g., leading "." is
|
||||||
|
// not accepted).
|
||||||
|
// * An HTTP GET on the URL must yield a [google.protobuf.Type][]
|
||||||
|
// value in binary format, or produce an error.
|
||||||
|
// * Applications are allowed to cache lookup results based on the
|
||||||
|
// URL, or have them precompiled into a binary to avoid any
|
||||||
|
// lookup. Therefore, binary compatibility needs to be preserved
|
||||||
|
// on changes to types. (Use versioned type names to manage
|
||||||
|
// breaking changes.)
|
||||||
|
//
|
||||||
|
// Schemes other than `http`, `https` (or the empty scheme) might be
|
||||||
|
// used with implementation specific semantics.
|
||||||
|
//
|
||||||
|
string type_url = 1;
|
||||||
|
|
||||||
|
// Must be a valid serialized protocol buffer of the above specified type.
|
||||||
|
bytes value = 2;
|
||||||
|
}
|
35
vendor/github.com/golang/protobuf/ptypes/doc.go
generated
vendored
Normal file
35
vendor/github.com/golang/protobuf/ptypes/doc.go
generated
vendored
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
// Go support for Protocol Buffers - Google's data interchange format
|
||||||
|
//
|
||||||
|
// Copyright 2016 The Go Authors. All rights reserved.
|
||||||
|
// https://github.com/golang/protobuf
|
||||||
|
//
|
||||||
|
// Redistribution and use in source and binary forms, with or without
|
||||||
|
// modification, are permitted provided that the following conditions are
|
||||||
|
// met:
|
||||||
|
//
|
||||||
|
// * Redistributions of source code must retain the above copyright
|
||||||
|
// notice, this list of conditions and the following disclaimer.
|
||||||
|
// * Redistributions in binary form must reproduce the above
|
||||||
|
// copyright notice, this list of conditions and the following disclaimer
|
||||||
|
// in the documentation and/or other materials provided with the
|
||||||
|
// distribution.
|
||||||
|
// * Neither the name of Google Inc. nor the names of its
|
||||||
|
// contributors may be used to endorse or promote products derived from
|
||||||
|
// this software without specific prior written permission.
|
||||||
|
//
|
||||||
|
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
/*
|
||||||
|
Package ptypes contains code for interacting with well-known types.
|
||||||
|
*/
|
||||||
|
package ptypes
|
102
vendor/github.com/golang/protobuf/ptypes/duration.go
generated
vendored
Normal file
102
vendor/github.com/golang/protobuf/ptypes/duration.go
generated
vendored
Normal file
|
@ -0,0 +1,102 @@
|
||||||
|
// Go support for Protocol Buffers - Google's data interchange format
|
||||||
|
//
|
||||||
|
// Copyright 2016 The Go Authors. All rights reserved.
|
||||||
|
// https://github.com/golang/protobuf
|
||||||
|
//
|
||||||
|
// Redistribution and use in source and binary forms, with or without
|
||||||
|
// modification, are permitted provided that the following conditions are
|
||||||
|
// met:
|
||||||
|
//
|
||||||
|
// * Redistributions of source code must retain the above copyright
|
||||||
|
// notice, this list of conditions and the following disclaimer.
|
||||||
|
// * Redistributions in binary form must reproduce the above
|
||||||
|
// copyright notice, this list of conditions and the following disclaimer
|
||||||
|
// in the documentation and/or other materials provided with the
|
||||||
|
// distribution.
|
||||||
|
// * Neither the name of Google Inc. nor the names of its
|
||||||
|
// contributors may be used to endorse or promote products derived from
|
||||||
|
// this software without specific prior written permission.
|
||||||
|
//
|
||||||
|
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
package ptypes
|
||||||
|
|
||||||
|
// This file implements conversions between google.protobuf.Duration
|
||||||
|
// and time.Duration.
|
||||||
|
|
||||||
|
import (
|
||||||
|
"errors"
|
||||||
|
"fmt"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
durpb "github.com/golang/protobuf/ptypes/duration"
|
||||||
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
// Range of a durpb.Duration in seconds, as specified in
|
||||||
|
// google/protobuf/duration.proto. This is about 10,000 years in seconds.
|
||||||
|
maxSeconds = int64(10000 * 365.25 * 24 * 60 * 60)
|
||||||
|
minSeconds = -maxSeconds
|
||||||
|
)
|
||||||
|
|
||||||
|
// validateDuration determines whether the durpb.Duration is valid according to the
|
||||||
|
// definition in google/protobuf/duration.proto. A valid durpb.Duration
|
||||||
|
// may still be too large to fit into a time.Duration (the range of durpb.Duration
|
||||||
|
// is about 10,000 years, and the range of time.Duration is about 290).
|
||||||
|
func validateDuration(d *durpb.Duration) error {
|
||||||
|
if d == nil {
|
||||||
|
return errors.New("duration: nil Duration")
|
||||||
|
}
|
||||||
|
if d.Seconds < minSeconds || d.Seconds > maxSeconds {
|
||||||
|
return fmt.Errorf("duration: %v: seconds out of range", d)
|
||||||
|
}
|
||||||
|
if d.Nanos <= -1e9 || d.Nanos >= 1e9 {
|
||||||
|
return fmt.Errorf("duration: %v: nanos out of range", d)
|
||||||
|
}
|
||||||
|
// Seconds and Nanos must have the same sign, unless d.Nanos is zero.
|
||||||
|
if (d.Seconds < 0 && d.Nanos > 0) || (d.Seconds > 0 && d.Nanos < 0) {
|
||||||
|
return fmt.Errorf("duration: %v: seconds and nanos have different signs", d)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Duration converts a durpb.Duration to a time.Duration. Duration
|
||||||
|
// returns an error if the durpb.Duration is invalid or is too large to be
|
||||||
|
// represented in a time.Duration.
|
||||||
|
func Duration(p *durpb.Duration) (time.Duration, error) {
|
||||||
|
if err := validateDuration(p); err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
d := time.Duration(p.Seconds) * time.Second
|
||||||
|
if int64(d/time.Second) != p.Seconds {
|
||||||
|
return 0, fmt.Errorf("duration: %v is out of range for time.Duration", p)
|
||||||
|
}
|
||||||
|
if p.Nanos != 0 {
|
||||||
|
d += time.Duration(p.Nanos)
|
||||||
|
if (d < 0) != (p.Nanos < 0) {
|
||||||
|
return 0, fmt.Errorf("duration: %v is out of range for time.Duration", p)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return d, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// DurationProto converts a time.Duration to a durpb.Duration.
|
||||||
|
func DurationProto(d time.Duration) *durpb.Duration {
|
||||||
|
nanos := d.Nanoseconds()
|
||||||
|
secs := nanos / 1e9
|
||||||
|
nanos -= secs * 1e9
|
||||||
|
return &durpb.Duration{
|
||||||
|
Seconds: secs,
|
||||||
|
Nanos: int32(nanos),
|
||||||
|
}
|
||||||
|
}
|
114
vendor/github.com/golang/protobuf/ptypes/duration/duration.pb.go
generated
vendored
Normal file
114
vendor/github.com/golang/protobuf/ptypes/duration/duration.pb.go
generated
vendored
Normal file
|
@ -0,0 +1,114 @@
|
||||||
|
// Code generated by protoc-gen-go.
|
||||||
|
// source: github.com/golang/protobuf/ptypes/duration/duration.proto
|
||||||
|
// DO NOT EDIT!
|
||||||
|
|
||||||
|
/*
|
||||||
|
Package duration is a generated protocol buffer package.
|
||||||
|
|
||||||
|
It is generated from these files:
|
||||||
|
github.com/golang/protobuf/ptypes/duration/duration.proto
|
||||||
|
|
||||||
|
It has these top-level messages:
|
||||||
|
Duration
|
||||||
|
*/
|
||||||
|
package duration
|
||||||
|
|
||||||
|
import proto "github.com/golang/protobuf/proto"
|
||||||
|
import fmt "fmt"
|
||||||
|
import math "math"
|
||||||
|
|
||||||
|
// Reference imports to suppress errors if they are not otherwise used.
|
||||||
|
var _ = proto.Marshal
|
||||||
|
var _ = fmt.Errorf
|
||||||
|
var _ = math.Inf
|
||||||
|
|
||||||
|
// This is a compile-time assertion to ensure that this generated file
|
||||||
|
// is compatible with the proto package it is being compiled against.
|
||||||
|
// A compilation error at this line likely means your copy of the
|
||||||
|
// proto package needs to be updated.
|
||||||
|
const _ = proto.ProtoPackageIsVersion2 // please upgrade the proto package
|
||||||
|
|
||||||
|
// A Duration represents a signed, fixed-length span of time represented
|
||||||
|
// as a count of seconds and fractions of seconds at nanosecond
|
||||||
|
// resolution. It is independent of any calendar and concepts like "day"
|
||||||
|
// or "month". It is related to Timestamp in that the difference between
|
||||||
|
// two Timestamp values is a Duration and it can be added or subtracted
|
||||||
|
// from a Timestamp. Range is approximately +-10,000 years.
|
||||||
|
//
|
||||||
|
// Example 1: Compute Duration from two Timestamps in pseudo code.
|
||||||
|
//
|
||||||
|
// Timestamp start = ...;
|
||||||
|
// Timestamp end = ...;
|
||||||
|
// Duration duration = ...;
|
||||||
|
//
|
||||||
|
// duration.seconds = end.seconds - start.seconds;
|
||||||
|
// duration.nanos = end.nanos - start.nanos;
|
||||||
|
//
|
||||||
|
// if (duration.seconds < 0 && duration.nanos > 0) {
|
||||||
|
// duration.seconds += 1;
|
||||||
|
// duration.nanos -= 1000000000;
|
||||||
|
// } else if (durations.seconds > 0 && duration.nanos < 0) {
|
||||||
|
// duration.seconds -= 1;
|
||||||
|
// duration.nanos += 1000000000;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// Example 2: Compute Timestamp from Timestamp + Duration in pseudo code.
|
||||||
|
//
|
||||||
|
// Timestamp start = ...;
|
||||||
|
// Duration duration = ...;
|
||||||
|
// Timestamp end = ...;
|
||||||
|
//
|
||||||
|
// end.seconds = start.seconds + duration.seconds;
|
||||||
|
// end.nanos = start.nanos + duration.nanos;
|
||||||
|
//
|
||||||
|
// if (end.nanos < 0) {
|
||||||
|
// end.seconds -= 1;
|
||||||
|
// end.nanos += 1000000000;
|
||||||
|
// } else if (end.nanos >= 1000000000) {
|
||||||
|
// end.seconds += 1;
|
||||||
|
// end.nanos -= 1000000000;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
//
|
||||||
|
type Duration struct {
|
||||||
|
// Signed seconds of the span of time. Must be from -315,576,000,000
|
||||||
|
// to +315,576,000,000 inclusive.
|
||||||
|
Seconds int64 `protobuf:"varint,1,opt,name=seconds" json:"seconds,omitempty"`
|
||||||
|
// Signed fractions of a second at nanosecond resolution of the span
|
||||||
|
// of time. Durations less than one second are represented with a 0
|
||||||
|
// `seconds` field and a positive or negative `nanos` field. For durations
|
||||||
|
// of one second or more, a non-zero value for the `nanos` field must be
|
||||||
|
// of the same sign as the `seconds` field. Must be from -999,999,999
|
||||||
|
// to +999,999,999 inclusive.
|
||||||
|
Nanos int32 `protobuf:"varint,2,opt,name=nanos" json:"nanos,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *Duration) Reset() { *m = Duration{} }
|
||||||
|
func (m *Duration) String() string { return proto.CompactTextString(m) }
|
||||||
|
func (*Duration) ProtoMessage() {}
|
||||||
|
func (*Duration) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{0} }
|
||||||
|
func (*Duration) XXX_WellKnownType() string { return "Duration" }
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
proto.RegisterType((*Duration)(nil), "google.protobuf.Duration")
|
||||||
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
proto.RegisterFile("github.com/golang/protobuf/ptypes/duration/duration.proto", fileDescriptor0)
|
||||||
|
}
|
||||||
|
|
||||||
|
var fileDescriptor0 = []byte{
|
||||||
|
// 189 bytes of a gzipped FileDescriptorProto
|
||||||
|
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0xe2, 0xb2, 0x4c, 0xcf, 0x2c, 0xc9,
|
||||||
|
0x28, 0x4d, 0xd2, 0x4b, 0xce, 0xcf, 0xd5, 0x4f, 0xcf, 0xcf, 0x49, 0xcc, 0x4b, 0xd7, 0x2f, 0x28,
|
||||||
|
0xca, 0x2f, 0xc9, 0x4f, 0x2a, 0x4d, 0xd3, 0x2f, 0x28, 0xa9, 0x2c, 0x48, 0x2d, 0xd6, 0x4f, 0x29,
|
||||||
|
0x2d, 0x4a, 0x2c, 0xc9, 0xcc, 0xcf, 0x83, 0x33, 0xf4, 0xc0, 0x2a, 0x84, 0xf8, 0xd3, 0xf3, 0xf3,
|
||||||
|
0xd3, 0x73, 0x52, 0xf5, 0x60, 0xea, 0x95, 0xac, 0xb8, 0x38, 0x5c, 0xa0, 0x4a, 0x84, 0x24, 0xb8,
|
||||||
|
0xd8, 0x8b, 0x53, 0x93, 0xf3, 0xf3, 0x52, 0x8a, 0x25, 0x18, 0x15, 0x18, 0x35, 0x98, 0x83, 0x60,
|
||||||
|
0x5c, 0x21, 0x11, 0x2e, 0xd6, 0xbc, 0xc4, 0xbc, 0xfc, 0x62, 0x09, 0x26, 0x05, 0x46, 0x0d, 0xd6,
|
||||||
|
0x20, 0x08, 0xc7, 0xa9, 0x86, 0x4b, 0x38, 0x39, 0x3f, 0x57, 0x0f, 0xcd, 0x48, 0x27, 0x5e, 0x98,
|
||||||
|
0x81, 0x01, 0x20, 0x91, 0x00, 0xc6, 0x28, 0x2d, 0xe2, 0xdd, 0xbb, 0x80, 0x91, 0x71, 0x11, 0x13,
|
||||||
|
0xb3, 0x7b, 0x80, 0xd3, 0x2a, 0x26, 0x39, 0x77, 0x88, 0xb9, 0x01, 0x50, 0xa5, 0x7a, 0xe1, 0xa9,
|
||||||
|
0x39, 0x39, 0xde, 0x79, 0xf9, 0xe5, 0x79, 0x21, 0x20, 0x2d, 0x49, 0x6c, 0x60, 0x33, 0x8c, 0x01,
|
||||||
|
0x01, 0x00, 0x00, 0xff, 0xff, 0x62, 0xfb, 0xb1, 0x51, 0x0e, 0x01, 0x00, 0x00,
|
||||||
|
}
|
98
vendor/github.com/golang/protobuf/ptypes/duration/duration.proto
generated
vendored
Normal file
98
vendor/github.com/golang/protobuf/ptypes/duration/duration.proto
generated
vendored
Normal file
|
@ -0,0 +1,98 @@
|
||||||
|
// Protocol Buffers - Google's data interchange format
|
||||||
|
// Copyright 2008 Google Inc. All rights reserved.
|
||||||
|
// https://developers.google.com/protocol-buffers/
|
||||||
|
//
|
||||||
|
// Redistribution and use in source and binary forms, with or without
|
||||||
|
// modification, are permitted provided that the following conditions are
|
||||||
|
// met:
|
||||||
|
//
|
||||||
|
// * Redistributions of source code must retain the above copyright
|
||||||
|
// notice, this list of conditions and the following disclaimer.
|
||||||
|
// * Redistributions in binary form must reproduce the above
|
||||||
|
// copyright notice, this list of conditions and the following disclaimer
|
||||||
|
// in the documentation and/or other materials provided with the
|
||||||
|
// distribution.
|
||||||
|
// * Neither the name of Google Inc. nor the names of its
|
||||||
|
// contributors may be used to endorse or promote products derived from
|
||||||
|
// this software without specific prior written permission.
|
||||||
|
//
|
||||||
|
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
syntax = "proto3";
|
||||||
|
|
||||||
|
package google.protobuf;
|
||||||
|
|
||||||
|
option csharp_namespace = "Google.Protobuf.WellKnownTypes";
|
||||||
|
option go_package = "github.com/golang/protobuf/ptypes/duration";
|
||||||
|
option java_package = "com.google.protobuf";
|
||||||
|
option java_outer_classname = "DurationProto";
|
||||||
|
option java_multiple_files = true;
|
||||||
|
option java_generate_equals_and_hash = true;
|
||||||
|
option objc_class_prefix = "GPB";
|
||||||
|
|
||||||
|
// A Duration represents a signed, fixed-length span of time represented
|
||||||
|
// as a count of seconds and fractions of seconds at nanosecond
|
||||||
|
// resolution. It is independent of any calendar and concepts like "day"
|
||||||
|
// or "month". It is related to Timestamp in that the difference between
|
||||||
|
// two Timestamp values is a Duration and it can be added or subtracted
|
||||||
|
// from a Timestamp. Range is approximately +-10,000 years.
|
||||||
|
//
|
||||||
|
// Example 1: Compute Duration from two Timestamps in pseudo code.
|
||||||
|
//
|
||||||
|
// Timestamp start = ...;
|
||||||
|
// Timestamp end = ...;
|
||||||
|
// Duration duration = ...;
|
||||||
|
//
|
||||||
|
// duration.seconds = end.seconds - start.seconds;
|
||||||
|
// duration.nanos = end.nanos - start.nanos;
|
||||||
|
//
|
||||||
|
// if (duration.seconds < 0 && duration.nanos > 0) {
|
||||||
|
// duration.seconds += 1;
|
||||||
|
// duration.nanos -= 1000000000;
|
||||||
|
// } else if (durations.seconds > 0 && duration.nanos < 0) {
|
||||||
|
// duration.seconds -= 1;
|
||||||
|
// duration.nanos += 1000000000;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// Example 2: Compute Timestamp from Timestamp + Duration in pseudo code.
|
||||||
|
//
|
||||||
|
// Timestamp start = ...;
|
||||||
|
// Duration duration = ...;
|
||||||
|
// Timestamp end = ...;
|
||||||
|
//
|
||||||
|
// end.seconds = start.seconds + duration.seconds;
|
||||||
|
// end.nanos = start.nanos + duration.nanos;
|
||||||
|
//
|
||||||
|
// if (end.nanos < 0) {
|
||||||
|
// end.seconds -= 1;
|
||||||
|
// end.nanos += 1000000000;
|
||||||
|
// } else if (end.nanos >= 1000000000) {
|
||||||
|
// end.seconds += 1;
|
||||||
|
// end.nanos -= 1000000000;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
//
|
||||||
|
message Duration {
|
||||||
|
|
||||||
|
// Signed seconds of the span of time. Must be from -315,576,000,000
|
||||||
|
// to +315,576,000,000 inclusive.
|
||||||
|
int64 seconds = 1;
|
||||||
|
|
||||||
|
// Signed fractions of a second at nanosecond resolution of the span
|
||||||
|
// of time. Durations less than one second are represented with a 0
|
||||||
|
// `seconds` field and a positive or negative `nanos` field. For durations
|
||||||
|
// of one second or more, a non-zero value for the `nanos` field must be
|
||||||
|
// of the same sign as the `seconds` field. Must be from -999,999,999
|
||||||
|
// to +999,999,999 inclusive.
|
||||||
|
int32 nanos = 2;
|
||||||
|
}
|
66
vendor/github.com/golang/protobuf/ptypes/regen.sh
generated
vendored
Executable file
66
vendor/github.com/golang/protobuf/ptypes/regen.sh
generated
vendored
Executable file
|
@ -0,0 +1,66 @@
|
||||||
|
#!/bin/bash -e
|
||||||
|
#
|
||||||
|
# This script fetches and rebuilds the "well-known types" protocol buffers.
|
||||||
|
# To run this you will need protoc and goprotobuf installed;
|
||||||
|
# see https://github.com/golang/protobuf for instructions.
|
||||||
|
# You also need Go and Git installed.
|
||||||
|
|
||||||
|
PKG=github.com/golang/protobuf/ptypes
|
||||||
|
UPSTREAM=https://github.com/google/protobuf
|
||||||
|
UPSTREAM_SUBDIR=src/google/protobuf
|
||||||
|
PROTO_FILES='
|
||||||
|
any.proto
|
||||||
|
duration.proto
|
||||||
|
empty.proto
|
||||||
|
struct.proto
|
||||||
|
timestamp.proto
|
||||||
|
wrappers.proto
|
||||||
|
'
|
||||||
|
|
||||||
|
function die() {
|
||||||
|
echo 1>&2 $*
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
# Sanity check that the right tools are accessible.
|
||||||
|
for tool in go git protoc protoc-gen-go; do
|
||||||
|
q=$(which $tool) || die "didn't find $tool"
|
||||||
|
echo 1>&2 "$tool: $q"
|
||||||
|
done
|
||||||
|
|
||||||
|
tmpdir=$(mktemp -d -t regen-wkt.XXXXXX)
|
||||||
|
trap 'rm -rf $tmpdir' EXIT
|
||||||
|
|
||||||
|
echo -n 1>&2 "finding package dir... "
|
||||||
|
pkgdir=$(go list -f '{{.Dir}}' $PKG)
|
||||||
|
echo 1>&2 $pkgdir
|
||||||
|
base=$(echo $pkgdir | sed "s,/$PKG\$,,")
|
||||||
|
echo 1>&2 "base: $base"
|
||||||
|
cd $base
|
||||||
|
|
||||||
|
echo 1>&2 "fetching latest protos... "
|
||||||
|
git clone -q $UPSTREAM $tmpdir
|
||||||
|
# Pass 1: build mapping from upstream filename to our filename.
|
||||||
|
declare -A filename_map
|
||||||
|
for f in $(cd $PKG && find * -name '*.proto'); do
|
||||||
|
echo -n 1>&2 "looking for latest version of $f... "
|
||||||
|
up=$(cd $tmpdir/$UPSTREAM_SUBDIR && find * -name $(basename $f) | grep -v /testdata/)
|
||||||
|
echo 1>&2 $up
|
||||||
|
if [ $(echo $up | wc -w) != "1" ]; then
|
||||||
|
die "not exactly one match"
|
||||||
|
fi
|
||||||
|
filename_map[$up]=$f
|
||||||
|
done
|
||||||
|
# Pass 2: copy files
|
||||||
|
for up in "${!filename_map[@]}"; do
|
||||||
|
f=${filename_map[$up]}
|
||||||
|
shortname=$(basename $f | sed 's,\.proto$,,')
|
||||||
|
cp $tmpdir/$UPSTREAM_SUBDIR/$up $PKG/$f
|
||||||
|
done
|
||||||
|
|
||||||
|
# Run protoc once per package.
|
||||||
|
for dir in $(find $PKG -name '*.proto' | xargs dirname | sort | uniq); do
|
||||||
|
echo 1>&2 "* $dir"
|
||||||
|
protoc --go_out=. $dir/*.proto
|
||||||
|
done
|
||||||
|
echo 1>&2 "All OK"
|
125
vendor/github.com/golang/protobuf/ptypes/timestamp.go
generated
vendored
Normal file
125
vendor/github.com/golang/protobuf/ptypes/timestamp.go
generated
vendored
Normal file
|
@ -0,0 +1,125 @@
|
||||||
|
// Go support for Protocol Buffers - Google's data interchange format
|
||||||
|
//
|
||||||
|
// Copyright 2016 The Go Authors. All rights reserved.
|
||||||
|
// https://github.com/golang/protobuf
|
||||||
|
//
|
||||||
|
// Redistribution and use in source and binary forms, with or without
|
||||||
|
// modification, are permitted provided that the following conditions are
|
||||||
|
// met:
|
||||||
|
//
|
||||||
|
// * Redistributions of source code must retain the above copyright
|
||||||
|
// notice, this list of conditions and the following disclaimer.
|
||||||
|
// * Redistributions in binary form must reproduce the above
|
||||||
|
// copyright notice, this list of conditions and the following disclaimer
|
||||||
|
// in the documentation and/or other materials provided with the
|
||||||
|
// distribution.
|
||||||
|
// * Neither the name of Google Inc. nor the names of its
|
||||||
|
// contributors may be used to endorse or promote products derived from
|
||||||
|
// this software without specific prior written permission.
|
||||||
|
//
|
||||||
|
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
package ptypes
|
||||||
|
|
||||||
|
// This file implements operations on google.protobuf.Timestamp.
|
||||||
|
|
||||||
|
import (
|
||||||
|
"errors"
|
||||||
|
"fmt"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
tspb "github.com/golang/protobuf/ptypes/timestamp"
|
||||||
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
// Seconds field of the earliest valid Timestamp.
|
||||||
|
// This is time.Date(1, 1, 1, 0, 0, 0, 0, time.UTC).Unix().
|
||||||
|
minValidSeconds = -62135596800
|
||||||
|
// Seconds field just after the latest valid Timestamp.
|
||||||
|
// This is time.Date(10000, 1, 1, 0, 0, 0, 0, time.UTC).Unix().
|
||||||
|
maxValidSeconds = 253402300800
|
||||||
|
)
|
||||||
|
|
||||||
|
// validateTimestamp determines whether a Timestamp is valid.
|
||||||
|
// A valid timestamp represents a time in the range
|
||||||
|
// [0001-01-01, 10000-01-01) and has a Nanos field
|
||||||
|
// in the range [0, 1e9).
|
||||||
|
//
|
||||||
|
// If the Timestamp is valid, validateTimestamp returns nil.
|
||||||
|
// Otherwise, it returns an error that describes
|
||||||
|
// the problem.
|
||||||
|
//
|
||||||
|
// Every valid Timestamp can be represented by a time.Time, but the converse is not true.
|
||||||
|
func validateTimestamp(ts *tspb.Timestamp) error {
|
||||||
|
if ts == nil {
|
||||||
|
return errors.New("timestamp: nil Timestamp")
|
||||||
|
}
|
||||||
|
if ts.Seconds < minValidSeconds {
|
||||||
|
return fmt.Errorf("timestamp: %v before 0001-01-01", ts)
|
||||||
|
}
|
||||||
|
if ts.Seconds >= maxValidSeconds {
|
||||||
|
return fmt.Errorf("timestamp: %v after 10000-01-01", ts)
|
||||||
|
}
|
||||||
|
if ts.Nanos < 0 || ts.Nanos >= 1e9 {
|
||||||
|
return fmt.Errorf("timestamp: %v: nanos not in range [0, 1e9)", ts)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Timestamp converts a google.protobuf.Timestamp proto to a time.Time.
|
||||||
|
// It returns an error if the argument is invalid.
|
||||||
|
//
|
||||||
|
// Unlike most Go functions, if Timestamp returns an error, the first return value
|
||||||
|
// is not the zero time.Time. Instead, it is the value obtained from the
|
||||||
|
// time.Unix function when passed the contents of the Timestamp, in the UTC
|
||||||
|
// locale. This may or may not be a meaningful time; many invalid Timestamps
|
||||||
|
// do map to valid time.Times.
|
||||||
|
//
|
||||||
|
// A nil Timestamp returns an error. The first return value in that case is
|
||||||
|
// undefined.
|
||||||
|
func Timestamp(ts *tspb.Timestamp) (time.Time, error) {
|
||||||
|
// Don't return the zero value on error, because corresponds to a valid
|
||||||
|
// timestamp. Instead return whatever time.Unix gives us.
|
||||||
|
var t time.Time
|
||||||
|
if ts == nil {
|
||||||
|
t = time.Unix(0, 0).UTC() // treat nil like the empty Timestamp
|
||||||
|
} else {
|
||||||
|
t = time.Unix(ts.Seconds, int64(ts.Nanos)).UTC()
|
||||||
|
}
|
||||||
|
return t, validateTimestamp(ts)
|
||||||
|
}
|
||||||
|
|
||||||
|
// TimestampProto converts the time.Time to a google.protobuf.Timestamp proto.
|
||||||
|
// It returns an error if the resulting Timestamp is invalid.
|
||||||
|
func TimestampProto(t time.Time) (*tspb.Timestamp, error) {
|
||||||
|
seconds := t.Unix()
|
||||||
|
nanos := int32(t.Sub(time.Unix(seconds, 0)))
|
||||||
|
ts := &tspb.Timestamp{
|
||||||
|
Seconds: seconds,
|
||||||
|
Nanos: nanos,
|
||||||
|
}
|
||||||
|
if err := validateTimestamp(ts); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return ts, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// TimestampString returns the RFC 3339 string for valid Timestamps. For invalid
|
||||||
|
// Timestamps, it returns an error message in parentheses.
|
||||||
|
func TimestampString(ts *tspb.Timestamp) string {
|
||||||
|
t, err := Timestamp(ts)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Sprintf("(%v)", err)
|
||||||
|
}
|
||||||
|
return t.Format(time.RFC3339Nano)
|
||||||
|
}
|
127
vendor/github.com/golang/protobuf/ptypes/timestamp/timestamp.pb.go
generated
vendored
Normal file
127
vendor/github.com/golang/protobuf/ptypes/timestamp/timestamp.pb.go
generated
vendored
Normal file
|
@ -0,0 +1,127 @@
|
||||||
|
// Code generated by protoc-gen-go.
|
||||||
|
// source: github.com/golang/protobuf/ptypes/timestamp/timestamp.proto
|
||||||
|
// DO NOT EDIT!
|
||||||
|
|
||||||
|
/*
|
||||||
|
Package timestamp is a generated protocol buffer package.
|
||||||
|
|
||||||
|
It is generated from these files:
|
||||||
|
github.com/golang/protobuf/ptypes/timestamp/timestamp.proto
|
||||||
|
|
||||||
|
It has these top-level messages:
|
||||||
|
Timestamp
|
||||||
|
*/
|
||||||
|
package timestamp
|
||||||
|
|
||||||
|
import proto "github.com/golang/protobuf/proto"
|
||||||
|
import fmt "fmt"
|
||||||
|
import math "math"
|
||||||
|
|
||||||
|
// Reference imports to suppress errors if they are not otherwise used.
|
||||||
|
var _ = proto.Marshal
|
||||||
|
var _ = fmt.Errorf
|
||||||
|
var _ = math.Inf
|
||||||
|
|
||||||
|
// This is a compile-time assertion to ensure that this generated file
|
||||||
|
// is compatible with the proto package it is being compiled against.
|
||||||
|
// A compilation error at this line likely means your copy of the
|
||||||
|
// proto package needs to be updated.
|
||||||
|
const _ = proto.ProtoPackageIsVersion2 // please upgrade the proto package
|
||||||
|
|
||||||
|
// A Timestamp represents a point in time independent of any time zone
|
||||||
|
// or calendar, represented as seconds and fractions of seconds at
|
||||||
|
// nanosecond resolution in UTC Epoch time. It is encoded using the
|
||||||
|
// Proleptic Gregorian Calendar which extends the Gregorian calendar
|
||||||
|
// backwards to year one. It is encoded assuming all minutes are 60
|
||||||
|
// seconds long, i.e. leap seconds are "smeared" so that no leap second
|
||||||
|
// table is needed for interpretation. Range is from
|
||||||
|
// 0001-01-01T00:00:00Z to 9999-12-31T23:59:59.999999999Z.
|
||||||
|
// By restricting to that range, we ensure that we can convert to
|
||||||
|
// and from RFC 3339 date strings.
|
||||||
|
// See [https://www.ietf.org/rfc/rfc3339.txt](https://www.ietf.org/rfc/rfc3339.txt).
|
||||||
|
//
|
||||||
|
// Example 1: Compute Timestamp from POSIX `time()`.
|
||||||
|
//
|
||||||
|
// Timestamp timestamp;
|
||||||
|
// timestamp.set_seconds(time(NULL));
|
||||||
|
// timestamp.set_nanos(0);
|
||||||
|
//
|
||||||
|
// Example 2: Compute Timestamp from POSIX `gettimeofday()`.
|
||||||
|
//
|
||||||
|
// struct timeval tv;
|
||||||
|
// gettimeofday(&tv, NULL);
|
||||||
|
//
|
||||||
|
// Timestamp timestamp;
|
||||||
|
// timestamp.set_seconds(tv.tv_sec);
|
||||||
|
// timestamp.set_nanos(tv.tv_usec * 1000);
|
||||||
|
//
|
||||||
|
// Example 3: Compute Timestamp from Win32 `GetSystemTimeAsFileTime()`.
|
||||||
|
//
|
||||||
|
// FILETIME ft;
|
||||||
|
// GetSystemTimeAsFileTime(&ft);
|
||||||
|
// UINT64 ticks = (((UINT64)ft.dwHighDateTime) << 32) | ft.dwLowDateTime;
|
||||||
|
//
|
||||||
|
// // A Windows tick is 100 nanoseconds. Windows epoch 1601-01-01T00:00:00Z
|
||||||
|
// // is 11644473600 seconds before Unix epoch 1970-01-01T00:00:00Z.
|
||||||
|
// Timestamp timestamp;
|
||||||
|
// timestamp.set_seconds((INT64) ((ticks / 10000000) - 11644473600LL));
|
||||||
|
// timestamp.set_nanos((INT32) ((ticks % 10000000) * 100));
|
||||||
|
//
|
||||||
|
// Example 4: Compute Timestamp from Java `System.currentTimeMillis()`.
|
||||||
|
//
|
||||||
|
// long millis = System.currentTimeMillis();
|
||||||
|
//
|
||||||
|
// Timestamp timestamp = Timestamp.newBuilder().setSeconds(millis / 1000)
|
||||||
|
// .setNanos((int) ((millis % 1000) * 1000000)).build();
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// Example 5: Compute Timestamp from current time in Python.
|
||||||
|
//
|
||||||
|
// now = time.time()
|
||||||
|
// seconds = int(now)
|
||||||
|
// nanos = int((now - seconds) * 10**9)
|
||||||
|
// timestamp = Timestamp(seconds=seconds, nanos=nanos)
|
||||||
|
//
|
||||||
|
//
|
||||||
|
type Timestamp struct {
|
||||||
|
// Represents seconds of UTC time since Unix epoch
|
||||||
|
// 1970-01-01T00:00:00Z. Must be from from 0001-01-01T00:00:00Z to
|
||||||
|
// 9999-12-31T23:59:59Z inclusive.
|
||||||
|
Seconds int64 `protobuf:"varint,1,opt,name=seconds" json:"seconds,omitempty"`
|
||||||
|
// Non-negative fractions of a second at nanosecond resolution. Negative
|
||||||
|
// second values with fractions must still have non-negative nanos values
|
||||||
|
// that count forward in time. Must be from 0 to 999,999,999
|
||||||
|
// inclusive.
|
||||||
|
Nanos int32 `protobuf:"varint,2,opt,name=nanos" json:"nanos,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *Timestamp) Reset() { *m = Timestamp{} }
|
||||||
|
func (m *Timestamp) String() string { return proto.CompactTextString(m) }
|
||||||
|
func (*Timestamp) ProtoMessage() {}
|
||||||
|
func (*Timestamp) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{0} }
|
||||||
|
func (*Timestamp) XXX_WellKnownType() string { return "Timestamp" }
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
proto.RegisterType((*Timestamp)(nil), "google.protobuf.Timestamp")
|
||||||
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
proto.RegisterFile("github.com/golang/protobuf/ptypes/timestamp/timestamp.proto", fileDescriptor0)
|
||||||
|
}
|
||||||
|
|
||||||
|
var fileDescriptor0 = []byte{
|
||||||
|
// 194 bytes of a gzipped FileDescriptorProto
|
||||||
|
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0xe2, 0xb2, 0x4e, 0xcf, 0x2c, 0xc9,
|
||||||
|
0x28, 0x4d, 0xd2, 0x4b, 0xce, 0xcf, 0xd5, 0x4f, 0xcf, 0xcf, 0x49, 0xcc, 0x4b, 0xd7, 0x2f, 0x28,
|
||||||
|
0xca, 0x2f, 0xc9, 0x4f, 0x2a, 0x4d, 0xd3, 0x2f, 0x28, 0xa9, 0x2c, 0x48, 0x2d, 0xd6, 0x2f, 0xc9,
|
||||||
|
0xcc, 0x4d, 0x2d, 0x2e, 0x49, 0xcc, 0x2d, 0x40, 0xb0, 0xf4, 0xc0, 0x6a, 0x84, 0xf8, 0xd3, 0xf3,
|
||||||
|
0xf3, 0xd3, 0x73, 0x52, 0xf5, 0x60, 0x3a, 0x94, 0xac, 0xb9, 0x38, 0x43, 0x60, 0x6a, 0x84, 0x24,
|
||||||
|
0xb8, 0xd8, 0x8b, 0x53, 0x93, 0xf3, 0xf3, 0x52, 0x8a, 0x25, 0x18, 0x15, 0x18, 0x35, 0x98, 0x83,
|
||||||
|
0x60, 0x5c, 0x21, 0x11, 0x2e, 0xd6, 0xbc, 0xc4, 0xbc, 0xfc, 0x62, 0x09, 0x26, 0x05, 0x46, 0x0d,
|
||||||
|
0xd6, 0x20, 0x08, 0xc7, 0xa9, 0x91, 0x91, 0x4b, 0x38, 0x39, 0x3f, 0x57, 0x0f, 0xcd, 0x50, 0x27,
|
||||||
|
0x3e, 0xb8, 0x91, 0x01, 0x20, 0xa1, 0x00, 0xc6, 0x28, 0x6d, 0x12, 0x1c, 0xbd, 0x80, 0x91, 0xf1,
|
||||||
|
0x07, 0x23, 0xe3, 0x22, 0x26, 0x66, 0xf7, 0x00, 0xa7, 0x55, 0x4c, 0x72, 0xee, 0x10, 0xc3, 0x03,
|
||||||
|
0xa0, 0xca, 0xf5, 0xc2, 0x53, 0x73, 0x72, 0xbc, 0xf3, 0xf2, 0xcb, 0xf3, 0x42, 0x40, 0xda, 0x92,
|
||||||
|
0xd8, 0xc0, 0xe6, 0x18, 0x03, 0x02, 0x00, 0x00, 0xff, 0xff, 0x17, 0x5f, 0xb7, 0xdc, 0x17, 0x01,
|
||||||
|
0x00, 0x00,
|
||||||
|
}
|
111
vendor/github.com/golang/protobuf/ptypes/timestamp/timestamp.proto
generated
vendored
Normal file
111
vendor/github.com/golang/protobuf/ptypes/timestamp/timestamp.proto
generated
vendored
Normal file
|
@ -0,0 +1,111 @@
|
||||||
|
// Protocol Buffers - Google's data interchange format
|
||||||
|
// Copyright 2008 Google Inc. All rights reserved.
|
||||||
|
// https://developers.google.com/protocol-buffers/
|
||||||
|
//
|
||||||
|
// Redistribution and use in source and binary forms, with or without
|
||||||
|
// modification, are permitted provided that the following conditions are
|
||||||
|
// met:
|
||||||
|
//
|
||||||
|
// * Redistributions of source code must retain the above copyright
|
||||||
|
// notice, this list of conditions and the following disclaimer.
|
||||||
|
// * Redistributions in binary form must reproduce the above
|
||||||
|
// copyright notice, this list of conditions and the following disclaimer
|
||||||
|
// in the documentation and/or other materials provided with the
|
||||||
|
// distribution.
|
||||||
|
// * Neither the name of Google Inc. nor the names of its
|
||||||
|
// contributors may be used to endorse or promote products derived from
|
||||||
|
// this software without specific prior written permission.
|
||||||
|
//
|
||||||
|
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
syntax = "proto3";
|
||||||
|
|
||||||
|
package google.protobuf;
|
||||||
|
|
||||||
|
option csharp_namespace = "Google.Protobuf.WellKnownTypes";
|
||||||
|
option cc_enable_arenas = true;
|
||||||
|
option go_package = "github.com/golang/protobuf/ptypes/timestamp";
|
||||||
|
option java_package = "com.google.protobuf";
|
||||||
|
option java_outer_classname = "TimestampProto";
|
||||||
|
option java_multiple_files = true;
|
||||||
|
option java_generate_equals_and_hash = true;
|
||||||
|
option objc_class_prefix = "GPB";
|
||||||
|
|
||||||
|
// A Timestamp represents a point in time independent of any time zone
|
||||||
|
// or calendar, represented as seconds and fractions of seconds at
|
||||||
|
// nanosecond resolution in UTC Epoch time. It is encoded using the
|
||||||
|
// Proleptic Gregorian Calendar which extends the Gregorian calendar
|
||||||
|
// backwards to year one. It is encoded assuming all minutes are 60
|
||||||
|
// seconds long, i.e. leap seconds are "smeared" so that no leap second
|
||||||
|
// table is needed for interpretation. Range is from
|
||||||
|
// 0001-01-01T00:00:00Z to 9999-12-31T23:59:59.999999999Z.
|
||||||
|
// By restricting to that range, we ensure that we can convert to
|
||||||
|
// and from RFC 3339 date strings.
|
||||||
|
// See [https://www.ietf.org/rfc/rfc3339.txt](https://www.ietf.org/rfc/rfc3339.txt).
|
||||||
|
//
|
||||||
|
// Example 1: Compute Timestamp from POSIX `time()`.
|
||||||
|
//
|
||||||
|
// Timestamp timestamp;
|
||||||
|
// timestamp.set_seconds(time(NULL));
|
||||||
|
// timestamp.set_nanos(0);
|
||||||
|
//
|
||||||
|
// Example 2: Compute Timestamp from POSIX `gettimeofday()`.
|
||||||
|
//
|
||||||
|
// struct timeval tv;
|
||||||
|
// gettimeofday(&tv, NULL);
|
||||||
|
//
|
||||||
|
// Timestamp timestamp;
|
||||||
|
// timestamp.set_seconds(tv.tv_sec);
|
||||||
|
// timestamp.set_nanos(tv.tv_usec * 1000);
|
||||||
|
//
|
||||||
|
// Example 3: Compute Timestamp from Win32 `GetSystemTimeAsFileTime()`.
|
||||||
|
//
|
||||||
|
// FILETIME ft;
|
||||||
|
// GetSystemTimeAsFileTime(&ft);
|
||||||
|
// UINT64 ticks = (((UINT64)ft.dwHighDateTime) << 32) | ft.dwLowDateTime;
|
||||||
|
//
|
||||||
|
// // A Windows tick is 100 nanoseconds. Windows epoch 1601-01-01T00:00:00Z
|
||||||
|
// // is 11644473600 seconds before Unix epoch 1970-01-01T00:00:00Z.
|
||||||
|
// Timestamp timestamp;
|
||||||
|
// timestamp.set_seconds((INT64) ((ticks / 10000000) - 11644473600LL));
|
||||||
|
// timestamp.set_nanos((INT32) ((ticks % 10000000) * 100));
|
||||||
|
//
|
||||||
|
// Example 4: Compute Timestamp from Java `System.currentTimeMillis()`.
|
||||||
|
//
|
||||||
|
// long millis = System.currentTimeMillis();
|
||||||
|
//
|
||||||
|
// Timestamp timestamp = Timestamp.newBuilder().setSeconds(millis / 1000)
|
||||||
|
// .setNanos((int) ((millis % 1000) * 1000000)).build();
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// Example 5: Compute Timestamp from current time in Python.
|
||||||
|
//
|
||||||
|
// now = time.time()
|
||||||
|
// seconds = int(now)
|
||||||
|
// nanos = int((now - seconds) * 10**9)
|
||||||
|
// timestamp = Timestamp(seconds=seconds, nanos=nanos)
|
||||||
|
//
|
||||||
|
//
|
||||||
|
message Timestamp {
|
||||||
|
|
||||||
|
// Represents seconds of UTC time since Unix epoch
|
||||||
|
// 1970-01-01T00:00:00Z. Must be from from 0001-01-01T00:00:00Z to
|
||||||
|
// 9999-12-31T23:59:59Z inclusive.
|
||||||
|
int64 seconds = 1;
|
||||||
|
|
||||||
|
// Non-negative fractions of a second at nanosecond resolution. Negative
|
||||||
|
// second values with fractions must still have non-negative nanos values
|
||||||
|
// that count forward in time. Must be from 0 to 999,999,999
|
||||||
|
// inclusive.
|
||||||
|
int32 nanos = 2;
|
||||||
|
}
|
|
@ -200,3 +200,4 @@
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
|
|
6944
vendor/github.com/googleapis/gnostic/OpenAPIv2/OpenAPIv2.go
generated
vendored
Normal file
6944
vendor/github.com/googleapis/gnostic/OpenAPIv2/OpenAPIv2.go
generated
vendored
Normal file
File diff suppressed because it is too large
Load diff
4456
vendor/github.com/googleapis/gnostic/OpenAPIv2/OpenAPIv2.pb.go
generated
vendored
Normal file
4456
vendor/github.com/googleapis/gnostic/OpenAPIv2/OpenAPIv2.pb.go
generated
vendored
Normal file
File diff suppressed because it is too large
Load diff
663
vendor/github.com/googleapis/gnostic/OpenAPIv2/OpenAPIv2.proto
generated
vendored
Normal file
663
vendor/github.com/googleapis/gnostic/OpenAPIv2/OpenAPIv2.proto
generated
vendored
Normal file
|
@ -0,0 +1,663 @@
|
||||||
|
// Copyright 2017 Google Inc. All Rights Reserved.
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
|
// THIS FILE IS AUTOMATICALLY GENERATED.
|
||||||
|
|
||||||
|
syntax = "proto3";
|
||||||
|
|
||||||
|
package openapi.v2;
|
||||||
|
|
||||||
|
import "google/protobuf/any.proto";
|
||||||
|
|
||||||
|
// This option lets the proto compiler generate Java code inside the package
|
||||||
|
// name (see below) instead of inside an outer class. It creates a simpler
|
||||||
|
// developer experience by reducing one-level of name nesting and be
|
||||||
|
// consistent with most programming languages that don't support outer classes.
|
||||||
|
option java_multiple_files = true;
|
||||||
|
|
||||||
|
// The Java outer classname should be the filename in UpperCamelCase. This
|
||||||
|
// class is only used to hold proto descriptor, so developers don't need to
|
||||||
|
// work with it directly.
|
||||||
|
option java_outer_classname = "OpenAPIProto";
|
||||||
|
|
||||||
|
// The Java package name must be proto package name with proper prefix.
|
||||||
|
option java_package = "org.openapi_v2";
|
||||||
|
|
||||||
|
// A reasonable prefix for the Objective-C symbols generated from the package.
|
||||||
|
// It should at a minimum be 3 characters long, all uppercase, and convention
|
||||||
|
// is to use an abbreviation of the package name. Something short, but
|
||||||
|
// hopefully unique enough to not conflict with things that may come along in
|
||||||
|
// the future. 'GPB' is reserved for the protocol buffer implementation itself.
|
||||||
|
option objc_class_prefix = "OAS";
|
||||||
|
|
||||||
|
message AdditionalPropertiesItem {
|
||||||
|
oneof oneof {
|
||||||
|
Schema schema = 1;
|
||||||
|
bool boolean = 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
message Any {
|
||||||
|
google.protobuf.Any value = 1;
|
||||||
|
string yaml = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
message ApiKeySecurity {
|
||||||
|
string type = 1;
|
||||||
|
string name = 2;
|
||||||
|
string in = 3;
|
||||||
|
string description = 4;
|
||||||
|
repeated NamedAny vendor_extension = 5;
|
||||||
|
}
|
||||||
|
|
||||||
|
message BasicAuthenticationSecurity {
|
||||||
|
string type = 1;
|
||||||
|
string description = 2;
|
||||||
|
repeated NamedAny vendor_extension = 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
message BodyParameter {
|
||||||
|
// A brief description of the parameter. This could contain examples of use. GitHub Flavored Markdown is allowed.
|
||||||
|
string description = 1;
|
||||||
|
// The name of the parameter.
|
||||||
|
string name = 2;
|
||||||
|
// Determines the location of the parameter.
|
||||||
|
string in = 3;
|
||||||
|
// Determines whether or not this parameter is required or optional.
|
||||||
|
bool required = 4;
|
||||||
|
Schema schema = 5;
|
||||||
|
repeated NamedAny vendor_extension = 6;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Contact information for the owners of the API.
|
||||||
|
message Contact {
|
||||||
|
// The identifying name of the contact person/organization.
|
||||||
|
string name = 1;
|
||||||
|
// The URL pointing to the contact information.
|
||||||
|
string url = 2;
|
||||||
|
// The email address of the contact person/organization.
|
||||||
|
string email = 3;
|
||||||
|
repeated NamedAny vendor_extension = 4;
|
||||||
|
}
|
||||||
|
|
||||||
|
message Default {
|
||||||
|
repeated NamedAny additional_properties = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// One or more JSON objects describing the schemas being consumed and produced by the API.
|
||||||
|
message Definitions {
|
||||||
|
repeated NamedSchema additional_properties = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
message Document {
|
||||||
|
// The Swagger version of this document.
|
||||||
|
string swagger = 1;
|
||||||
|
Info info = 2;
|
||||||
|
// The host (name or ip) of the API. Example: 'swagger.io'
|
||||||
|
string host = 3;
|
||||||
|
// The base path to the API. Example: '/api'.
|
||||||
|
string base_path = 4;
|
||||||
|
// The transfer protocol of the API.
|
||||||
|
repeated string schemes = 5;
|
||||||
|
// A list of MIME types accepted by the API.
|
||||||
|
repeated string consumes = 6;
|
||||||
|
// A list of MIME types the API can produce.
|
||||||
|
repeated string produces = 7;
|
||||||
|
Paths paths = 8;
|
||||||
|
Definitions definitions = 9;
|
||||||
|
ParameterDefinitions parameters = 10;
|
||||||
|
ResponseDefinitions responses = 11;
|
||||||
|
repeated SecurityRequirement security = 12;
|
||||||
|
SecurityDefinitions security_definitions = 13;
|
||||||
|
repeated Tag tags = 14;
|
||||||
|
ExternalDocs external_docs = 15;
|
||||||
|
repeated NamedAny vendor_extension = 16;
|
||||||
|
}
|
||||||
|
|
||||||
|
message Examples {
|
||||||
|
repeated NamedAny additional_properties = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// information about external documentation
|
||||||
|
message ExternalDocs {
|
||||||
|
string description = 1;
|
||||||
|
string url = 2;
|
||||||
|
repeated NamedAny vendor_extension = 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
// A deterministic version of a JSON Schema object.
|
||||||
|
message FileSchema {
|
||||||
|
string format = 1;
|
||||||
|
string title = 2;
|
||||||
|
string description = 3;
|
||||||
|
Any default = 4;
|
||||||
|
repeated string required = 5;
|
||||||
|
string type = 6;
|
||||||
|
bool read_only = 7;
|
||||||
|
ExternalDocs external_docs = 8;
|
||||||
|
Any example = 9;
|
||||||
|
repeated NamedAny vendor_extension = 10;
|
||||||
|
}
|
||||||
|
|
||||||
|
message FormDataParameterSubSchema {
|
||||||
|
// Determines whether or not this parameter is required or optional.
|
||||||
|
bool required = 1;
|
||||||
|
// Determines the location of the parameter.
|
||||||
|
string in = 2;
|
||||||
|
// A brief description of the parameter. This could contain examples of use. GitHub Flavored Markdown is allowed.
|
||||||
|
string description = 3;
|
||||||
|
// The name of the parameter.
|
||||||
|
string name = 4;
|
||||||
|
// allows sending a parameter by name only or with an empty value.
|
||||||
|
bool allow_empty_value = 5;
|
||||||
|
string type = 6;
|
||||||
|
string format = 7;
|
||||||
|
PrimitivesItems items = 8;
|
||||||
|
string collection_format = 9;
|
||||||
|
Any default = 10;
|
||||||
|
double maximum = 11;
|
||||||
|
bool exclusive_maximum = 12;
|
||||||
|
double minimum = 13;
|
||||||
|
bool exclusive_minimum = 14;
|
||||||
|
int64 max_length = 15;
|
||||||
|
int64 min_length = 16;
|
||||||
|
string pattern = 17;
|
||||||
|
int64 max_items = 18;
|
||||||
|
int64 min_items = 19;
|
||||||
|
bool unique_items = 20;
|
||||||
|
repeated Any enum = 21;
|
||||||
|
double multiple_of = 22;
|
||||||
|
repeated NamedAny vendor_extension = 23;
|
||||||
|
}
|
||||||
|
|
||||||
|
message Header {
|
||||||
|
string type = 1;
|
||||||
|
string format = 2;
|
||||||
|
PrimitivesItems items = 3;
|
||||||
|
string collection_format = 4;
|
||||||
|
Any default = 5;
|
||||||
|
double maximum = 6;
|
||||||
|
bool exclusive_maximum = 7;
|
||||||
|
double minimum = 8;
|
||||||
|
bool exclusive_minimum = 9;
|
||||||
|
int64 max_length = 10;
|
||||||
|
int64 min_length = 11;
|
||||||
|
string pattern = 12;
|
||||||
|
int64 max_items = 13;
|
||||||
|
int64 min_items = 14;
|
||||||
|
bool unique_items = 15;
|
||||||
|
repeated Any enum = 16;
|
||||||
|
double multiple_of = 17;
|
||||||
|
string description = 18;
|
||||||
|
repeated NamedAny vendor_extension = 19;
|
||||||
|
}
|
||||||
|
|
||||||
|
message HeaderParameterSubSchema {
|
||||||
|
// Determines whether or not this parameter is required or optional.
|
||||||
|
bool required = 1;
|
||||||
|
// Determines the location of the parameter.
|
||||||
|
string in = 2;
|
||||||
|
// A brief description of the parameter. This could contain examples of use. GitHub Flavored Markdown is allowed.
|
||||||
|
string description = 3;
|
||||||
|
// The name of the parameter.
|
||||||
|
string name = 4;
|
||||||
|
string type = 5;
|
||||||
|
string format = 6;
|
||||||
|
PrimitivesItems items = 7;
|
||||||
|
string collection_format = 8;
|
||||||
|
Any default = 9;
|
||||||
|
double maximum = 10;
|
||||||
|
bool exclusive_maximum = 11;
|
||||||
|
double minimum = 12;
|
||||||
|
bool exclusive_minimum = 13;
|
||||||
|
int64 max_length = 14;
|
||||||
|
int64 min_length = 15;
|
||||||
|
string pattern = 16;
|
||||||
|
int64 max_items = 17;
|
||||||
|
int64 min_items = 18;
|
||||||
|
bool unique_items = 19;
|
||||||
|
repeated Any enum = 20;
|
||||||
|
double multiple_of = 21;
|
||||||
|
repeated NamedAny vendor_extension = 22;
|
||||||
|
}
|
||||||
|
|
||||||
|
message Headers {
|
||||||
|
repeated NamedHeader additional_properties = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// General information about the API.
|
||||||
|
message Info {
|
||||||
|
// A unique and precise title of the API.
|
||||||
|
string title = 1;
|
||||||
|
// A semantic version number of the API.
|
||||||
|
string version = 2;
|
||||||
|
// A longer description of the API. Should be different from the title. GitHub Flavored Markdown is allowed.
|
||||||
|
string description = 3;
|
||||||
|
// The terms of service for the API.
|
||||||
|
string terms_of_service = 4;
|
||||||
|
Contact contact = 5;
|
||||||
|
License license = 6;
|
||||||
|
repeated NamedAny vendor_extension = 7;
|
||||||
|
}
|
||||||
|
|
||||||
|
message ItemsItem {
|
||||||
|
repeated Schema schema = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
message JsonReference {
|
||||||
|
string _ref = 1;
|
||||||
|
string description = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
message License {
|
||||||
|
// The name of the license type. It's encouraged to use an OSI compatible license.
|
||||||
|
string name = 1;
|
||||||
|
// The URL pointing to the license.
|
||||||
|
string url = 2;
|
||||||
|
repeated NamedAny vendor_extension = 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Automatically-generated message used to represent maps of Any as ordered (name,value) pairs.
|
||||||
|
message NamedAny {
|
||||||
|
// Map key
|
||||||
|
string name = 1;
|
||||||
|
// Mapped value
|
||||||
|
Any value = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Automatically-generated message used to represent maps of Header as ordered (name,value) pairs.
|
||||||
|
message NamedHeader {
|
||||||
|
// Map key
|
||||||
|
string name = 1;
|
||||||
|
// Mapped value
|
||||||
|
Header value = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Automatically-generated message used to represent maps of Parameter as ordered (name,value) pairs.
|
||||||
|
message NamedParameter {
|
||||||
|
// Map key
|
||||||
|
string name = 1;
|
||||||
|
// Mapped value
|
||||||
|
Parameter value = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Automatically-generated message used to represent maps of PathItem as ordered (name,value) pairs.
|
||||||
|
message NamedPathItem {
|
||||||
|
// Map key
|
||||||
|
string name = 1;
|
||||||
|
// Mapped value
|
||||||
|
PathItem value = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Automatically-generated message used to represent maps of Response as ordered (name,value) pairs.
|
||||||
|
message NamedResponse {
|
||||||
|
// Map key
|
||||||
|
string name = 1;
|
||||||
|
// Mapped value
|
||||||
|
Response value = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Automatically-generated message used to represent maps of ResponseValue as ordered (name,value) pairs.
|
||||||
|
message NamedResponseValue {
|
||||||
|
// Map key
|
||||||
|
string name = 1;
|
||||||
|
// Mapped value
|
||||||
|
ResponseValue value = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Automatically-generated message used to represent maps of Schema as ordered (name,value) pairs.
|
||||||
|
message NamedSchema {
|
||||||
|
// Map key
|
||||||
|
string name = 1;
|
||||||
|
// Mapped value
|
||||||
|
Schema value = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Automatically-generated message used to represent maps of SecurityDefinitionsItem as ordered (name,value) pairs.
|
||||||
|
message NamedSecurityDefinitionsItem {
|
||||||
|
// Map key
|
||||||
|
string name = 1;
|
||||||
|
// Mapped value
|
||||||
|
SecurityDefinitionsItem value = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Automatically-generated message used to represent maps of string as ordered (name,value) pairs.
|
||||||
|
message NamedString {
|
||||||
|
// Map key
|
||||||
|
string name = 1;
|
||||||
|
// Mapped value
|
||||||
|
string value = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Automatically-generated message used to represent maps of StringArray as ordered (name,value) pairs.
|
||||||
|
message NamedStringArray {
|
||||||
|
// Map key
|
||||||
|
string name = 1;
|
||||||
|
// Mapped value
|
||||||
|
StringArray value = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
message NonBodyParameter {
|
||||||
|
oneof oneof {
|
||||||
|
HeaderParameterSubSchema header_parameter_sub_schema = 1;
|
||||||
|
FormDataParameterSubSchema form_data_parameter_sub_schema = 2;
|
||||||
|
QueryParameterSubSchema query_parameter_sub_schema = 3;
|
||||||
|
PathParameterSubSchema path_parameter_sub_schema = 4;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
message Oauth2AccessCodeSecurity {
|
||||||
|
string type = 1;
|
||||||
|
string flow = 2;
|
||||||
|
Oauth2Scopes scopes = 3;
|
||||||
|
string authorization_url = 4;
|
||||||
|
string token_url = 5;
|
||||||
|
string description = 6;
|
||||||
|
repeated NamedAny vendor_extension = 7;
|
||||||
|
}
|
||||||
|
|
||||||
|
message Oauth2ApplicationSecurity {
|
||||||
|
string type = 1;
|
||||||
|
string flow = 2;
|
||||||
|
Oauth2Scopes scopes = 3;
|
||||||
|
string token_url = 4;
|
||||||
|
string description = 5;
|
||||||
|
repeated NamedAny vendor_extension = 6;
|
||||||
|
}
|
||||||
|
|
||||||
|
message Oauth2ImplicitSecurity {
|
||||||
|
string type = 1;
|
||||||
|
string flow = 2;
|
||||||
|
Oauth2Scopes scopes = 3;
|
||||||
|
string authorization_url = 4;
|
||||||
|
string description = 5;
|
||||||
|
repeated NamedAny vendor_extension = 6;
|
||||||
|
}
|
||||||
|
|
||||||
|
message Oauth2PasswordSecurity {
|
||||||
|
string type = 1;
|
||||||
|
string flow = 2;
|
||||||
|
Oauth2Scopes scopes = 3;
|
||||||
|
string token_url = 4;
|
||||||
|
string description = 5;
|
||||||
|
repeated NamedAny vendor_extension = 6;
|
||||||
|
}
|
||||||
|
|
||||||
|
message Oauth2Scopes {
|
||||||
|
repeated NamedString additional_properties = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
message Operation {
|
||||||
|
repeated string tags = 1;
|
||||||
|
// A brief summary of the operation.
|
||||||
|
string summary = 2;
|
||||||
|
// A longer description of the operation, GitHub Flavored Markdown is allowed.
|
||||||
|
string description = 3;
|
||||||
|
ExternalDocs external_docs = 4;
|
||||||
|
// A unique identifier of the operation.
|
||||||
|
string operation_id = 5;
|
||||||
|
// A list of MIME types the API can produce.
|
||||||
|
repeated string produces = 6;
|
||||||
|
// A list of MIME types the API can consume.
|
||||||
|
repeated string consumes = 7;
|
||||||
|
// The parameters needed to send a valid API call.
|
||||||
|
repeated ParametersItem parameters = 8;
|
||||||
|
Responses responses = 9;
|
||||||
|
// The transfer protocol of the API.
|
||||||
|
repeated string schemes = 10;
|
||||||
|
bool deprecated = 11;
|
||||||
|
repeated SecurityRequirement security = 12;
|
||||||
|
repeated NamedAny vendor_extension = 13;
|
||||||
|
}
|
||||||
|
|
||||||
|
message Parameter {
|
||||||
|
oneof oneof {
|
||||||
|
BodyParameter body_parameter = 1;
|
||||||
|
NonBodyParameter non_body_parameter = 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// One or more JSON representations for parameters
|
||||||
|
message ParameterDefinitions {
|
||||||
|
repeated NamedParameter additional_properties = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
message ParametersItem {
|
||||||
|
oneof oneof {
|
||||||
|
Parameter parameter = 1;
|
||||||
|
JsonReference json_reference = 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
message PathItem {
|
||||||
|
string _ref = 1;
|
||||||
|
Operation get = 2;
|
||||||
|
Operation put = 3;
|
||||||
|
Operation post = 4;
|
||||||
|
Operation delete = 5;
|
||||||
|
Operation options = 6;
|
||||||
|
Operation head = 7;
|
||||||
|
Operation patch = 8;
|
||||||
|
// The parameters needed to send a valid API call.
|
||||||
|
repeated ParametersItem parameters = 9;
|
||||||
|
repeated NamedAny vendor_extension = 10;
|
||||||
|
}
|
||||||
|
|
||||||
|
message PathParameterSubSchema {
|
||||||
|
// Determines whether or not this parameter is required or optional.
|
||||||
|
bool required = 1;
|
||||||
|
// Determines the location of the parameter.
|
||||||
|
string in = 2;
|
||||||
|
// A brief description of the parameter. This could contain examples of use. GitHub Flavored Markdown is allowed.
|
||||||
|
string description = 3;
|
||||||
|
// The name of the parameter.
|
||||||
|
string name = 4;
|
||||||
|
string type = 5;
|
||||||
|
string format = 6;
|
||||||
|
PrimitivesItems items = 7;
|
||||||
|
string collection_format = 8;
|
||||||
|
Any default = 9;
|
||||||
|
double maximum = 10;
|
||||||
|
bool exclusive_maximum = 11;
|
||||||
|
double minimum = 12;
|
||||||
|
bool exclusive_minimum = 13;
|
||||||
|
int64 max_length = 14;
|
||||||
|
int64 min_length = 15;
|
||||||
|
string pattern = 16;
|
||||||
|
int64 max_items = 17;
|
||||||
|
int64 min_items = 18;
|
||||||
|
bool unique_items = 19;
|
||||||
|
repeated Any enum = 20;
|
||||||
|
double multiple_of = 21;
|
||||||
|
repeated NamedAny vendor_extension = 22;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Relative paths to the individual endpoints. They must be relative to the 'basePath'.
|
||||||
|
message Paths {
|
||||||
|
repeated NamedAny vendor_extension = 1;
|
||||||
|
repeated NamedPathItem path = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
message PrimitivesItems {
|
||||||
|
string type = 1;
|
||||||
|
string format = 2;
|
||||||
|
PrimitivesItems items = 3;
|
||||||
|
string collection_format = 4;
|
||||||
|
Any default = 5;
|
||||||
|
double maximum = 6;
|
||||||
|
bool exclusive_maximum = 7;
|
||||||
|
double minimum = 8;
|
||||||
|
bool exclusive_minimum = 9;
|
||||||
|
int64 max_length = 10;
|
||||||
|
int64 min_length = 11;
|
||||||
|
string pattern = 12;
|
||||||
|
int64 max_items = 13;
|
||||||
|
int64 min_items = 14;
|
||||||
|
bool unique_items = 15;
|
||||||
|
repeated Any enum = 16;
|
||||||
|
double multiple_of = 17;
|
||||||
|
repeated NamedAny vendor_extension = 18;
|
||||||
|
}
|
||||||
|
|
||||||
|
message Properties {
|
||||||
|
repeated NamedSchema additional_properties = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
message QueryParameterSubSchema {
|
||||||
|
// Determines whether or not this parameter is required or optional.
|
||||||
|
bool required = 1;
|
||||||
|
// Determines the location of the parameter.
|
||||||
|
string in = 2;
|
||||||
|
// A brief description of the parameter. This could contain examples of use. GitHub Flavored Markdown is allowed.
|
||||||
|
string description = 3;
|
||||||
|
// The name of the parameter.
|
||||||
|
string name = 4;
|
||||||
|
// allows sending a parameter by name only or with an empty value.
|
||||||
|
bool allow_empty_value = 5;
|
||||||
|
string type = 6;
|
||||||
|
string format = 7;
|
||||||
|
PrimitivesItems items = 8;
|
||||||
|
string collection_format = 9;
|
||||||
|
Any default = 10;
|
||||||
|
double maximum = 11;
|
||||||
|
bool exclusive_maximum = 12;
|
||||||
|
double minimum = 13;
|
||||||
|
bool exclusive_minimum = 14;
|
||||||
|
int64 max_length = 15;
|
||||||
|
int64 min_length = 16;
|
||||||
|
string pattern = 17;
|
||||||
|
int64 max_items = 18;
|
||||||
|
int64 min_items = 19;
|
||||||
|
bool unique_items = 20;
|
||||||
|
repeated Any enum = 21;
|
||||||
|
double multiple_of = 22;
|
||||||
|
repeated NamedAny vendor_extension = 23;
|
||||||
|
}
|
||||||
|
|
||||||
|
message Response {
|
||||||
|
string description = 1;
|
||||||
|
SchemaItem schema = 2;
|
||||||
|
Headers headers = 3;
|
||||||
|
Examples examples = 4;
|
||||||
|
repeated NamedAny vendor_extension = 5;
|
||||||
|
}
|
||||||
|
|
||||||
|
// One or more JSON representations for parameters
|
||||||
|
message ResponseDefinitions {
|
||||||
|
repeated NamedResponse additional_properties = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
message ResponseValue {
|
||||||
|
oneof oneof {
|
||||||
|
Response response = 1;
|
||||||
|
JsonReference json_reference = 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Response objects names can either be any valid HTTP status code or 'default'.
|
||||||
|
message Responses {
|
||||||
|
repeated NamedResponseValue response_code = 1;
|
||||||
|
repeated NamedAny vendor_extension = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
// A deterministic version of a JSON Schema object.
|
||||||
|
message Schema {
|
||||||
|
string _ref = 1;
|
||||||
|
string format = 2;
|
||||||
|
string title = 3;
|
||||||
|
string description = 4;
|
||||||
|
Any default = 5;
|
||||||
|
double multiple_of = 6;
|
||||||
|
double maximum = 7;
|
||||||
|
bool exclusive_maximum = 8;
|
||||||
|
double minimum = 9;
|
||||||
|
bool exclusive_minimum = 10;
|
||||||
|
int64 max_length = 11;
|
||||||
|
int64 min_length = 12;
|
||||||
|
string pattern = 13;
|
||||||
|
int64 max_items = 14;
|
||||||
|
int64 min_items = 15;
|
||||||
|
bool unique_items = 16;
|
||||||
|
int64 max_properties = 17;
|
||||||
|
int64 min_properties = 18;
|
||||||
|
repeated string required = 19;
|
||||||
|
repeated Any enum = 20;
|
||||||
|
AdditionalPropertiesItem additional_properties = 21;
|
||||||
|
TypeItem type = 22;
|
||||||
|
ItemsItem items = 23;
|
||||||
|
repeated Schema all_of = 24;
|
||||||
|
Properties properties = 25;
|
||||||
|
string discriminator = 26;
|
||||||
|
bool read_only = 27;
|
||||||
|
Xml xml = 28;
|
||||||
|
ExternalDocs external_docs = 29;
|
||||||
|
Any example = 30;
|
||||||
|
repeated NamedAny vendor_extension = 31;
|
||||||
|
}
|
||||||
|
|
||||||
|
message SchemaItem {
|
||||||
|
oneof oneof {
|
||||||
|
Schema schema = 1;
|
||||||
|
FileSchema file_schema = 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
message SecurityDefinitions {
|
||||||
|
repeated NamedSecurityDefinitionsItem additional_properties = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
message SecurityDefinitionsItem {
|
||||||
|
oneof oneof {
|
||||||
|
BasicAuthenticationSecurity basic_authentication_security = 1;
|
||||||
|
ApiKeySecurity api_key_security = 2;
|
||||||
|
Oauth2ImplicitSecurity oauth2_implicit_security = 3;
|
||||||
|
Oauth2PasswordSecurity oauth2_password_security = 4;
|
||||||
|
Oauth2ApplicationSecurity oauth2_application_security = 5;
|
||||||
|
Oauth2AccessCodeSecurity oauth2_access_code_security = 6;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
message SecurityRequirement {
|
||||||
|
repeated NamedStringArray additional_properties = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
message StringArray {
|
||||||
|
repeated string value = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
message Tag {
|
||||||
|
string name = 1;
|
||||||
|
string description = 2;
|
||||||
|
ExternalDocs external_docs = 3;
|
||||||
|
repeated NamedAny vendor_extension = 4;
|
||||||
|
}
|
||||||
|
|
||||||
|
message TypeItem {
|
||||||
|
repeated string value = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Any property starting with x- is valid.
|
||||||
|
message VendorExtension {
|
||||||
|
repeated NamedAny additional_properties = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
message Xml {
|
||||||
|
string name = 1;
|
||||||
|
string namespace = 2;
|
||||||
|
string prefix = 3;
|
||||||
|
bool attribute = 4;
|
||||||
|
bool wrapped = 5;
|
||||||
|
repeated NamedAny vendor_extension = 6;
|
||||||
|
}
|
||||||
|
|
16
vendor/github.com/googleapis/gnostic/OpenAPIv2/README.md
generated
vendored
Normal file
16
vendor/github.com/googleapis/gnostic/OpenAPIv2/README.md
generated
vendored
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
# OpenAPI v2 Protocol Buffer Models
|
||||||
|
|
||||||
|
This directory contains a Protocol Buffer-language model
|
||||||
|
and related code for supporting OpenAPI v2.
|
||||||
|
|
||||||
|
Gnostic applications and plugins can use OpenAPIv2.proto
|
||||||
|
to generate Protocol Buffer support code for their preferred languages.
|
||||||
|
|
||||||
|
OpenAPIv2.go is used by Gnostic to read JSON and YAML OpenAPI
|
||||||
|
descriptions into the Protocol Buffer-based datastructures
|
||||||
|
generated from OpenAPIv2.proto.
|
||||||
|
|
||||||
|
OpenAPIv2.proto and OpenAPIv2.go are generated by the Gnostic
|
||||||
|
compiler generator, and OpenAPIv2.pb.go is generated by
|
||||||
|
protoc, the Protocol Buffer compiler, and protoc-gen-go, the
|
||||||
|
Protocol Buffer Go code generation plugin.
|
1610
vendor/github.com/googleapis/gnostic/OpenAPIv2/openapi-2.0.json
generated
vendored
Normal file
1610
vendor/github.com/googleapis/gnostic/OpenAPIv2/openapi-2.0.json
generated
vendored
Normal file
File diff suppressed because it is too large
Load diff
3
vendor/github.com/googleapis/gnostic/compiler/README.md
generated
vendored
Normal file
3
vendor/github.com/googleapis/gnostic/compiler/README.md
generated
vendored
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
# Compiler support code
|
||||||
|
|
||||||
|
This directory contains compiler support code used by Gnostic and Gnostic extensions.
|
41
vendor/github.com/googleapis/gnostic/compiler/context.go
generated
vendored
Normal file
41
vendor/github.com/googleapis/gnostic/compiler/context.go
generated
vendored
Normal file
|
@ -0,0 +1,41 @@
|
||||||
|
// Copyright 2017 Google Inc. All Rights Reserved.
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
|
package compiler
|
||||||
|
|
||||||
|
type Context struct {
|
||||||
|
Parent *Context
|
||||||
|
Name string
|
||||||
|
ExtensionHandlers *[]ExtensionHandler
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewContextWithExtensions(name string, parent *Context, extensionHandlers *[]ExtensionHandler) *Context {
|
||||||
|
return &Context{Name: name, Parent: parent, ExtensionHandlers: extensionHandlers}
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewContext(name string, parent *Context) *Context {
|
||||||
|
if parent != nil {
|
||||||
|
return &Context{Name: name, Parent: parent, ExtensionHandlers: parent.ExtensionHandlers}
|
||||||
|
} else {
|
||||||
|
return &Context{Name: name, Parent: parent, ExtensionHandlers: nil}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (context *Context) Description() string {
|
||||||
|
if context.Parent != nil {
|
||||||
|
return context.Parent.Description() + "." + context.Name
|
||||||
|
} else {
|
||||||
|
return context.Name
|
||||||
|
}
|
||||||
|
}
|
59
vendor/github.com/googleapis/gnostic/compiler/error.go
generated
vendored
Normal file
59
vendor/github.com/googleapis/gnostic/compiler/error.go
generated
vendored
Normal file
|
@ -0,0 +1,59 @@
|
||||||
|
// Copyright 2017 Google Inc. All Rights Reserved.
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
|
package compiler
|
||||||
|
|
||||||
|
// basic error type
|
||||||
|
type Error struct {
|
||||||
|
Context *Context
|
||||||
|
Message string
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewError(context *Context, message string) *Error {
|
||||||
|
return &Error{Context: context, Message: message}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (err *Error) Error() string {
|
||||||
|
if err.Context != nil {
|
||||||
|
return "ERROR " + err.Context.Description() + " " + err.Message
|
||||||
|
} else {
|
||||||
|
return "ERROR " + err.Message
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// container for groups of errors
|
||||||
|
type ErrorGroup struct {
|
||||||
|
Errors []error
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewErrorGroupOrNil(errors []error) error {
|
||||||
|
if len(errors) == 0 {
|
||||||
|
return nil
|
||||||
|
} else if len(errors) == 1 {
|
||||||
|
return errors[0]
|
||||||
|
} else {
|
||||||
|
return &ErrorGroup{Errors: errors}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (group *ErrorGroup) Error() string {
|
||||||
|
result := ""
|
||||||
|
for i, err := range group.Errors {
|
||||||
|
if i > 0 {
|
||||||
|
result += "\n"
|
||||||
|
}
|
||||||
|
result += err.Error()
|
||||||
|
}
|
||||||
|
return result
|
||||||
|
}
|
99
vendor/github.com/googleapis/gnostic/compiler/extension-handler.go
generated
vendored
Normal file
99
vendor/github.com/googleapis/gnostic/compiler/extension-handler.go
generated
vendored
Normal file
|
@ -0,0 +1,99 @@
|
||||||
|
// Copyright 2017 Google Inc. All Rights Reserved.
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
|
package compiler
|
||||||
|
|
||||||
|
import (
|
||||||
|
"bytes"
|
||||||
|
"fmt"
|
||||||
|
"os/exec"
|
||||||
|
|
||||||
|
"strings"
|
||||||
|
|
||||||
|
"errors"
|
||||||
|
|
||||||
|
"github.com/golang/protobuf/proto"
|
||||||
|
"github.com/golang/protobuf/ptypes/any"
|
||||||
|
ext_plugin "github.com/googleapis/gnostic/extensions"
|
||||||
|
yaml "gopkg.in/yaml.v2"
|
||||||
|
)
|
||||||
|
|
||||||
|
type ExtensionHandler struct {
|
||||||
|
Name string
|
||||||
|
}
|
||||||
|
|
||||||
|
func HandleExtension(context *Context, in interface{}, extensionName string) (bool, *any.Any, error) {
|
||||||
|
handled := false
|
||||||
|
var errFromPlugin error
|
||||||
|
var outFromPlugin *any.Any
|
||||||
|
|
||||||
|
if context.ExtensionHandlers != nil && len(*(context.ExtensionHandlers)) != 0 {
|
||||||
|
for _, customAnyProtoGenerator := range *(context.ExtensionHandlers) {
|
||||||
|
outFromPlugin, errFromPlugin = customAnyProtoGenerator.handle(in, extensionName)
|
||||||
|
if outFromPlugin == nil {
|
||||||
|
continue
|
||||||
|
} else {
|
||||||
|
handled = true
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return handled, outFromPlugin, errFromPlugin
|
||||||
|
}
|
||||||
|
|
||||||
|
func (extensionHandlers *ExtensionHandler) handle(in interface{}, extensionName string) (*any.Any, error) {
|
||||||
|
if extensionHandlers.Name != "" {
|
||||||
|
binary, _ := yaml.Marshal(in)
|
||||||
|
|
||||||
|
request := &ext_plugin.ExtensionHandlerRequest{}
|
||||||
|
|
||||||
|
version := &ext_plugin.Version{}
|
||||||
|
version.Major = 0
|
||||||
|
version.Minor = 1
|
||||||
|
version.Patch = 0
|
||||||
|
request.CompilerVersion = version
|
||||||
|
|
||||||
|
request.Wrapper = &ext_plugin.Wrapper{}
|
||||||
|
|
||||||
|
request.Wrapper.Version = "v2"
|
||||||
|
request.Wrapper.Yaml = string(binary)
|
||||||
|
request.Wrapper.ExtensionName = extensionName
|
||||||
|
|
||||||
|
requestBytes, _ := proto.Marshal(request)
|
||||||
|
cmd := exec.Command(extensionHandlers.Name)
|
||||||
|
cmd.Stdin = bytes.NewReader(requestBytes)
|
||||||
|
output, err := cmd.Output()
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
fmt.Printf("Error: %+v\n", err)
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
response := &ext_plugin.ExtensionHandlerResponse{}
|
||||||
|
err = proto.Unmarshal(output, response)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Printf("Error: %+v\n", err)
|
||||||
|
fmt.Printf("%s\n", string(output))
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if !response.Handled {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
if len(response.Error) != 0 {
|
||||||
|
message := fmt.Sprintf("Errors when parsing: %+v for field %s by vendor extension handler %s. Details %+v", in, extensionName, extensionHandlers.Name, strings.Join(response.Error, ","))
|
||||||
|
return nil, errors.New(message)
|
||||||
|
}
|
||||||
|
return response.Value, nil
|
||||||
|
}
|
||||||
|
return nil, nil
|
||||||
|
}
|
193
vendor/github.com/googleapis/gnostic/compiler/helpers.go
generated
vendored
Normal file
193
vendor/github.com/googleapis/gnostic/compiler/helpers.go
generated
vendored
Normal file
|
@ -0,0 +1,193 @@
|
||||||
|
// Copyright 2017 Google Inc. All Rights Reserved.
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
|
package compiler
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"gopkg.in/yaml.v2"
|
||||||
|
"regexp"
|
||||||
|
"sort"
|
||||||
|
"strings"
|
||||||
|
)
|
||||||
|
|
||||||
|
// compiler helper functions, usually called from generated code
|
||||||
|
|
||||||
|
func UnpackMap(in interface{}) (yaml.MapSlice, bool) {
|
||||||
|
m, ok := in.(yaml.MapSlice)
|
||||||
|
if ok {
|
||||||
|
return m, ok
|
||||||
|
} else {
|
||||||
|
// do we have an empty array?
|
||||||
|
a, ok := in.([]interface{})
|
||||||
|
if ok && len(a) == 0 {
|
||||||
|
// if so, return an empty map
|
||||||
|
return yaml.MapSlice{}, ok
|
||||||
|
} else {
|
||||||
|
return nil, ok
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func SortedKeysForMap(m yaml.MapSlice) []string {
|
||||||
|
keys := make([]string, 0)
|
||||||
|
for _, item := range m {
|
||||||
|
keys = append(keys, item.Key.(string))
|
||||||
|
}
|
||||||
|
sort.Strings(keys)
|
||||||
|
return keys
|
||||||
|
}
|
||||||
|
|
||||||
|
func MapHasKey(m yaml.MapSlice, key string) bool {
|
||||||
|
for _, item := range m {
|
||||||
|
itemKey, ok := item.Key.(string)
|
||||||
|
if ok && key == itemKey {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
func MapValueForKey(m yaml.MapSlice, key string) interface{} {
|
||||||
|
for _, item := range m {
|
||||||
|
itemKey, ok := item.Key.(string)
|
||||||
|
if ok && key == itemKey {
|
||||||
|
return item.Value
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func ConvertInterfaceArrayToStringArray(interfaceArray []interface{}) []string {
|
||||||
|
stringArray := make([]string, 0)
|
||||||
|
for _, item := range interfaceArray {
|
||||||
|
v, ok := item.(string)
|
||||||
|
if ok {
|
||||||
|
stringArray = append(stringArray, v)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return stringArray
|
||||||
|
}
|
||||||
|
|
||||||
|
func PatternMatches(pattern string, value string) bool {
|
||||||
|
// if pattern contains a subpattern like "{path}", replace it with ".*"
|
||||||
|
if pattern[0] != '^' {
|
||||||
|
subpatternPattern := regexp.MustCompile("^.*(\\{.*\\}).*$")
|
||||||
|
if matches := subpatternPattern.FindSubmatch([]byte(pattern)); matches != nil {
|
||||||
|
match := string(matches[1])
|
||||||
|
pattern = strings.Replace(pattern, match, ".*", -1)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
matched, err := regexp.Match(pattern, []byte(value))
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
return matched
|
||||||
|
}
|
||||||
|
|
||||||
|
func MissingKeysInMap(m yaml.MapSlice, requiredKeys []string) []string {
|
||||||
|
missingKeys := make([]string, 0)
|
||||||
|
for _, k := range requiredKeys {
|
||||||
|
if !MapHasKey(m, k) {
|
||||||
|
missingKeys = append(missingKeys, k)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return missingKeys
|
||||||
|
}
|
||||||
|
|
||||||
|
func InvalidKeysInMap(m yaml.MapSlice, allowedKeys []string, allowedPatterns []string) []string {
|
||||||
|
invalidKeys := make([]string, 0)
|
||||||
|
for _, item := range m {
|
||||||
|
itemKey, ok := item.Key.(string)
|
||||||
|
if ok {
|
||||||
|
key := itemKey
|
||||||
|
found := false
|
||||||
|
// does the key match an allowed key?
|
||||||
|
for _, allowedKey := range allowedKeys {
|
||||||
|
if key == allowedKey {
|
||||||
|
found = true
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if !found {
|
||||||
|
// does the key match an allowed pattern?
|
||||||
|
for _, allowedPattern := range allowedPatterns {
|
||||||
|
if PatternMatches(allowedPattern, key) {
|
||||||
|
found = true
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if !found {
|
||||||
|
invalidKeys = append(invalidKeys, key)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return invalidKeys
|
||||||
|
}
|
||||||
|
|
||||||
|
// describe a map (for debugging purposes)
|
||||||
|
func DescribeMap(in interface{}, indent string) string {
|
||||||
|
description := ""
|
||||||
|
m, ok := in.(map[string]interface{})
|
||||||
|
if ok {
|
||||||
|
keys := make([]string, 0)
|
||||||
|
for k, _ := range m {
|
||||||
|
keys = append(keys, k)
|
||||||
|
}
|
||||||
|
sort.Strings(keys)
|
||||||
|
for _, k := range keys {
|
||||||
|
v := m[k]
|
||||||
|
description += fmt.Sprintf("%s%s:\n", indent, k)
|
||||||
|
description += DescribeMap(v, indent+" ")
|
||||||
|
}
|
||||||
|
return description
|
||||||
|
}
|
||||||
|
a, ok := in.([]interface{})
|
||||||
|
if ok {
|
||||||
|
for i, v := range a {
|
||||||
|
description += fmt.Sprintf("%s%d:\n", indent, i)
|
||||||
|
description += DescribeMap(v, indent+" ")
|
||||||
|
}
|
||||||
|
return description
|
||||||
|
}
|
||||||
|
description += fmt.Sprintf("%s%+v\n", indent, in)
|
||||||
|
return description
|
||||||
|
}
|
||||||
|
|
||||||
|
func PluralProperties(count int) string {
|
||||||
|
if count == 1 {
|
||||||
|
return "property"
|
||||||
|
} else {
|
||||||
|
return "properties"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func StringArrayContainsValue(array []string, value string) bool {
|
||||||
|
for _, item := range array {
|
||||||
|
if item == value {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
func StringArrayContainsValues(array []string, values []string) bool {
|
||||||
|
for _, value := range values {
|
||||||
|
if !StringArrayContainsValue(array, value) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
}
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue