From ffadb30c6396607aba0ed76b945173e353d724bf Mon Sep 17 00:00:00 2001 From: Yousong Zhou Date: Fri, 8 May 2020 22:20:30 +0800 Subject: [PATCH 01/13] vendor: tidy and vendoring --- go.mod | 1 - .../go/monitoring/apiv3/.repo-metadata.json | 12 - .../monitoring/apiv3/alert_policy_client.go | 288 -- .../go/monitoring/apiv3/doc.go | 108 - .../go/monitoring/apiv3/group_client.go | 373 --- .../go/monitoring/apiv3/metric_client.go | 467 --- .../apiv3/notification_channel_client.go | 464 --- .../go/monitoring/apiv3/path_funcs.go | 107 - .../apiv3/service_monitoring_client.go | 435 --- .../monitoring/apiv3/uptime_check_client.go | 372 --- vendor/github.com/google/go-cmp/LICENSE | 27 - .../github.com/google/go-cmp/cmp/compare.go | 616 ---- .../google/go-cmp/cmp/export_panic.go | 15 - .../google/go-cmp/cmp/export_unsafe.go | 23 - .../go-cmp/cmp/internal/diff/debug_disable.go | 17 - .../go-cmp/cmp/internal/diff/debug_enable.go | 122 - .../google/go-cmp/cmp/internal/diff/diff.go | 372 --- .../google/go-cmp/cmp/internal/flags/flags.go | 9 - .../cmp/internal/flags/toolchain_legacy.go | 10 - .../cmp/internal/flags/toolchain_recent.go | 10 - .../go-cmp/cmp/internal/function/func.go | 99 - .../cmp/internal/value/pointer_purego.go | 23 - .../cmp/internal/value/pointer_unsafe.go | 26 - .../google/go-cmp/cmp/internal/value/sort.go | 106 - .../google/go-cmp/cmp/internal/value/zero.go | 48 - .../github.com/google/go-cmp/cmp/options.go | 524 --- vendor/github.com/google/go-cmp/cmp/path.go | 308 -- vendor/github.com/google/go-cmp/cmp/report.go | 51 - .../google/go-cmp/cmp/report_compare.go | 296 -- .../google/go-cmp/cmp/report_reflect.go | 278 -- .../google/go-cmp/cmp/report_slices.go | 333 -- .../google/go-cmp/cmp/report_text.go | 387 --- .../google/go-cmp/cmp/report_value.go | 121 - .../go.opencensus.io/plugin/ocgrpc/client.go | 56 - .../plugin/ocgrpc/client_metrics.go | 107 - .../plugin/ocgrpc/client_stats_handler.go | 49 - vendor/go.opencensus.io/plugin/ocgrpc/doc.go | 19 - .../go.opencensus.io/plugin/ocgrpc/server.go | 80 - .../plugin/ocgrpc/server_metrics.go | 97 - .../plugin/ocgrpc/server_stats_handler.go | 63 - .../plugin/ocgrpc/stats_common.go | 227 -- .../plugin/ocgrpc/trace_common.go | 107 - .../google.golang.org/api/transport/dial.go | 36 - vendor/google.golang.org/api/transport/doc.go | 11 - .../google.golang.org/api/transport/go19.go | 25 - .../api/transport/grpc/dial.go | 202 -- .../api/transport/grpc/dial_appengine.go | 31 - .../api/transport/grpc/dial_socketopt.go | 49 - .../api/transport/not_go19.go | 25 - .../internal/socket/socket_service.pb.go | 2822 ----------------- .../internal/socket/socket_service.proto | 460 --- .../google.golang.org/appengine/socket/doc.go | 10 - .../appengine/socket/socket_classic.go | 290 -- .../appengine/socket/socket_vm.go | 64 - .../grpclb/grpc_lb_v1/load_balancer.pb.go | 722 ----- .../grpc/balancer/grpclb/grpclb.go | 490 --- .../grpc/balancer/grpclb/grpclb_config.go | 66 - .../grpc/balancer/grpclb/grpclb_picker.go | 202 -- .../balancer/grpclb/grpclb_remote_balancer.go | 409 --- .../grpc/balancer/grpclb/grpclb_util.go | 208 -- .../grpc/balancer/grpclb/regenerate.sh | 33 - .../grpc/credentials/alts/alts.go | 330 -- .../alts/internal/authinfo/authinfo.go | 87 - .../grpc/credentials/alts/internal/common.go | 69 - .../alts/internal/conn/aeadrekey.go | 131 - .../alts/internal/conn/aes128gcm.go | 105 - .../alts/internal/conn/aes128gcmrekey.go | 116 - .../credentials/alts/internal/conn/common.go | 70 - .../credentials/alts/internal/conn/counter.go | 62 - .../credentials/alts/internal/conn/record.go | 271 -- .../credentials/alts/internal/conn/utils.go | 63 - .../alts/internal/handshaker/handshaker.go | 375 --- .../internal/handshaker/service/service.go | 54 - .../internal/proto/grpc_gcp/altscontext.pb.go | 152 - .../internal/proto/grpc_gcp/handshaker.pb.go | 1105 ------- .../grpc_gcp/transport_security_common.pb.go | 184 -- .../credentials/alts/internal/regenerate.sh | 35 - .../grpc/credentials/alts/utils.go | 144 - .../grpc/credentials/google/google.go | 125 - .../grpc/credentials/oauth/oauth.go | 173 - vendor/modules.txt | 23 - 81 files changed, 17082 deletions(-) delete mode 100644 vendor/cloud.google.com/go/monitoring/apiv3/.repo-metadata.json delete mode 100644 vendor/cloud.google.com/go/monitoring/apiv3/alert_policy_client.go delete mode 100644 vendor/cloud.google.com/go/monitoring/apiv3/doc.go delete mode 100644 vendor/cloud.google.com/go/monitoring/apiv3/group_client.go delete mode 100644 vendor/cloud.google.com/go/monitoring/apiv3/metric_client.go delete mode 100644 vendor/cloud.google.com/go/monitoring/apiv3/notification_channel_client.go delete mode 100644 vendor/cloud.google.com/go/monitoring/apiv3/path_funcs.go delete mode 100644 vendor/cloud.google.com/go/monitoring/apiv3/service_monitoring_client.go delete mode 100644 vendor/cloud.google.com/go/monitoring/apiv3/uptime_check_client.go delete mode 100644 vendor/github.com/google/go-cmp/LICENSE delete mode 100644 vendor/github.com/google/go-cmp/cmp/compare.go delete mode 100644 vendor/github.com/google/go-cmp/cmp/export_panic.go delete mode 100644 vendor/github.com/google/go-cmp/cmp/export_unsafe.go delete mode 100644 vendor/github.com/google/go-cmp/cmp/internal/diff/debug_disable.go delete mode 100644 vendor/github.com/google/go-cmp/cmp/internal/diff/debug_enable.go delete mode 100644 vendor/github.com/google/go-cmp/cmp/internal/diff/diff.go delete mode 100644 vendor/github.com/google/go-cmp/cmp/internal/flags/flags.go delete mode 100644 vendor/github.com/google/go-cmp/cmp/internal/flags/toolchain_legacy.go delete mode 100644 vendor/github.com/google/go-cmp/cmp/internal/flags/toolchain_recent.go delete mode 100644 vendor/github.com/google/go-cmp/cmp/internal/function/func.go delete mode 100644 vendor/github.com/google/go-cmp/cmp/internal/value/pointer_purego.go delete mode 100644 vendor/github.com/google/go-cmp/cmp/internal/value/pointer_unsafe.go delete mode 100644 vendor/github.com/google/go-cmp/cmp/internal/value/sort.go delete mode 100644 vendor/github.com/google/go-cmp/cmp/internal/value/zero.go delete mode 100644 vendor/github.com/google/go-cmp/cmp/options.go delete mode 100644 vendor/github.com/google/go-cmp/cmp/path.go delete mode 100644 vendor/github.com/google/go-cmp/cmp/report.go delete mode 100644 vendor/github.com/google/go-cmp/cmp/report_compare.go delete mode 100644 vendor/github.com/google/go-cmp/cmp/report_reflect.go delete mode 100644 vendor/github.com/google/go-cmp/cmp/report_slices.go delete mode 100644 vendor/github.com/google/go-cmp/cmp/report_text.go delete mode 100644 vendor/github.com/google/go-cmp/cmp/report_value.go delete mode 100644 vendor/go.opencensus.io/plugin/ocgrpc/client.go delete mode 100644 vendor/go.opencensus.io/plugin/ocgrpc/client_metrics.go delete mode 100644 vendor/go.opencensus.io/plugin/ocgrpc/client_stats_handler.go delete mode 100644 vendor/go.opencensus.io/plugin/ocgrpc/doc.go delete mode 100644 vendor/go.opencensus.io/plugin/ocgrpc/server.go delete mode 100644 vendor/go.opencensus.io/plugin/ocgrpc/server_metrics.go delete mode 100644 vendor/go.opencensus.io/plugin/ocgrpc/server_stats_handler.go delete mode 100644 vendor/go.opencensus.io/plugin/ocgrpc/stats_common.go delete mode 100644 vendor/go.opencensus.io/plugin/ocgrpc/trace_common.go delete mode 100644 vendor/google.golang.org/api/transport/dial.go delete mode 100644 vendor/google.golang.org/api/transport/doc.go delete mode 100644 vendor/google.golang.org/api/transport/go19.go delete mode 100644 vendor/google.golang.org/api/transport/grpc/dial.go delete mode 100644 vendor/google.golang.org/api/transport/grpc/dial_appengine.go delete mode 100644 vendor/google.golang.org/api/transport/grpc/dial_socketopt.go delete mode 100644 vendor/google.golang.org/api/transport/not_go19.go delete mode 100644 vendor/google.golang.org/appengine/internal/socket/socket_service.pb.go delete mode 100644 vendor/google.golang.org/appengine/internal/socket/socket_service.proto delete mode 100644 vendor/google.golang.org/appengine/socket/doc.go delete mode 100644 vendor/google.golang.org/appengine/socket/socket_classic.go delete mode 100644 vendor/google.golang.org/appengine/socket/socket_vm.go delete mode 100644 vendor/google.golang.org/grpc/balancer/grpclb/grpc_lb_v1/load_balancer.pb.go delete mode 100644 vendor/google.golang.org/grpc/balancer/grpclb/grpclb.go delete mode 100644 vendor/google.golang.org/grpc/balancer/grpclb/grpclb_config.go delete mode 100644 vendor/google.golang.org/grpc/balancer/grpclb/grpclb_picker.go delete mode 100644 vendor/google.golang.org/grpc/balancer/grpclb/grpclb_remote_balancer.go delete mode 100644 vendor/google.golang.org/grpc/balancer/grpclb/grpclb_util.go delete mode 100644 vendor/google.golang.org/grpc/balancer/grpclb/regenerate.sh delete mode 100644 vendor/google.golang.org/grpc/credentials/alts/alts.go delete mode 100644 vendor/google.golang.org/grpc/credentials/alts/internal/authinfo/authinfo.go delete mode 100644 vendor/google.golang.org/grpc/credentials/alts/internal/common.go delete mode 100644 vendor/google.golang.org/grpc/credentials/alts/internal/conn/aeadrekey.go delete mode 100644 vendor/google.golang.org/grpc/credentials/alts/internal/conn/aes128gcm.go delete mode 100644 vendor/google.golang.org/grpc/credentials/alts/internal/conn/aes128gcmrekey.go delete mode 100644 vendor/google.golang.org/grpc/credentials/alts/internal/conn/common.go delete mode 100644 vendor/google.golang.org/grpc/credentials/alts/internal/conn/counter.go delete mode 100644 vendor/google.golang.org/grpc/credentials/alts/internal/conn/record.go delete mode 100644 vendor/google.golang.org/grpc/credentials/alts/internal/conn/utils.go delete mode 100644 vendor/google.golang.org/grpc/credentials/alts/internal/handshaker/handshaker.go delete mode 100644 vendor/google.golang.org/grpc/credentials/alts/internal/handshaker/service/service.go delete mode 100644 vendor/google.golang.org/grpc/credentials/alts/internal/proto/grpc_gcp/altscontext.pb.go delete mode 100644 vendor/google.golang.org/grpc/credentials/alts/internal/proto/grpc_gcp/handshaker.pb.go delete mode 100644 vendor/google.golang.org/grpc/credentials/alts/internal/proto/grpc_gcp/transport_security_common.pb.go delete mode 100644 vendor/google.golang.org/grpc/credentials/alts/internal/regenerate.sh delete mode 100644 vendor/google.golang.org/grpc/credentials/alts/utils.go delete mode 100644 vendor/google.golang.org/grpc/credentials/google/google.go delete mode 100644 vendor/google.golang.org/grpc/credentials/oauth/oauth.go diff --git a/go.mod b/go.mod index 675649face..db1a200eb4 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,6 @@ module yunion.io/x/onecloud go 1.12 require ( - cloud.google.com/go v0.50.0 cloud.google.com/go/storage v1.5.0 github.com/360EntSecGroup-Skylar/excelize v1.4.0 github.com/Azure/azure-sdk-for-go v36.1.0+incompatible diff --git a/vendor/cloud.google.com/go/monitoring/apiv3/.repo-metadata.json b/vendor/cloud.google.com/go/monitoring/apiv3/.repo-metadata.json deleted file mode 100644 index ec9a49c44f..0000000000 --- a/vendor/cloud.google.com/go/monitoring/apiv3/.repo-metadata.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "name": "monitoring", - "name_pretty": "Stackdriver Monitoring API", - "product_documentation": "https://cloud.google.com/monitoring", - "client_documentation": "https://godoc.org/cloud.google.com/go/monitoring/apiv3", - "release_level": "alpha", - "language": "go", - "repo": "googleapis/google-cloud-go", - "distribution_name": "cloud.google.com/go", - "api_id": "monitoring.googleapis.com", - "requires_billing": true -} diff --git a/vendor/cloud.google.com/go/monitoring/apiv3/alert_policy_client.go b/vendor/cloud.google.com/go/monitoring/apiv3/alert_policy_client.go deleted file mode 100644 index 836b033321..0000000000 --- a/vendor/cloud.google.com/go/monitoring/apiv3/alert_policy_client.go +++ /dev/null @@ -1,288 +0,0 @@ -// Copyright 2019 Google LLC -// -// 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 -// -// https://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. - -// Code generated by gapic-generator. DO NOT EDIT. - -package monitoring - -import ( - "context" - "fmt" - "math" - "net/url" - "time" - - "github.com/golang/protobuf/proto" - gax "github.com/googleapis/gax-go/v2" - "google.golang.org/api/iterator" - "google.golang.org/api/option" - "google.golang.org/api/transport" - monitoringpb "google.golang.org/genproto/googleapis/monitoring/v3" - "google.golang.org/grpc" - "google.golang.org/grpc/codes" - "google.golang.org/grpc/metadata" -) - -// AlertPolicyCallOptions contains the retry settings for each method of AlertPolicyClient. -type AlertPolicyCallOptions struct { - ListAlertPolicies []gax.CallOption - GetAlertPolicy []gax.CallOption - CreateAlertPolicy []gax.CallOption - DeleteAlertPolicy []gax.CallOption - UpdateAlertPolicy []gax.CallOption -} - -func defaultAlertPolicyClientOptions() []option.ClientOption { - return []option.ClientOption{ - option.WithEndpoint("monitoring.googleapis.com:443"), - option.WithScopes(DefaultAuthScopes()...), - option.WithGRPCDialOption(grpc.WithDefaultCallOptions( - grpc.MaxCallRecvMsgSize(math.MaxInt32))), - } -} - -func defaultAlertPolicyCallOptions() *AlertPolicyCallOptions { - retry := map[[2]string][]gax.CallOption{ - {"default", "idempotent"}: { - gax.WithRetry(func() gax.Retryer { - return gax.OnCodes([]codes.Code{ - codes.DeadlineExceeded, - codes.Unavailable, - }, gax.Backoff{ - Initial: 100 * time.Millisecond, - Max: 60000 * time.Millisecond, - Multiplier: 1.3, - }) - }), - }, - } - return &AlertPolicyCallOptions{ - ListAlertPolicies: retry[[2]string{"default", "idempotent"}], - GetAlertPolicy: retry[[2]string{"default", "idempotent"}], - CreateAlertPolicy: retry[[2]string{"default", "non_idempotent"}], - DeleteAlertPolicy: retry[[2]string{"default", "idempotent"}], - UpdateAlertPolicy: retry[[2]string{"default", "non_idempotent"}], - } -} - -// AlertPolicyClient is a client for interacting with Stackdriver Monitoring API. -// -// Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls. -type AlertPolicyClient struct { - // The connection to the service. - conn *grpc.ClientConn - - // The gRPC API client. - alertPolicyClient monitoringpb.AlertPolicyServiceClient - - // The call options for this service. - CallOptions *AlertPolicyCallOptions - - // The x-goog-* metadata to be sent with each request. - xGoogMetadata metadata.MD -} - -// NewAlertPolicyClient creates a new alert policy service client. -// -// The AlertPolicyService API is used to manage (list, create, delete, -// edit) alert policies in Stackdriver Monitoring. An alerting policy is -// a description of the conditions under which some aspect of your -// system is considered to be "unhealthy" and the ways to notify -// people or services about this state. In addition to using this API, alert -// policies can also be managed through -// Stackdriver Monitoring (at https://cloud.google.com/monitoring/docs/), -// which can be reached by clicking the "Monitoring" tab in -// Cloud Console (at https://console.cloud.google.com/). -func NewAlertPolicyClient(ctx context.Context, opts ...option.ClientOption) (*AlertPolicyClient, error) { - conn, err := transport.DialGRPC(ctx, append(defaultAlertPolicyClientOptions(), opts...)...) - if err != nil { - return nil, err - } - c := &AlertPolicyClient{ - conn: conn, - CallOptions: defaultAlertPolicyCallOptions(), - - alertPolicyClient: monitoringpb.NewAlertPolicyServiceClient(conn), - } - c.setGoogleClientInfo() - return c, nil -} - -// Connection returns the client's connection to the API service. -func (c *AlertPolicyClient) Connection() *grpc.ClientConn { - return c.conn -} - -// Close closes the connection to the API service. The user should invoke this when -// the client is no longer required. -func (c *AlertPolicyClient) Close() error { - return c.conn.Close() -} - -// setGoogleClientInfo sets the name and version of the application in -// the `x-goog-api-client` header passed on each request. Intended for -// use by Google-written clients. -func (c *AlertPolicyClient) setGoogleClientInfo(keyval ...string) { - kv := append([]string{"gl-go", versionGo()}, keyval...) - kv = append(kv, "gapic", versionClient, "gax", gax.Version, "grpc", grpc.Version) - c.xGoogMetadata = metadata.Pairs("x-goog-api-client", gax.XGoogHeader(kv...)) -} - -// ListAlertPolicies lists the existing alerting policies for the project. -func (c *AlertPolicyClient) ListAlertPolicies(ctx context.Context, req *monitoringpb.ListAlertPoliciesRequest, opts ...gax.CallOption) *AlertPolicyIterator { - md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))) - ctx = insertMetadata(ctx, c.xGoogMetadata, md) - opts = append(c.CallOptions.ListAlertPolicies[0:len(c.CallOptions.ListAlertPolicies):len(c.CallOptions.ListAlertPolicies)], opts...) - it := &AlertPolicyIterator{} - req = proto.Clone(req).(*monitoringpb.ListAlertPoliciesRequest) - it.InternalFetch = func(pageSize int, pageToken string) ([]*monitoringpb.AlertPolicy, string, error) { - var resp *monitoringpb.ListAlertPoliciesResponse - req.PageToken = pageToken - if pageSize > math.MaxInt32 { - req.PageSize = math.MaxInt32 - } else { - req.PageSize = int32(pageSize) - } - err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { - var err error - resp, err = c.alertPolicyClient.ListAlertPolicies(ctx, req, settings.GRPC...) - return err - }, opts...) - if err != nil { - return nil, "", err - } - return resp.AlertPolicies, resp.NextPageToken, nil - } - fetch := func(pageSize int, pageToken string) (string, error) { - items, nextPageToken, err := it.InternalFetch(pageSize, pageToken) - if err != nil { - return "", err - } - it.items = append(it.items, items...) - return nextPageToken, nil - } - it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf) - it.pageInfo.MaxSize = int(req.PageSize) - it.pageInfo.Token = req.PageToken - return it -} - -// GetAlertPolicy gets a single alerting policy. -func (c *AlertPolicyClient) GetAlertPolicy(ctx context.Context, req *monitoringpb.GetAlertPolicyRequest, opts ...gax.CallOption) (*monitoringpb.AlertPolicy, error) { - md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))) - ctx = insertMetadata(ctx, c.xGoogMetadata, md) - opts = append(c.CallOptions.GetAlertPolicy[0:len(c.CallOptions.GetAlertPolicy):len(c.CallOptions.GetAlertPolicy)], opts...) - var resp *monitoringpb.AlertPolicy - err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { - var err error - resp, err = c.alertPolicyClient.GetAlertPolicy(ctx, req, settings.GRPC...) - return err - }, opts...) - if err != nil { - return nil, err - } - return resp, nil -} - -// CreateAlertPolicy creates a new alerting policy. -func (c *AlertPolicyClient) CreateAlertPolicy(ctx context.Context, req *monitoringpb.CreateAlertPolicyRequest, opts ...gax.CallOption) (*monitoringpb.AlertPolicy, error) { - md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))) - ctx = insertMetadata(ctx, c.xGoogMetadata, md) - opts = append(c.CallOptions.CreateAlertPolicy[0:len(c.CallOptions.CreateAlertPolicy):len(c.CallOptions.CreateAlertPolicy)], opts...) - var resp *monitoringpb.AlertPolicy - err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { - var err error - resp, err = c.alertPolicyClient.CreateAlertPolicy(ctx, req, settings.GRPC...) - return err - }, opts...) - if err != nil { - return nil, err - } - return resp, nil -} - -// DeleteAlertPolicy deletes an alerting policy. -func (c *AlertPolicyClient) DeleteAlertPolicy(ctx context.Context, req *monitoringpb.DeleteAlertPolicyRequest, opts ...gax.CallOption) error { - md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))) - ctx = insertMetadata(ctx, c.xGoogMetadata, md) - opts = append(c.CallOptions.DeleteAlertPolicy[0:len(c.CallOptions.DeleteAlertPolicy):len(c.CallOptions.DeleteAlertPolicy)], opts...) - err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { - var err error - _, err = c.alertPolicyClient.DeleteAlertPolicy(ctx, req, settings.GRPC...) - return err - }, opts...) - return err -} - -// UpdateAlertPolicy updates an alerting policy. You can either replace the entire policy with -// a new one or replace only certain fields in the current alerting policy by -// specifying the fields to be updated via updateMask. Returns the -// updated alerting policy. -func (c *AlertPolicyClient) UpdateAlertPolicy(ctx context.Context, req *monitoringpb.UpdateAlertPolicyRequest, opts ...gax.CallOption) (*monitoringpb.AlertPolicy, error) { - md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "alert_policy.name", url.QueryEscape(req.GetAlertPolicy().GetName()))) - ctx = insertMetadata(ctx, c.xGoogMetadata, md) - opts = append(c.CallOptions.UpdateAlertPolicy[0:len(c.CallOptions.UpdateAlertPolicy):len(c.CallOptions.UpdateAlertPolicy)], opts...) - var resp *monitoringpb.AlertPolicy - err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { - var err error - resp, err = c.alertPolicyClient.UpdateAlertPolicy(ctx, req, settings.GRPC...) - return err - }, opts...) - if err != nil { - return nil, err - } - return resp, nil -} - -// AlertPolicyIterator manages a stream of *monitoringpb.AlertPolicy. -type AlertPolicyIterator struct { - items []*monitoringpb.AlertPolicy - pageInfo *iterator.PageInfo - nextFunc func() error - - // InternalFetch is for use by the Google Cloud Libraries only. - // It is not part of the stable interface of this package. - // - // InternalFetch returns results from a single call to the underlying RPC. - // The number of results is no greater than pageSize. - // If there are no more results, nextPageToken is empty and err is nil. - InternalFetch func(pageSize int, pageToken string) (results []*monitoringpb.AlertPolicy, nextPageToken string, err error) -} - -// PageInfo supports pagination. See the google.golang.org/api/iterator package for details. -func (it *AlertPolicyIterator) PageInfo() *iterator.PageInfo { - return it.pageInfo -} - -// Next returns the next result. Its second return value is iterator.Done if there are no more -// results. Once Next returns Done, all subsequent calls will return Done. -func (it *AlertPolicyIterator) Next() (*monitoringpb.AlertPolicy, error) { - var item *monitoringpb.AlertPolicy - if err := it.nextFunc(); err != nil { - return item, err - } - item = it.items[0] - it.items = it.items[1:] - return item, nil -} - -func (it *AlertPolicyIterator) bufLen() int { - return len(it.items) -} - -func (it *AlertPolicyIterator) takeBuf() interface{} { - b := it.items - it.items = nil - return b -} diff --git a/vendor/cloud.google.com/go/monitoring/apiv3/doc.go b/vendor/cloud.google.com/go/monitoring/apiv3/doc.go deleted file mode 100644 index a9fa74d200..0000000000 --- a/vendor/cloud.google.com/go/monitoring/apiv3/doc.go +++ /dev/null @@ -1,108 +0,0 @@ -// Copyright 2019 Google LLC -// -// 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 -// -// https://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. - -// Code generated by gapic-generator. DO NOT EDIT. - -// Package monitoring is an auto-generated package for the -// Stackdriver Monitoring API. -// -// NOTE: This package is in alpha. It is not stable, and is likely to change. -// -// Manages your Stackdriver Monitoring data and configurations. Most projects -// must be associated with a Stackdriver account, with a few exceptions as -// noted on the individual method pages. The table entries below are -// presented in alphabetical order, not in order of common use. For -// explanations of the concepts found in the table entries, read the -// [Stackdriver Monitoring documentation](/monitoring/docs). -// -// Use of Context -// -// The ctx passed to NewClient is used for authentication requests and -// for creating the underlying connection, but is not used for subsequent calls. -// Individual methods on the client use the ctx given to them. -// -// To close the open connection, use the Close() method. -// -// For information about setting deadlines, reusing contexts, and more -// please visit godoc.org/cloud.google.com/go. -package monitoring // import "cloud.google.com/go/monitoring/apiv3" - -import ( - "context" - "runtime" - "strings" - "unicode" - - "google.golang.org/grpc/metadata" -) - -func insertMetadata(ctx context.Context, mds ...metadata.MD) context.Context { - out, _ := metadata.FromOutgoingContext(ctx) - out = out.Copy() - for _, md := range mds { - for k, v := range md { - out[k] = append(out[k], v...) - } - } - return metadata.NewOutgoingContext(ctx, out) -} - -// DefaultAuthScopes reports the default set of authentication scopes to use with this package. -func DefaultAuthScopes() []string { - return []string{ - "https://www.googleapis.com/auth/cloud-platform", - "https://www.googleapis.com/auth/monitoring", - "https://www.googleapis.com/auth/monitoring.read", - "https://www.googleapis.com/auth/monitoring.write", - } -} - -// versionGo returns the Go runtime version. The returned string -// has no whitespace, suitable for reporting in header. -func versionGo() string { - const develPrefix = "devel +" - - s := runtime.Version() - if strings.HasPrefix(s, develPrefix) { - s = s[len(develPrefix):] - if p := strings.IndexFunc(s, unicode.IsSpace); p >= 0 { - s = s[:p] - } - return s - } - - notSemverRune := func(r rune) bool { - return strings.IndexRune("0123456789.", r) < 0 - } - - if strings.HasPrefix(s, "go1") { - s = s[2:] - var prerelease string - if p := strings.IndexFunc(s, notSemverRune); p >= 0 { - s, prerelease = s[:p], s[p:] - } - if strings.HasSuffix(s, ".") { - s += "0" - } else if strings.Count(s, ".") < 2 { - s += ".0" - } - if prerelease != "" { - s += "-" + prerelease - } - return s - } - return "UNKNOWN" -} - -const versionClient = "20191216" diff --git a/vendor/cloud.google.com/go/monitoring/apiv3/group_client.go b/vendor/cloud.google.com/go/monitoring/apiv3/group_client.go deleted file mode 100644 index eecb511e63..0000000000 --- a/vendor/cloud.google.com/go/monitoring/apiv3/group_client.go +++ /dev/null @@ -1,373 +0,0 @@ -// Copyright 2019 Google LLC -// -// 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 -// -// https://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. - -// Code generated by gapic-generator. DO NOT EDIT. - -package monitoring - -import ( - "context" - "fmt" - "math" - "net/url" - "time" - - "github.com/golang/protobuf/proto" - gax "github.com/googleapis/gax-go/v2" - "google.golang.org/api/iterator" - "google.golang.org/api/option" - "google.golang.org/api/transport" - monitoredrespb "google.golang.org/genproto/googleapis/api/monitoredres" - monitoringpb "google.golang.org/genproto/googleapis/monitoring/v3" - "google.golang.org/grpc" - "google.golang.org/grpc/codes" - "google.golang.org/grpc/metadata" -) - -// GroupCallOptions contains the retry settings for each method of GroupClient. -type GroupCallOptions struct { - ListGroups []gax.CallOption - GetGroup []gax.CallOption - CreateGroup []gax.CallOption - UpdateGroup []gax.CallOption - DeleteGroup []gax.CallOption - ListGroupMembers []gax.CallOption -} - -func defaultGroupClientOptions() []option.ClientOption { - return []option.ClientOption{ - option.WithEndpoint("monitoring.googleapis.com:443"), - option.WithScopes(DefaultAuthScopes()...), - option.WithGRPCDialOption(grpc.WithDefaultCallOptions( - grpc.MaxCallRecvMsgSize(math.MaxInt32))), - } -} - -func defaultGroupCallOptions() *GroupCallOptions { - retry := map[[2]string][]gax.CallOption{ - {"default", "idempotent"}: { - gax.WithRetry(func() gax.Retryer { - return gax.OnCodes([]codes.Code{ - codes.DeadlineExceeded, - codes.Unavailable, - }, gax.Backoff{ - Initial: 100 * time.Millisecond, - Max: 60000 * time.Millisecond, - Multiplier: 1.3, - }) - }), - }, - } - return &GroupCallOptions{ - ListGroups: retry[[2]string{"default", "idempotent"}], - GetGroup: retry[[2]string{"default", "idempotent"}], - CreateGroup: retry[[2]string{"default", "non_idempotent"}], - UpdateGroup: retry[[2]string{"default", "idempotent"}], - DeleteGroup: retry[[2]string{"default", "idempotent"}], - ListGroupMembers: retry[[2]string{"default", "idempotent"}], - } -} - -// GroupClient is a client for interacting with Stackdriver Monitoring API. -// -// Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls. -type GroupClient struct { - // The connection to the service. - conn *grpc.ClientConn - - // The gRPC API client. - groupClient monitoringpb.GroupServiceClient - - // The call options for this service. - CallOptions *GroupCallOptions - - // The x-goog-* metadata to be sent with each request. - xGoogMetadata metadata.MD -} - -// NewGroupClient creates a new group service client. -// -// The Group API lets you inspect and manage your -// groups (at #google.monitoring.v3.Group). -// -// A group is a named filter that is used to identify -// a collection of monitored resources. Groups are typically used to -// mirror the physical and/or logical topology of the environment. -// Because group membership is computed dynamically, monitored -// resources that are started in the future are automatically placed -// in matching groups. By using a group to name monitored resources in, -// for example, an alert policy, the target of that alert policy is -// updated automatically as monitored resources are added and removed -// from the infrastructure. -func NewGroupClient(ctx context.Context, opts ...option.ClientOption) (*GroupClient, error) { - conn, err := transport.DialGRPC(ctx, append(defaultGroupClientOptions(), opts...)...) - if err != nil { - return nil, err - } - c := &GroupClient{ - conn: conn, - CallOptions: defaultGroupCallOptions(), - - groupClient: monitoringpb.NewGroupServiceClient(conn), - } - c.setGoogleClientInfo() - return c, nil -} - -// Connection returns the client's connection to the API service. -func (c *GroupClient) Connection() *grpc.ClientConn { - return c.conn -} - -// Close closes the connection to the API service. The user should invoke this when -// the client is no longer required. -func (c *GroupClient) Close() error { - return c.conn.Close() -} - -// setGoogleClientInfo sets the name and version of the application in -// the `x-goog-api-client` header passed on each request. Intended for -// use by Google-written clients. -func (c *GroupClient) setGoogleClientInfo(keyval ...string) { - kv := append([]string{"gl-go", versionGo()}, keyval...) - kv = append(kv, "gapic", versionClient, "gax", gax.Version, "grpc", grpc.Version) - c.xGoogMetadata = metadata.Pairs("x-goog-api-client", gax.XGoogHeader(kv...)) -} - -// ListGroups lists the existing groups. -func (c *GroupClient) ListGroups(ctx context.Context, req *monitoringpb.ListGroupsRequest, opts ...gax.CallOption) *GroupIterator { - md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))) - ctx = insertMetadata(ctx, c.xGoogMetadata, md) - opts = append(c.CallOptions.ListGroups[0:len(c.CallOptions.ListGroups):len(c.CallOptions.ListGroups)], opts...) - it := &GroupIterator{} - req = proto.Clone(req).(*monitoringpb.ListGroupsRequest) - it.InternalFetch = func(pageSize int, pageToken string) ([]*monitoringpb.Group, string, error) { - var resp *monitoringpb.ListGroupsResponse - req.PageToken = pageToken - if pageSize > math.MaxInt32 { - req.PageSize = math.MaxInt32 - } else { - req.PageSize = int32(pageSize) - } - err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { - var err error - resp, err = c.groupClient.ListGroups(ctx, req, settings.GRPC...) - return err - }, opts...) - if err != nil { - return nil, "", err - } - return resp.Group, resp.NextPageToken, nil - } - fetch := func(pageSize int, pageToken string) (string, error) { - items, nextPageToken, err := it.InternalFetch(pageSize, pageToken) - if err != nil { - return "", err - } - it.items = append(it.items, items...) - return nextPageToken, nil - } - it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf) - it.pageInfo.MaxSize = int(req.PageSize) - it.pageInfo.Token = req.PageToken - return it -} - -// GetGroup gets a single group. -func (c *GroupClient) GetGroup(ctx context.Context, req *monitoringpb.GetGroupRequest, opts ...gax.CallOption) (*monitoringpb.Group, error) { - md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))) - ctx = insertMetadata(ctx, c.xGoogMetadata, md) - opts = append(c.CallOptions.GetGroup[0:len(c.CallOptions.GetGroup):len(c.CallOptions.GetGroup)], opts...) - var resp *monitoringpb.Group - err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { - var err error - resp, err = c.groupClient.GetGroup(ctx, req, settings.GRPC...) - return err - }, opts...) - if err != nil { - return nil, err - } - return resp, nil -} - -// CreateGroup creates a new group. -func (c *GroupClient) CreateGroup(ctx context.Context, req *monitoringpb.CreateGroupRequest, opts ...gax.CallOption) (*monitoringpb.Group, error) { - md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))) - ctx = insertMetadata(ctx, c.xGoogMetadata, md) - opts = append(c.CallOptions.CreateGroup[0:len(c.CallOptions.CreateGroup):len(c.CallOptions.CreateGroup)], opts...) - var resp *monitoringpb.Group - err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { - var err error - resp, err = c.groupClient.CreateGroup(ctx, req, settings.GRPC...) - return err - }, opts...) - if err != nil { - return nil, err - } - return resp, nil -} - -// UpdateGroup updates an existing group. -// You can change any group attributes except name. -func (c *GroupClient) UpdateGroup(ctx context.Context, req *monitoringpb.UpdateGroupRequest, opts ...gax.CallOption) (*monitoringpb.Group, error) { - md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "group.name", url.QueryEscape(req.GetGroup().GetName()))) - ctx = insertMetadata(ctx, c.xGoogMetadata, md) - opts = append(c.CallOptions.UpdateGroup[0:len(c.CallOptions.UpdateGroup):len(c.CallOptions.UpdateGroup)], opts...) - var resp *monitoringpb.Group - err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { - var err error - resp, err = c.groupClient.UpdateGroup(ctx, req, settings.GRPC...) - return err - }, opts...) - if err != nil { - return nil, err - } - return resp, nil -} - -// DeleteGroup deletes an existing group. -func (c *GroupClient) DeleteGroup(ctx context.Context, req *monitoringpb.DeleteGroupRequest, opts ...gax.CallOption) error { - md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))) - ctx = insertMetadata(ctx, c.xGoogMetadata, md) - opts = append(c.CallOptions.DeleteGroup[0:len(c.CallOptions.DeleteGroup):len(c.CallOptions.DeleteGroup)], opts...) - err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { - var err error - _, err = c.groupClient.DeleteGroup(ctx, req, settings.GRPC...) - return err - }, opts...) - return err -} - -// ListGroupMembers lists the monitored resources that are members of a group. -func (c *GroupClient) ListGroupMembers(ctx context.Context, req *monitoringpb.ListGroupMembersRequest, opts ...gax.CallOption) *MonitoredResourceIterator { - md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))) - ctx = insertMetadata(ctx, c.xGoogMetadata, md) - opts = append(c.CallOptions.ListGroupMembers[0:len(c.CallOptions.ListGroupMembers):len(c.CallOptions.ListGroupMembers)], opts...) - it := &MonitoredResourceIterator{} - req = proto.Clone(req).(*monitoringpb.ListGroupMembersRequest) - it.InternalFetch = func(pageSize int, pageToken string) ([]*monitoredrespb.MonitoredResource, string, error) { - var resp *monitoringpb.ListGroupMembersResponse - req.PageToken = pageToken - if pageSize > math.MaxInt32 { - req.PageSize = math.MaxInt32 - } else { - req.PageSize = int32(pageSize) - } - err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { - var err error - resp, err = c.groupClient.ListGroupMembers(ctx, req, settings.GRPC...) - return err - }, opts...) - if err != nil { - return nil, "", err - } - return resp.Members, resp.NextPageToken, nil - } - fetch := func(pageSize int, pageToken string) (string, error) { - items, nextPageToken, err := it.InternalFetch(pageSize, pageToken) - if err != nil { - return "", err - } - it.items = append(it.items, items...) - return nextPageToken, nil - } - it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf) - it.pageInfo.MaxSize = int(req.PageSize) - it.pageInfo.Token = req.PageToken - return it -} - -// GroupIterator manages a stream of *monitoringpb.Group. -type GroupIterator struct { - items []*monitoringpb.Group - pageInfo *iterator.PageInfo - nextFunc func() error - - // InternalFetch is for use by the Google Cloud Libraries only. - // It is not part of the stable interface of this package. - // - // InternalFetch returns results from a single call to the underlying RPC. - // The number of results is no greater than pageSize. - // If there are no more results, nextPageToken is empty and err is nil. - InternalFetch func(pageSize int, pageToken string) (results []*monitoringpb.Group, nextPageToken string, err error) -} - -// PageInfo supports pagination. See the google.golang.org/api/iterator package for details. -func (it *GroupIterator) PageInfo() *iterator.PageInfo { - return it.pageInfo -} - -// Next returns the next result. Its second return value is iterator.Done if there are no more -// results. Once Next returns Done, all subsequent calls will return Done. -func (it *GroupIterator) Next() (*monitoringpb.Group, error) { - var item *monitoringpb.Group - if err := it.nextFunc(); err != nil { - return item, err - } - item = it.items[0] - it.items = it.items[1:] - return item, nil -} - -func (it *GroupIterator) bufLen() int { - return len(it.items) -} - -func (it *GroupIterator) takeBuf() interface{} { - b := it.items - it.items = nil - return b -} - -// MonitoredResourceIterator manages a stream of *monitoredrespb.MonitoredResource. -type MonitoredResourceIterator struct { - items []*monitoredrespb.MonitoredResource - pageInfo *iterator.PageInfo - nextFunc func() error - - // InternalFetch is for use by the Google Cloud Libraries only. - // It is not part of the stable interface of this package. - // - // InternalFetch returns results from a single call to the underlying RPC. - // The number of results is no greater than pageSize. - // If there are no more results, nextPageToken is empty and err is nil. - InternalFetch func(pageSize int, pageToken string) (results []*monitoredrespb.MonitoredResource, nextPageToken string, err error) -} - -// PageInfo supports pagination. See the google.golang.org/api/iterator package for details. -func (it *MonitoredResourceIterator) PageInfo() *iterator.PageInfo { - return it.pageInfo -} - -// Next returns the next result. Its second return value is iterator.Done if there are no more -// results. Once Next returns Done, all subsequent calls will return Done. -func (it *MonitoredResourceIterator) Next() (*monitoredrespb.MonitoredResource, error) { - var item *monitoredrespb.MonitoredResource - if err := it.nextFunc(); err != nil { - return item, err - } - item = it.items[0] - it.items = it.items[1:] - return item, nil -} - -func (it *MonitoredResourceIterator) bufLen() int { - return len(it.items) -} - -func (it *MonitoredResourceIterator) takeBuf() interface{} { - b := it.items - it.items = nil - return b -} diff --git a/vendor/cloud.google.com/go/monitoring/apiv3/metric_client.go b/vendor/cloud.google.com/go/monitoring/apiv3/metric_client.go deleted file mode 100644 index 03856223b7..0000000000 --- a/vendor/cloud.google.com/go/monitoring/apiv3/metric_client.go +++ /dev/null @@ -1,467 +0,0 @@ -// Copyright 2019 Google LLC -// -// 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 -// -// https://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. - -// Code generated by gapic-generator. DO NOT EDIT. - -package monitoring - -import ( - "context" - "fmt" - "math" - "net/url" - "time" - - "github.com/golang/protobuf/proto" - gax "github.com/googleapis/gax-go/v2" - "google.golang.org/api/iterator" - "google.golang.org/api/option" - "google.golang.org/api/transport" - metricpb "google.golang.org/genproto/googleapis/api/metric" - monitoredrespb "google.golang.org/genproto/googleapis/api/monitoredres" - monitoringpb "google.golang.org/genproto/googleapis/monitoring/v3" - "google.golang.org/grpc" - "google.golang.org/grpc/codes" - "google.golang.org/grpc/metadata" -) - -// MetricCallOptions contains the retry settings for each method of MetricClient. -type MetricCallOptions struct { - ListMonitoredResourceDescriptors []gax.CallOption - GetMonitoredResourceDescriptor []gax.CallOption - ListMetricDescriptors []gax.CallOption - GetMetricDescriptor []gax.CallOption - CreateMetricDescriptor []gax.CallOption - DeleteMetricDescriptor []gax.CallOption - ListTimeSeries []gax.CallOption - CreateTimeSeries []gax.CallOption -} - -func defaultMetricClientOptions() []option.ClientOption { - return []option.ClientOption{ - option.WithEndpoint("monitoring.googleapis.com:443"), - option.WithScopes(DefaultAuthScopes()...), - option.WithGRPCDialOption(grpc.WithDefaultCallOptions( - grpc.MaxCallRecvMsgSize(math.MaxInt32))), - } -} - -func defaultMetricCallOptions() *MetricCallOptions { - retry := map[[2]string][]gax.CallOption{ - {"default", "idempotent"}: { - gax.WithRetry(func() gax.Retryer { - return gax.OnCodes([]codes.Code{ - codes.DeadlineExceeded, - codes.Unavailable, - }, gax.Backoff{ - Initial: 100 * time.Millisecond, - Max: 60000 * time.Millisecond, - Multiplier: 1.3, - }) - }), - }, - } - return &MetricCallOptions{ - ListMonitoredResourceDescriptors: retry[[2]string{"default", "idempotent"}], - GetMonitoredResourceDescriptor: retry[[2]string{"default", "idempotent"}], - ListMetricDescriptors: retry[[2]string{"default", "idempotent"}], - GetMetricDescriptor: retry[[2]string{"default", "idempotent"}], - CreateMetricDescriptor: retry[[2]string{"default", "non_idempotent"}], - DeleteMetricDescriptor: retry[[2]string{"default", "idempotent"}], - ListTimeSeries: retry[[2]string{"default", "idempotent"}], - CreateTimeSeries: retry[[2]string{"default", "non_idempotent"}], - } -} - -// MetricClient is a client for interacting with Stackdriver Monitoring API. -// -// Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls. -type MetricClient struct { - // The connection to the service. - conn *grpc.ClientConn - - // The gRPC API client. - metricClient monitoringpb.MetricServiceClient - - // The call options for this service. - CallOptions *MetricCallOptions - - // The x-goog-* metadata to be sent with each request. - xGoogMetadata metadata.MD -} - -// NewMetricClient creates a new metric service client. -// -// Manages metric descriptors, monitored resource descriptors, and -// time series data. -func NewMetricClient(ctx context.Context, opts ...option.ClientOption) (*MetricClient, error) { - conn, err := transport.DialGRPC(ctx, append(defaultMetricClientOptions(), opts...)...) - if err != nil { - return nil, err - } - c := &MetricClient{ - conn: conn, - CallOptions: defaultMetricCallOptions(), - - metricClient: monitoringpb.NewMetricServiceClient(conn), - } - c.setGoogleClientInfo() - return c, nil -} - -// Connection returns the client's connection to the API service. -func (c *MetricClient) Connection() *grpc.ClientConn { - return c.conn -} - -// Close closes the connection to the API service. The user should invoke this when -// the client is no longer required. -func (c *MetricClient) Close() error { - return c.conn.Close() -} - -// setGoogleClientInfo sets the name and version of the application in -// the `x-goog-api-client` header passed on each request. Intended for -// use by Google-written clients. -func (c *MetricClient) setGoogleClientInfo(keyval ...string) { - kv := append([]string{"gl-go", versionGo()}, keyval...) - kv = append(kv, "gapic", versionClient, "gax", gax.Version, "grpc", grpc.Version) - c.xGoogMetadata = metadata.Pairs("x-goog-api-client", gax.XGoogHeader(kv...)) -} - -// ListMonitoredResourceDescriptors lists monitored resource descriptors that match a filter. This method does not require a Stackdriver account. -func (c *MetricClient) ListMonitoredResourceDescriptors(ctx context.Context, req *monitoringpb.ListMonitoredResourceDescriptorsRequest, opts ...gax.CallOption) *MonitoredResourceDescriptorIterator { - md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))) - ctx = insertMetadata(ctx, c.xGoogMetadata, md) - opts = append(c.CallOptions.ListMonitoredResourceDescriptors[0:len(c.CallOptions.ListMonitoredResourceDescriptors):len(c.CallOptions.ListMonitoredResourceDescriptors)], opts...) - it := &MonitoredResourceDescriptorIterator{} - req = proto.Clone(req).(*monitoringpb.ListMonitoredResourceDescriptorsRequest) - it.InternalFetch = func(pageSize int, pageToken string) ([]*monitoredrespb.MonitoredResourceDescriptor, string, error) { - var resp *monitoringpb.ListMonitoredResourceDescriptorsResponse - req.PageToken = pageToken - if pageSize > math.MaxInt32 { - req.PageSize = math.MaxInt32 - } else { - req.PageSize = int32(pageSize) - } - err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { - var err error - resp, err = c.metricClient.ListMonitoredResourceDescriptors(ctx, req, settings.GRPC...) - return err - }, opts...) - if err != nil { - return nil, "", err - } - return resp.ResourceDescriptors, resp.NextPageToken, nil - } - fetch := func(pageSize int, pageToken string) (string, error) { - items, nextPageToken, err := it.InternalFetch(pageSize, pageToken) - if err != nil { - return "", err - } - it.items = append(it.items, items...) - return nextPageToken, nil - } - it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf) - it.pageInfo.MaxSize = int(req.PageSize) - it.pageInfo.Token = req.PageToken - return it -} - -// GetMonitoredResourceDescriptor gets a single monitored resource descriptor. This method does not require a Stackdriver account. -func (c *MetricClient) GetMonitoredResourceDescriptor(ctx context.Context, req *monitoringpb.GetMonitoredResourceDescriptorRequest, opts ...gax.CallOption) (*monitoredrespb.MonitoredResourceDescriptor, error) { - md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))) - ctx = insertMetadata(ctx, c.xGoogMetadata, md) - opts = append(c.CallOptions.GetMonitoredResourceDescriptor[0:len(c.CallOptions.GetMonitoredResourceDescriptor):len(c.CallOptions.GetMonitoredResourceDescriptor)], opts...) - var resp *monitoredrespb.MonitoredResourceDescriptor - err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { - var err error - resp, err = c.metricClient.GetMonitoredResourceDescriptor(ctx, req, settings.GRPC...) - return err - }, opts...) - if err != nil { - return nil, err - } - return resp, nil -} - -// ListMetricDescriptors lists metric descriptors that match a filter. This method does not require a Stackdriver account. -func (c *MetricClient) ListMetricDescriptors(ctx context.Context, req *monitoringpb.ListMetricDescriptorsRequest, opts ...gax.CallOption) *MetricDescriptorIterator { - md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))) - ctx = insertMetadata(ctx, c.xGoogMetadata, md) - opts = append(c.CallOptions.ListMetricDescriptors[0:len(c.CallOptions.ListMetricDescriptors):len(c.CallOptions.ListMetricDescriptors)], opts...) - it := &MetricDescriptorIterator{} - req = proto.Clone(req).(*monitoringpb.ListMetricDescriptorsRequest) - it.InternalFetch = func(pageSize int, pageToken string) ([]*metricpb.MetricDescriptor, string, error) { - var resp *monitoringpb.ListMetricDescriptorsResponse - req.PageToken = pageToken - if pageSize > math.MaxInt32 { - req.PageSize = math.MaxInt32 - } else { - req.PageSize = int32(pageSize) - } - err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { - var err error - resp, err = c.metricClient.ListMetricDescriptors(ctx, req, settings.GRPC...) - return err - }, opts...) - if err != nil { - return nil, "", err - } - return resp.MetricDescriptors, resp.NextPageToken, nil - } - fetch := func(pageSize int, pageToken string) (string, error) { - items, nextPageToken, err := it.InternalFetch(pageSize, pageToken) - if err != nil { - return "", err - } - it.items = append(it.items, items...) - return nextPageToken, nil - } - it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf) - it.pageInfo.MaxSize = int(req.PageSize) - it.pageInfo.Token = req.PageToken - return it -} - -// GetMetricDescriptor gets a single metric descriptor. This method does not require a Stackdriver account. -func (c *MetricClient) GetMetricDescriptor(ctx context.Context, req *monitoringpb.GetMetricDescriptorRequest, opts ...gax.CallOption) (*metricpb.MetricDescriptor, error) { - md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))) - ctx = insertMetadata(ctx, c.xGoogMetadata, md) - opts = append(c.CallOptions.GetMetricDescriptor[0:len(c.CallOptions.GetMetricDescriptor):len(c.CallOptions.GetMetricDescriptor)], opts...) - var resp *metricpb.MetricDescriptor - err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { - var err error - resp, err = c.metricClient.GetMetricDescriptor(ctx, req, settings.GRPC...) - return err - }, opts...) - if err != nil { - return nil, err - } - return resp, nil -} - -// CreateMetricDescriptor creates a new metric descriptor. -// User-created metric descriptors define -// custom metrics (at /monitoring/custom-metrics). -func (c *MetricClient) CreateMetricDescriptor(ctx context.Context, req *monitoringpb.CreateMetricDescriptorRequest, opts ...gax.CallOption) (*metricpb.MetricDescriptor, error) { - md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))) - ctx = insertMetadata(ctx, c.xGoogMetadata, md) - opts = append(c.CallOptions.CreateMetricDescriptor[0:len(c.CallOptions.CreateMetricDescriptor):len(c.CallOptions.CreateMetricDescriptor)], opts...) - var resp *metricpb.MetricDescriptor - err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { - var err error - resp, err = c.metricClient.CreateMetricDescriptor(ctx, req, settings.GRPC...) - return err - }, opts...) - if err != nil { - return nil, err - } - return resp, nil -} - -// DeleteMetricDescriptor deletes a metric descriptor. Only user-created -// custom metrics (at /monitoring/custom-metrics) can be deleted. -func (c *MetricClient) DeleteMetricDescriptor(ctx context.Context, req *monitoringpb.DeleteMetricDescriptorRequest, opts ...gax.CallOption) error { - md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))) - ctx = insertMetadata(ctx, c.xGoogMetadata, md) - opts = append(c.CallOptions.DeleteMetricDescriptor[0:len(c.CallOptions.DeleteMetricDescriptor):len(c.CallOptions.DeleteMetricDescriptor)], opts...) - err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { - var err error - _, err = c.metricClient.DeleteMetricDescriptor(ctx, req, settings.GRPC...) - return err - }, opts...) - return err -} - -// ListTimeSeries lists time series that match a filter. This method does not require a Stackdriver account. -func (c *MetricClient) ListTimeSeries(ctx context.Context, req *monitoringpb.ListTimeSeriesRequest, opts ...gax.CallOption) *TimeSeriesIterator { - md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))) - ctx = insertMetadata(ctx, c.xGoogMetadata, md) - opts = append(c.CallOptions.ListTimeSeries[0:len(c.CallOptions.ListTimeSeries):len(c.CallOptions.ListTimeSeries)], opts...) - it := &TimeSeriesIterator{} - req = proto.Clone(req).(*monitoringpb.ListTimeSeriesRequest) - it.InternalFetch = func(pageSize int, pageToken string) ([]*monitoringpb.TimeSeries, string, error) { - var resp *monitoringpb.ListTimeSeriesResponse - req.PageToken = pageToken - if pageSize > math.MaxInt32 { - req.PageSize = math.MaxInt32 - } else { - req.PageSize = int32(pageSize) - } - err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { - var err error - resp, err = c.metricClient.ListTimeSeries(ctx, req, settings.GRPC...) - return err - }, opts...) - if err != nil { - return nil, "", err - } - return resp.TimeSeries, resp.NextPageToken, nil - } - fetch := func(pageSize int, pageToken string) (string, error) { - items, nextPageToken, err := it.InternalFetch(pageSize, pageToken) - if err != nil { - return "", err - } - it.items = append(it.items, items...) - return nextPageToken, nil - } - it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf) - it.pageInfo.MaxSize = int(req.PageSize) - it.pageInfo.Token = req.PageToken - return it -} - -// CreateTimeSeries creates or adds data to one or more time series. -// The response is empty if all time series in the request were written. -// If any time series could not be written, a corresponding failure message is -// included in the error response. -func (c *MetricClient) CreateTimeSeries(ctx context.Context, req *monitoringpb.CreateTimeSeriesRequest, opts ...gax.CallOption) error { - md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))) - ctx = insertMetadata(ctx, c.xGoogMetadata, md) - opts = append(c.CallOptions.CreateTimeSeries[0:len(c.CallOptions.CreateTimeSeries):len(c.CallOptions.CreateTimeSeries)], opts...) - err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { - var err error - _, err = c.metricClient.CreateTimeSeries(ctx, req, settings.GRPC...) - return err - }, opts...) - return err -} - -// MetricDescriptorIterator manages a stream of *metricpb.MetricDescriptor. -type MetricDescriptorIterator struct { - items []*metricpb.MetricDescriptor - pageInfo *iterator.PageInfo - nextFunc func() error - - // InternalFetch is for use by the Google Cloud Libraries only. - // It is not part of the stable interface of this package. - // - // InternalFetch returns results from a single call to the underlying RPC. - // The number of results is no greater than pageSize. - // If there are no more results, nextPageToken is empty and err is nil. - InternalFetch func(pageSize int, pageToken string) (results []*metricpb.MetricDescriptor, nextPageToken string, err error) -} - -// PageInfo supports pagination. See the google.golang.org/api/iterator package for details. -func (it *MetricDescriptorIterator) PageInfo() *iterator.PageInfo { - return it.pageInfo -} - -// Next returns the next result. Its second return value is iterator.Done if there are no more -// results. Once Next returns Done, all subsequent calls will return Done. -func (it *MetricDescriptorIterator) Next() (*metricpb.MetricDescriptor, error) { - var item *metricpb.MetricDescriptor - if err := it.nextFunc(); err != nil { - return item, err - } - item = it.items[0] - it.items = it.items[1:] - return item, nil -} - -func (it *MetricDescriptorIterator) bufLen() int { - return len(it.items) -} - -func (it *MetricDescriptorIterator) takeBuf() interface{} { - b := it.items - it.items = nil - return b -} - -// MonitoredResourceDescriptorIterator manages a stream of *monitoredrespb.MonitoredResourceDescriptor. -type MonitoredResourceDescriptorIterator struct { - items []*monitoredrespb.MonitoredResourceDescriptor - pageInfo *iterator.PageInfo - nextFunc func() error - - // InternalFetch is for use by the Google Cloud Libraries only. - // It is not part of the stable interface of this package. - // - // InternalFetch returns results from a single call to the underlying RPC. - // The number of results is no greater than pageSize. - // If there are no more results, nextPageToken is empty and err is nil. - InternalFetch func(pageSize int, pageToken string) (results []*monitoredrespb.MonitoredResourceDescriptor, nextPageToken string, err error) -} - -// PageInfo supports pagination. See the google.golang.org/api/iterator package for details. -func (it *MonitoredResourceDescriptorIterator) PageInfo() *iterator.PageInfo { - return it.pageInfo -} - -// Next returns the next result. Its second return value is iterator.Done if there are no more -// results. Once Next returns Done, all subsequent calls will return Done. -func (it *MonitoredResourceDescriptorIterator) Next() (*monitoredrespb.MonitoredResourceDescriptor, error) { - var item *monitoredrespb.MonitoredResourceDescriptor - if err := it.nextFunc(); err != nil { - return item, err - } - item = it.items[0] - it.items = it.items[1:] - return item, nil -} - -func (it *MonitoredResourceDescriptorIterator) bufLen() int { - return len(it.items) -} - -func (it *MonitoredResourceDescriptorIterator) takeBuf() interface{} { - b := it.items - it.items = nil - return b -} - -// TimeSeriesIterator manages a stream of *monitoringpb.TimeSeries. -type TimeSeriesIterator struct { - items []*monitoringpb.TimeSeries - pageInfo *iterator.PageInfo - nextFunc func() error - - // InternalFetch is for use by the Google Cloud Libraries only. - // It is not part of the stable interface of this package. - // - // InternalFetch returns results from a single call to the underlying RPC. - // The number of results is no greater than pageSize. - // If there are no more results, nextPageToken is empty and err is nil. - InternalFetch func(pageSize int, pageToken string) (results []*monitoringpb.TimeSeries, nextPageToken string, err error) -} - -// PageInfo supports pagination. See the google.golang.org/api/iterator package for details. -func (it *TimeSeriesIterator) PageInfo() *iterator.PageInfo { - return it.pageInfo -} - -// Next returns the next result. Its second return value is iterator.Done if there are no more -// results. Once Next returns Done, all subsequent calls will return Done. -func (it *TimeSeriesIterator) Next() (*monitoringpb.TimeSeries, error) { - var item *monitoringpb.TimeSeries - if err := it.nextFunc(); err != nil { - return item, err - } - item = it.items[0] - it.items = it.items[1:] - return item, nil -} - -func (it *TimeSeriesIterator) bufLen() int { - return len(it.items) -} - -func (it *TimeSeriesIterator) takeBuf() interface{} { - b := it.items - it.items = nil - return b -} diff --git a/vendor/cloud.google.com/go/monitoring/apiv3/notification_channel_client.go b/vendor/cloud.google.com/go/monitoring/apiv3/notification_channel_client.go deleted file mode 100644 index f97444af2c..0000000000 --- a/vendor/cloud.google.com/go/monitoring/apiv3/notification_channel_client.go +++ /dev/null @@ -1,464 +0,0 @@ -// Copyright 2019 Google LLC -// -// 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 -// -// https://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. - -// Code generated by gapic-generator. DO NOT EDIT. - -package monitoring - -import ( - "context" - "fmt" - "math" - "net/url" - "time" - - "github.com/golang/protobuf/proto" - gax "github.com/googleapis/gax-go/v2" - "google.golang.org/api/iterator" - "google.golang.org/api/option" - "google.golang.org/api/transport" - monitoringpb "google.golang.org/genproto/googleapis/monitoring/v3" - "google.golang.org/grpc" - "google.golang.org/grpc/codes" - "google.golang.org/grpc/metadata" -) - -// NotificationChannelCallOptions contains the retry settings for each method of NotificationChannelClient. -type NotificationChannelCallOptions struct { - ListNotificationChannelDescriptors []gax.CallOption - GetNotificationChannelDescriptor []gax.CallOption - ListNotificationChannels []gax.CallOption - GetNotificationChannel []gax.CallOption - CreateNotificationChannel []gax.CallOption - UpdateNotificationChannel []gax.CallOption - DeleteNotificationChannel []gax.CallOption - SendNotificationChannelVerificationCode []gax.CallOption - GetNotificationChannelVerificationCode []gax.CallOption - VerifyNotificationChannel []gax.CallOption -} - -func defaultNotificationChannelClientOptions() []option.ClientOption { - return []option.ClientOption{ - option.WithEndpoint("monitoring.googleapis.com:443"), - option.WithScopes(DefaultAuthScopes()...), - option.WithGRPCDialOption(grpc.WithDefaultCallOptions( - grpc.MaxCallRecvMsgSize(math.MaxInt32))), - } -} - -func defaultNotificationChannelCallOptions() *NotificationChannelCallOptions { - retry := map[[2]string][]gax.CallOption{ - {"default", "idempotent"}: { - gax.WithRetry(func() gax.Retryer { - return gax.OnCodes([]codes.Code{ - codes.DeadlineExceeded, - codes.Unavailable, - }, gax.Backoff{ - Initial: 100 * time.Millisecond, - Max: 60000 * time.Millisecond, - Multiplier: 1.3, - }) - }), - }, - } - return &NotificationChannelCallOptions{ - ListNotificationChannelDescriptors: retry[[2]string{"default", "idempotent"}], - GetNotificationChannelDescriptor: retry[[2]string{"default", "idempotent"}], - ListNotificationChannels: retry[[2]string{"default", "idempotent"}], - GetNotificationChannel: retry[[2]string{"default", "idempotent"}], - CreateNotificationChannel: retry[[2]string{"default", "non_idempotent"}], - UpdateNotificationChannel: retry[[2]string{"default", "non_idempotent"}], - DeleteNotificationChannel: retry[[2]string{"default", "idempotent"}], - SendNotificationChannelVerificationCode: retry[[2]string{"default", "non_idempotent"}], - GetNotificationChannelVerificationCode: retry[[2]string{"default", "idempotent"}], - VerifyNotificationChannel: retry[[2]string{"default", "idempotent"}], - } -} - -// NotificationChannelClient is a client for interacting with Stackdriver Monitoring API. -// -// Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls. -type NotificationChannelClient struct { - // The connection to the service. - conn *grpc.ClientConn - - // The gRPC API client. - notificationChannelClient monitoringpb.NotificationChannelServiceClient - - // The call options for this service. - CallOptions *NotificationChannelCallOptions - - // The x-goog-* metadata to be sent with each request. - xGoogMetadata metadata.MD -} - -// NewNotificationChannelClient creates a new notification channel service client. -// -// The Notification Channel API provides access to configuration that -// controls how messages related to incidents are sent. -func NewNotificationChannelClient(ctx context.Context, opts ...option.ClientOption) (*NotificationChannelClient, error) { - conn, err := transport.DialGRPC(ctx, append(defaultNotificationChannelClientOptions(), opts...)...) - if err != nil { - return nil, err - } - c := &NotificationChannelClient{ - conn: conn, - CallOptions: defaultNotificationChannelCallOptions(), - - notificationChannelClient: monitoringpb.NewNotificationChannelServiceClient(conn), - } - c.setGoogleClientInfo() - return c, nil -} - -// Connection returns the client's connection to the API service. -func (c *NotificationChannelClient) Connection() *grpc.ClientConn { - return c.conn -} - -// Close closes the connection to the API service. The user should invoke this when -// the client is no longer required. -func (c *NotificationChannelClient) Close() error { - return c.conn.Close() -} - -// setGoogleClientInfo sets the name and version of the application in -// the `x-goog-api-client` header passed on each request. Intended for -// use by Google-written clients. -func (c *NotificationChannelClient) setGoogleClientInfo(keyval ...string) { - kv := append([]string{"gl-go", versionGo()}, keyval...) - kv = append(kv, "gapic", versionClient, "gax", gax.Version, "grpc", grpc.Version) - c.xGoogMetadata = metadata.Pairs("x-goog-api-client", gax.XGoogHeader(kv...)) -} - -// ListNotificationChannelDescriptors lists the descriptors for supported channel types. The use of descriptors -// makes it possible for new channel types to be dynamically added. -func (c *NotificationChannelClient) ListNotificationChannelDescriptors(ctx context.Context, req *monitoringpb.ListNotificationChannelDescriptorsRequest, opts ...gax.CallOption) *NotificationChannelDescriptorIterator { - md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))) - ctx = insertMetadata(ctx, c.xGoogMetadata, md) - opts = append(c.CallOptions.ListNotificationChannelDescriptors[0:len(c.CallOptions.ListNotificationChannelDescriptors):len(c.CallOptions.ListNotificationChannelDescriptors)], opts...) - it := &NotificationChannelDescriptorIterator{} - req = proto.Clone(req).(*monitoringpb.ListNotificationChannelDescriptorsRequest) - it.InternalFetch = func(pageSize int, pageToken string) ([]*monitoringpb.NotificationChannelDescriptor, string, error) { - var resp *monitoringpb.ListNotificationChannelDescriptorsResponse - req.PageToken = pageToken - if pageSize > math.MaxInt32 { - req.PageSize = math.MaxInt32 - } else { - req.PageSize = int32(pageSize) - } - err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { - var err error - resp, err = c.notificationChannelClient.ListNotificationChannelDescriptors(ctx, req, settings.GRPC...) - return err - }, opts...) - if err != nil { - return nil, "", err - } - return resp.ChannelDescriptors, resp.NextPageToken, nil - } - fetch := func(pageSize int, pageToken string) (string, error) { - items, nextPageToken, err := it.InternalFetch(pageSize, pageToken) - if err != nil { - return "", err - } - it.items = append(it.items, items...) - return nextPageToken, nil - } - it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf) - it.pageInfo.MaxSize = int(req.PageSize) - it.pageInfo.Token = req.PageToken - return it -} - -// GetNotificationChannelDescriptor gets a single channel descriptor. The descriptor indicates which fields -// are expected / permitted for a notification channel of the given type. -func (c *NotificationChannelClient) GetNotificationChannelDescriptor(ctx context.Context, req *monitoringpb.GetNotificationChannelDescriptorRequest, opts ...gax.CallOption) (*monitoringpb.NotificationChannelDescriptor, error) { - md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))) - ctx = insertMetadata(ctx, c.xGoogMetadata, md) - opts = append(c.CallOptions.GetNotificationChannelDescriptor[0:len(c.CallOptions.GetNotificationChannelDescriptor):len(c.CallOptions.GetNotificationChannelDescriptor)], opts...) - var resp *monitoringpb.NotificationChannelDescriptor - err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { - var err error - resp, err = c.notificationChannelClient.GetNotificationChannelDescriptor(ctx, req, settings.GRPC...) - return err - }, opts...) - if err != nil { - return nil, err - } - return resp, nil -} - -// ListNotificationChannels lists the notification channels that have been created for the project. -func (c *NotificationChannelClient) ListNotificationChannels(ctx context.Context, req *monitoringpb.ListNotificationChannelsRequest, opts ...gax.CallOption) *NotificationChannelIterator { - md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))) - ctx = insertMetadata(ctx, c.xGoogMetadata, md) - opts = append(c.CallOptions.ListNotificationChannels[0:len(c.CallOptions.ListNotificationChannels):len(c.CallOptions.ListNotificationChannels)], opts...) - it := &NotificationChannelIterator{} - req = proto.Clone(req).(*monitoringpb.ListNotificationChannelsRequest) - it.InternalFetch = func(pageSize int, pageToken string) ([]*monitoringpb.NotificationChannel, string, error) { - var resp *monitoringpb.ListNotificationChannelsResponse - req.PageToken = pageToken - if pageSize > math.MaxInt32 { - req.PageSize = math.MaxInt32 - } else { - req.PageSize = int32(pageSize) - } - err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { - var err error - resp, err = c.notificationChannelClient.ListNotificationChannels(ctx, req, settings.GRPC...) - return err - }, opts...) - if err != nil { - return nil, "", err - } - return resp.NotificationChannels, resp.NextPageToken, nil - } - fetch := func(pageSize int, pageToken string) (string, error) { - items, nextPageToken, err := it.InternalFetch(pageSize, pageToken) - if err != nil { - return "", err - } - it.items = append(it.items, items...) - return nextPageToken, nil - } - it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf) - it.pageInfo.MaxSize = int(req.PageSize) - it.pageInfo.Token = req.PageToken - return it -} - -// GetNotificationChannel gets a single notification channel. The channel includes the relevant -// configuration details with which the channel was created. However, the -// response may truncate or omit passwords, API keys, or other private key -// matter and thus the response may not be 100% identical to the information -// that was supplied in the call to the create method. -func (c *NotificationChannelClient) GetNotificationChannel(ctx context.Context, req *monitoringpb.GetNotificationChannelRequest, opts ...gax.CallOption) (*monitoringpb.NotificationChannel, error) { - md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))) - ctx = insertMetadata(ctx, c.xGoogMetadata, md) - opts = append(c.CallOptions.GetNotificationChannel[0:len(c.CallOptions.GetNotificationChannel):len(c.CallOptions.GetNotificationChannel)], opts...) - var resp *monitoringpb.NotificationChannel - err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { - var err error - resp, err = c.notificationChannelClient.GetNotificationChannel(ctx, req, settings.GRPC...) - return err - }, opts...) - if err != nil { - return nil, err - } - return resp, nil -} - -// CreateNotificationChannel creates a new notification channel, representing a single notification -// endpoint such as an email address, SMS number, or PagerDuty service. -func (c *NotificationChannelClient) CreateNotificationChannel(ctx context.Context, req *monitoringpb.CreateNotificationChannelRequest, opts ...gax.CallOption) (*monitoringpb.NotificationChannel, error) { - md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))) - ctx = insertMetadata(ctx, c.xGoogMetadata, md) - opts = append(c.CallOptions.CreateNotificationChannel[0:len(c.CallOptions.CreateNotificationChannel):len(c.CallOptions.CreateNotificationChannel)], opts...) - var resp *monitoringpb.NotificationChannel - err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { - var err error - resp, err = c.notificationChannelClient.CreateNotificationChannel(ctx, req, settings.GRPC...) - return err - }, opts...) - if err != nil { - return nil, err - } - return resp, nil -} - -// UpdateNotificationChannel updates a notification channel. Fields not specified in the field mask -// remain unchanged. -func (c *NotificationChannelClient) UpdateNotificationChannel(ctx context.Context, req *monitoringpb.UpdateNotificationChannelRequest, opts ...gax.CallOption) (*monitoringpb.NotificationChannel, error) { - md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "notification_channel.name", url.QueryEscape(req.GetNotificationChannel().GetName()))) - ctx = insertMetadata(ctx, c.xGoogMetadata, md) - opts = append(c.CallOptions.UpdateNotificationChannel[0:len(c.CallOptions.UpdateNotificationChannel):len(c.CallOptions.UpdateNotificationChannel)], opts...) - var resp *monitoringpb.NotificationChannel - err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { - var err error - resp, err = c.notificationChannelClient.UpdateNotificationChannel(ctx, req, settings.GRPC...) - return err - }, opts...) - if err != nil { - return nil, err - } - return resp, nil -} - -// DeleteNotificationChannel deletes a notification channel. -func (c *NotificationChannelClient) DeleteNotificationChannel(ctx context.Context, req *monitoringpb.DeleteNotificationChannelRequest, opts ...gax.CallOption) error { - md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))) - ctx = insertMetadata(ctx, c.xGoogMetadata, md) - opts = append(c.CallOptions.DeleteNotificationChannel[0:len(c.CallOptions.DeleteNotificationChannel):len(c.CallOptions.DeleteNotificationChannel)], opts...) - err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { - var err error - _, err = c.notificationChannelClient.DeleteNotificationChannel(ctx, req, settings.GRPC...) - return err - }, opts...) - return err -} - -// SendNotificationChannelVerificationCode causes a verification code to be delivered to the channel. The code -// can then be supplied in VerifyNotificationChannel to verify the channel. -func (c *NotificationChannelClient) SendNotificationChannelVerificationCode(ctx context.Context, req *monitoringpb.SendNotificationChannelVerificationCodeRequest, opts ...gax.CallOption) error { - md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))) - ctx = insertMetadata(ctx, c.xGoogMetadata, md) - opts = append(c.CallOptions.SendNotificationChannelVerificationCode[0:len(c.CallOptions.SendNotificationChannelVerificationCode):len(c.CallOptions.SendNotificationChannelVerificationCode)], opts...) - err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { - var err error - _, err = c.notificationChannelClient.SendNotificationChannelVerificationCode(ctx, req, settings.GRPC...) - return err - }, opts...) - return err -} - -// GetNotificationChannelVerificationCode requests a verification code for an already verified channel that can then -// be used in a call to VerifyNotificationChannel() on a different channel -// with an equivalent identity in the same or in a different project. This -// makes it possible to copy a channel between projects without requiring -// manual reverification of the channel. If the channel is not in the -// verified state, this method will fail (in other words, this may only be -// used if the SendNotificationChannelVerificationCode and -// VerifyNotificationChannel paths have already been used to put the given -// channel into the verified state). -// -// There is no guarantee that the verification codes returned by this method -// will be of a similar structure or form as the ones that are delivered -// to the channel via SendNotificationChannelVerificationCode; while -// VerifyNotificationChannel() will recognize both the codes delivered via -// SendNotificationChannelVerificationCode() and returned from -// GetNotificationChannelVerificationCode(), it is typically the case that -// the verification codes delivered via -// SendNotificationChannelVerificationCode() will be shorter and also -// have a shorter expiration (e.g. codes such as "G-123456") whereas -// GetVerificationCode() will typically return a much longer, websafe base -// 64 encoded string that has a longer expiration time. -func (c *NotificationChannelClient) GetNotificationChannelVerificationCode(ctx context.Context, req *monitoringpb.GetNotificationChannelVerificationCodeRequest, opts ...gax.CallOption) (*monitoringpb.GetNotificationChannelVerificationCodeResponse, error) { - md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))) - ctx = insertMetadata(ctx, c.xGoogMetadata, md) - opts = append(c.CallOptions.GetNotificationChannelVerificationCode[0:len(c.CallOptions.GetNotificationChannelVerificationCode):len(c.CallOptions.GetNotificationChannelVerificationCode)], opts...) - var resp *monitoringpb.GetNotificationChannelVerificationCodeResponse - err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { - var err error - resp, err = c.notificationChannelClient.GetNotificationChannelVerificationCode(ctx, req, settings.GRPC...) - return err - }, opts...) - if err != nil { - return nil, err - } - return resp, nil -} - -// VerifyNotificationChannel verifies a NotificationChannel by proving receipt of the code -// delivered to the channel as a result of calling -// SendNotificationChannelVerificationCode. -func (c *NotificationChannelClient) VerifyNotificationChannel(ctx context.Context, req *monitoringpb.VerifyNotificationChannelRequest, opts ...gax.CallOption) (*monitoringpb.NotificationChannel, error) { - md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))) - ctx = insertMetadata(ctx, c.xGoogMetadata, md) - opts = append(c.CallOptions.VerifyNotificationChannel[0:len(c.CallOptions.VerifyNotificationChannel):len(c.CallOptions.VerifyNotificationChannel)], opts...) - var resp *monitoringpb.NotificationChannel - err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { - var err error - resp, err = c.notificationChannelClient.VerifyNotificationChannel(ctx, req, settings.GRPC...) - return err - }, opts...) - if err != nil { - return nil, err - } - return resp, nil -} - -// NotificationChannelDescriptorIterator manages a stream of *monitoringpb.NotificationChannelDescriptor. -type NotificationChannelDescriptorIterator struct { - items []*monitoringpb.NotificationChannelDescriptor - pageInfo *iterator.PageInfo - nextFunc func() error - - // InternalFetch is for use by the Google Cloud Libraries only. - // It is not part of the stable interface of this package. - // - // InternalFetch returns results from a single call to the underlying RPC. - // The number of results is no greater than pageSize. - // If there are no more results, nextPageToken is empty and err is nil. - InternalFetch func(pageSize int, pageToken string) (results []*monitoringpb.NotificationChannelDescriptor, nextPageToken string, err error) -} - -// PageInfo supports pagination. See the google.golang.org/api/iterator package for details. -func (it *NotificationChannelDescriptorIterator) PageInfo() *iterator.PageInfo { - return it.pageInfo -} - -// Next returns the next result. Its second return value is iterator.Done if there are no more -// results. Once Next returns Done, all subsequent calls will return Done. -func (it *NotificationChannelDescriptorIterator) Next() (*monitoringpb.NotificationChannelDescriptor, error) { - var item *monitoringpb.NotificationChannelDescriptor - if err := it.nextFunc(); err != nil { - return item, err - } - item = it.items[0] - it.items = it.items[1:] - return item, nil -} - -func (it *NotificationChannelDescriptorIterator) bufLen() int { - return len(it.items) -} - -func (it *NotificationChannelDescriptorIterator) takeBuf() interface{} { - b := it.items - it.items = nil - return b -} - -// NotificationChannelIterator manages a stream of *monitoringpb.NotificationChannel. -type NotificationChannelIterator struct { - items []*monitoringpb.NotificationChannel - pageInfo *iterator.PageInfo - nextFunc func() error - - // InternalFetch is for use by the Google Cloud Libraries only. - // It is not part of the stable interface of this package. - // - // InternalFetch returns results from a single call to the underlying RPC. - // The number of results is no greater than pageSize. - // If there are no more results, nextPageToken is empty and err is nil. - InternalFetch func(pageSize int, pageToken string) (results []*monitoringpb.NotificationChannel, nextPageToken string, err error) -} - -// PageInfo supports pagination. See the google.golang.org/api/iterator package for details. -func (it *NotificationChannelIterator) PageInfo() *iterator.PageInfo { - return it.pageInfo -} - -// Next returns the next result. Its second return value is iterator.Done if there are no more -// results. Once Next returns Done, all subsequent calls will return Done. -func (it *NotificationChannelIterator) Next() (*monitoringpb.NotificationChannel, error) { - var item *monitoringpb.NotificationChannel - if err := it.nextFunc(); err != nil { - return item, err - } - item = it.items[0] - it.items = it.items[1:] - return item, nil -} - -func (it *NotificationChannelIterator) bufLen() int { - return len(it.items) -} - -func (it *NotificationChannelIterator) takeBuf() interface{} { - b := it.items - it.items = nil - return b -} diff --git a/vendor/cloud.google.com/go/monitoring/apiv3/path_funcs.go b/vendor/cloud.google.com/go/monitoring/apiv3/path_funcs.go deleted file mode 100644 index b2b514ba52..0000000000 --- a/vendor/cloud.google.com/go/monitoring/apiv3/path_funcs.go +++ /dev/null @@ -1,107 +0,0 @@ -// Copyright 2018 Google LLC -// -// 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 -// -// https://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 monitoring - -// GroupProjectPath returns the path for the project resource. -// -// Deprecated: Use -// fmt.Sprintf("projects/%s", project) -// instead. -func GroupProjectPath(project string) string { - return "" + - "projects/" + - project + - "" -} - -// GroupGroupPath returns the path for the group resource. -// -// Deprecated: Use -// fmt.Sprintf("projects/%s/groups/%s", project, group) -// instead. -func GroupGroupPath(project, group string) string { - return "" + - "projects/" + - project + - "/groups/" + - group + - "" -} - -// MetricProjectPath returns the path for the project resource. -// -// Deprecated: Use -// fmt.Sprintf("projects/%s", project) -// instead. -func MetricProjectPath(project string) string { - return "" + - "projects/" + - project + - "" -} - -// MetricMetricDescriptorPath returns the path for the metric descriptor resource. -// -// Deprecated: Use -// fmt.Sprintf("projects/%s/metricDescriptors/%s", project, metricDescriptor) -// instead. -func MetricMetricDescriptorPath(project, metricDescriptor string) string { - return "" + - "projects/" + - project + - "/metricDescriptors/" + - metricDescriptor + - "" -} - -// MetricMonitoredResourceDescriptorPath returns the path for the monitored resource descriptor resource. -// -// Deprecated: Use -// fmt.Sprintf("projects/%s/monitoredResourceDescriptors/%s", project, monitoredResourceDescriptor) -// instead. -func MetricMonitoredResourceDescriptorPath(project, monitoredResourceDescriptor string) string { - return "" + - "projects/" + - project + - "/monitoredResourceDescriptors/" + - monitoredResourceDescriptor + - "" -} - -// UptimeCheckProjectPath returns the path for the project resource. -// -// Deprecated: Use -// fmt.Sprintf("projects/%s", project) -// instead. -func UptimeCheckProjectPath(project string) string { - return "" + - "projects/" + - project + - "" -} - -// UptimeCheckUptimeCheckConfigPath returns the path for the uptime check config resource. -// -// Deprecated: Use -// fmt.Sprintf("projects/%s/uptimeCheckConfigs/%s", project, uptimeCheckConfig) -// instead. -func UptimeCheckUptimeCheckConfigPath(project, uptimeCheckConfig string) string { - return "" + - "projects/" + - project + - "/uptimeCheckConfigs/" + - uptimeCheckConfig + - "" -} diff --git a/vendor/cloud.google.com/go/monitoring/apiv3/service_monitoring_client.go b/vendor/cloud.google.com/go/monitoring/apiv3/service_monitoring_client.go deleted file mode 100644 index 9cb574b4fb..0000000000 --- a/vendor/cloud.google.com/go/monitoring/apiv3/service_monitoring_client.go +++ /dev/null @@ -1,435 +0,0 @@ -// Copyright 2019 Google LLC -// -// 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 -// -// https://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. - -// Code generated by gapic-generator. DO NOT EDIT. - -package monitoring - -import ( - "context" - "fmt" - "math" - "net/url" - "time" - - "github.com/golang/protobuf/proto" - gax "github.com/googleapis/gax-go/v2" - "google.golang.org/api/iterator" - "google.golang.org/api/option" - "google.golang.org/api/transport" - monitoringpb "google.golang.org/genproto/googleapis/monitoring/v3" - "google.golang.org/grpc" - "google.golang.org/grpc/codes" - "google.golang.org/grpc/metadata" -) - -// ServiceMonitoringCallOptions contains the retry settings for each method of ServiceMonitoringClient. -type ServiceMonitoringCallOptions struct { - CreateService []gax.CallOption - GetService []gax.CallOption - ListServices []gax.CallOption - UpdateService []gax.CallOption - DeleteService []gax.CallOption - CreateServiceLevelObjective []gax.CallOption - GetServiceLevelObjective []gax.CallOption - ListServiceLevelObjectives []gax.CallOption - UpdateServiceLevelObjective []gax.CallOption - DeleteServiceLevelObjective []gax.CallOption -} - -func defaultServiceMonitoringClientOptions() []option.ClientOption { - return []option.ClientOption{ - option.WithEndpoint("monitoring.googleapis.com:443"), - option.WithScopes(DefaultAuthScopes()...), - option.WithGRPCDialOption(grpc.WithDefaultCallOptions( - grpc.MaxCallRecvMsgSize(math.MaxInt32))), - } -} - -func defaultServiceMonitoringCallOptions() *ServiceMonitoringCallOptions { - retry := map[[2]string][]gax.CallOption{ - {"default", "idempotent"}: { - gax.WithRetry(func() gax.Retryer { - return gax.OnCodes([]codes.Code{ - codes.DeadlineExceeded, - codes.Unavailable, - }, gax.Backoff{ - Initial: 100 * time.Millisecond, - Max: 60000 * time.Millisecond, - Multiplier: 1.3, - }) - }), - }, - } - return &ServiceMonitoringCallOptions{ - CreateService: retry[[2]string{"default", "non_idempotent"}], - GetService: retry[[2]string{"default", "idempotent"}], - ListServices: retry[[2]string{"default", "idempotent"}], - UpdateService: retry[[2]string{"default", "non_idempotent"}], - DeleteService: retry[[2]string{"default", "idempotent"}], - CreateServiceLevelObjective: retry[[2]string{"default", "non_idempotent"}], - GetServiceLevelObjective: retry[[2]string{"default", "idempotent"}], - ListServiceLevelObjectives: retry[[2]string{"default", "idempotent"}], - UpdateServiceLevelObjective: retry[[2]string{"default", "non_idempotent"}], - DeleteServiceLevelObjective: retry[[2]string{"default", "idempotent"}], - } -} - -// ServiceMonitoringClient is a client for interacting with Stackdriver Monitoring API. -// -// Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls. -type ServiceMonitoringClient struct { - // The connection to the service. - conn *grpc.ClientConn - - // The gRPC API client. - serviceMonitoringClient monitoringpb.ServiceMonitoringServiceClient - - // The call options for this service. - CallOptions *ServiceMonitoringCallOptions - - // The x-goog-* metadata to be sent with each request. - xGoogMetadata metadata.MD -} - -// NewServiceMonitoringClient creates a new service monitoring service client. -// -// The Stackdriver Monitoring Service-Oriented Monitoring API has endpoints for -// managing and querying aspects of a workspace's services. These include the -// Service's monitored resources, its Service-Level Objectives, and a taxonomy -// of categorized Health Metrics. -func NewServiceMonitoringClient(ctx context.Context, opts ...option.ClientOption) (*ServiceMonitoringClient, error) { - conn, err := transport.DialGRPC(ctx, append(defaultServiceMonitoringClientOptions(), opts...)...) - if err != nil { - return nil, err - } - c := &ServiceMonitoringClient{ - conn: conn, - CallOptions: defaultServiceMonitoringCallOptions(), - - serviceMonitoringClient: monitoringpb.NewServiceMonitoringServiceClient(conn), - } - c.setGoogleClientInfo() - return c, nil -} - -// Connection returns the client's connection to the API service. -func (c *ServiceMonitoringClient) Connection() *grpc.ClientConn { - return c.conn -} - -// Close closes the connection to the API service. The user should invoke this when -// the client is no longer required. -func (c *ServiceMonitoringClient) Close() error { - return c.conn.Close() -} - -// setGoogleClientInfo sets the name and version of the application in -// the `x-goog-api-client` header passed on each request. Intended for -// use by Google-written clients. -func (c *ServiceMonitoringClient) setGoogleClientInfo(keyval ...string) { - kv := append([]string{"gl-go", versionGo()}, keyval...) - kv = append(kv, "gapic", versionClient, "gax", gax.Version, "grpc", grpc.Version) - c.xGoogMetadata = metadata.Pairs("x-goog-api-client", gax.XGoogHeader(kv...)) -} - -// CreateService create a Service. -func (c *ServiceMonitoringClient) CreateService(ctx context.Context, req *monitoringpb.CreateServiceRequest, opts ...gax.CallOption) (*monitoringpb.Service, error) { - md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))) - ctx = insertMetadata(ctx, c.xGoogMetadata, md) - opts = append(c.CallOptions.CreateService[0:len(c.CallOptions.CreateService):len(c.CallOptions.CreateService)], opts...) - var resp *monitoringpb.Service - err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { - var err error - resp, err = c.serviceMonitoringClient.CreateService(ctx, req, settings.GRPC...) - return err - }, opts...) - if err != nil { - return nil, err - } - return resp, nil -} - -// GetService get the named Service. -func (c *ServiceMonitoringClient) GetService(ctx context.Context, req *monitoringpb.GetServiceRequest, opts ...gax.CallOption) (*monitoringpb.Service, error) { - md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))) - ctx = insertMetadata(ctx, c.xGoogMetadata, md) - opts = append(c.CallOptions.GetService[0:len(c.CallOptions.GetService):len(c.CallOptions.GetService)], opts...) - var resp *monitoringpb.Service - err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { - var err error - resp, err = c.serviceMonitoringClient.GetService(ctx, req, settings.GRPC...) - return err - }, opts...) - if err != nil { - return nil, err - } - return resp, nil -} - -// ListServices list Services for this workspace. -func (c *ServiceMonitoringClient) ListServices(ctx context.Context, req *monitoringpb.ListServicesRequest, opts ...gax.CallOption) *ServiceIterator { - md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))) - ctx = insertMetadata(ctx, c.xGoogMetadata, md) - opts = append(c.CallOptions.ListServices[0:len(c.CallOptions.ListServices):len(c.CallOptions.ListServices)], opts...) - it := &ServiceIterator{} - req = proto.Clone(req).(*monitoringpb.ListServicesRequest) - it.InternalFetch = func(pageSize int, pageToken string) ([]*monitoringpb.Service, string, error) { - var resp *monitoringpb.ListServicesResponse - req.PageToken = pageToken - if pageSize > math.MaxInt32 { - req.PageSize = math.MaxInt32 - } else { - req.PageSize = int32(pageSize) - } - err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { - var err error - resp, err = c.serviceMonitoringClient.ListServices(ctx, req, settings.GRPC...) - return err - }, opts...) - if err != nil { - return nil, "", err - } - return resp.Services, resp.NextPageToken, nil - } - fetch := func(pageSize int, pageToken string) (string, error) { - items, nextPageToken, err := it.InternalFetch(pageSize, pageToken) - if err != nil { - return "", err - } - it.items = append(it.items, items...) - return nextPageToken, nil - } - it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf) - it.pageInfo.MaxSize = int(req.PageSize) - it.pageInfo.Token = req.PageToken - return it -} - -// UpdateService update this Service. -func (c *ServiceMonitoringClient) UpdateService(ctx context.Context, req *monitoringpb.UpdateServiceRequest, opts ...gax.CallOption) (*monitoringpb.Service, error) { - md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "service.name", url.QueryEscape(req.GetService().GetName()))) - ctx = insertMetadata(ctx, c.xGoogMetadata, md) - opts = append(c.CallOptions.UpdateService[0:len(c.CallOptions.UpdateService):len(c.CallOptions.UpdateService)], opts...) - var resp *monitoringpb.Service - err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { - var err error - resp, err = c.serviceMonitoringClient.UpdateService(ctx, req, settings.GRPC...) - return err - }, opts...) - if err != nil { - return nil, err - } - return resp, nil -} - -// DeleteService soft delete this Service. -func (c *ServiceMonitoringClient) DeleteService(ctx context.Context, req *monitoringpb.DeleteServiceRequest, opts ...gax.CallOption) error { - md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))) - ctx = insertMetadata(ctx, c.xGoogMetadata, md) - opts = append(c.CallOptions.DeleteService[0:len(c.CallOptions.DeleteService):len(c.CallOptions.DeleteService)], opts...) - err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { - var err error - _, err = c.serviceMonitoringClient.DeleteService(ctx, req, settings.GRPC...) - return err - }, opts...) - return err -} - -// CreateServiceLevelObjective create a ServiceLevelObjective for the given Service. -func (c *ServiceMonitoringClient) CreateServiceLevelObjective(ctx context.Context, req *monitoringpb.CreateServiceLevelObjectiveRequest, opts ...gax.CallOption) (*monitoringpb.ServiceLevelObjective, error) { - md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))) - ctx = insertMetadata(ctx, c.xGoogMetadata, md) - opts = append(c.CallOptions.CreateServiceLevelObjective[0:len(c.CallOptions.CreateServiceLevelObjective):len(c.CallOptions.CreateServiceLevelObjective)], opts...) - var resp *monitoringpb.ServiceLevelObjective - err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { - var err error - resp, err = c.serviceMonitoringClient.CreateServiceLevelObjective(ctx, req, settings.GRPC...) - return err - }, opts...) - if err != nil { - return nil, err - } - return resp, nil -} - -// GetServiceLevelObjective get a ServiceLevelObjective by name. -func (c *ServiceMonitoringClient) GetServiceLevelObjective(ctx context.Context, req *monitoringpb.GetServiceLevelObjectiveRequest, opts ...gax.CallOption) (*monitoringpb.ServiceLevelObjective, error) { - md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))) - ctx = insertMetadata(ctx, c.xGoogMetadata, md) - opts = append(c.CallOptions.GetServiceLevelObjective[0:len(c.CallOptions.GetServiceLevelObjective):len(c.CallOptions.GetServiceLevelObjective)], opts...) - var resp *monitoringpb.ServiceLevelObjective - err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { - var err error - resp, err = c.serviceMonitoringClient.GetServiceLevelObjective(ctx, req, settings.GRPC...) - return err - }, opts...) - if err != nil { - return nil, err - } - return resp, nil -} - -// ListServiceLevelObjectives list the ServiceLevelObjectives for the given Service. -func (c *ServiceMonitoringClient) ListServiceLevelObjectives(ctx context.Context, req *monitoringpb.ListServiceLevelObjectivesRequest, opts ...gax.CallOption) *ServiceLevelObjectiveIterator { - md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))) - ctx = insertMetadata(ctx, c.xGoogMetadata, md) - opts = append(c.CallOptions.ListServiceLevelObjectives[0:len(c.CallOptions.ListServiceLevelObjectives):len(c.CallOptions.ListServiceLevelObjectives)], opts...) - it := &ServiceLevelObjectiveIterator{} - req = proto.Clone(req).(*monitoringpb.ListServiceLevelObjectivesRequest) - it.InternalFetch = func(pageSize int, pageToken string) ([]*monitoringpb.ServiceLevelObjective, string, error) { - var resp *monitoringpb.ListServiceLevelObjectivesResponse - req.PageToken = pageToken - if pageSize > math.MaxInt32 { - req.PageSize = math.MaxInt32 - } else { - req.PageSize = int32(pageSize) - } - err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { - var err error - resp, err = c.serviceMonitoringClient.ListServiceLevelObjectives(ctx, req, settings.GRPC...) - return err - }, opts...) - if err != nil { - return nil, "", err - } - return resp.ServiceLevelObjectives, resp.NextPageToken, nil - } - fetch := func(pageSize int, pageToken string) (string, error) { - items, nextPageToken, err := it.InternalFetch(pageSize, pageToken) - if err != nil { - return "", err - } - it.items = append(it.items, items...) - return nextPageToken, nil - } - it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf) - it.pageInfo.MaxSize = int(req.PageSize) - it.pageInfo.Token = req.PageToken - return it -} - -// UpdateServiceLevelObjective update the given ServiceLevelObjective. -func (c *ServiceMonitoringClient) UpdateServiceLevelObjective(ctx context.Context, req *monitoringpb.UpdateServiceLevelObjectiveRequest, opts ...gax.CallOption) (*monitoringpb.ServiceLevelObjective, error) { - md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "service_level_objective.name", url.QueryEscape(req.GetServiceLevelObjective().GetName()))) - ctx = insertMetadata(ctx, c.xGoogMetadata, md) - opts = append(c.CallOptions.UpdateServiceLevelObjective[0:len(c.CallOptions.UpdateServiceLevelObjective):len(c.CallOptions.UpdateServiceLevelObjective)], opts...) - var resp *monitoringpb.ServiceLevelObjective - err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { - var err error - resp, err = c.serviceMonitoringClient.UpdateServiceLevelObjective(ctx, req, settings.GRPC...) - return err - }, opts...) - if err != nil { - return nil, err - } - return resp, nil -} - -// DeleteServiceLevelObjective delete the given ServiceLevelObjective. -func (c *ServiceMonitoringClient) DeleteServiceLevelObjective(ctx context.Context, req *monitoringpb.DeleteServiceLevelObjectiveRequest, opts ...gax.CallOption) error { - md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))) - ctx = insertMetadata(ctx, c.xGoogMetadata, md) - opts = append(c.CallOptions.DeleteServiceLevelObjective[0:len(c.CallOptions.DeleteServiceLevelObjective):len(c.CallOptions.DeleteServiceLevelObjective)], opts...) - err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { - var err error - _, err = c.serviceMonitoringClient.DeleteServiceLevelObjective(ctx, req, settings.GRPC...) - return err - }, opts...) - return err -} - -// ServiceIterator manages a stream of *monitoringpb.Service. -type ServiceIterator struct { - items []*monitoringpb.Service - pageInfo *iterator.PageInfo - nextFunc func() error - - // InternalFetch is for use by the Google Cloud Libraries only. - // It is not part of the stable interface of this package. - // - // InternalFetch returns results from a single call to the underlying RPC. - // The number of results is no greater than pageSize. - // If there are no more results, nextPageToken is empty and err is nil. - InternalFetch func(pageSize int, pageToken string) (results []*monitoringpb.Service, nextPageToken string, err error) -} - -// PageInfo supports pagination. See the google.golang.org/api/iterator package for details. -func (it *ServiceIterator) PageInfo() *iterator.PageInfo { - return it.pageInfo -} - -// Next returns the next result. Its second return value is iterator.Done if there are no more -// results. Once Next returns Done, all subsequent calls will return Done. -func (it *ServiceIterator) Next() (*monitoringpb.Service, error) { - var item *monitoringpb.Service - if err := it.nextFunc(); err != nil { - return item, err - } - item = it.items[0] - it.items = it.items[1:] - return item, nil -} - -func (it *ServiceIterator) bufLen() int { - return len(it.items) -} - -func (it *ServiceIterator) takeBuf() interface{} { - b := it.items - it.items = nil - return b -} - -// ServiceLevelObjectiveIterator manages a stream of *monitoringpb.ServiceLevelObjective. -type ServiceLevelObjectiveIterator struct { - items []*monitoringpb.ServiceLevelObjective - pageInfo *iterator.PageInfo - nextFunc func() error - - // InternalFetch is for use by the Google Cloud Libraries only. - // It is not part of the stable interface of this package. - // - // InternalFetch returns results from a single call to the underlying RPC. - // The number of results is no greater than pageSize. - // If there are no more results, nextPageToken is empty and err is nil. - InternalFetch func(pageSize int, pageToken string) (results []*monitoringpb.ServiceLevelObjective, nextPageToken string, err error) -} - -// PageInfo supports pagination. See the google.golang.org/api/iterator package for details. -func (it *ServiceLevelObjectiveIterator) PageInfo() *iterator.PageInfo { - return it.pageInfo -} - -// Next returns the next result. Its second return value is iterator.Done if there are no more -// results. Once Next returns Done, all subsequent calls will return Done. -func (it *ServiceLevelObjectiveIterator) Next() (*monitoringpb.ServiceLevelObjective, error) { - var item *monitoringpb.ServiceLevelObjective - if err := it.nextFunc(); err != nil { - return item, err - } - item = it.items[0] - it.items = it.items[1:] - return item, nil -} - -func (it *ServiceLevelObjectiveIterator) bufLen() int { - return len(it.items) -} - -func (it *ServiceLevelObjectiveIterator) takeBuf() interface{} { - b := it.items - it.items = nil - return b -} diff --git a/vendor/cloud.google.com/go/monitoring/apiv3/uptime_check_client.go b/vendor/cloud.google.com/go/monitoring/apiv3/uptime_check_client.go deleted file mode 100644 index 5a558cdb3f..0000000000 --- a/vendor/cloud.google.com/go/monitoring/apiv3/uptime_check_client.go +++ /dev/null @@ -1,372 +0,0 @@ -// Copyright 2019 Google LLC -// -// 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 -// -// https://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. - -// Code generated by gapic-generator. DO NOT EDIT. - -package monitoring - -import ( - "context" - "fmt" - "math" - "net/url" - "time" - - "github.com/golang/protobuf/proto" - gax "github.com/googleapis/gax-go/v2" - "google.golang.org/api/iterator" - "google.golang.org/api/option" - "google.golang.org/api/transport" - monitoringpb "google.golang.org/genproto/googleapis/monitoring/v3" - "google.golang.org/grpc" - "google.golang.org/grpc/codes" - "google.golang.org/grpc/metadata" -) - -// UptimeCheckCallOptions contains the retry settings for each method of UptimeCheckClient. -type UptimeCheckCallOptions struct { - ListUptimeCheckConfigs []gax.CallOption - GetUptimeCheckConfig []gax.CallOption - CreateUptimeCheckConfig []gax.CallOption - UpdateUptimeCheckConfig []gax.CallOption - DeleteUptimeCheckConfig []gax.CallOption - ListUptimeCheckIps []gax.CallOption -} - -func defaultUptimeCheckClientOptions() []option.ClientOption { - return []option.ClientOption{ - option.WithEndpoint("monitoring.googleapis.com:443"), - option.WithScopes(DefaultAuthScopes()...), - option.WithGRPCDialOption(grpc.WithDefaultCallOptions( - grpc.MaxCallRecvMsgSize(math.MaxInt32))), - } -} - -func defaultUptimeCheckCallOptions() *UptimeCheckCallOptions { - retry := map[[2]string][]gax.CallOption{ - {"default", "idempotent"}: { - gax.WithRetry(func() gax.Retryer { - return gax.OnCodes([]codes.Code{ - codes.DeadlineExceeded, - codes.Unavailable, - }, gax.Backoff{ - Initial: 100 * time.Millisecond, - Max: 60000 * time.Millisecond, - Multiplier: 1.3, - }) - }), - }, - } - return &UptimeCheckCallOptions{ - ListUptimeCheckConfigs: retry[[2]string{"default", "idempotent"}], - GetUptimeCheckConfig: retry[[2]string{"default", "idempotent"}], - CreateUptimeCheckConfig: retry[[2]string{"default", "non_idempotent"}], - UpdateUptimeCheckConfig: retry[[2]string{"default", "non_idempotent"}], - DeleteUptimeCheckConfig: retry[[2]string{"default", "idempotent"}], - ListUptimeCheckIps: retry[[2]string{"default", "idempotent"}], - } -} - -// UptimeCheckClient is a client for interacting with Stackdriver Monitoring API. -// -// Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls. -type UptimeCheckClient struct { - // The connection to the service. - conn *grpc.ClientConn - - // The gRPC API client. - uptimeCheckClient monitoringpb.UptimeCheckServiceClient - - // The call options for this service. - CallOptions *UptimeCheckCallOptions - - // The x-goog-* metadata to be sent with each request. - xGoogMetadata metadata.MD -} - -// NewUptimeCheckClient creates a new uptime check service client. -// -// The UptimeCheckService API is used to manage (list, create, delete, edit) -// Uptime check configurations in the Stackdriver Monitoring product. An Uptime -// check is a piece of configuration that determines which resources and -// services to monitor for availability. These configurations can also be -// configured interactively by navigating to the [Cloud Console] -// (http://console.cloud.google.com), selecting the appropriate project, -// clicking on "Monitoring" on the left-hand side to navigate to Stackdriver, -// and then clicking on "Uptime". -func NewUptimeCheckClient(ctx context.Context, opts ...option.ClientOption) (*UptimeCheckClient, error) { - conn, err := transport.DialGRPC(ctx, append(defaultUptimeCheckClientOptions(), opts...)...) - if err != nil { - return nil, err - } - c := &UptimeCheckClient{ - conn: conn, - CallOptions: defaultUptimeCheckCallOptions(), - - uptimeCheckClient: monitoringpb.NewUptimeCheckServiceClient(conn), - } - c.setGoogleClientInfo() - return c, nil -} - -// Connection returns the client's connection to the API service. -func (c *UptimeCheckClient) Connection() *grpc.ClientConn { - return c.conn -} - -// Close closes the connection to the API service. The user should invoke this when -// the client is no longer required. -func (c *UptimeCheckClient) Close() error { - return c.conn.Close() -} - -// setGoogleClientInfo sets the name and version of the application in -// the `x-goog-api-client` header passed on each request. Intended for -// use by Google-written clients. -func (c *UptimeCheckClient) setGoogleClientInfo(keyval ...string) { - kv := append([]string{"gl-go", versionGo()}, keyval...) - kv = append(kv, "gapic", versionClient, "gax", gax.Version, "grpc", grpc.Version) - c.xGoogMetadata = metadata.Pairs("x-goog-api-client", gax.XGoogHeader(kv...)) -} - -// ListUptimeCheckConfigs lists the existing valid Uptime check configurations for the project -// (leaving out any invalid configurations). -func (c *UptimeCheckClient) ListUptimeCheckConfigs(ctx context.Context, req *monitoringpb.ListUptimeCheckConfigsRequest, opts ...gax.CallOption) *UptimeCheckConfigIterator { - md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))) - ctx = insertMetadata(ctx, c.xGoogMetadata, md) - opts = append(c.CallOptions.ListUptimeCheckConfigs[0:len(c.CallOptions.ListUptimeCheckConfigs):len(c.CallOptions.ListUptimeCheckConfigs)], opts...) - it := &UptimeCheckConfigIterator{} - req = proto.Clone(req).(*monitoringpb.ListUptimeCheckConfigsRequest) - it.InternalFetch = func(pageSize int, pageToken string) ([]*monitoringpb.UptimeCheckConfig, string, error) { - var resp *monitoringpb.ListUptimeCheckConfigsResponse - req.PageToken = pageToken - if pageSize > math.MaxInt32 { - req.PageSize = math.MaxInt32 - } else { - req.PageSize = int32(pageSize) - } - err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { - var err error - resp, err = c.uptimeCheckClient.ListUptimeCheckConfigs(ctx, req, settings.GRPC...) - return err - }, opts...) - if err != nil { - return nil, "", err - } - return resp.UptimeCheckConfigs, resp.NextPageToken, nil - } - fetch := func(pageSize int, pageToken string) (string, error) { - items, nextPageToken, err := it.InternalFetch(pageSize, pageToken) - if err != nil { - return "", err - } - it.items = append(it.items, items...) - return nextPageToken, nil - } - it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf) - it.pageInfo.MaxSize = int(req.PageSize) - it.pageInfo.Token = req.PageToken - return it -} - -// GetUptimeCheckConfig gets a single Uptime check configuration. -func (c *UptimeCheckClient) GetUptimeCheckConfig(ctx context.Context, req *monitoringpb.GetUptimeCheckConfigRequest, opts ...gax.CallOption) (*monitoringpb.UptimeCheckConfig, error) { - md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))) - ctx = insertMetadata(ctx, c.xGoogMetadata, md) - opts = append(c.CallOptions.GetUptimeCheckConfig[0:len(c.CallOptions.GetUptimeCheckConfig):len(c.CallOptions.GetUptimeCheckConfig)], opts...) - var resp *monitoringpb.UptimeCheckConfig - err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { - var err error - resp, err = c.uptimeCheckClient.GetUptimeCheckConfig(ctx, req, settings.GRPC...) - return err - }, opts...) - if err != nil { - return nil, err - } - return resp, nil -} - -// CreateUptimeCheckConfig creates a new Uptime check configuration. -func (c *UptimeCheckClient) CreateUptimeCheckConfig(ctx context.Context, req *monitoringpb.CreateUptimeCheckConfigRequest, opts ...gax.CallOption) (*monitoringpb.UptimeCheckConfig, error) { - md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))) - ctx = insertMetadata(ctx, c.xGoogMetadata, md) - opts = append(c.CallOptions.CreateUptimeCheckConfig[0:len(c.CallOptions.CreateUptimeCheckConfig):len(c.CallOptions.CreateUptimeCheckConfig)], opts...) - var resp *monitoringpb.UptimeCheckConfig - err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { - var err error - resp, err = c.uptimeCheckClient.CreateUptimeCheckConfig(ctx, req, settings.GRPC...) - return err - }, opts...) - if err != nil { - return nil, err - } - return resp, nil -} - -// UpdateUptimeCheckConfig updates an Uptime check configuration. You can either replace the entire -// configuration with a new one or replace only certain fields in the current -// configuration by specifying the fields to be updated via updateMask. -// Returns the updated configuration. -func (c *UptimeCheckClient) UpdateUptimeCheckConfig(ctx context.Context, req *monitoringpb.UpdateUptimeCheckConfigRequest, opts ...gax.CallOption) (*monitoringpb.UptimeCheckConfig, error) { - md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "uptime_check_config.name", url.QueryEscape(req.GetUptimeCheckConfig().GetName()))) - ctx = insertMetadata(ctx, c.xGoogMetadata, md) - opts = append(c.CallOptions.UpdateUptimeCheckConfig[0:len(c.CallOptions.UpdateUptimeCheckConfig):len(c.CallOptions.UpdateUptimeCheckConfig)], opts...) - var resp *monitoringpb.UptimeCheckConfig - err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { - var err error - resp, err = c.uptimeCheckClient.UpdateUptimeCheckConfig(ctx, req, settings.GRPC...) - return err - }, opts...) - if err != nil { - return nil, err - } - return resp, nil -} - -// DeleteUptimeCheckConfig deletes an Uptime check configuration. Note that this method will fail -// if the Uptime check configuration is referenced by an alert policy or -// other dependent configs that would be rendered invalid by the deletion. -func (c *UptimeCheckClient) DeleteUptimeCheckConfig(ctx context.Context, req *monitoringpb.DeleteUptimeCheckConfigRequest, opts ...gax.CallOption) error { - md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))) - ctx = insertMetadata(ctx, c.xGoogMetadata, md) - opts = append(c.CallOptions.DeleteUptimeCheckConfig[0:len(c.CallOptions.DeleteUptimeCheckConfig):len(c.CallOptions.DeleteUptimeCheckConfig)], opts...) - err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { - var err error - _, err = c.uptimeCheckClient.DeleteUptimeCheckConfig(ctx, req, settings.GRPC...) - return err - }, opts...) - return err -} - -// ListUptimeCheckIps returns the list of IP addresses that checkers run from -func (c *UptimeCheckClient) ListUptimeCheckIps(ctx context.Context, req *monitoringpb.ListUptimeCheckIpsRequest, opts ...gax.CallOption) *UptimeCheckIpIterator { - ctx = insertMetadata(ctx, c.xGoogMetadata) - opts = append(c.CallOptions.ListUptimeCheckIps[0:len(c.CallOptions.ListUptimeCheckIps):len(c.CallOptions.ListUptimeCheckIps)], opts...) - it := &UptimeCheckIpIterator{} - req = proto.Clone(req).(*monitoringpb.ListUptimeCheckIpsRequest) - it.InternalFetch = func(pageSize int, pageToken string) ([]*monitoringpb.UptimeCheckIp, string, error) { - var resp *monitoringpb.ListUptimeCheckIpsResponse - req.PageToken = pageToken - if pageSize > math.MaxInt32 { - req.PageSize = math.MaxInt32 - } else { - req.PageSize = int32(pageSize) - } - err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { - var err error - resp, err = c.uptimeCheckClient.ListUptimeCheckIps(ctx, req, settings.GRPC...) - return err - }, opts...) - if err != nil { - return nil, "", err - } - return resp.UptimeCheckIps, resp.NextPageToken, nil - } - fetch := func(pageSize int, pageToken string) (string, error) { - items, nextPageToken, err := it.InternalFetch(pageSize, pageToken) - if err != nil { - return "", err - } - it.items = append(it.items, items...) - return nextPageToken, nil - } - it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf) - it.pageInfo.MaxSize = int(req.PageSize) - it.pageInfo.Token = req.PageToken - return it -} - -// UptimeCheckConfigIterator manages a stream of *monitoringpb.UptimeCheckConfig. -type UptimeCheckConfigIterator struct { - items []*monitoringpb.UptimeCheckConfig - pageInfo *iterator.PageInfo - nextFunc func() error - - // InternalFetch is for use by the Google Cloud Libraries only. - // It is not part of the stable interface of this package. - // - // InternalFetch returns results from a single call to the underlying RPC. - // The number of results is no greater than pageSize. - // If there are no more results, nextPageToken is empty and err is nil. - InternalFetch func(pageSize int, pageToken string) (results []*monitoringpb.UptimeCheckConfig, nextPageToken string, err error) -} - -// PageInfo supports pagination. See the google.golang.org/api/iterator package for details. -func (it *UptimeCheckConfigIterator) PageInfo() *iterator.PageInfo { - return it.pageInfo -} - -// Next returns the next result. Its second return value is iterator.Done if there are no more -// results. Once Next returns Done, all subsequent calls will return Done. -func (it *UptimeCheckConfigIterator) Next() (*monitoringpb.UptimeCheckConfig, error) { - var item *monitoringpb.UptimeCheckConfig - if err := it.nextFunc(); err != nil { - return item, err - } - item = it.items[0] - it.items = it.items[1:] - return item, nil -} - -func (it *UptimeCheckConfigIterator) bufLen() int { - return len(it.items) -} - -func (it *UptimeCheckConfigIterator) takeBuf() interface{} { - b := it.items - it.items = nil - return b -} - -// UptimeCheckIpIterator manages a stream of *monitoringpb.UptimeCheckIp. -type UptimeCheckIpIterator struct { - items []*monitoringpb.UptimeCheckIp - pageInfo *iterator.PageInfo - nextFunc func() error - - // InternalFetch is for use by the Google Cloud Libraries only. - // It is not part of the stable interface of this package. - // - // InternalFetch returns results from a single call to the underlying RPC. - // The number of results is no greater than pageSize. - // If there are no more results, nextPageToken is empty and err is nil. - InternalFetch func(pageSize int, pageToken string) (results []*monitoringpb.UptimeCheckIp, nextPageToken string, err error) -} - -// PageInfo supports pagination. See the google.golang.org/api/iterator package for details. -func (it *UptimeCheckIpIterator) PageInfo() *iterator.PageInfo { - return it.pageInfo -} - -// Next returns the next result. Its second return value is iterator.Done if there are no more -// results. Once Next returns Done, all subsequent calls will return Done. -func (it *UptimeCheckIpIterator) Next() (*monitoringpb.UptimeCheckIp, error) { - var item *monitoringpb.UptimeCheckIp - if err := it.nextFunc(); err != nil { - return item, err - } - item = it.items[0] - it.items = it.items[1:] - return item, nil -} - -func (it *UptimeCheckIpIterator) bufLen() int { - return len(it.items) -} - -func (it *UptimeCheckIpIterator) takeBuf() interface{} { - b := it.items - it.items = nil - return b -} diff --git a/vendor/github.com/google/go-cmp/LICENSE b/vendor/github.com/google/go-cmp/LICENSE deleted file mode 100644 index 32017f8fa1..0000000000 --- a/vendor/github.com/google/go-cmp/LICENSE +++ /dev/null @@ -1,27 +0,0 @@ -Copyright (c) 2017 The Go Authors. 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 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. diff --git a/vendor/github.com/google/go-cmp/cmp/compare.go b/vendor/github.com/google/go-cmp/cmp/compare.go deleted file mode 100644 index 2133562b01..0000000000 --- a/vendor/github.com/google/go-cmp/cmp/compare.go +++ /dev/null @@ -1,616 +0,0 @@ -// Copyright 2017, The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE.md file. - -// Package cmp determines equality of values. -// -// This package is intended to be a more powerful and safer alternative to -// reflect.DeepEqual for comparing whether two values are semantically equal. -// -// The primary features of cmp are: -// -// • When the default behavior of equality does not suit the needs of the test, -// custom equality functions can override the equality operation. -// For example, an equality function may report floats as equal so long as they -// are within some tolerance of each other. -// -// • Types that have an Equal method may use that method to determine equality. -// This allows package authors to determine the equality operation for the types -// that they define. -// -// • If no custom equality functions are used and no Equal method is defined, -// equality is determined by recursively comparing the primitive kinds on both -// values, much like reflect.DeepEqual. Unlike reflect.DeepEqual, unexported -// fields are not compared by default; they result in panics unless suppressed -// by using an Ignore option (see cmpopts.IgnoreUnexported) or explicitly compared -// using the AllowUnexported option. -package cmp - -import ( - "fmt" - "reflect" - "strings" - - "github.com/google/go-cmp/cmp/internal/diff" - "github.com/google/go-cmp/cmp/internal/flags" - "github.com/google/go-cmp/cmp/internal/function" - "github.com/google/go-cmp/cmp/internal/value" -) - -// Equal reports whether x and y are equal by recursively applying the -// following rules in the given order to x and y and all of their sub-values: -// -// • Let S be the set of all Ignore, Transformer, and Comparer options that -// remain after applying all path filters, value filters, and type filters. -// If at least one Ignore exists in S, then the comparison is ignored. -// If the number of Transformer and Comparer options in S is greater than one, -// then Equal panics because it is ambiguous which option to use. -// If S contains a single Transformer, then use that to transform the current -// values and recursively call Equal on the output values. -// If S contains a single Comparer, then use that to compare the current values. -// Otherwise, evaluation proceeds to the next rule. -// -// • If the values have an Equal method of the form "(T) Equal(T) bool" or -// "(T) Equal(I) bool" where T is assignable to I, then use the result of -// x.Equal(y) even if x or y is nil. Otherwise, no such method exists and -// evaluation proceeds to the next rule. -// -// • Lastly, try to compare x and y based on their basic kinds. -// Simple kinds like booleans, integers, floats, complex numbers, strings, and -// channels are compared using the equivalent of the == operator in Go. -// Functions are only equal if they are both nil, otherwise they are unequal. -// -// Structs are equal if recursively calling Equal on all fields report equal. -// If a struct contains unexported fields, Equal panics unless an Ignore option -// (e.g., cmpopts.IgnoreUnexported) ignores that field or the AllowUnexported -// option explicitly permits comparing the unexported field. -// -// Slices are equal if they are both nil or both non-nil, where recursively -// calling Equal on all non-ignored slice or array elements report equal. -// Empty non-nil slices and nil slices are not equal; to equate empty slices, -// consider using cmpopts.EquateEmpty. -// -// Maps are equal if they are both nil or both non-nil, where recursively -// calling Equal on all non-ignored map entries report equal. -// Map keys are equal according to the == operator. -// To use custom comparisons for map keys, consider using cmpopts.SortMaps. -// Empty non-nil maps and nil maps are not equal; to equate empty maps, -// consider using cmpopts.EquateEmpty. -// -// Pointers and interfaces are equal if they are both nil or both non-nil, -// where they have the same underlying concrete type and recursively -// calling Equal on the underlying values reports equal. -func Equal(x, y interface{}, opts ...Option) bool { - vx := reflect.ValueOf(x) - vy := reflect.ValueOf(y) - - // If the inputs are different types, auto-wrap them in an empty interface - // so that they have the same parent type. - var t reflect.Type - if !vx.IsValid() || !vy.IsValid() || vx.Type() != vy.Type() { - t = reflect.TypeOf((*interface{})(nil)).Elem() - if vx.IsValid() { - vvx := reflect.New(t).Elem() - vvx.Set(vx) - vx = vvx - } - if vy.IsValid() { - vvy := reflect.New(t).Elem() - vvy.Set(vy) - vy = vvy - } - } else { - t = vx.Type() - } - - s := newState(opts) - s.compareAny(&pathStep{t, vx, vy}) - return s.result.Equal() -} - -// Diff returns a human-readable report of the differences between two values. -// It returns an empty string if and only if Equal returns true for the same -// input values and options. -// -// The output is displayed as a literal in pseudo-Go syntax. -// At the start of each line, a "-" prefix indicates an element removed from x, -// a "+" prefix to indicates an element added to y, and the lack of a prefix -// indicates an element common to both x and y. If possible, the output -// uses fmt.Stringer.String or error.Error methods to produce more humanly -// readable outputs. In such cases, the string is prefixed with either an -// 's' or 'e' character, respectively, to indicate that the method was called. -// -// Do not depend on this output being stable. If you need the ability to -// programmatically interpret the difference, consider using a custom Reporter. -func Diff(x, y interface{}, opts ...Option) string { - r := new(defaultReporter) - eq := Equal(x, y, Options(opts), Reporter(r)) - d := r.String() - if (d == "") != eq { - panic("inconsistent difference and equality results") - } - return d -} - -type state struct { - // These fields represent the "comparison state". - // Calling statelessCompare must not result in observable changes to these. - result diff.Result // The current result of comparison - curPath Path // The current path in the value tree - reporters []reporter // Optional reporters - - // recChecker checks for infinite cycles applying the same set of - // transformers upon the output of itself. - recChecker recChecker - - // dynChecker triggers pseudo-random checks for option correctness. - // It is safe for statelessCompare to mutate this value. - dynChecker dynChecker - - // These fields, once set by processOption, will not change. - exporters map[reflect.Type]bool // Set of structs with unexported field visibility - opts Options // List of all fundamental and filter options -} - -func newState(opts []Option) *state { - // Always ensure a validator option exists to validate the inputs. - s := &state{opts: Options{validator{}}} - s.processOption(Options(opts)) - return s -} - -func (s *state) processOption(opt Option) { - switch opt := opt.(type) { - case nil: - case Options: - for _, o := range opt { - s.processOption(o) - } - case coreOption: - type filtered interface { - isFiltered() bool - } - if fopt, ok := opt.(filtered); ok && !fopt.isFiltered() { - panic(fmt.Sprintf("cannot use an unfiltered option: %v", opt)) - } - s.opts = append(s.opts, opt) - case visibleStructs: - if s.exporters == nil { - s.exporters = make(map[reflect.Type]bool) - } - for t := range opt { - s.exporters[t] = true - } - case reporter: - s.reporters = append(s.reporters, opt) - default: - panic(fmt.Sprintf("unknown option %T", opt)) - } -} - -// statelessCompare compares two values and returns the result. -// This function is stateless in that it does not alter the current result, -// or output to any registered reporters. -func (s *state) statelessCompare(step PathStep) diff.Result { - // We do not save and restore the curPath because all of the compareX - // methods should properly push and pop from the path. - // It is an implementation bug if the contents of curPath differs from - // when calling this function to when returning from it. - - oldResult, oldReporters := s.result, s.reporters - s.result = diff.Result{} // Reset result - s.reporters = nil // Remove reporters to avoid spurious printouts - s.compareAny(step) - res := s.result - s.result, s.reporters = oldResult, oldReporters - return res -} - -func (s *state) compareAny(step PathStep) { - // Update the path stack. - s.curPath.push(step) - defer s.curPath.pop() - for _, r := range s.reporters { - r.PushStep(step) - defer r.PopStep() - } - s.recChecker.Check(s.curPath) - - // Obtain the current type and values. - t := step.Type() - vx, vy := step.Values() - - // Rule 1: Check whether an option applies on this node in the value tree. - if s.tryOptions(t, vx, vy) { - return - } - - // Rule 2: Check whether the type has a valid Equal method. - if s.tryMethod(t, vx, vy) { - return - } - - // Rule 3: Compare based on the underlying kind. - switch t.Kind() { - case reflect.Bool: - s.report(vx.Bool() == vy.Bool(), 0) - case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: - s.report(vx.Int() == vy.Int(), 0) - case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr: - s.report(vx.Uint() == vy.Uint(), 0) - case reflect.Float32, reflect.Float64: - s.report(vx.Float() == vy.Float(), 0) - case reflect.Complex64, reflect.Complex128: - s.report(vx.Complex() == vy.Complex(), 0) - case reflect.String: - s.report(vx.String() == vy.String(), 0) - case reflect.Chan, reflect.UnsafePointer: - s.report(vx.Pointer() == vy.Pointer(), 0) - case reflect.Func: - s.report(vx.IsNil() && vy.IsNil(), 0) - case reflect.Struct: - s.compareStruct(t, vx, vy) - case reflect.Slice, reflect.Array: - s.compareSlice(t, vx, vy) - case reflect.Map: - s.compareMap(t, vx, vy) - case reflect.Ptr: - s.comparePtr(t, vx, vy) - case reflect.Interface: - s.compareInterface(t, vx, vy) - default: - panic(fmt.Sprintf("%v kind not handled", t.Kind())) - } -} - -func (s *state) tryOptions(t reflect.Type, vx, vy reflect.Value) bool { - // Evaluate all filters and apply the remaining options. - if opt := s.opts.filter(s, t, vx, vy); opt != nil { - opt.apply(s, vx, vy) - return true - } - return false -} - -func (s *state) tryMethod(t reflect.Type, vx, vy reflect.Value) bool { - // Check if this type even has an Equal method. - m, ok := t.MethodByName("Equal") - if !ok || !function.IsType(m.Type, function.EqualAssignable) { - return false - } - - eq := s.callTTBFunc(m.Func, vx, vy) - s.report(eq, reportByMethod) - return true -} - -func (s *state) callTRFunc(f, v reflect.Value, step Transform) reflect.Value { - v = sanitizeValue(v, f.Type().In(0)) - if !s.dynChecker.Next() { - return f.Call([]reflect.Value{v})[0] - } - - // Run the function twice and ensure that we get the same results back. - // We run in goroutines so that the race detector (if enabled) can detect - // unsafe mutations to the input. - c := make(chan reflect.Value) - go detectRaces(c, f, v) - got := <-c - want := f.Call([]reflect.Value{v})[0] - if step.vx, step.vy = got, want; !s.statelessCompare(step).Equal() { - // To avoid false-positives with non-reflexive equality operations, - // we sanity check whether a value is equal to itself. - if step.vx, step.vy = want, want; !s.statelessCompare(step).Equal() { - return want - } - panic(fmt.Sprintf("non-deterministic function detected: %s", function.NameOf(f))) - } - return want -} - -func (s *state) callTTBFunc(f, x, y reflect.Value) bool { - x = sanitizeValue(x, f.Type().In(0)) - y = sanitizeValue(y, f.Type().In(1)) - if !s.dynChecker.Next() { - return f.Call([]reflect.Value{x, y})[0].Bool() - } - - // Swapping the input arguments is sufficient to check that - // f is symmetric and deterministic. - // We run in goroutines so that the race detector (if enabled) can detect - // unsafe mutations to the input. - c := make(chan reflect.Value) - go detectRaces(c, f, y, x) - got := <-c - want := f.Call([]reflect.Value{x, y})[0].Bool() - if !got.IsValid() || got.Bool() != want { - panic(fmt.Sprintf("non-deterministic or non-symmetric function detected: %s", function.NameOf(f))) - } - return want -} - -func detectRaces(c chan<- reflect.Value, f reflect.Value, vs ...reflect.Value) { - var ret reflect.Value - defer func() { - recover() // Ignore panics, let the other call to f panic instead - c <- ret - }() - ret = f.Call(vs)[0] -} - -// sanitizeValue converts nil interfaces of type T to those of type R, -// assuming that T is assignable to R. -// Otherwise, it returns the input value as is. -func sanitizeValue(v reflect.Value, t reflect.Type) reflect.Value { - // TODO(dsnet): Workaround for reflect bug (https://golang.org/issue/22143). - if !flags.AtLeastGo110 { - if v.Kind() == reflect.Interface && v.IsNil() && v.Type() != t { - return reflect.New(t).Elem() - } - } - return v -} - -func (s *state) compareStruct(t reflect.Type, vx, vy reflect.Value) { - var vax, vay reflect.Value // Addressable versions of vx and vy - - step := StructField{&structField{}} - for i := 0; i < t.NumField(); i++ { - step.typ = t.Field(i).Type - step.vx = vx.Field(i) - step.vy = vy.Field(i) - step.name = t.Field(i).Name - step.idx = i - step.unexported = !isExported(step.name) - if step.unexported { - if step.name == "_" { - continue - } - // Defer checking of unexported fields until later to give an - // Ignore a chance to ignore the field. - if !vax.IsValid() || !vay.IsValid() { - // For retrieveUnexportedField to work, the parent struct must - // be addressable. Create a new copy of the values if - // necessary to make them addressable. - vax = makeAddressable(vx) - vay = makeAddressable(vy) - } - step.mayForce = s.exporters[t] - step.pvx = vax - step.pvy = vay - step.field = t.Field(i) - } - s.compareAny(step) - } -} - -func (s *state) compareSlice(t reflect.Type, vx, vy reflect.Value) { - isSlice := t.Kind() == reflect.Slice - if isSlice && (vx.IsNil() || vy.IsNil()) { - s.report(vx.IsNil() && vy.IsNil(), 0) - return - } - - // TODO: Support cyclic data structures. - - step := SliceIndex{&sliceIndex{pathStep: pathStep{typ: t.Elem()}}} - withIndexes := func(ix, iy int) SliceIndex { - if ix >= 0 { - step.vx, step.xkey = vx.Index(ix), ix - } else { - step.vx, step.xkey = reflect.Value{}, -1 - } - if iy >= 0 { - step.vy, step.ykey = vy.Index(iy), iy - } else { - step.vy, step.ykey = reflect.Value{}, -1 - } - return step - } - - // Ignore options are able to ignore missing elements in a slice. - // However, detecting these reliably requires an optimal differencing - // algorithm, for which diff.Difference is not. - // - // Instead, we first iterate through both slices to detect which elements - // would be ignored if standing alone. The index of non-discarded elements - // are stored in a separate slice, which diffing is then performed on. - var indexesX, indexesY []int - var ignoredX, ignoredY []bool - for ix := 0; ix < vx.Len(); ix++ { - ignored := s.statelessCompare(withIndexes(ix, -1)).NumDiff == 0 - if !ignored { - indexesX = append(indexesX, ix) - } - ignoredX = append(ignoredX, ignored) - } - for iy := 0; iy < vy.Len(); iy++ { - ignored := s.statelessCompare(withIndexes(-1, iy)).NumDiff == 0 - if !ignored { - indexesY = append(indexesY, iy) - } - ignoredY = append(ignoredY, ignored) - } - - // Compute an edit-script for slices vx and vy (excluding ignored elements). - edits := diff.Difference(len(indexesX), len(indexesY), func(ix, iy int) diff.Result { - return s.statelessCompare(withIndexes(indexesX[ix], indexesY[iy])) - }) - - // Replay the ignore-scripts and the edit-script. - var ix, iy int - for ix < vx.Len() || iy < vy.Len() { - var e diff.EditType - switch { - case ix < len(ignoredX) && ignoredX[ix]: - e = diff.UniqueX - case iy < len(ignoredY) && ignoredY[iy]: - e = diff.UniqueY - default: - e, edits = edits[0], edits[1:] - } - switch e { - case diff.UniqueX: - s.compareAny(withIndexes(ix, -1)) - ix++ - case diff.UniqueY: - s.compareAny(withIndexes(-1, iy)) - iy++ - default: - s.compareAny(withIndexes(ix, iy)) - ix++ - iy++ - } - } -} - -func (s *state) compareMap(t reflect.Type, vx, vy reflect.Value) { - if vx.IsNil() || vy.IsNil() { - s.report(vx.IsNil() && vy.IsNil(), 0) - return - } - - // TODO: Support cyclic data structures. - - // We combine and sort the two map keys so that we can perform the - // comparisons in a deterministic order. - step := MapIndex{&mapIndex{pathStep: pathStep{typ: t.Elem()}}} - for _, k := range value.SortKeys(append(vx.MapKeys(), vy.MapKeys()...)) { - step.vx = vx.MapIndex(k) - step.vy = vy.MapIndex(k) - step.key = k - if !step.vx.IsValid() && !step.vy.IsValid() { - // It is possible for both vx and vy to be invalid if the - // key contained a NaN value in it. - // - // Even with the ability to retrieve NaN keys in Go 1.12, - // there still isn't a sensible way to compare the values since - // a NaN key may map to multiple unordered values. - // The most reasonable way to compare NaNs would be to compare the - // set of values. However, this is impossible to do efficiently - // since set equality is provably an O(n^2) operation given only - // an Equal function. If we had a Less function or Hash function, - // this could be done in O(n*log(n)) or O(n), respectively. - // - // Rather than adding complex logic to deal with NaNs, make it - // the user's responsibility to compare such obscure maps. - const help = "consider providing a Comparer to compare the map" - panic(fmt.Sprintf("%#v has map key with NaNs\n%s", s.curPath, help)) - } - s.compareAny(step) - } -} - -func (s *state) comparePtr(t reflect.Type, vx, vy reflect.Value) { - if vx.IsNil() || vy.IsNil() { - s.report(vx.IsNil() && vy.IsNil(), 0) - return - } - - // TODO: Support cyclic data structures. - - vx, vy = vx.Elem(), vy.Elem() - s.compareAny(Indirect{&indirect{pathStep{t.Elem(), vx, vy}}}) -} - -func (s *state) compareInterface(t reflect.Type, vx, vy reflect.Value) { - if vx.IsNil() || vy.IsNil() { - s.report(vx.IsNil() && vy.IsNil(), 0) - return - } - vx, vy = vx.Elem(), vy.Elem() - if vx.Type() != vy.Type() { - s.report(false, 0) - return - } - s.compareAny(TypeAssertion{&typeAssertion{pathStep{vx.Type(), vx, vy}}}) -} - -func (s *state) report(eq bool, rf resultFlags) { - if rf&reportByIgnore == 0 { - if eq { - s.result.NumSame++ - rf |= reportEqual - } else { - s.result.NumDiff++ - rf |= reportUnequal - } - } - for _, r := range s.reporters { - r.Report(Result{flags: rf}) - } -} - -// recChecker tracks the state needed to periodically perform checks that -// user provided transformers are not stuck in an infinitely recursive cycle. -type recChecker struct{ next int } - -// Check scans the Path for any recursive transformers and panics when any -// recursive transformers are detected. Note that the presence of a -// recursive Transformer does not necessarily imply an infinite cycle. -// As such, this check only activates after some minimal number of path steps. -func (rc *recChecker) Check(p Path) { - const minLen = 1 << 16 - if rc.next == 0 { - rc.next = minLen - } - if len(p) < rc.next { - return - } - rc.next <<= 1 - - // Check whether the same transformer has appeared at least twice. - var ss []string - m := map[Option]int{} - for _, ps := range p { - if t, ok := ps.(Transform); ok { - t := t.Option() - if m[t] == 1 { // Transformer was used exactly once before - tf := t.(*transformer).fnc.Type() - ss = append(ss, fmt.Sprintf("%v: %v => %v", t, tf.In(0), tf.Out(0))) - } - m[t]++ - } - } - if len(ss) > 0 { - const warning = "recursive set of Transformers detected" - const help = "consider using cmpopts.AcyclicTransformer" - set := strings.Join(ss, "\n\t") - panic(fmt.Sprintf("%s:\n\t%s\n%s", warning, set, help)) - } -} - -// dynChecker tracks the state needed to periodically perform checks that -// user provided functions are symmetric and deterministic. -// The zero value is safe for immediate use. -type dynChecker struct{ curr, next int } - -// Next increments the state and reports whether a check should be performed. -// -// Checks occur every Nth function call, where N is a triangular number: -// 0 1 3 6 10 15 21 28 36 45 55 66 78 91 105 120 136 153 171 190 ... -// See https://en.wikipedia.org/wiki/Triangular_number -// -// This sequence ensures that the cost of checks drops significantly as -// the number of functions calls grows larger. -func (dc *dynChecker) Next() bool { - ok := dc.curr == dc.next - if ok { - dc.curr = 0 - dc.next++ - } - dc.curr++ - return ok -} - -// makeAddressable returns a value that is always addressable. -// It returns the input verbatim if it is already addressable, -// otherwise it creates a new value and returns an addressable copy. -func makeAddressable(v reflect.Value) reflect.Value { - if v.CanAddr() { - return v - } - vc := reflect.New(v.Type()).Elem() - vc.Set(v) - return vc -} diff --git a/vendor/github.com/google/go-cmp/cmp/export_panic.go b/vendor/github.com/google/go-cmp/cmp/export_panic.go deleted file mode 100644 index abc3a1c3e7..0000000000 --- a/vendor/github.com/google/go-cmp/cmp/export_panic.go +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright 2017, The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE.md file. - -// +build purego - -package cmp - -import "reflect" - -const supportAllowUnexported = false - -func retrieveUnexportedField(reflect.Value, reflect.StructField) reflect.Value { - panic("retrieveUnexportedField is not implemented") -} diff --git a/vendor/github.com/google/go-cmp/cmp/export_unsafe.go b/vendor/github.com/google/go-cmp/cmp/export_unsafe.go deleted file mode 100644 index 59d4ee91b4..0000000000 --- a/vendor/github.com/google/go-cmp/cmp/export_unsafe.go +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2017, The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE.md file. - -// +build !purego - -package cmp - -import ( - "reflect" - "unsafe" -) - -const supportAllowUnexported = true - -// retrieveUnexportedField uses unsafe to forcibly retrieve any field from -// a struct such that the value has read-write permissions. -// -// The parent struct, v, must be addressable, while f must be a StructField -// describing the field to retrieve. -func retrieveUnexportedField(v reflect.Value, f reflect.StructField) reflect.Value { - return reflect.NewAt(f.Type, unsafe.Pointer(v.UnsafeAddr()+f.Offset)).Elem() -} diff --git a/vendor/github.com/google/go-cmp/cmp/internal/diff/debug_disable.go b/vendor/github.com/google/go-cmp/cmp/internal/diff/debug_disable.go deleted file mode 100644 index fe98dcc677..0000000000 --- a/vendor/github.com/google/go-cmp/cmp/internal/diff/debug_disable.go +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright 2017, The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE.md file. - -// +build !cmp_debug - -package diff - -var debug debugger - -type debugger struct{} - -func (debugger) Begin(_, _ int, f EqualFunc, _, _ *EditScript) EqualFunc { - return f -} -func (debugger) Update() {} -func (debugger) Finish() {} diff --git a/vendor/github.com/google/go-cmp/cmp/internal/diff/debug_enable.go b/vendor/github.com/google/go-cmp/cmp/internal/diff/debug_enable.go deleted file mode 100644 index 597b6ae56b..0000000000 --- a/vendor/github.com/google/go-cmp/cmp/internal/diff/debug_enable.go +++ /dev/null @@ -1,122 +0,0 @@ -// Copyright 2017, The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE.md file. - -// +build cmp_debug - -package diff - -import ( - "fmt" - "strings" - "sync" - "time" -) - -// The algorithm can be seen running in real-time by enabling debugging: -// go test -tags=cmp_debug -v -// -// Example output: -// === RUN TestDifference/#34 -// ┌───────────────────────────────┐ -// │ \ · · · · · · · · · · · · · · │ -// │ · # · · · · · · · · · · · · · │ -// │ · \ · · · · · · · · · · · · · │ -// │ · · \ · · · · · · · · · · · · │ -// │ · · · X # · · · · · · · · · · │ -// │ · · · # \ · · · · · · · · · · │ -// │ · · · · · # # · · · · · · · · │ -// │ · · · · · # \ · · · · · · · · │ -// │ · · · · · · · \ · · · · · · · │ -// │ · · · · · · · · \ · · · · · · │ -// │ · · · · · · · · · \ · · · · · │ -// │ · · · · · · · · · · \ · · # · │ -// │ · · · · · · · · · · · \ # # · │ -// │ · · · · · · · · · · · # # # · │ -// │ · · · · · · · · · · # # # # · │ -// │ · · · · · · · · · # # # # # · │ -// │ · · · · · · · · · · · · · · \ │ -// └───────────────────────────────┘ -// [.Y..M.XY......YXYXY.|] -// -// The grid represents the edit-graph where the horizontal axis represents -// list X and the vertical axis represents list Y. The start of the two lists -// is the top-left, while the ends are the bottom-right. The '·' represents -// an unexplored node in the graph. The '\' indicates that the two symbols -// from list X and Y are equal. The 'X' indicates that two symbols are similar -// (but not exactly equal) to each other. The '#' indicates that the two symbols -// are different (and not similar). The algorithm traverses this graph trying to -// make the paths starting in the top-left and the bottom-right connect. -// -// The series of '.', 'X', 'Y', and 'M' characters at the bottom represents -// the currently established path from the forward and reverse searches, -// separated by a '|' character. - -const ( - updateDelay = 100 * time.Millisecond - finishDelay = 500 * time.Millisecond - ansiTerminal = true // ANSI escape codes used to move terminal cursor -) - -var debug debugger - -type debugger struct { - sync.Mutex - p1, p2 EditScript - fwdPath, revPath *EditScript - grid []byte - lines int -} - -func (dbg *debugger) Begin(nx, ny int, f EqualFunc, p1, p2 *EditScript) EqualFunc { - dbg.Lock() - dbg.fwdPath, dbg.revPath = p1, p2 - top := "┌─" + strings.Repeat("──", nx) + "┐\n" - row := "│ " + strings.Repeat("· ", nx) + "│\n" - btm := "└─" + strings.Repeat("──", nx) + "┘\n" - dbg.grid = []byte(top + strings.Repeat(row, ny) + btm) - dbg.lines = strings.Count(dbg.String(), "\n") - fmt.Print(dbg) - - // Wrap the EqualFunc so that we can intercept each result. - return func(ix, iy int) (r Result) { - cell := dbg.grid[len(top)+iy*len(row):][len("│ ")+len("· ")*ix:][:len("·")] - for i := range cell { - cell[i] = 0 // Zero out the multiple bytes of UTF-8 middle-dot - } - switch r = f(ix, iy); { - case r.Equal(): - cell[0] = '\\' - case r.Similar(): - cell[0] = 'X' - default: - cell[0] = '#' - } - return - } -} - -func (dbg *debugger) Update() { - dbg.print(updateDelay) -} - -func (dbg *debugger) Finish() { - dbg.print(finishDelay) - dbg.Unlock() -} - -func (dbg *debugger) String() string { - dbg.p1, dbg.p2 = *dbg.fwdPath, dbg.p2[:0] - for i := len(*dbg.revPath) - 1; i >= 0; i-- { - dbg.p2 = append(dbg.p2, (*dbg.revPath)[i]) - } - return fmt.Sprintf("%s[%v|%v]\n\n", dbg.grid, dbg.p1, dbg.p2) -} - -func (dbg *debugger) print(d time.Duration) { - if ansiTerminal { - fmt.Printf("\x1b[%dA", dbg.lines) // Reset terminal cursor - } - fmt.Print(dbg) - time.Sleep(d) -} diff --git a/vendor/github.com/google/go-cmp/cmp/internal/diff/diff.go b/vendor/github.com/google/go-cmp/cmp/internal/diff/diff.go deleted file mode 100644 index 3d2e42662c..0000000000 --- a/vendor/github.com/google/go-cmp/cmp/internal/diff/diff.go +++ /dev/null @@ -1,372 +0,0 @@ -// Copyright 2017, The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE.md file. - -// Package diff implements an algorithm for producing edit-scripts. -// The edit-script is a sequence of operations needed to transform one list -// of symbols into another (or vice-versa). The edits allowed are insertions, -// deletions, and modifications. The summation of all edits is called the -// Levenshtein distance as this problem is well-known in computer science. -// -// This package prioritizes performance over accuracy. That is, the run time -// is more important than obtaining a minimal Levenshtein distance. -package diff - -// EditType represents a single operation within an edit-script. -type EditType uint8 - -const ( - // Identity indicates that a symbol pair is identical in both list X and Y. - Identity EditType = iota - // UniqueX indicates that a symbol only exists in X and not Y. - UniqueX - // UniqueY indicates that a symbol only exists in Y and not X. - UniqueY - // Modified indicates that a symbol pair is a modification of each other. - Modified -) - -// EditScript represents the series of differences between two lists. -type EditScript []EditType - -// String returns a human-readable string representing the edit-script where -// Identity, UniqueX, UniqueY, and Modified are represented by the -// '.', 'X', 'Y', and 'M' characters, respectively. -func (es EditScript) String() string { - b := make([]byte, len(es)) - for i, e := range es { - switch e { - case Identity: - b[i] = '.' - case UniqueX: - b[i] = 'X' - case UniqueY: - b[i] = 'Y' - case Modified: - b[i] = 'M' - default: - panic("invalid edit-type") - } - } - return string(b) -} - -// stats returns a histogram of the number of each type of edit operation. -func (es EditScript) stats() (s struct{ NI, NX, NY, NM int }) { - for _, e := range es { - switch e { - case Identity: - s.NI++ - case UniqueX: - s.NX++ - case UniqueY: - s.NY++ - case Modified: - s.NM++ - default: - panic("invalid edit-type") - } - } - return -} - -// Dist is the Levenshtein distance and is guaranteed to be 0 if and only if -// lists X and Y are equal. -func (es EditScript) Dist() int { return len(es) - es.stats().NI } - -// LenX is the length of the X list. -func (es EditScript) LenX() int { return len(es) - es.stats().NY } - -// LenY is the length of the Y list. -func (es EditScript) LenY() int { return len(es) - es.stats().NX } - -// EqualFunc reports whether the symbols at indexes ix and iy are equal. -// When called by Difference, the index is guaranteed to be within nx and ny. -type EqualFunc func(ix int, iy int) Result - -// Result is the result of comparison. -// NumSame is the number of sub-elements that are equal. -// NumDiff is the number of sub-elements that are not equal. -type Result struct{ NumSame, NumDiff int } - -// BoolResult returns a Result that is either Equal or not Equal. -func BoolResult(b bool) Result { - if b { - return Result{NumSame: 1} // Equal, Similar - } else { - return Result{NumDiff: 2} // Not Equal, not Similar - } -} - -// Equal indicates whether the symbols are equal. Two symbols are equal -// if and only if NumDiff == 0. If Equal, then they are also Similar. -func (r Result) Equal() bool { return r.NumDiff == 0 } - -// Similar indicates whether two symbols are similar and may be represented -// by using the Modified type. As a special case, we consider binary comparisons -// (i.e., those that return Result{1, 0} or Result{0, 1}) to be similar. -// -// The exact ratio of NumSame to NumDiff to determine similarity may change. -func (r Result) Similar() bool { - // Use NumSame+1 to offset NumSame so that binary comparisons are similar. - return r.NumSame+1 >= r.NumDiff -} - -// Difference reports whether two lists of lengths nx and ny are equal -// given the definition of equality provided as f. -// -// This function returns an edit-script, which is a sequence of operations -// needed to convert one list into the other. The following invariants for -// the edit-script are maintained: -// • eq == (es.Dist()==0) -// • nx == es.LenX() -// • ny == es.LenY() -// -// This algorithm is not guaranteed to be an optimal solution (i.e., one that -// produces an edit-script with a minimal Levenshtein distance). This algorithm -// favors performance over optimality. The exact output is not guaranteed to -// be stable and may change over time. -func Difference(nx, ny int, f EqualFunc) (es EditScript) { - // This algorithm is based on traversing what is known as an "edit-graph". - // See Figure 1 from "An O(ND) Difference Algorithm and Its Variations" - // by Eugene W. Myers. Since D can be as large as N itself, this is - // effectively O(N^2). Unlike the algorithm from that paper, we are not - // interested in the optimal path, but at least some "decent" path. - // - // For example, let X and Y be lists of symbols: - // X = [A B C A B B A] - // Y = [C B A B A C] - // - // The edit-graph can be drawn as the following: - // A B C A B B A - // ┌─────────────┐ - // C │_|_|\|_|_|_|_│ 0 - // B │_|\|_|_|\|\|_│ 1 - // A │\|_|_|\|_|_|\│ 2 - // B │_|\|_|_|\|\|_│ 3 - // A │\|_|_|\|_|_|\│ 4 - // C │ | |\| | | | │ 5 - // └─────────────┘ 6 - // 0 1 2 3 4 5 6 7 - // - // List X is written along the horizontal axis, while list Y is written - // along the vertical axis. At any point on this grid, if the symbol in - // list X matches the corresponding symbol in list Y, then a '\' is drawn. - // The goal of any minimal edit-script algorithm is to find a path from the - // top-left corner to the bottom-right corner, while traveling through the - // fewest horizontal or vertical edges. - // A horizontal edge is equivalent to inserting a symbol from list X. - // A vertical edge is equivalent to inserting a symbol from list Y. - // A diagonal edge is equivalent to a matching symbol between both X and Y. - - // Invariants: - // • 0 ≤ fwdPath.X ≤ (fwdFrontier.X, revFrontier.X) ≤ revPath.X ≤ nx - // • 0 ≤ fwdPath.Y ≤ (fwdFrontier.Y, revFrontier.Y) ≤ revPath.Y ≤ ny - // - // In general: - // • fwdFrontier.X < revFrontier.X - // • fwdFrontier.Y < revFrontier.Y - // Unless, it is time for the algorithm to terminate. - fwdPath := path{+1, point{0, 0}, make(EditScript, 0, (nx+ny)/2)} - revPath := path{-1, point{nx, ny}, make(EditScript, 0)} - fwdFrontier := fwdPath.point // Forward search frontier - revFrontier := revPath.point // Reverse search frontier - - // Search budget bounds the cost of searching for better paths. - // The longest sequence of non-matching symbols that can be tolerated is - // approximately the square-root of the search budget. - searchBudget := 4 * (nx + ny) // O(n) - - // The algorithm below is a greedy, meet-in-the-middle algorithm for - // computing sub-optimal edit-scripts between two lists. - // - // The algorithm is approximately as follows: - // • Searching for differences switches back-and-forth between - // a search that starts at the beginning (the top-left corner), and - // a search that starts at the end (the bottom-right corner). The goal of - // the search is connect with the search from the opposite corner. - // • As we search, we build a path in a greedy manner, where the first - // match seen is added to the path (this is sub-optimal, but provides a - // decent result in practice). When matches are found, we try the next pair - // of symbols in the lists and follow all matches as far as possible. - // • When searching for matches, we search along a diagonal going through - // through the "frontier" point. If no matches are found, we advance the - // frontier towards the opposite corner. - // • This algorithm terminates when either the X coordinates or the - // Y coordinates of the forward and reverse frontier points ever intersect. - // - // This algorithm is correct even if searching only in the forward direction - // or in the reverse direction. We do both because it is commonly observed - // that two lists commonly differ because elements were added to the front - // or end of the other list. - // - // Running the tests with the "cmp_debug" build tag prints a visualization - // of the algorithm running in real-time. This is educational for - // understanding how the algorithm works. See debug_enable.go. - f = debug.Begin(nx, ny, f, &fwdPath.es, &revPath.es) - for { - // Forward search from the beginning. - if fwdFrontier.X >= revFrontier.X || fwdFrontier.Y >= revFrontier.Y || searchBudget == 0 { - break - } - for stop1, stop2, i := false, false, 0; !(stop1 && stop2) && searchBudget > 0; i++ { - // Search in a diagonal pattern for a match. - z := zigzag(i) - p := point{fwdFrontier.X + z, fwdFrontier.Y - z} - switch { - case p.X >= revPath.X || p.Y < fwdPath.Y: - stop1 = true // Hit top-right corner - case p.Y >= revPath.Y || p.X < fwdPath.X: - stop2 = true // Hit bottom-left corner - case f(p.X, p.Y).Equal(): - // Match found, so connect the path to this point. - fwdPath.connect(p, f) - fwdPath.append(Identity) - // Follow sequence of matches as far as possible. - for fwdPath.X < revPath.X && fwdPath.Y < revPath.Y { - if !f(fwdPath.X, fwdPath.Y).Equal() { - break - } - fwdPath.append(Identity) - } - fwdFrontier = fwdPath.point - stop1, stop2 = true, true - default: - searchBudget-- // Match not found - } - debug.Update() - } - // Advance the frontier towards reverse point. - if revPath.X-fwdFrontier.X >= revPath.Y-fwdFrontier.Y { - fwdFrontier.X++ - } else { - fwdFrontier.Y++ - } - - // Reverse search from the end. - if fwdFrontier.X >= revFrontier.X || fwdFrontier.Y >= revFrontier.Y || searchBudget == 0 { - break - } - for stop1, stop2, i := false, false, 0; !(stop1 && stop2) && searchBudget > 0; i++ { - // Search in a diagonal pattern for a match. - z := zigzag(i) - p := point{revFrontier.X - z, revFrontier.Y + z} - switch { - case fwdPath.X >= p.X || revPath.Y < p.Y: - stop1 = true // Hit bottom-left corner - case fwdPath.Y >= p.Y || revPath.X < p.X: - stop2 = true // Hit top-right corner - case f(p.X-1, p.Y-1).Equal(): - // Match found, so connect the path to this point. - revPath.connect(p, f) - revPath.append(Identity) - // Follow sequence of matches as far as possible. - for fwdPath.X < revPath.X && fwdPath.Y < revPath.Y { - if !f(revPath.X-1, revPath.Y-1).Equal() { - break - } - revPath.append(Identity) - } - revFrontier = revPath.point - stop1, stop2 = true, true - default: - searchBudget-- // Match not found - } - debug.Update() - } - // Advance the frontier towards forward point. - if revFrontier.X-fwdPath.X >= revFrontier.Y-fwdPath.Y { - revFrontier.X-- - } else { - revFrontier.Y-- - } - } - - // Join the forward and reverse paths and then append the reverse path. - fwdPath.connect(revPath.point, f) - for i := len(revPath.es) - 1; i >= 0; i-- { - t := revPath.es[i] - revPath.es = revPath.es[:i] - fwdPath.append(t) - } - debug.Finish() - return fwdPath.es -} - -type path struct { - dir int // +1 if forward, -1 if reverse - point // Leading point of the EditScript path - es EditScript -} - -// connect appends any necessary Identity, Modified, UniqueX, or UniqueY types -// to the edit-script to connect p.point to dst. -func (p *path) connect(dst point, f EqualFunc) { - if p.dir > 0 { - // Connect in forward direction. - for dst.X > p.X && dst.Y > p.Y { - switch r := f(p.X, p.Y); { - case r.Equal(): - p.append(Identity) - case r.Similar(): - p.append(Modified) - case dst.X-p.X >= dst.Y-p.Y: - p.append(UniqueX) - default: - p.append(UniqueY) - } - } - for dst.X > p.X { - p.append(UniqueX) - } - for dst.Y > p.Y { - p.append(UniqueY) - } - } else { - // Connect in reverse direction. - for p.X > dst.X && p.Y > dst.Y { - switch r := f(p.X-1, p.Y-1); { - case r.Equal(): - p.append(Identity) - case r.Similar(): - p.append(Modified) - case p.Y-dst.Y >= p.X-dst.X: - p.append(UniqueY) - default: - p.append(UniqueX) - } - } - for p.X > dst.X { - p.append(UniqueX) - } - for p.Y > dst.Y { - p.append(UniqueY) - } - } -} - -func (p *path) append(t EditType) { - p.es = append(p.es, t) - switch t { - case Identity, Modified: - p.add(p.dir, p.dir) - case UniqueX: - p.add(p.dir, 0) - case UniqueY: - p.add(0, p.dir) - } - debug.Update() -} - -type point struct{ X, Y int } - -func (p *point) add(dx, dy int) { p.X += dx; p.Y += dy } - -// zigzag maps a consecutive sequence of integers to a zig-zag sequence. -// [0 1 2 3 4 5 ...] => [0 -1 +1 -2 +2 ...] -func zigzag(x int) int { - if x&1 != 0 { - x = ^x - } - return x >> 1 -} diff --git a/vendor/github.com/google/go-cmp/cmp/internal/flags/flags.go b/vendor/github.com/google/go-cmp/cmp/internal/flags/flags.go deleted file mode 100644 index a9e7fc0b5b..0000000000 --- a/vendor/github.com/google/go-cmp/cmp/internal/flags/flags.go +++ /dev/null @@ -1,9 +0,0 @@ -// Copyright 2019, The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE.md file. - -package flags - -// Deterministic controls whether the output of Diff should be deterministic. -// This is only used for testing. -var Deterministic bool diff --git a/vendor/github.com/google/go-cmp/cmp/internal/flags/toolchain_legacy.go b/vendor/github.com/google/go-cmp/cmp/internal/flags/toolchain_legacy.go deleted file mode 100644 index 01aed0a153..0000000000 --- a/vendor/github.com/google/go-cmp/cmp/internal/flags/toolchain_legacy.go +++ /dev/null @@ -1,10 +0,0 @@ -// Copyright 2019, The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE.md file. - -// +build !go1.10 - -package flags - -// AtLeastGo110 reports whether the Go toolchain is at least Go 1.10. -const AtLeastGo110 = false diff --git a/vendor/github.com/google/go-cmp/cmp/internal/flags/toolchain_recent.go b/vendor/github.com/google/go-cmp/cmp/internal/flags/toolchain_recent.go deleted file mode 100644 index c0b667f58b..0000000000 --- a/vendor/github.com/google/go-cmp/cmp/internal/flags/toolchain_recent.go +++ /dev/null @@ -1,10 +0,0 @@ -// Copyright 2019, The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE.md file. - -// +build go1.10 - -package flags - -// AtLeastGo110 reports whether the Go toolchain is at least Go 1.10. -const AtLeastGo110 = true diff --git a/vendor/github.com/google/go-cmp/cmp/internal/function/func.go b/vendor/github.com/google/go-cmp/cmp/internal/function/func.go deleted file mode 100644 index ace1dbe86e..0000000000 --- a/vendor/github.com/google/go-cmp/cmp/internal/function/func.go +++ /dev/null @@ -1,99 +0,0 @@ -// Copyright 2017, The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE.md file. - -// Package function provides functionality for identifying function types. -package function - -import ( - "reflect" - "regexp" - "runtime" - "strings" -) - -type funcType int - -const ( - _ funcType = iota - - tbFunc // func(T) bool - ttbFunc // func(T, T) bool - trbFunc // func(T, R) bool - tibFunc // func(T, I) bool - trFunc // func(T) R - - Equal = ttbFunc // func(T, T) bool - EqualAssignable = tibFunc // func(T, I) bool; encapsulates func(T, T) bool - Transformer = trFunc // func(T) R - ValueFilter = ttbFunc // func(T, T) bool - Less = ttbFunc // func(T, T) bool - ValuePredicate = tbFunc // func(T) bool - KeyValuePredicate = trbFunc // func(T, R) bool -) - -var boolType = reflect.TypeOf(true) - -// IsType reports whether the reflect.Type is of the specified function type. -func IsType(t reflect.Type, ft funcType) bool { - if t == nil || t.Kind() != reflect.Func || t.IsVariadic() { - return false - } - ni, no := t.NumIn(), t.NumOut() - switch ft { - case tbFunc: // func(T) bool - if ni == 1 && no == 1 && t.Out(0) == boolType { - return true - } - case ttbFunc: // func(T, T) bool - if ni == 2 && no == 1 && t.In(0) == t.In(1) && t.Out(0) == boolType { - return true - } - case trbFunc: // func(T, R) bool - if ni == 2 && no == 1 && t.Out(0) == boolType { - return true - } - case tibFunc: // func(T, I) bool - if ni == 2 && no == 1 && t.In(0).AssignableTo(t.In(1)) && t.Out(0) == boolType { - return true - } - case trFunc: // func(T) R - if ni == 1 && no == 1 { - return true - } - } - return false -} - -var lastIdentRx = regexp.MustCompile(`[_\p{L}][_\p{L}\p{N}]*$`) - -// NameOf returns the name of the function value. -func NameOf(v reflect.Value) string { - fnc := runtime.FuncForPC(v.Pointer()) - if fnc == nil { - return "" - } - fullName := fnc.Name() // e.g., "long/path/name/mypkg.(*MyType).(long/path/name/mypkg.myMethod)-fm" - - // Method closures have a "-fm" suffix. - fullName = strings.TrimSuffix(fullName, "-fm") - - var name string - for len(fullName) > 0 { - inParen := strings.HasSuffix(fullName, ")") - fullName = strings.TrimSuffix(fullName, ")") - - s := lastIdentRx.FindString(fullName) - if s == "" { - break - } - name = s + "." + name - fullName = strings.TrimSuffix(fullName, s) - - if i := strings.LastIndexByte(fullName, '('); inParen && i >= 0 { - fullName = fullName[:i] - } - fullName = strings.TrimSuffix(fullName, ".") - } - return strings.TrimSuffix(name, ".") -} diff --git a/vendor/github.com/google/go-cmp/cmp/internal/value/pointer_purego.go b/vendor/github.com/google/go-cmp/cmp/internal/value/pointer_purego.go deleted file mode 100644 index 0a01c4796f..0000000000 --- a/vendor/github.com/google/go-cmp/cmp/internal/value/pointer_purego.go +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2018, The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE.md file. - -// +build purego - -package value - -import "reflect" - -// Pointer is an opaque typed pointer and is guaranteed to be comparable. -type Pointer struct { - p uintptr - t reflect.Type -} - -// PointerOf returns a Pointer from v, which must be a -// reflect.Ptr, reflect.Slice, or reflect.Map. -func PointerOf(v reflect.Value) Pointer { - // NOTE: Storing a pointer as an uintptr is technically incorrect as it - // assumes that the GC implementation does not use a moving collector. - return Pointer{v.Pointer(), v.Type()} -} diff --git a/vendor/github.com/google/go-cmp/cmp/internal/value/pointer_unsafe.go b/vendor/github.com/google/go-cmp/cmp/internal/value/pointer_unsafe.go deleted file mode 100644 index da134ae2a8..0000000000 --- a/vendor/github.com/google/go-cmp/cmp/internal/value/pointer_unsafe.go +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright 2018, The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE.md file. - -// +build !purego - -package value - -import ( - "reflect" - "unsafe" -) - -// Pointer is an opaque typed pointer and is guaranteed to be comparable. -type Pointer struct { - p unsafe.Pointer - t reflect.Type -} - -// PointerOf returns a Pointer from v, which must be a -// reflect.Ptr, reflect.Slice, or reflect.Map. -func PointerOf(v reflect.Value) Pointer { - // The proper representation of a pointer is unsafe.Pointer, - // which is necessary if the GC ever uses a moving collector. - return Pointer{unsafe.Pointer(v.Pointer()), v.Type()} -} diff --git a/vendor/github.com/google/go-cmp/cmp/internal/value/sort.go b/vendor/github.com/google/go-cmp/cmp/internal/value/sort.go deleted file mode 100644 index 24fbae6e3c..0000000000 --- a/vendor/github.com/google/go-cmp/cmp/internal/value/sort.go +++ /dev/null @@ -1,106 +0,0 @@ -// Copyright 2017, The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE.md file. - -package value - -import ( - "fmt" - "math" - "reflect" - "sort" -) - -// SortKeys sorts a list of map keys, deduplicating keys if necessary. -// The type of each value must be comparable. -func SortKeys(vs []reflect.Value) []reflect.Value { - if len(vs) == 0 { - return vs - } - - // Sort the map keys. - sort.SliceStable(vs, func(i, j int) bool { return isLess(vs[i], vs[j]) }) - - // Deduplicate keys (fails for NaNs). - vs2 := vs[:1] - for _, v := range vs[1:] { - if isLess(vs2[len(vs2)-1], v) { - vs2 = append(vs2, v) - } - } - return vs2 -} - -// isLess is a generic function for sorting arbitrary map keys. -// The inputs must be of the same type and must be comparable. -func isLess(x, y reflect.Value) bool { - switch x.Type().Kind() { - case reflect.Bool: - return !x.Bool() && y.Bool() - case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: - return x.Int() < y.Int() - case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr: - return x.Uint() < y.Uint() - case reflect.Float32, reflect.Float64: - // NOTE: This does not sort -0 as less than +0 - // since Go maps treat -0 and +0 as equal keys. - fx, fy := x.Float(), y.Float() - return fx < fy || math.IsNaN(fx) && !math.IsNaN(fy) - case reflect.Complex64, reflect.Complex128: - cx, cy := x.Complex(), y.Complex() - rx, ix, ry, iy := real(cx), imag(cx), real(cy), imag(cy) - if rx == ry || (math.IsNaN(rx) && math.IsNaN(ry)) { - return ix < iy || math.IsNaN(ix) && !math.IsNaN(iy) - } - return rx < ry || math.IsNaN(rx) && !math.IsNaN(ry) - case reflect.Ptr, reflect.UnsafePointer, reflect.Chan: - return x.Pointer() < y.Pointer() - case reflect.String: - return x.String() < y.String() - case reflect.Array: - for i := 0; i < x.Len(); i++ { - if isLess(x.Index(i), y.Index(i)) { - return true - } - if isLess(y.Index(i), x.Index(i)) { - return false - } - } - return false - case reflect.Struct: - for i := 0; i < x.NumField(); i++ { - if isLess(x.Field(i), y.Field(i)) { - return true - } - if isLess(y.Field(i), x.Field(i)) { - return false - } - } - return false - case reflect.Interface: - vx, vy := x.Elem(), y.Elem() - if !vx.IsValid() || !vy.IsValid() { - return !vx.IsValid() && vy.IsValid() - } - tx, ty := vx.Type(), vy.Type() - if tx == ty { - return isLess(x.Elem(), y.Elem()) - } - if tx.Kind() != ty.Kind() { - return vx.Kind() < vy.Kind() - } - if tx.String() != ty.String() { - return tx.String() < ty.String() - } - if tx.PkgPath() != ty.PkgPath() { - return tx.PkgPath() < ty.PkgPath() - } - // This can happen in rare situations, so we fallback to just comparing - // the unique pointer for a reflect.Type. This guarantees deterministic - // ordering within a program, but it is obviously not stable. - return reflect.ValueOf(vx.Type()).Pointer() < reflect.ValueOf(vy.Type()).Pointer() - default: - // Must be Func, Map, or Slice; which are not comparable. - panic(fmt.Sprintf("%T is not comparable", x.Type())) - } -} diff --git a/vendor/github.com/google/go-cmp/cmp/internal/value/zero.go b/vendor/github.com/google/go-cmp/cmp/internal/value/zero.go deleted file mode 100644 index 06a8ffd036..0000000000 --- a/vendor/github.com/google/go-cmp/cmp/internal/value/zero.go +++ /dev/null @@ -1,48 +0,0 @@ -// Copyright 2017, The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE.md file. - -package value - -import ( - "math" - "reflect" -) - -// IsZero reports whether v is the zero value. -// This does not rely on Interface and so can be used on unexported fields. -func IsZero(v reflect.Value) bool { - switch v.Kind() { - case reflect.Bool: - return v.Bool() == false - case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: - return v.Int() == 0 - case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr: - return v.Uint() == 0 - case reflect.Float32, reflect.Float64: - return math.Float64bits(v.Float()) == 0 - case reflect.Complex64, reflect.Complex128: - return math.Float64bits(real(v.Complex())) == 0 && math.Float64bits(imag(v.Complex())) == 0 - case reflect.String: - return v.String() == "" - case reflect.UnsafePointer: - return v.Pointer() == 0 - case reflect.Chan, reflect.Func, reflect.Interface, reflect.Ptr, reflect.Map, reflect.Slice: - return v.IsNil() - case reflect.Array: - for i := 0; i < v.Len(); i++ { - if !IsZero(v.Index(i)) { - return false - } - } - return true - case reflect.Struct: - for i := 0; i < v.NumField(); i++ { - if !IsZero(v.Field(i)) { - return false - } - } - return true - } - return false -} diff --git a/vendor/github.com/google/go-cmp/cmp/options.go b/vendor/github.com/google/go-cmp/cmp/options.go deleted file mode 100644 index 793448160e..0000000000 --- a/vendor/github.com/google/go-cmp/cmp/options.go +++ /dev/null @@ -1,524 +0,0 @@ -// Copyright 2017, The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE.md file. - -package cmp - -import ( - "fmt" - "reflect" - "regexp" - "strings" - - "github.com/google/go-cmp/cmp/internal/function" -) - -// Option configures for specific behavior of Equal and Diff. In particular, -// the fundamental Option functions (Ignore, Transformer, and Comparer), -// configure how equality is determined. -// -// The fundamental options may be composed with filters (FilterPath and -// FilterValues) to control the scope over which they are applied. -// -// The cmp/cmpopts package provides helper functions for creating options that -// may be used with Equal and Diff. -type Option interface { - // filter applies all filters and returns the option that remains. - // Each option may only read s.curPath and call s.callTTBFunc. - // - // An Options is returned only if multiple comparers or transformers - // can apply simultaneously and will only contain values of those types - // or sub-Options containing values of those types. - filter(s *state, t reflect.Type, vx, vy reflect.Value) applicableOption -} - -// applicableOption represents the following types: -// Fundamental: ignore | validator | *comparer | *transformer -// Grouping: Options -type applicableOption interface { - Option - - // apply executes the option, which may mutate s or panic. - apply(s *state, vx, vy reflect.Value) -} - -// coreOption represents the following types: -// Fundamental: ignore | validator | *comparer | *transformer -// Filters: *pathFilter | *valuesFilter -type coreOption interface { - Option - isCore() -} - -type core struct{} - -func (core) isCore() {} - -// Options is a list of Option values that also satisfies the Option interface. -// Helper comparison packages may return an Options value when packing multiple -// Option values into a single Option. When this package processes an Options, -// it will be implicitly expanded into a flat list. -// -// Applying a filter on an Options is equivalent to applying that same filter -// on all individual options held within. -type Options []Option - -func (opts Options) filter(s *state, t reflect.Type, vx, vy reflect.Value) (out applicableOption) { - for _, opt := range opts { - switch opt := opt.filter(s, t, vx, vy); opt.(type) { - case ignore: - return ignore{} // Only ignore can short-circuit evaluation - case validator: - out = validator{} // Takes precedence over comparer or transformer - case *comparer, *transformer, Options: - switch out.(type) { - case nil: - out = opt - case validator: - // Keep validator - case *comparer, *transformer, Options: - out = Options{out, opt} // Conflicting comparers or transformers - } - } - } - return out -} - -func (opts Options) apply(s *state, _, _ reflect.Value) { - const warning = "ambiguous set of applicable options" - const help = "consider using filters to ensure at most one Comparer or Transformer may apply" - var ss []string - for _, opt := range flattenOptions(nil, opts) { - ss = append(ss, fmt.Sprint(opt)) - } - set := strings.Join(ss, "\n\t") - panic(fmt.Sprintf("%s at %#v:\n\t%s\n%s", warning, s.curPath, set, help)) -} - -func (opts Options) String() string { - var ss []string - for _, opt := range opts { - ss = append(ss, fmt.Sprint(opt)) - } - return fmt.Sprintf("Options{%s}", strings.Join(ss, ", ")) -} - -// FilterPath returns a new Option where opt is only evaluated if filter f -// returns true for the current Path in the value tree. -// -// This filter is called even if a slice element or map entry is missing and -// provides an opportunity to ignore such cases. The filter function must be -// symmetric such that the filter result is identical regardless of whether the -// missing value is from x or y. -// -// The option passed in may be an Ignore, Transformer, Comparer, Options, or -// a previously filtered Option. -func FilterPath(f func(Path) bool, opt Option) Option { - if f == nil { - panic("invalid path filter function") - } - if opt := normalizeOption(opt); opt != nil { - return &pathFilter{fnc: f, opt: opt} - } - return nil -} - -type pathFilter struct { - core - fnc func(Path) bool - opt Option -} - -func (f pathFilter) filter(s *state, t reflect.Type, vx, vy reflect.Value) applicableOption { - if f.fnc(s.curPath) { - return f.opt.filter(s, t, vx, vy) - } - return nil -} - -func (f pathFilter) String() string { - return fmt.Sprintf("FilterPath(%s, %v)", function.NameOf(reflect.ValueOf(f.fnc)), f.opt) -} - -// FilterValues returns a new Option where opt is only evaluated if filter f, -// which is a function of the form "func(T, T) bool", returns true for the -// current pair of values being compared. If either value is invalid or -// the type of the values is not assignable to T, then this filter implicitly -// returns false. -// -// The filter function must be -// symmetric (i.e., agnostic to the order of the inputs) and -// deterministic (i.e., produces the same result when given the same inputs). -// If T is an interface, it is possible that f is called with two values with -// different concrete types that both implement T. -// -// The option passed in may be an Ignore, Transformer, Comparer, Options, or -// a previously filtered Option. -func FilterValues(f interface{}, opt Option) Option { - v := reflect.ValueOf(f) - if !function.IsType(v.Type(), function.ValueFilter) || v.IsNil() { - panic(fmt.Sprintf("invalid values filter function: %T", f)) - } - if opt := normalizeOption(opt); opt != nil { - vf := &valuesFilter{fnc: v, opt: opt} - if ti := v.Type().In(0); ti.Kind() != reflect.Interface || ti.NumMethod() > 0 { - vf.typ = ti - } - return vf - } - return nil -} - -type valuesFilter struct { - core - typ reflect.Type // T - fnc reflect.Value // func(T, T) bool - opt Option -} - -func (f valuesFilter) filter(s *state, t reflect.Type, vx, vy reflect.Value) applicableOption { - if !vx.IsValid() || !vx.CanInterface() || !vy.IsValid() || !vy.CanInterface() { - return nil - } - if (f.typ == nil || t.AssignableTo(f.typ)) && s.callTTBFunc(f.fnc, vx, vy) { - return f.opt.filter(s, t, vx, vy) - } - return nil -} - -func (f valuesFilter) String() string { - return fmt.Sprintf("FilterValues(%s, %v)", function.NameOf(f.fnc), f.opt) -} - -// Ignore is an Option that causes all comparisons to be ignored. -// This value is intended to be combined with FilterPath or FilterValues. -// It is an error to pass an unfiltered Ignore option to Equal. -func Ignore() Option { return ignore{} } - -type ignore struct{ core } - -func (ignore) isFiltered() bool { return false } -func (ignore) filter(_ *state, _ reflect.Type, _, _ reflect.Value) applicableOption { return ignore{} } -func (ignore) apply(s *state, _, _ reflect.Value) { s.report(true, reportByIgnore) } -func (ignore) String() string { return "Ignore()" } - -// validator is a sentinel Option type to indicate that some options could not -// be evaluated due to unexported fields, missing slice elements, or -// missing map entries. Both values are validator only for unexported fields. -type validator struct{ core } - -func (validator) filter(_ *state, _ reflect.Type, vx, vy reflect.Value) applicableOption { - if !vx.IsValid() || !vy.IsValid() { - return validator{} - } - if !vx.CanInterface() || !vy.CanInterface() { - return validator{} - } - return nil -} -func (validator) apply(s *state, vx, vy reflect.Value) { - // Implies missing slice element or map entry. - if !vx.IsValid() || !vy.IsValid() { - s.report(vx.IsValid() == vy.IsValid(), 0) - return - } - - // Unable to Interface implies unexported field without visibility access. - if !vx.CanInterface() || !vy.CanInterface() { - const help = "consider using a custom Comparer; if you control the implementation of type, you can also consider AllowUnexported or cmpopts.IgnoreUnexported" - panic(fmt.Sprintf("cannot handle unexported field: %#v\n%s", s.curPath, help)) - } - - panic("not reachable") -} - -// identRx represents a valid identifier according to the Go specification. -const identRx = `[_\p{L}][_\p{L}\p{N}]*` - -var identsRx = regexp.MustCompile(`^` + identRx + `(\.` + identRx + `)*$`) - -// Transformer returns an Option that applies a transformation function that -// converts values of a certain type into that of another. -// -// The transformer f must be a function "func(T) R" that converts values of -// type T to those of type R and is implicitly filtered to input values -// assignable to T. The transformer must not mutate T in any way. -// -// To help prevent some cases of infinite recursive cycles applying the -// same transform to the output of itself (e.g., in the case where the -// input and output types are the same), an implicit filter is added such that -// a transformer is applicable only if that exact transformer is not already -// in the tail of the Path since the last non-Transform step. -// For situations where the implicit filter is still insufficient, -// consider using cmpopts.AcyclicTransformer, which adds a filter -// to prevent the transformer from being recursively applied upon itself. -// -// The name is a user provided label that is used as the Transform.Name in the -// transformation PathStep (and eventually shown in the Diff output). -// The name must be a valid identifier or qualified identifier in Go syntax. -// If empty, an arbitrary name is used. -func Transformer(name string, f interface{}) Option { - v := reflect.ValueOf(f) - if !function.IsType(v.Type(), function.Transformer) || v.IsNil() { - panic(fmt.Sprintf("invalid transformer function: %T", f)) - } - if name == "" { - name = function.NameOf(v) - if !identsRx.MatchString(name) { - name = "λ" // Lambda-symbol as placeholder name - } - } else if !identsRx.MatchString(name) { - panic(fmt.Sprintf("invalid name: %q", name)) - } - tr := &transformer{name: name, fnc: reflect.ValueOf(f)} - if ti := v.Type().In(0); ti.Kind() != reflect.Interface || ti.NumMethod() > 0 { - tr.typ = ti - } - return tr -} - -type transformer struct { - core - name string - typ reflect.Type // T - fnc reflect.Value // func(T) R -} - -func (tr *transformer) isFiltered() bool { return tr.typ != nil } - -func (tr *transformer) filter(s *state, t reflect.Type, _, _ reflect.Value) applicableOption { - for i := len(s.curPath) - 1; i >= 0; i-- { - if t, ok := s.curPath[i].(Transform); !ok { - break // Hit most recent non-Transform step - } else if tr == t.trans { - return nil // Cannot directly use same Transform - } - } - if tr.typ == nil || t.AssignableTo(tr.typ) { - return tr - } - return nil -} - -func (tr *transformer) apply(s *state, vx, vy reflect.Value) { - step := Transform{&transform{pathStep{typ: tr.fnc.Type().Out(0)}, tr}} - vvx := s.callTRFunc(tr.fnc, vx, step) - vvy := s.callTRFunc(tr.fnc, vy, step) - step.vx, step.vy = vvx, vvy - s.compareAny(step) -} - -func (tr transformer) String() string { - return fmt.Sprintf("Transformer(%s, %s)", tr.name, function.NameOf(tr.fnc)) -} - -// Comparer returns an Option that determines whether two values are equal -// to each other. -// -// The comparer f must be a function "func(T, T) bool" and is implicitly -// filtered to input values assignable to T. If T is an interface, it is -// possible that f is called with two values of different concrete types that -// both implement T. -// -// The equality function must be: -// • Symmetric: equal(x, y) == equal(y, x) -// • Deterministic: equal(x, y) == equal(x, y) -// • Pure: equal(x, y) does not modify x or y -func Comparer(f interface{}) Option { - v := reflect.ValueOf(f) - if !function.IsType(v.Type(), function.Equal) || v.IsNil() { - panic(fmt.Sprintf("invalid comparer function: %T", f)) - } - cm := &comparer{fnc: v} - if ti := v.Type().In(0); ti.Kind() != reflect.Interface || ti.NumMethod() > 0 { - cm.typ = ti - } - return cm -} - -type comparer struct { - core - typ reflect.Type // T - fnc reflect.Value // func(T, T) bool -} - -func (cm *comparer) isFiltered() bool { return cm.typ != nil } - -func (cm *comparer) filter(_ *state, t reflect.Type, _, _ reflect.Value) applicableOption { - if cm.typ == nil || t.AssignableTo(cm.typ) { - return cm - } - return nil -} - -func (cm *comparer) apply(s *state, vx, vy reflect.Value) { - eq := s.callTTBFunc(cm.fnc, vx, vy) - s.report(eq, reportByFunc) -} - -func (cm comparer) String() string { - return fmt.Sprintf("Comparer(%s)", function.NameOf(cm.fnc)) -} - -// AllowUnexported returns an Option that forcibly allows operations on -// unexported fields in certain structs, which are specified by passing in a -// value of each struct type. -// -// Users of this option must understand that comparing on unexported fields -// from external packages is not safe since changes in the internal -// implementation of some external package may cause the result of Equal -// to unexpectedly change. However, it may be valid to use this option on types -// defined in an internal package where the semantic meaning of an unexported -// field is in the control of the user. -// -// In many cases, a custom Comparer should be used instead that defines -// equality as a function of the public API of a type rather than the underlying -// unexported implementation. -// -// For example, the reflect.Type documentation defines equality to be determined -// by the == operator on the interface (essentially performing a shallow pointer -// comparison) and most attempts to compare *regexp.Regexp types are interested -// in only checking that the regular expression strings are equal. -// Both of these are accomplished using Comparers: -// -// Comparer(func(x, y reflect.Type) bool { return x == y }) -// Comparer(func(x, y *regexp.Regexp) bool { return x.String() == y.String() }) -// -// In other cases, the cmpopts.IgnoreUnexported option can be used to ignore -// all unexported fields on specified struct types. -func AllowUnexported(types ...interface{}) Option { - if !supportAllowUnexported { - panic("AllowUnexported is not supported on purego builds, Google App Engine Standard, or GopherJS") - } - m := make(map[reflect.Type]bool) - for _, typ := range types { - t := reflect.TypeOf(typ) - if t.Kind() != reflect.Struct { - panic(fmt.Sprintf("invalid struct type: %T", typ)) - } - m[t] = true - } - return visibleStructs(m) -} - -type visibleStructs map[reflect.Type]bool - -func (visibleStructs) filter(_ *state, _ reflect.Type, _, _ reflect.Value) applicableOption { - panic("not implemented") -} - -// Result represents the comparison result for a single node and -// is provided by cmp when calling Result (see Reporter). -type Result struct { - _ [0]func() // Make Result incomparable - flags resultFlags -} - -// Equal reports whether the node was determined to be equal or not. -// As a special case, ignored nodes are considered equal. -func (r Result) Equal() bool { - return r.flags&(reportEqual|reportByIgnore) != 0 -} - -// ByIgnore reports whether the node is equal because it was ignored. -// This never reports true if Equal reports false. -func (r Result) ByIgnore() bool { - return r.flags&reportByIgnore != 0 -} - -// ByMethod reports whether the Equal method determined equality. -func (r Result) ByMethod() bool { - return r.flags&reportByMethod != 0 -} - -// ByFunc reports whether a Comparer function determined equality. -func (r Result) ByFunc() bool { - return r.flags&reportByFunc != 0 -} - -type resultFlags uint - -const ( - _ resultFlags = (1 << iota) / 2 - - reportEqual - reportUnequal - reportByIgnore - reportByMethod - reportByFunc -) - -// Reporter is an Option that can be passed to Equal. When Equal traverses -// the value trees, it calls PushStep as it descends into each node in the -// tree and PopStep as it ascend out of the node. The leaves of the tree are -// either compared (determined to be equal or not equal) or ignored and reported -// as such by calling the Report method. -func Reporter(r interface { - // PushStep is called when a tree-traversal operation is performed. - // The PathStep itself is only valid until the step is popped. - // The PathStep.Values are valid for the duration of the entire traversal - // and must not be mutated. - // - // Equal always calls PushStep at the start to provide an operation-less - // PathStep used to report the root values. - // - // Within a slice, the exact set of inserted, removed, or modified elements - // is unspecified and may change in future implementations. - // The entries of a map are iterated through in an unspecified order. - PushStep(PathStep) - - // Report is called exactly once on leaf nodes to report whether the - // comparison identified the node as equal, unequal, or ignored. - // A leaf node is one that is immediately preceded by and followed by - // a pair of PushStep and PopStep calls. - Report(Result) - - // PopStep ascends back up the value tree. - // There is always a matching pop call for every push call. - PopStep() -}) Option { - return reporter{r} -} - -type reporter struct{ reporterIface } -type reporterIface interface { - PushStep(PathStep) - Report(Result) - PopStep() -} - -func (reporter) filter(_ *state, _ reflect.Type, _, _ reflect.Value) applicableOption { - panic("not implemented") -} - -// normalizeOption normalizes the input options such that all Options groups -// are flattened and groups with a single element are reduced to that element. -// Only coreOptions and Options containing coreOptions are allowed. -func normalizeOption(src Option) Option { - switch opts := flattenOptions(nil, Options{src}); len(opts) { - case 0: - return nil - case 1: - return opts[0] - default: - return opts - } -} - -// flattenOptions copies all options in src to dst as a flat list. -// Only coreOptions and Options containing coreOptions are allowed. -func flattenOptions(dst, src Options) Options { - for _, opt := range src { - switch opt := opt.(type) { - case nil: - continue - case Options: - dst = flattenOptions(dst, opt) - case coreOption: - dst = append(dst, opt) - default: - panic(fmt.Sprintf("invalid option type: %T", opt)) - } - } - return dst -} diff --git a/vendor/github.com/google/go-cmp/cmp/path.go b/vendor/github.com/google/go-cmp/cmp/path.go deleted file mode 100644 index 96fffd291f..0000000000 --- a/vendor/github.com/google/go-cmp/cmp/path.go +++ /dev/null @@ -1,308 +0,0 @@ -// Copyright 2017, The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE.md file. - -package cmp - -import ( - "fmt" - "reflect" - "strings" - "unicode" - "unicode/utf8" -) - -// Path is a list of PathSteps describing the sequence of operations to get -// from some root type to the current position in the value tree. -// The first Path element is always an operation-less PathStep that exists -// simply to identify the initial type. -// -// When traversing structs with embedded structs, the embedded struct will -// always be accessed as a field before traversing the fields of the -// embedded struct themselves. That is, an exported field from the -// embedded struct will never be accessed directly from the parent struct. -type Path []PathStep - -// PathStep is a union-type for specific operations to traverse -// a value's tree structure. Users of this package never need to implement -// these types as values of this type will be returned by this package. -// -// Implementations of this interface are -// StructField, SliceIndex, MapIndex, Indirect, TypeAssertion, and Transform. -type PathStep interface { - String() string - - // Type is the resulting type after performing the path step. - Type() reflect.Type - - // Values is the resulting values after performing the path step. - // The type of each valid value is guaranteed to be identical to Type. - // - // In some cases, one or both may be invalid or have restrictions: - // • For StructField, both are not interface-able if the current field - // is unexported and the struct type is not explicitly permitted by - // AllowUnexported to traverse unexported fields. - // • For SliceIndex, one may be invalid if an element is missing from - // either the x or y slice. - // • For MapIndex, one may be invalid if an entry is missing from - // either the x or y map. - // - // The provided values must not be mutated. - Values() (vx, vy reflect.Value) -} - -var ( - _ PathStep = StructField{} - _ PathStep = SliceIndex{} - _ PathStep = MapIndex{} - _ PathStep = Indirect{} - _ PathStep = TypeAssertion{} - _ PathStep = Transform{} -) - -func (pa *Path) push(s PathStep) { - *pa = append(*pa, s) -} - -func (pa *Path) pop() { - *pa = (*pa)[:len(*pa)-1] -} - -// Last returns the last PathStep in the Path. -// If the path is empty, this returns a non-nil PathStep that reports a nil Type. -func (pa Path) Last() PathStep { - return pa.Index(-1) -} - -// Index returns the ith step in the Path and supports negative indexing. -// A negative index starts counting from the tail of the Path such that -1 -// refers to the last step, -2 refers to the second-to-last step, and so on. -// If index is invalid, this returns a non-nil PathStep that reports a nil Type. -func (pa Path) Index(i int) PathStep { - if i < 0 { - i = len(pa) + i - } - if i < 0 || i >= len(pa) { - return pathStep{} - } - return pa[i] -} - -// String returns the simplified path to a node. -// The simplified path only contains struct field accesses. -// -// For example: -// MyMap.MySlices.MyField -func (pa Path) String() string { - var ss []string - for _, s := range pa { - if _, ok := s.(StructField); ok { - ss = append(ss, s.String()) - } - } - return strings.TrimPrefix(strings.Join(ss, ""), ".") -} - -// GoString returns the path to a specific node using Go syntax. -// -// For example: -// (*root.MyMap["key"].(*mypkg.MyStruct).MySlices)[2][3].MyField -func (pa Path) GoString() string { - var ssPre, ssPost []string - var numIndirect int - for i, s := range pa { - var nextStep PathStep - if i+1 < len(pa) { - nextStep = pa[i+1] - } - switch s := s.(type) { - case Indirect: - numIndirect++ - pPre, pPost := "(", ")" - switch nextStep.(type) { - case Indirect: - continue // Next step is indirection, so let them batch up - case StructField: - numIndirect-- // Automatic indirection on struct fields - case nil: - pPre, pPost = "", "" // Last step; no need for parenthesis - } - if numIndirect > 0 { - ssPre = append(ssPre, pPre+strings.Repeat("*", numIndirect)) - ssPost = append(ssPost, pPost) - } - numIndirect = 0 - continue - case Transform: - ssPre = append(ssPre, s.trans.name+"(") - ssPost = append(ssPost, ")") - continue - } - ssPost = append(ssPost, s.String()) - } - for i, j := 0, len(ssPre)-1; i < j; i, j = i+1, j-1 { - ssPre[i], ssPre[j] = ssPre[j], ssPre[i] - } - return strings.Join(ssPre, "") + strings.Join(ssPost, "") -} - -type pathStep struct { - typ reflect.Type - vx, vy reflect.Value -} - -func (ps pathStep) Type() reflect.Type { return ps.typ } -func (ps pathStep) Values() (vx, vy reflect.Value) { return ps.vx, ps.vy } -func (ps pathStep) String() string { - if ps.typ == nil { - return "" - } - s := ps.typ.String() - if s == "" || strings.ContainsAny(s, "{}\n") { - return "root" // Type too simple or complex to print - } - return fmt.Sprintf("{%s}", s) -} - -// StructField represents a struct field access on a field called Name. -type StructField struct{ *structField } -type structField struct { - pathStep - name string - idx int - - // These fields are used for forcibly accessing an unexported field. - // pvx, pvy, and field are only valid if unexported is true. - unexported bool - mayForce bool // Forcibly allow visibility - pvx, pvy reflect.Value // Parent values - field reflect.StructField // Field information -} - -func (sf StructField) Type() reflect.Type { return sf.typ } -func (sf StructField) Values() (vx, vy reflect.Value) { - if !sf.unexported { - return sf.vx, sf.vy // CanInterface reports true - } - - // Forcibly obtain read-write access to an unexported struct field. - if sf.mayForce { - vx = retrieveUnexportedField(sf.pvx, sf.field) - vy = retrieveUnexportedField(sf.pvy, sf.field) - return vx, vy // CanInterface reports true - } - return sf.vx, sf.vy // CanInterface reports false -} -func (sf StructField) String() string { return fmt.Sprintf(".%s", sf.name) } - -// Name is the field name. -func (sf StructField) Name() string { return sf.name } - -// Index is the index of the field in the parent struct type. -// See reflect.Type.Field. -func (sf StructField) Index() int { return sf.idx } - -// SliceIndex is an index operation on a slice or array at some index Key. -type SliceIndex struct{ *sliceIndex } -type sliceIndex struct { - pathStep - xkey, ykey int -} - -func (si SliceIndex) Type() reflect.Type { return si.typ } -func (si SliceIndex) Values() (vx, vy reflect.Value) { return si.vx, si.vy } -func (si SliceIndex) String() string { - switch { - case si.xkey == si.ykey: - return fmt.Sprintf("[%d]", si.xkey) - case si.ykey == -1: - // [5->?] means "I don't know where X[5] went" - return fmt.Sprintf("[%d->?]", si.xkey) - case si.xkey == -1: - // [?->3] means "I don't know where Y[3] came from" - return fmt.Sprintf("[?->%d]", si.ykey) - default: - // [5->3] means "X[5] moved to Y[3]" - return fmt.Sprintf("[%d->%d]", si.xkey, si.ykey) - } -} - -// Key is the index key; it may return -1 if in a split state -func (si SliceIndex) Key() int { - if si.xkey != si.ykey { - return -1 - } - return si.xkey -} - -// SplitKeys are the indexes for indexing into slices in the -// x and y values, respectively. These indexes may differ due to the -// insertion or removal of an element in one of the slices, causing -// all of the indexes to be shifted. If an index is -1, then that -// indicates that the element does not exist in the associated slice. -// -// Key is guaranteed to return -1 if and only if the indexes returned -// by SplitKeys are not the same. SplitKeys will never return -1 for -// both indexes. -func (si SliceIndex) SplitKeys() (ix, iy int) { return si.xkey, si.ykey } - -// MapIndex is an index operation on a map at some index Key. -type MapIndex struct{ *mapIndex } -type mapIndex struct { - pathStep - key reflect.Value -} - -func (mi MapIndex) Type() reflect.Type { return mi.typ } -func (mi MapIndex) Values() (vx, vy reflect.Value) { return mi.vx, mi.vy } -func (mi MapIndex) String() string { return fmt.Sprintf("[%#v]", mi.key) } - -// Key is the value of the map key. -func (mi MapIndex) Key() reflect.Value { return mi.key } - -// Indirect represents pointer indirection on the parent type. -type Indirect struct{ *indirect } -type indirect struct { - pathStep -} - -func (in Indirect) Type() reflect.Type { return in.typ } -func (in Indirect) Values() (vx, vy reflect.Value) { return in.vx, in.vy } -func (in Indirect) String() string { return "*" } - -// TypeAssertion represents a type assertion on an interface. -type TypeAssertion struct{ *typeAssertion } -type typeAssertion struct { - pathStep -} - -func (ta TypeAssertion) Type() reflect.Type { return ta.typ } -func (ta TypeAssertion) Values() (vx, vy reflect.Value) { return ta.vx, ta.vy } -func (ta TypeAssertion) String() string { return fmt.Sprintf(".(%v)", ta.typ) } - -// Transform is a transformation from the parent type to the current type. -type Transform struct{ *transform } -type transform struct { - pathStep - trans *transformer -} - -func (tf Transform) Type() reflect.Type { return tf.typ } -func (tf Transform) Values() (vx, vy reflect.Value) { return tf.vx, tf.vy } -func (tf Transform) String() string { return fmt.Sprintf("%s()", tf.trans.name) } - -// Name is the name of the Transformer. -func (tf Transform) Name() string { return tf.trans.name } - -// Func is the function pointer to the transformer function. -func (tf Transform) Func() reflect.Value { return tf.trans.fnc } - -// Option returns the originally constructed Transformer option. -// The == operator can be used to detect the exact option used. -func (tf Transform) Option() Option { return tf.trans } - -// isExported reports whether the identifier is exported. -func isExported(id string) bool { - r, _ := utf8.DecodeRuneInString(id) - return unicode.IsUpper(r) -} diff --git a/vendor/github.com/google/go-cmp/cmp/report.go b/vendor/github.com/google/go-cmp/cmp/report.go deleted file mode 100644 index 6ddf29993e..0000000000 --- a/vendor/github.com/google/go-cmp/cmp/report.go +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright 2017, The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE.md file. - -package cmp - -// defaultReporter implements the reporter interface. -// -// As Equal serially calls the PushStep, Report, and PopStep methods, the -// defaultReporter constructs a tree-based representation of the compared value -// and the result of each comparison (see valueNode). -// -// When the String method is called, the FormatDiff method transforms the -// valueNode tree into a textNode tree, which is a tree-based representation -// of the textual output (see textNode). -// -// Lastly, the textNode.String method produces the final report as a string. -type defaultReporter struct { - root *valueNode - curr *valueNode -} - -func (r *defaultReporter) PushStep(ps PathStep) { - r.curr = r.curr.PushStep(ps) - if r.root == nil { - r.root = r.curr - } -} -func (r *defaultReporter) Report(rs Result) { - r.curr.Report(rs) -} -func (r *defaultReporter) PopStep() { - r.curr = r.curr.PopStep() -} - -// String provides a full report of the differences detected as a structured -// literal in pseudo-Go syntax. String may only be called after the entire tree -// has been traversed. -func (r *defaultReporter) String() string { - assert(r.root != nil && r.curr == nil) - if r.root.NumDiff == 0 { - return "" - } - return formatOptions{}.FormatDiff(r.root).String() -} - -func assert(ok bool) { - if !ok { - panic("assertion failure") - } -} diff --git a/vendor/github.com/google/go-cmp/cmp/report_compare.go b/vendor/github.com/google/go-cmp/cmp/report_compare.go deleted file mode 100644 index 17a05eede4..0000000000 --- a/vendor/github.com/google/go-cmp/cmp/report_compare.go +++ /dev/null @@ -1,296 +0,0 @@ -// Copyright 2019, The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE.md file. - -package cmp - -import ( - "fmt" - "reflect" - - "github.com/google/go-cmp/cmp/internal/value" -) - -// TODO: Enforce limits? -// * Enforce maximum number of records to print per node? -// * Enforce maximum size in bytes allowed? -// * As a heuristic, use less verbosity for equal nodes than unequal nodes. -// TODO: Enforce unique outputs? -// * Avoid Stringer methods if it results in same output? -// * Print pointer address if outputs still equal? - -// numContextRecords is the number of surrounding equal records to print. -const numContextRecords = 2 - -type diffMode byte - -const ( - diffUnknown diffMode = 0 - diffIdentical diffMode = ' ' - diffRemoved diffMode = '-' - diffInserted diffMode = '+' -) - -type typeMode int - -const ( - // emitType always prints the type. - emitType typeMode = iota - // elideType never prints the type. - elideType - // autoType prints the type only for composite kinds - // (i.e., structs, slices, arrays, and maps). - autoType -) - -type formatOptions struct { - // DiffMode controls the output mode of FormatDiff. - // - // If diffUnknown, then produce a diff of the x and y values. - // If diffIdentical, then emit values as if they were equal. - // If diffRemoved, then only emit x values (ignoring y values). - // If diffInserted, then only emit y values (ignoring x values). - DiffMode diffMode - - // TypeMode controls whether to print the type for the current node. - // - // As a general rule of thumb, we always print the type of the next node - // after an interface, and always elide the type of the next node after - // a slice or map node. - TypeMode typeMode - - // formatValueOptions are options specific to printing reflect.Values. - formatValueOptions -} - -func (opts formatOptions) WithDiffMode(d diffMode) formatOptions { - opts.DiffMode = d - return opts -} -func (opts formatOptions) WithTypeMode(t typeMode) formatOptions { - opts.TypeMode = t - return opts -} - -// FormatDiff converts a valueNode tree into a textNode tree, where the later -// is a textual representation of the differences detected in the former. -func (opts formatOptions) FormatDiff(v *valueNode) textNode { - // Check whether we have specialized formatting for this node. - // This is not necessary, but helpful for producing more readable outputs. - if opts.CanFormatDiffSlice(v) { - return opts.FormatDiffSlice(v) - } - - // For leaf nodes, format the value based on the reflect.Values alone. - if v.MaxDepth == 0 { - switch opts.DiffMode { - case diffUnknown, diffIdentical: - // Format Equal. - if v.NumDiff == 0 { - outx := opts.FormatValue(v.ValueX, visitedPointers{}) - outy := opts.FormatValue(v.ValueY, visitedPointers{}) - if v.NumIgnored > 0 && v.NumSame == 0 { - return textEllipsis - } else if outx.Len() < outy.Len() { - return outx - } else { - return outy - } - } - - // Format unequal. - assert(opts.DiffMode == diffUnknown) - var list textList - outx := opts.WithTypeMode(elideType).FormatValue(v.ValueX, visitedPointers{}) - outy := opts.WithTypeMode(elideType).FormatValue(v.ValueY, visitedPointers{}) - if outx != nil { - list = append(list, textRecord{Diff: '-', Value: outx}) - } - if outy != nil { - list = append(list, textRecord{Diff: '+', Value: outy}) - } - return opts.WithTypeMode(emitType).FormatType(v.Type, list) - case diffRemoved: - return opts.FormatValue(v.ValueX, visitedPointers{}) - case diffInserted: - return opts.FormatValue(v.ValueY, visitedPointers{}) - default: - panic("invalid diff mode") - } - } - - // Descend into the child value node. - if v.TransformerName != "" { - out := opts.WithTypeMode(emitType).FormatDiff(v.Value) - out = textWrap{"Inverse(" + v.TransformerName + ", ", out, ")"} - return opts.FormatType(v.Type, out) - } else { - switch k := v.Type.Kind(); k { - case reflect.Struct, reflect.Array, reflect.Slice, reflect.Map: - return opts.FormatType(v.Type, opts.formatDiffList(v.Records, k)) - case reflect.Ptr: - return textWrap{"&", opts.FormatDiff(v.Value), ""} - case reflect.Interface: - return opts.WithTypeMode(emitType).FormatDiff(v.Value) - default: - panic(fmt.Sprintf("%v cannot have children", k)) - } - } -} - -func (opts formatOptions) formatDiffList(recs []reportRecord, k reflect.Kind) textNode { - // Derive record name based on the data structure kind. - var name string - var formatKey func(reflect.Value) string - switch k { - case reflect.Struct: - name = "field" - opts = opts.WithTypeMode(autoType) - formatKey = func(v reflect.Value) string { return v.String() } - case reflect.Slice, reflect.Array: - name = "element" - opts = opts.WithTypeMode(elideType) - formatKey = func(reflect.Value) string { return "" } - case reflect.Map: - name = "entry" - opts = opts.WithTypeMode(elideType) - formatKey = formatMapKey - } - - // Handle unification. - switch opts.DiffMode { - case diffIdentical, diffRemoved, diffInserted: - var list textList - var deferredEllipsis bool // Add final "..." to indicate records were dropped - for _, r := range recs { - // Elide struct fields that are zero value. - if k == reflect.Struct { - var isZero bool - switch opts.DiffMode { - case diffIdentical: - isZero = value.IsZero(r.Value.ValueX) || value.IsZero(r.Value.ValueY) - case diffRemoved: - isZero = value.IsZero(r.Value.ValueX) - case diffInserted: - isZero = value.IsZero(r.Value.ValueY) - } - if isZero { - continue - } - } - // Elide ignored nodes. - if r.Value.NumIgnored > 0 && r.Value.NumSame+r.Value.NumDiff == 0 { - deferredEllipsis = !(k == reflect.Slice || k == reflect.Array) - if !deferredEllipsis { - list.AppendEllipsis(diffStats{}) - } - continue - } - if out := opts.FormatDiff(r.Value); out != nil { - list = append(list, textRecord{Key: formatKey(r.Key), Value: out}) - } - } - if deferredEllipsis { - list.AppendEllipsis(diffStats{}) - } - return textWrap{"{", list, "}"} - case diffUnknown: - default: - panic("invalid diff mode") - } - - // Handle differencing. - var list textList - groups := coalesceAdjacentRecords(name, recs) - for i, ds := range groups { - // Handle equal records. - if ds.NumDiff() == 0 { - // Compute the number of leading and trailing records to print. - var numLo, numHi int - numEqual := ds.NumIgnored + ds.NumIdentical - for numLo < numContextRecords && numLo+numHi < numEqual && i != 0 { - if r := recs[numLo].Value; r.NumIgnored > 0 && r.NumSame+r.NumDiff == 0 { - break - } - numLo++ - } - for numHi < numContextRecords && numLo+numHi < numEqual && i != len(groups)-1 { - if r := recs[numEqual-numHi-1].Value; r.NumIgnored > 0 && r.NumSame+r.NumDiff == 0 { - break - } - numHi++ - } - if numEqual-(numLo+numHi) == 1 && ds.NumIgnored == 0 { - numHi++ // Avoid pointless coalescing of a single equal record - } - - // Format the equal values. - for _, r := range recs[:numLo] { - out := opts.WithDiffMode(diffIdentical).FormatDiff(r.Value) - list = append(list, textRecord{Key: formatKey(r.Key), Value: out}) - } - if numEqual > numLo+numHi { - ds.NumIdentical -= numLo + numHi - list.AppendEllipsis(ds) - } - for _, r := range recs[numEqual-numHi : numEqual] { - out := opts.WithDiffMode(diffIdentical).FormatDiff(r.Value) - list = append(list, textRecord{Key: formatKey(r.Key), Value: out}) - } - recs = recs[numEqual:] - continue - } - - // Handle unequal records. - for _, r := range recs[:ds.NumDiff()] { - switch { - case opts.CanFormatDiffSlice(r.Value): - out := opts.FormatDiffSlice(r.Value) - list = append(list, textRecord{Key: formatKey(r.Key), Value: out}) - case r.Value.NumChildren == r.Value.MaxDepth: - outx := opts.WithDiffMode(diffRemoved).FormatDiff(r.Value) - outy := opts.WithDiffMode(diffInserted).FormatDiff(r.Value) - if outx != nil { - list = append(list, textRecord{Diff: diffRemoved, Key: formatKey(r.Key), Value: outx}) - } - if outy != nil { - list = append(list, textRecord{Diff: diffInserted, Key: formatKey(r.Key), Value: outy}) - } - default: - out := opts.FormatDiff(r.Value) - list = append(list, textRecord{Key: formatKey(r.Key), Value: out}) - } - } - recs = recs[ds.NumDiff():] - } - assert(len(recs) == 0) - return textWrap{"{", list, "}"} -} - -// coalesceAdjacentRecords coalesces the list of records into groups of -// adjacent equal, or unequal counts. -func coalesceAdjacentRecords(name string, recs []reportRecord) (groups []diffStats) { - var prevCase int // Arbitrary index into which case last occurred - lastStats := func(i int) *diffStats { - if prevCase != i { - groups = append(groups, diffStats{Name: name}) - prevCase = i - } - return &groups[len(groups)-1] - } - for _, r := range recs { - switch rv := r.Value; { - case rv.NumIgnored > 0 && rv.NumSame+rv.NumDiff == 0: - lastStats(1).NumIgnored++ - case rv.NumDiff == 0: - lastStats(1).NumIdentical++ - case rv.NumDiff > 0 && !rv.ValueY.IsValid(): - lastStats(2).NumRemoved++ - case rv.NumDiff > 0 && !rv.ValueX.IsValid(): - lastStats(2).NumInserted++ - default: - lastStats(2).NumModified++ - } - } - return groups -} diff --git a/vendor/github.com/google/go-cmp/cmp/report_reflect.go b/vendor/github.com/google/go-cmp/cmp/report_reflect.go deleted file mode 100644 index 2761b62892..0000000000 --- a/vendor/github.com/google/go-cmp/cmp/report_reflect.go +++ /dev/null @@ -1,278 +0,0 @@ -// Copyright 2019, The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE.md file. - -package cmp - -import ( - "fmt" - "reflect" - "strconv" - "strings" - "unicode" - - "github.com/google/go-cmp/cmp/internal/flags" - "github.com/google/go-cmp/cmp/internal/value" -) - -type formatValueOptions struct { - // AvoidStringer controls whether to avoid calling custom stringer - // methods like error.Error or fmt.Stringer.String. - AvoidStringer bool - - // ShallowPointers controls whether to avoid descending into pointers. - // Useful when printing map keys, where pointer comparison is performed - // on the pointer address rather than the pointed-at value. - ShallowPointers bool - - // PrintAddresses controls whether to print the address of all pointers, - // slice elements, and maps. - PrintAddresses bool -} - -// FormatType prints the type as if it were wrapping s. -// This may return s as-is depending on the current type and TypeMode mode. -func (opts formatOptions) FormatType(t reflect.Type, s textNode) textNode { - // Check whether to emit the type or not. - switch opts.TypeMode { - case autoType: - switch t.Kind() { - case reflect.Struct, reflect.Slice, reflect.Array, reflect.Map: - if s.Equal(textNil) { - return s - } - default: - return s - } - case elideType: - return s - } - - // Determine the type label, applying special handling for unnamed types. - typeName := t.String() - if t.Name() == "" { - // According to Go grammar, certain type literals contain symbols that - // do not strongly bind to the next lexicographical token (e.g., *T). - switch t.Kind() { - case reflect.Chan, reflect.Func, reflect.Ptr: - typeName = "(" + typeName + ")" - } - typeName = strings.Replace(typeName, "struct {", "struct{", -1) - typeName = strings.Replace(typeName, "interface {", "interface{", -1) - } - - // Avoid wrap the value in parenthesis if unnecessary. - if s, ok := s.(textWrap); ok { - hasParens := strings.HasPrefix(s.Prefix, "(") && strings.HasSuffix(s.Suffix, ")") - hasBraces := strings.HasPrefix(s.Prefix, "{") && strings.HasSuffix(s.Suffix, "}") - if hasParens || hasBraces { - return textWrap{typeName, s, ""} - } - } - return textWrap{typeName + "(", s, ")"} -} - -// FormatValue prints the reflect.Value, taking extra care to avoid descending -// into pointers already in m. As pointers are visited, m is also updated. -func (opts formatOptions) FormatValue(v reflect.Value, m visitedPointers) (out textNode) { - if !v.IsValid() { - return nil - } - t := v.Type() - - // Check whether there is an Error or String method to call. - if !opts.AvoidStringer && v.CanInterface() { - // Avoid calling Error or String methods on nil receivers since many - // implementations crash when doing so. - if (t.Kind() != reflect.Ptr && t.Kind() != reflect.Interface) || !v.IsNil() { - switch v := v.Interface().(type) { - case error: - return textLine("e" + formatString(v.Error())) - case fmt.Stringer: - return textLine("s" + formatString(v.String())) - } - } - } - - // Check whether to explicitly wrap the result with the type. - var skipType bool - defer func() { - if !skipType { - out = opts.FormatType(t, out) - } - }() - - var ptr string - switch t.Kind() { - case reflect.Bool: - return textLine(fmt.Sprint(v.Bool())) - case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: - return textLine(fmt.Sprint(v.Int())) - case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr: - // Unnamed uints are usually bytes or words, so use hexadecimal. - if t.PkgPath() == "" || t.Kind() == reflect.Uintptr { - return textLine(formatHex(v.Uint())) - } - return textLine(fmt.Sprint(v.Uint())) - case reflect.Float32, reflect.Float64: - return textLine(fmt.Sprint(v.Float())) - case reflect.Complex64, reflect.Complex128: - return textLine(fmt.Sprint(v.Complex())) - case reflect.String: - return textLine(formatString(v.String())) - case reflect.UnsafePointer, reflect.Chan, reflect.Func: - return textLine(formatPointer(v)) - case reflect.Struct: - var list textList - for i := 0; i < v.NumField(); i++ { - vv := v.Field(i) - if value.IsZero(vv) { - continue // Elide fields with zero values - } - s := opts.WithTypeMode(autoType).FormatValue(vv, m) - list = append(list, textRecord{Key: t.Field(i).Name, Value: s}) - } - return textWrap{"{", list, "}"} - case reflect.Slice: - if v.IsNil() { - return textNil - } - if opts.PrintAddresses { - ptr = formatPointer(v) - } - fallthrough - case reflect.Array: - var list textList - for i := 0; i < v.Len(); i++ { - vi := v.Index(i) - if vi.CanAddr() { // Check for cyclic elements - p := vi.Addr() - if m.Visit(p) { - var out textNode - out = textLine(formatPointer(p)) - out = opts.WithTypeMode(emitType).FormatType(p.Type(), out) - out = textWrap{"*", out, ""} - list = append(list, textRecord{Value: out}) - continue - } - } - s := opts.WithTypeMode(elideType).FormatValue(vi, m) - list = append(list, textRecord{Value: s}) - } - return textWrap{ptr + "{", list, "}"} - case reflect.Map: - if v.IsNil() { - return textNil - } - if m.Visit(v) { - return textLine(formatPointer(v)) - } - - var list textList - for _, k := range value.SortKeys(v.MapKeys()) { - sk := formatMapKey(k) - sv := opts.WithTypeMode(elideType).FormatValue(v.MapIndex(k), m) - list = append(list, textRecord{Key: sk, Value: sv}) - } - if opts.PrintAddresses { - ptr = formatPointer(v) - } - return textWrap{ptr + "{", list, "}"} - case reflect.Ptr: - if v.IsNil() { - return textNil - } - if m.Visit(v) || opts.ShallowPointers { - return textLine(formatPointer(v)) - } - if opts.PrintAddresses { - ptr = formatPointer(v) - } - skipType = true // Let the underlying value print the type instead - return textWrap{"&" + ptr, opts.FormatValue(v.Elem(), m), ""} - case reflect.Interface: - if v.IsNil() { - return textNil - } - // Interfaces accept different concrete types, - // so configure the underlying value to explicitly print the type. - skipType = true // Print the concrete type instead - return opts.WithTypeMode(emitType).FormatValue(v.Elem(), m) - default: - panic(fmt.Sprintf("%v kind not handled", v.Kind())) - } -} - -// formatMapKey formats v as if it were a map key. -// The result is guaranteed to be a single line. -func formatMapKey(v reflect.Value) string { - var opts formatOptions - opts.TypeMode = elideType - opts.ShallowPointers = true - s := opts.FormatValue(v, visitedPointers{}).String() - return strings.TrimSpace(s) -} - -// formatString prints s as a double-quoted or backtick-quoted string. -func formatString(s string) string { - // Use quoted string if it the same length as a raw string literal. - // Otherwise, attempt to use the raw string form. - qs := strconv.Quote(s) - if len(qs) == 1+len(s)+1 { - return qs - } - - // Disallow newlines to ensure output is a single line. - // Only allow printable runes for readability purposes. - rawInvalid := func(r rune) bool { - return r == '`' || r == '\n' || !(unicode.IsPrint(r) || r == '\t') - } - if strings.IndexFunc(s, rawInvalid) < 0 { - return "`" + s + "`" - } - return qs -} - -// formatHex prints u as a hexadecimal integer in Go notation. -func formatHex(u uint64) string { - var f string - switch { - case u <= 0xff: - f = "0x%02x" - case u <= 0xffff: - f = "0x%04x" - case u <= 0xffffff: - f = "0x%06x" - case u <= 0xffffffff: - f = "0x%08x" - case u <= 0xffffffffff: - f = "0x%010x" - case u <= 0xffffffffffff: - f = "0x%012x" - case u <= 0xffffffffffffff: - f = "0x%014x" - case u <= 0xffffffffffffffff: - f = "0x%016x" - } - return fmt.Sprintf(f, u) -} - -// formatPointer prints the address of the pointer. -func formatPointer(v reflect.Value) string { - p := v.Pointer() - if flags.Deterministic { - p = 0xdeadf00f // Only used for stable testing purposes - } - return fmt.Sprintf("⟪0x%x⟫", p) -} - -type visitedPointers map[value.Pointer]struct{} - -// Visit inserts pointer v into the visited map and reports whether it had -// already been visited before. -func (m visitedPointers) Visit(v reflect.Value) bool { - p := value.PointerOf(v) - _, visited := m[p] - m[p] = struct{}{} - return visited -} diff --git a/vendor/github.com/google/go-cmp/cmp/report_slices.go b/vendor/github.com/google/go-cmp/cmp/report_slices.go deleted file mode 100644 index eafcf2e4c0..0000000000 --- a/vendor/github.com/google/go-cmp/cmp/report_slices.go +++ /dev/null @@ -1,333 +0,0 @@ -// Copyright 2019, The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE.md file. - -package cmp - -import ( - "bytes" - "fmt" - "reflect" - "strings" - "unicode" - "unicode/utf8" - - "github.com/google/go-cmp/cmp/internal/diff" -) - -// CanFormatDiffSlice reports whether we support custom formatting for nodes -// that are slices of primitive kinds or strings. -func (opts formatOptions) CanFormatDiffSlice(v *valueNode) bool { - switch { - case opts.DiffMode != diffUnknown: - return false // Must be formatting in diff mode - case v.NumDiff == 0: - return false // No differences detected - case v.NumIgnored+v.NumCompared+v.NumTransformed > 0: - // TODO: Handle the case where someone uses bytes.Equal on a large slice. - return false // Some custom option was used to determined equality - case !v.ValueX.IsValid() || !v.ValueY.IsValid(): - return false // Both values must be valid - } - - switch t := v.Type; t.Kind() { - case reflect.String: - case reflect.Array, reflect.Slice: - // Only slices of primitive types have specialized handling. - switch t.Elem().Kind() { - case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64, - reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr, - reflect.Bool, reflect.Float32, reflect.Float64, reflect.Complex64, reflect.Complex128: - default: - return false - } - - // If a sufficient number of elements already differ, - // use specialized formatting even if length requirement is not met. - if v.NumDiff > v.NumSame { - return true - } - default: - return false - } - - // Use specialized string diffing for longer slices or strings. - const minLength = 64 - return v.ValueX.Len() >= minLength && v.ValueY.Len() >= minLength -} - -// FormatDiffSlice prints a diff for the slices (or strings) represented by v. -// This provides custom-tailored logic to make printing of differences in -// textual strings and slices of primitive kinds more readable. -func (opts formatOptions) FormatDiffSlice(v *valueNode) textNode { - assert(opts.DiffMode == diffUnknown) - t, vx, vy := v.Type, v.ValueX, v.ValueY - - // Auto-detect the type of the data. - var isLinedText, isText, isBinary bool - var sx, sy string - switch { - case t.Kind() == reflect.String: - sx, sy = vx.String(), vy.String() - isText = true // Initial estimate, verify later - case t.Kind() == reflect.Slice && t.Elem() == reflect.TypeOf(byte(0)): - sx, sy = string(vx.Bytes()), string(vy.Bytes()) - isBinary = true // Initial estimate, verify later - case t.Kind() == reflect.Array: - // Arrays need to be addressable for slice operations to work. - vx2, vy2 := reflect.New(t).Elem(), reflect.New(t).Elem() - vx2.Set(vx) - vy2.Set(vy) - vx, vy = vx2, vy2 - } - if isText || isBinary { - var numLines, lastLineIdx, maxLineLen int - isBinary = false - for i, r := range sx + sy { - if !(unicode.IsPrint(r) || unicode.IsSpace(r)) || r == utf8.RuneError { - isBinary = true - break - } - if r == '\n' { - if maxLineLen < i-lastLineIdx { - maxLineLen = i - lastLineIdx - } - lastLineIdx = i + 1 - numLines++ - } - } - isText = !isBinary - isLinedText = isText && numLines >= 4 && maxLineLen <= 256 - } - - // Format the string into printable records. - var list textList - var delim string - switch { - // If the text appears to be multi-lined text, - // then perform differencing across individual lines. - case isLinedText: - ssx := strings.Split(sx, "\n") - ssy := strings.Split(sy, "\n") - list = opts.formatDiffSlice( - reflect.ValueOf(ssx), reflect.ValueOf(ssy), 1, "line", - func(v reflect.Value, d diffMode) textRecord { - s := formatString(v.Index(0).String()) - return textRecord{Diff: d, Value: textLine(s)} - }, - ) - delim = "\n" - // If the text appears to be single-lined text, - // then perform differencing in approximately fixed-sized chunks. - // The output is printed as quoted strings. - case isText: - list = opts.formatDiffSlice( - reflect.ValueOf(sx), reflect.ValueOf(sy), 64, "byte", - func(v reflect.Value, d diffMode) textRecord { - s := formatString(v.String()) - return textRecord{Diff: d, Value: textLine(s)} - }, - ) - delim = "" - // If the text appears to be binary data, - // then perform differencing in approximately fixed-sized chunks. - // The output is inspired by hexdump. - case isBinary: - list = opts.formatDiffSlice( - reflect.ValueOf(sx), reflect.ValueOf(sy), 16, "byte", - func(v reflect.Value, d diffMode) textRecord { - var ss []string - for i := 0; i < v.Len(); i++ { - ss = append(ss, formatHex(v.Index(i).Uint())) - } - s := strings.Join(ss, ", ") - comment := commentString(fmt.Sprintf("%c|%v|", d, formatASCII(v.String()))) - return textRecord{Diff: d, Value: textLine(s), Comment: comment} - }, - ) - // For all other slices of primitive types, - // then perform differencing in approximately fixed-sized chunks. - // The size of each chunk depends on the width of the element kind. - default: - var chunkSize int - if t.Elem().Kind() == reflect.Bool { - chunkSize = 16 - } else { - switch t.Elem().Bits() { - case 8: - chunkSize = 16 - case 16: - chunkSize = 12 - case 32: - chunkSize = 8 - default: - chunkSize = 8 - } - } - list = opts.formatDiffSlice( - vx, vy, chunkSize, t.Elem().Kind().String(), - func(v reflect.Value, d diffMode) textRecord { - var ss []string - for i := 0; i < v.Len(); i++ { - switch t.Elem().Kind() { - case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: - ss = append(ss, fmt.Sprint(v.Index(i).Int())) - case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr: - ss = append(ss, formatHex(v.Index(i).Uint())) - case reflect.Bool, reflect.Float32, reflect.Float64, reflect.Complex64, reflect.Complex128: - ss = append(ss, fmt.Sprint(v.Index(i).Interface())) - } - } - s := strings.Join(ss, ", ") - return textRecord{Diff: d, Value: textLine(s)} - }, - ) - } - - // Wrap the output with appropriate type information. - var out textNode = textWrap{"{", list, "}"} - if !isText { - // The "{...}" byte-sequence literal is not valid Go syntax for strings. - // Emit the type for extra clarity (e.g. "string{...}"). - if t.Kind() == reflect.String { - opts = opts.WithTypeMode(emitType) - } - return opts.FormatType(t, out) - } - switch t.Kind() { - case reflect.String: - out = textWrap{"strings.Join(", out, fmt.Sprintf(", %q)", delim)} - if t != reflect.TypeOf(string("")) { - out = opts.FormatType(t, out) - } - case reflect.Slice: - out = textWrap{"bytes.Join(", out, fmt.Sprintf(", %q)", delim)} - if t != reflect.TypeOf([]byte(nil)) { - out = opts.FormatType(t, out) - } - } - return out -} - -// formatASCII formats s as an ASCII string. -// This is useful for printing binary strings in a semi-legible way. -func formatASCII(s string) string { - b := bytes.Repeat([]byte{'.'}, len(s)) - for i := 0; i < len(s); i++ { - if ' ' <= s[i] && s[i] <= '~' { - b[i] = s[i] - } - } - return string(b) -} - -func (opts formatOptions) formatDiffSlice( - vx, vy reflect.Value, chunkSize int, name string, - makeRec func(reflect.Value, diffMode) textRecord, -) (list textList) { - es := diff.Difference(vx.Len(), vy.Len(), func(ix int, iy int) diff.Result { - return diff.BoolResult(vx.Index(ix).Interface() == vy.Index(iy).Interface()) - }) - - appendChunks := func(v reflect.Value, d diffMode) int { - n0 := v.Len() - for v.Len() > 0 { - n := chunkSize - if n > v.Len() { - n = v.Len() - } - list = append(list, makeRec(v.Slice(0, n), d)) - v = v.Slice(n, v.Len()) - } - return n0 - v.Len() - } - - groups := coalesceAdjacentEdits(name, es) - groups = coalesceInterveningIdentical(groups, chunkSize/4) - for i, ds := range groups { - // Print equal. - if ds.NumDiff() == 0 { - // Compute the number of leading and trailing equal bytes to print. - var numLo, numHi int - numEqual := ds.NumIgnored + ds.NumIdentical - for numLo < chunkSize*numContextRecords && numLo+numHi < numEqual && i != 0 { - numLo++ - } - for numHi < chunkSize*numContextRecords && numLo+numHi < numEqual && i != len(groups)-1 { - numHi++ - } - if numEqual-(numLo+numHi) <= chunkSize && ds.NumIgnored == 0 { - numHi = numEqual - numLo // Avoid pointless coalescing of single equal row - } - - // Print the equal bytes. - appendChunks(vx.Slice(0, numLo), diffIdentical) - if numEqual > numLo+numHi { - ds.NumIdentical -= numLo + numHi - list.AppendEllipsis(ds) - } - appendChunks(vx.Slice(numEqual-numHi, numEqual), diffIdentical) - vx = vx.Slice(numEqual, vx.Len()) - vy = vy.Slice(numEqual, vy.Len()) - continue - } - - // Print unequal. - nx := appendChunks(vx.Slice(0, ds.NumIdentical+ds.NumRemoved+ds.NumModified), diffRemoved) - vx = vx.Slice(nx, vx.Len()) - ny := appendChunks(vy.Slice(0, ds.NumIdentical+ds.NumInserted+ds.NumModified), diffInserted) - vy = vy.Slice(ny, vy.Len()) - } - assert(vx.Len() == 0 && vy.Len() == 0) - return list -} - -// coalesceAdjacentEdits coalesces the list of edits into groups of adjacent -// equal or unequal counts. -func coalesceAdjacentEdits(name string, es diff.EditScript) (groups []diffStats) { - var prevCase int // Arbitrary index into which case last occurred - lastStats := func(i int) *diffStats { - if prevCase != i { - groups = append(groups, diffStats{Name: name}) - prevCase = i - } - return &groups[len(groups)-1] - } - for _, e := range es { - switch e { - case diff.Identity: - lastStats(1).NumIdentical++ - case diff.UniqueX: - lastStats(2).NumRemoved++ - case diff.UniqueY: - lastStats(2).NumInserted++ - case diff.Modified: - lastStats(2).NumModified++ - } - } - return groups -} - -// coalesceInterveningIdentical coalesces sufficiently short (<= windowSize) -// equal groups into adjacent unequal groups that currently result in a -// dual inserted/removed printout. This acts as a high-pass filter to smooth -// out high-frequency changes within the windowSize. -func coalesceInterveningIdentical(groups []diffStats, windowSize int) []diffStats { - groups, groupsOrig := groups[:0], groups - for i, ds := range groupsOrig { - if len(groups) >= 2 && ds.NumDiff() > 0 { - prev := &groups[len(groups)-2] // Unequal group - curr := &groups[len(groups)-1] // Equal group - next := &groupsOrig[i] // Unequal group - hadX, hadY := prev.NumRemoved > 0, prev.NumInserted > 0 - hasX, hasY := next.NumRemoved > 0, next.NumInserted > 0 - if ((hadX || hasX) && (hadY || hasY)) && curr.NumIdentical <= windowSize { - *prev = prev.Append(*curr).Append(*next) - groups = groups[:len(groups)-1] // Truncate off equal group - continue - } - } - groups = append(groups, ds) - } - return groups -} diff --git a/vendor/github.com/google/go-cmp/cmp/report_text.go b/vendor/github.com/google/go-cmp/cmp/report_text.go deleted file mode 100644 index 8b8fcab7bd..0000000000 --- a/vendor/github.com/google/go-cmp/cmp/report_text.go +++ /dev/null @@ -1,387 +0,0 @@ -// Copyright 2019, The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE.md file. - -package cmp - -import ( - "bytes" - "fmt" - "math/rand" - "strings" - "time" - - "github.com/google/go-cmp/cmp/internal/flags" -) - -var randBool = rand.New(rand.NewSource(time.Now().Unix())).Intn(2) == 0 - -type indentMode int - -func (n indentMode) appendIndent(b []byte, d diffMode) []byte { - // The output of Diff is documented as being unstable to provide future - // flexibility in changing the output for more humanly readable reports. - // This logic intentionally introduces instability to the exact output - // so that users can detect accidental reliance on stability early on, - // rather than much later when an actual change to the format occurs. - if flags.Deterministic || randBool { - // Use regular spaces (U+0020). - switch d { - case diffUnknown, diffIdentical: - b = append(b, " "...) - case diffRemoved: - b = append(b, "- "...) - case diffInserted: - b = append(b, "+ "...) - } - } else { - // Use non-breaking spaces (U+00a0). - switch d { - case diffUnknown, diffIdentical: - b = append(b, "  "...) - case diffRemoved: - b = append(b, "- "...) - case diffInserted: - b = append(b, "+ "...) - } - } - return repeatCount(n).appendChar(b, '\t') -} - -type repeatCount int - -func (n repeatCount) appendChar(b []byte, c byte) []byte { - for ; n > 0; n-- { - b = append(b, c) - } - return b -} - -// textNode is a simplified tree-based representation of structured text. -// Possible node types are textWrap, textList, or textLine. -type textNode interface { - // Len reports the length in bytes of a single-line version of the tree. - // Nested textRecord.Diff and textRecord.Comment fields are ignored. - Len() int - // Equal reports whether the two trees are structurally identical. - // Nested textRecord.Diff and textRecord.Comment fields are compared. - Equal(textNode) bool - // String returns the string representation of the text tree. - // It is not guaranteed that len(x.String()) == x.Len(), - // nor that x.String() == y.String() implies that x.Equal(y). - String() string - - // formatCompactTo formats the contents of the tree as a single-line string - // to the provided buffer. Any nested textRecord.Diff and textRecord.Comment - // fields are ignored. - // - // However, not all nodes in the tree should be collapsed as a single-line. - // If a node can be collapsed as a single-line, it is replaced by a textLine - // node. Since the top-level node cannot replace itself, this also returns - // the current node itself. - // - // This does not mutate the receiver. - formatCompactTo([]byte, diffMode) ([]byte, textNode) - // formatExpandedTo formats the contents of the tree as a multi-line string - // to the provided buffer. In order for column alignment to operate well, - // formatCompactTo must be called before calling formatExpandedTo. - formatExpandedTo([]byte, diffMode, indentMode) []byte -} - -// textWrap is a wrapper that concatenates a prefix and/or a suffix -// to the underlying node. -type textWrap struct { - Prefix string // e.g., "bytes.Buffer{" - Value textNode // textWrap | textList | textLine - Suffix string // e.g., "}" -} - -func (s textWrap) Len() int { - return len(s.Prefix) + s.Value.Len() + len(s.Suffix) -} -func (s1 textWrap) Equal(s2 textNode) bool { - if s2, ok := s2.(textWrap); ok { - return s1.Prefix == s2.Prefix && s1.Value.Equal(s2.Value) && s1.Suffix == s2.Suffix - } - return false -} -func (s textWrap) String() string { - var d diffMode - var n indentMode - _, s2 := s.formatCompactTo(nil, d) - b := n.appendIndent(nil, d) // Leading indent - b = s2.formatExpandedTo(b, d, n) // Main body - b = append(b, '\n') // Trailing newline - return string(b) -} -func (s textWrap) formatCompactTo(b []byte, d diffMode) ([]byte, textNode) { - n0 := len(b) // Original buffer length - b = append(b, s.Prefix...) - b, s.Value = s.Value.formatCompactTo(b, d) - b = append(b, s.Suffix...) - if _, ok := s.Value.(textLine); ok { - return b, textLine(b[n0:]) - } - return b, s -} -func (s textWrap) formatExpandedTo(b []byte, d diffMode, n indentMode) []byte { - b = append(b, s.Prefix...) - b = s.Value.formatExpandedTo(b, d, n) - b = append(b, s.Suffix...) - return b -} - -// textList is a comma-separated list of textWrap or textLine nodes. -// The list may be formatted as multi-lines or single-line at the discretion -// of the textList.formatCompactTo method. -type textList []textRecord -type textRecord struct { - Diff diffMode // e.g., 0 or '-' or '+' - Key string // e.g., "MyField" - Value textNode // textWrap | textLine - Comment fmt.Stringer // e.g., "6 identical fields" -} - -// AppendEllipsis appends a new ellipsis node to the list if none already -// exists at the end. If cs is non-zero it coalesces the statistics with the -// previous diffStats. -func (s *textList) AppendEllipsis(ds diffStats) { - hasStats := ds != diffStats{} - if len(*s) == 0 || !(*s)[len(*s)-1].Value.Equal(textEllipsis) { - if hasStats { - *s = append(*s, textRecord{Value: textEllipsis, Comment: ds}) - } else { - *s = append(*s, textRecord{Value: textEllipsis}) - } - return - } - if hasStats { - (*s)[len(*s)-1].Comment = (*s)[len(*s)-1].Comment.(diffStats).Append(ds) - } -} - -func (s textList) Len() (n int) { - for i, r := range s { - n += len(r.Key) - if r.Key != "" { - n += len(": ") - } - n += r.Value.Len() - if i < len(s)-1 { - n += len(", ") - } - } - return n -} - -func (s1 textList) Equal(s2 textNode) bool { - if s2, ok := s2.(textList); ok { - if len(s1) != len(s2) { - return false - } - for i := range s1 { - r1, r2 := s1[i], s2[i] - if !(r1.Diff == r2.Diff && r1.Key == r2.Key && r1.Value.Equal(r2.Value) && r1.Comment == r2.Comment) { - return false - } - } - return true - } - return false -} - -func (s textList) String() string { - return textWrap{"{", s, "}"}.String() -} - -func (s textList) formatCompactTo(b []byte, d diffMode) ([]byte, textNode) { - s = append(textList(nil), s...) // Avoid mutating original - - // Determine whether we can collapse this list as a single line. - n0 := len(b) // Original buffer length - var multiLine bool - for i, r := range s { - if r.Diff == diffInserted || r.Diff == diffRemoved { - multiLine = true - } - b = append(b, r.Key...) - if r.Key != "" { - b = append(b, ": "...) - } - b, s[i].Value = r.Value.formatCompactTo(b, d|r.Diff) - if _, ok := s[i].Value.(textLine); !ok { - multiLine = true - } - if r.Comment != nil { - multiLine = true - } - if i < len(s)-1 { - b = append(b, ", "...) - } - } - // Force multi-lined output when printing a removed/inserted node that - // is sufficiently long. - if (d == diffInserted || d == diffRemoved) && len(b[n0:]) > 80 { - multiLine = true - } - if !multiLine { - return b, textLine(b[n0:]) - } - return b, s -} - -func (s textList) formatExpandedTo(b []byte, d diffMode, n indentMode) []byte { - alignKeyLens := s.alignLens( - func(r textRecord) bool { - _, isLine := r.Value.(textLine) - return r.Key == "" || !isLine - }, - func(r textRecord) int { return len(r.Key) }, - ) - alignValueLens := s.alignLens( - func(r textRecord) bool { - _, isLine := r.Value.(textLine) - return !isLine || r.Value.Equal(textEllipsis) || r.Comment == nil - }, - func(r textRecord) int { return len(r.Value.(textLine)) }, - ) - - // Format the list as a multi-lined output. - n++ - for i, r := range s { - b = n.appendIndent(append(b, '\n'), d|r.Diff) - if r.Key != "" { - b = append(b, r.Key+": "...) - } - b = alignKeyLens[i].appendChar(b, ' ') - - b = r.Value.formatExpandedTo(b, d|r.Diff, n) - if !r.Value.Equal(textEllipsis) { - b = append(b, ',') - } - b = alignValueLens[i].appendChar(b, ' ') - - if r.Comment != nil { - b = append(b, " // "+r.Comment.String()...) - } - } - n-- - - return n.appendIndent(append(b, '\n'), d) -} - -func (s textList) alignLens( - skipFunc func(textRecord) bool, - lenFunc func(textRecord) int, -) []repeatCount { - var startIdx, endIdx, maxLen int - lens := make([]repeatCount, len(s)) - for i, r := range s { - if skipFunc(r) { - for j := startIdx; j < endIdx && j < len(s); j++ { - lens[j] = repeatCount(maxLen - lenFunc(s[j])) - } - startIdx, endIdx, maxLen = i+1, i+1, 0 - } else { - if maxLen < lenFunc(r) { - maxLen = lenFunc(r) - } - endIdx = i + 1 - } - } - for j := startIdx; j < endIdx && j < len(s); j++ { - lens[j] = repeatCount(maxLen - lenFunc(s[j])) - } - return lens -} - -// textLine is a single-line segment of text and is always a leaf node -// in the textNode tree. -type textLine []byte - -var ( - textNil = textLine("nil") - textEllipsis = textLine("...") -) - -func (s textLine) Len() int { - return len(s) -} -func (s1 textLine) Equal(s2 textNode) bool { - if s2, ok := s2.(textLine); ok { - return bytes.Equal([]byte(s1), []byte(s2)) - } - return false -} -func (s textLine) String() string { - return string(s) -} -func (s textLine) formatCompactTo(b []byte, d diffMode) ([]byte, textNode) { - return append(b, s...), s -} -func (s textLine) formatExpandedTo(b []byte, _ diffMode, _ indentMode) []byte { - return append(b, s...) -} - -type diffStats struct { - Name string - NumIgnored int - NumIdentical int - NumRemoved int - NumInserted int - NumModified int -} - -func (s diffStats) NumDiff() int { - return s.NumRemoved + s.NumInserted + s.NumModified -} - -func (s diffStats) Append(ds diffStats) diffStats { - assert(s.Name == ds.Name) - s.NumIgnored += ds.NumIgnored - s.NumIdentical += ds.NumIdentical - s.NumRemoved += ds.NumRemoved - s.NumInserted += ds.NumInserted - s.NumModified += ds.NumModified - return s -} - -// String prints a humanly-readable summary of coalesced records. -// -// Example: -// diffStats{Name: "Field", NumIgnored: 5}.String() => "5 ignored fields" -func (s diffStats) String() string { - var ss []string - var sum int - labels := [...]string{"ignored", "identical", "removed", "inserted", "modified"} - counts := [...]int{s.NumIgnored, s.NumIdentical, s.NumRemoved, s.NumInserted, s.NumModified} - for i, n := range counts { - if n > 0 { - ss = append(ss, fmt.Sprintf("%d %v", n, labels[i])) - } - sum += n - } - - // Pluralize the name (adjusting for some obscure English grammar rules). - name := s.Name - if sum > 1 { - name += "s" - if strings.HasSuffix(name, "ys") { - name = name[:len(name)-2] + "ies" // e.g., "entrys" => "entries" - } - } - - // Format the list according to English grammar (with Oxford comma). - switch n := len(ss); n { - case 0: - return "" - case 1, 2: - return strings.Join(ss, " and ") + " " + name - default: - return strings.Join(ss[:n-1], ", ") + ", and " + ss[n-1] + " " + name - } -} - -type commentString string - -func (s commentString) String() string { return string(s) } diff --git a/vendor/github.com/google/go-cmp/cmp/report_value.go b/vendor/github.com/google/go-cmp/cmp/report_value.go deleted file mode 100644 index 83031a7f50..0000000000 --- a/vendor/github.com/google/go-cmp/cmp/report_value.go +++ /dev/null @@ -1,121 +0,0 @@ -// Copyright 2019, The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE.md file. - -package cmp - -import "reflect" - -// valueNode represents a single node within a report, which is a -// structured representation of the value tree, containing information -// regarding which nodes are equal or not. -type valueNode struct { - parent *valueNode - - Type reflect.Type - ValueX reflect.Value - ValueY reflect.Value - - // NumSame is the number of leaf nodes that are equal. - // All descendants are equal only if NumDiff is 0. - NumSame int - // NumDiff is the number of leaf nodes that are not equal. - NumDiff int - // NumIgnored is the number of leaf nodes that are ignored. - NumIgnored int - // NumCompared is the number of leaf nodes that were compared - // using an Equal method or Comparer function. - NumCompared int - // NumTransformed is the number of non-leaf nodes that were transformed. - NumTransformed int - // NumChildren is the number of transitive descendants of this node. - // This counts from zero; thus, leaf nodes have no descendants. - NumChildren int - // MaxDepth is the maximum depth of the tree. This counts from zero; - // thus, leaf nodes have a depth of zero. - MaxDepth int - - // Records is a list of struct fields, slice elements, or map entries. - Records []reportRecord // If populated, implies Value is not populated - - // Value is the result of a transformation, pointer indirect, of - // type assertion. - Value *valueNode // If populated, implies Records is not populated - - // TransformerName is the name of the transformer. - TransformerName string // If non-empty, implies Value is populated -} -type reportRecord struct { - Key reflect.Value // Invalid for slice element - Value *valueNode -} - -func (parent *valueNode) PushStep(ps PathStep) (child *valueNode) { - vx, vy := ps.Values() - child = &valueNode{parent: parent, Type: ps.Type(), ValueX: vx, ValueY: vy} - switch s := ps.(type) { - case StructField: - assert(parent.Value == nil) - parent.Records = append(parent.Records, reportRecord{Key: reflect.ValueOf(s.Name()), Value: child}) - case SliceIndex: - assert(parent.Value == nil) - parent.Records = append(parent.Records, reportRecord{Value: child}) - case MapIndex: - assert(parent.Value == nil) - parent.Records = append(parent.Records, reportRecord{Key: s.Key(), Value: child}) - case Indirect: - assert(parent.Value == nil && parent.Records == nil) - parent.Value = child - case TypeAssertion: - assert(parent.Value == nil && parent.Records == nil) - parent.Value = child - case Transform: - assert(parent.Value == nil && parent.Records == nil) - parent.Value = child - parent.TransformerName = s.Name() - parent.NumTransformed++ - default: - assert(parent == nil) // Must be the root step - } - return child -} - -func (r *valueNode) Report(rs Result) { - assert(r.MaxDepth == 0) // May only be called on leaf nodes - - if rs.ByIgnore() { - r.NumIgnored++ - } else { - if rs.Equal() { - r.NumSame++ - } else { - r.NumDiff++ - } - } - assert(r.NumSame+r.NumDiff+r.NumIgnored == 1) - - if rs.ByMethod() { - r.NumCompared++ - } - if rs.ByFunc() { - r.NumCompared++ - } - assert(r.NumCompared <= 1) -} - -func (child *valueNode) PopStep() (parent *valueNode) { - if child.parent == nil { - return nil - } - parent = child.parent - parent.NumSame += child.NumSame - parent.NumDiff += child.NumDiff - parent.NumIgnored += child.NumIgnored - parent.NumCompared += child.NumCompared - parent.NumTransformed += child.NumTransformed - parent.NumChildren += child.NumChildren + 1 - if parent.MaxDepth < child.MaxDepth+1 { - parent.MaxDepth = child.MaxDepth + 1 - } - return parent -} diff --git a/vendor/go.opencensus.io/plugin/ocgrpc/client.go b/vendor/go.opencensus.io/plugin/ocgrpc/client.go deleted file mode 100644 index 28fddb8440..0000000000 --- a/vendor/go.opencensus.io/plugin/ocgrpc/client.go +++ /dev/null @@ -1,56 +0,0 @@ -// Copyright 2018, OpenCensus 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 ocgrpc - -import ( - "context" - "go.opencensus.io/trace" - - "google.golang.org/grpc/stats" -) - -// ClientHandler implements a gRPC stats.Handler for recording OpenCensus stats and -// traces. Use with gRPC clients only. -type ClientHandler struct { - // StartOptions allows configuring the StartOptions used to create new spans. - // - // StartOptions.SpanKind will always be set to trace.SpanKindClient - // for spans started by this handler. - StartOptions trace.StartOptions -} - -// HandleConn exists to satisfy gRPC stats.Handler. -func (c *ClientHandler) HandleConn(ctx context.Context, cs stats.ConnStats) { - // no-op -} - -// TagConn exists to satisfy gRPC stats.Handler. -func (c *ClientHandler) TagConn(ctx context.Context, cti *stats.ConnTagInfo) context.Context { - // no-op - return ctx -} - -// HandleRPC implements per-RPC tracing and stats instrumentation. -func (c *ClientHandler) HandleRPC(ctx context.Context, rs stats.RPCStats) { - traceHandleRPC(ctx, rs) - statsHandleRPC(ctx, rs) -} - -// TagRPC implements per-RPC context management. -func (c *ClientHandler) TagRPC(ctx context.Context, rti *stats.RPCTagInfo) context.Context { - ctx = c.traceTagRPC(ctx, rti) - ctx = c.statsTagRPC(ctx, rti) - return ctx -} diff --git a/vendor/go.opencensus.io/plugin/ocgrpc/client_metrics.go b/vendor/go.opencensus.io/plugin/ocgrpc/client_metrics.go deleted file mode 100644 index abe978b67b..0000000000 --- a/vendor/go.opencensus.io/plugin/ocgrpc/client_metrics.go +++ /dev/null @@ -1,107 +0,0 @@ -// Copyright 2017, OpenCensus 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 ocgrpc - -import ( - "go.opencensus.io/stats" - "go.opencensus.io/stats/view" - "go.opencensus.io/tag" -) - -// The following variables are measures are recorded by ClientHandler: -var ( - ClientSentMessagesPerRPC = stats.Int64("grpc.io/client/sent_messages_per_rpc", "Number of messages sent in the RPC (always 1 for non-streaming RPCs).", stats.UnitDimensionless) - ClientSentBytesPerRPC = stats.Int64("grpc.io/client/sent_bytes_per_rpc", "Total bytes sent across all request messages per RPC.", stats.UnitBytes) - ClientReceivedMessagesPerRPC = stats.Int64("grpc.io/client/received_messages_per_rpc", "Number of response messages received per RPC (always 1 for non-streaming RPCs).", stats.UnitDimensionless) - ClientReceivedBytesPerRPC = stats.Int64("grpc.io/client/received_bytes_per_rpc", "Total bytes received across all response messages per RPC.", stats.UnitBytes) - ClientRoundtripLatency = stats.Float64("grpc.io/client/roundtrip_latency", "Time between first byte of request sent to last byte of response received, or terminal error.", stats.UnitMilliseconds) - ClientServerLatency = stats.Float64("grpc.io/client/server_latency", `Propagated from the server and should have the same value as "grpc.io/server/latency".`, stats.UnitMilliseconds) -) - -// Predefined views may be registered to collect data for the above measures. -// As always, you may also define your own custom views over measures collected by this -// package. These are declared as a convenience only; none are registered by -// default. -var ( - ClientSentBytesPerRPCView = &view.View{ - Measure: ClientSentBytesPerRPC, - Name: "grpc.io/client/sent_bytes_per_rpc", - Description: "Distribution of bytes sent per RPC, by method.", - TagKeys: []tag.Key{KeyClientMethod}, - Aggregation: DefaultBytesDistribution, - } - - ClientReceivedBytesPerRPCView = &view.View{ - Measure: ClientReceivedBytesPerRPC, - Name: "grpc.io/client/received_bytes_per_rpc", - Description: "Distribution of bytes received per RPC, by method.", - TagKeys: []tag.Key{KeyClientMethod}, - Aggregation: DefaultBytesDistribution, - } - - ClientRoundtripLatencyView = &view.View{ - Measure: ClientRoundtripLatency, - Name: "grpc.io/client/roundtrip_latency", - Description: "Distribution of round-trip latency, by method.", - TagKeys: []tag.Key{KeyClientMethod}, - Aggregation: DefaultMillisecondsDistribution, - } - - ClientCompletedRPCsView = &view.View{ - Measure: ClientRoundtripLatency, - Name: "grpc.io/client/completed_rpcs", - Description: "Count of RPCs by method and status.", - TagKeys: []tag.Key{KeyClientMethod, KeyClientStatus}, - Aggregation: view.Count(), - } - - ClientSentMessagesPerRPCView = &view.View{ - Measure: ClientSentMessagesPerRPC, - Name: "grpc.io/client/sent_messages_per_rpc", - Description: "Distribution of sent messages count per RPC, by method.", - TagKeys: []tag.Key{KeyClientMethod}, - Aggregation: DefaultMessageCountDistribution, - } - - ClientReceivedMessagesPerRPCView = &view.View{ - Measure: ClientReceivedMessagesPerRPC, - Name: "grpc.io/client/received_messages_per_rpc", - Description: "Distribution of received messages count per RPC, by method.", - TagKeys: []tag.Key{KeyClientMethod}, - Aggregation: DefaultMessageCountDistribution, - } - - ClientServerLatencyView = &view.View{ - Measure: ClientServerLatency, - Name: "grpc.io/client/server_latency", - Description: "Distribution of server latency as viewed by client, by method.", - TagKeys: []tag.Key{KeyClientMethod}, - Aggregation: DefaultMillisecondsDistribution, - } -) - -// DefaultClientViews are the default client views provided by this package. -var DefaultClientViews = []*view.View{ - ClientSentBytesPerRPCView, - ClientReceivedBytesPerRPCView, - ClientRoundtripLatencyView, - ClientCompletedRPCsView, -} - -// TODO(jbd): Add roundtrip_latency, uncompressed_request_bytes, uncompressed_response_bytes, request_count, response_count. -// TODO(acetechnologist): This is temporary and will need to be replaced by a -// mechanism to load these defaults from a common repository/config shared by -// all supported languages. Likely a serialized protobuf of these defaults. diff --git a/vendor/go.opencensus.io/plugin/ocgrpc/client_stats_handler.go b/vendor/go.opencensus.io/plugin/ocgrpc/client_stats_handler.go deleted file mode 100644 index b36349820d..0000000000 --- a/vendor/go.opencensus.io/plugin/ocgrpc/client_stats_handler.go +++ /dev/null @@ -1,49 +0,0 @@ -// Copyright 2017, OpenCensus 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 ocgrpc - -import ( - "context" - "time" - - "go.opencensus.io/tag" - "google.golang.org/grpc/grpclog" - "google.golang.org/grpc/stats" -) - -// statsTagRPC gets the tag.Map populated by the application code, serializes -// its tags into the GRPC metadata in order to be sent to the server. -func (h *ClientHandler) statsTagRPC(ctx context.Context, info *stats.RPCTagInfo) context.Context { - startTime := time.Now() - if info == nil { - if grpclog.V(2) { - grpclog.Info("clientHandler.TagRPC called with nil info.") - } - return ctx - } - - d := &rpcData{ - startTime: startTime, - method: info.FullMethodName, - } - ts := tag.FromContext(ctx) - if ts != nil { - encoded := tag.Encode(ts) - ctx = stats.SetTags(ctx, encoded) - } - - return context.WithValue(ctx, rpcDataKey, d) -} diff --git a/vendor/go.opencensus.io/plugin/ocgrpc/doc.go b/vendor/go.opencensus.io/plugin/ocgrpc/doc.go deleted file mode 100644 index 1370323fb7..0000000000 --- a/vendor/go.opencensus.io/plugin/ocgrpc/doc.go +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright 2017, OpenCensus 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 ocgrpc contains OpenCensus stats and trace -// integrations for gRPC. -// -// Use ServerHandler for servers and ClientHandler for clients. -package ocgrpc // import "go.opencensus.io/plugin/ocgrpc" diff --git a/vendor/go.opencensus.io/plugin/ocgrpc/server.go b/vendor/go.opencensus.io/plugin/ocgrpc/server.go deleted file mode 100644 index 15ada839d6..0000000000 --- a/vendor/go.opencensus.io/plugin/ocgrpc/server.go +++ /dev/null @@ -1,80 +0,0 @@ -// Copyright 2018, OpenCensus 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 ocgrpc - -import ( - "context" - "go.opencensus.io/trace" - - "google.golang.org/grpc/stats" -) - -// ServerHandler implements gRPC stats.Handler recording OpenCensus stats and -// traces. Use with gRPC servers. -// -// When installed (see Example), tracing metadata is read from inbound RPCs -// by default. If no tracing metadata is present, or if the tracing metadata is -// present but the SpanContext isn't sampled, then a new trace may be started -// (as determined by Sampler). -type ServerHandler struct { - // IsPublicEndpoint may be set to true to always start a new trace around - // each RPC. Any SpanContext in the RPC metadata will be added as a linked - // span instead of making it the parent of the span created around the - // server RPC. - // - // Be aware that if you leave this false (the default) on a public-facing - // server, callers will be able to send tracing metadata in gRPC headers - // and trigger traces in your backend. - IsPublicEndpoint bool - - // StartOptions to use for to spans started around RPCs handled by this server. - // - // These will apply even if there is tracing metadata already - // present on the inbound RPC but the SpanContext is not sampled. This - // ensures that each service has some opportunity to be traced. If you would - // like to not add any additional traces for this gRPC service, set: - // - // StartOptions.Sampler = trace.ProbabilitySampler(0.0) - // - // StartOptions.SpanKind will always be set to trace.SpanKindServer - // for spans started by this handler. - StartOptions trace.StartOptions -} - -var _ stats.Handler = (*ServerHandler)(nil) - -// HandleConn exists to satisfy gRPC stats.Handler. -func (s *ServerHandler) HandleConn(ctx context.Context, cs stats.ConnStats) { - // no-op -} - -// TagConn exists to satisfy gRPC stats.Handler. -func (s *ServerHandler) TagConn(ctx context.Context, cti *stats.ConnTagInfo) context.Context { - // no-op - return ctx -} - -// HandleRPC implements per-RPC tracing and stats instrumentation. -func (s *ServerHandler) HandleRPC(ctx context.Context, rs stats.RPCStats) { - traceHandleRPC(ctx, rs) - statsHandleRPC(ctx, rs) -} - -// TagRPC implements per-RPC context management. -func (s *ServerHandler) TagRPC(ctx context.Context, rti *stats.RPCTagInfo) context.Context { - ctx = s.traceTagRPC(ctx, rti) - ctx = s.statsTagRPC(ctx, rti) - return ctx -} diff --git a/vendor/go.opencensus.io/plugin/ocgrpc/server_metrics.go b/vendor/go.opencensus.io/plugin/ocgrpc/server_metrics.go deleted file mode 100644 index 609d9ed248..0000000000 --- a/vendor/go.opencensus.io/plugin/ocgrpc/server_metrics.go +++ /dev/null @@ -1,97 +0,0 @@ -// Copyright 2017, OpenCensus 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 ocgrpc - -import ( - "go.opencensus.io/stats" - "go.opencensus.io/stats/view" - "go.opencensus.io/tag" -) - -// The following variables are measures are recorded by ServerHandler: -var ( - ServerReceivedMessagesPerRPC = stats.Int64("grpc.io/server/received_messages_per_rpc", "Number of messages received in each RPC. Has value 1 for non-streaming RPCs.", stats.UnitDimensionless) - ServerReceivedBytesPerRPC = stats.Int64("grpc.io/server/received_bytes_per_rpc", "Total bytes received across all messages per RPC.", stats.UnitBytes) - ServerSentMessagesPerRPC = stats.Int64("grpc.io/server/sent_messages_per_rpc", "Number of messages sent in each RPC. Has value 1 for non-streaming RPCs.", stats.UnitDimensionless) - ServerSentBytesPerRPC = stats.Int64("grpc.io/server/sent_bytes_per_rpc", "Total bytes sent in across all response messages per RPC.", stats.UnitBytes) - ServerLatency = stats.Float64("grpc.io/server/server_latency", "Time between first byte of request received to last byte of response sent, or terminal error.", stats.UnitMilliseconds) -) - -// TODO(acetechnologist): This is temporary and will need to be replaced by a -// mechanism to load these defaults from a common repository/config shared by -// all supported languages. Likely a serialized protobuf of these defaults. - -// Predefined views may be registered to collect data for the above measures. -// As always, you may also define your own custom views over measures collected by this -// package. These are declared as a convenience only; none are registered by -// default. -var ( - ServerReceivedBytesPerRPCView = &view.View{ - Name: "grpc.io/server/received_bytes_per_rpc", - Description: "Distribution of received bytes per RPC, by method.", - Measure: ServerReceivedBytesPerRPC, - TagKeys: []tag.Key{KeyServerMethod}, - Aggregation: DefaultBytesDistribution, - } - - ServerSentBytesPerRPCView = &view.View{ - Name: "grpc.io/server/sent_bytes_per_rpc", - Description: "Distribution of total sent bytes per RPC, by method.", - Measure: ServerSentBytesPerRPC, - TagKeys: []tag.Key{KeyServerMethod}, - Aggregation: DefaultBytesDistribution, - } - - ServerLatencyView = &view.View{ - Name: "grpc.io/server/server_latency", - Description: "Distribution of server latency in milliseconds, by method.", - TagKeys: []tag.Key{KeyServerMethod}, - Measure: ServerLatency, - Aggregation: DefaultMillisecondsDistribution, - } - - ServerCompletedRPCsView = &view.View{ - Name: "grpc.io/server/completed_rpcs", - Description: "Count of RPCs by method and status.", - TagKeys: []tag.Key{KeyServerMethod, KeyServerStatus}, - Measure: ServerLatency, - Aggregation: view.Count(), - } - - ServerReceivedMessagesPerRPCView = &view.View{ - Name: "grpc.io/server/received_messages_per_rpc", - Description: "Distribution of messages received count per RPC, by method.", - TagKeys: []tag.Key{KeyServerMethod}, - Measure: ServerReceivedMessagesPerRPC, - Aggregation: DefaultMessageCountDistribution, - } - - ServerSentMessagesPerRPCView = &view.View{ - Name: "grpc.io/server/sent_messages_per_rpc", - Description: "Distribution of messages sent count per RPC, by method.", - TagKeys: []tag.Key{KeyServerMethod}, - Measure: ServerSentMessagesPerRPC, - Aggregation: DefaultMessageCountDistribution, - } -) - -// DefaultServerViews are the default server views provided by this package. -var DefaultServerViews = []*view.View{ - ServerReceivedBytesPerRPCView, - ServerSentBytesPerRPCView, - ServerLatencyView, - ServerCompletedRPCsView, -} diff --git a/vendor/go.opencensus.io/plugin/ocgrpc/server_stats_handler.go b/vendor/go.opencensus.io/plugin/ocgrpc/server_stats_handler.go deleted file mode 100644 index afcef023af..0000000000 --- a/vendor/go.opencensus.io/plugin/ocgrpc/server_stats_handler.go +++ /dev/null @@ -1,63 +0,0 @@ -// Copyright 2017, OpenCensus 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 ocgrpc - -import ( - "time" - - "context" - - "go.opencensus.io/tag" - "google.golang.org/grpc/grpclog" - "google.golang.org/grpc/stats" -) - -// statsTagRPC gets the metadata from gRPC context, extracts the encoded tags from -// it and creates a new tag.Map and puts them into the returned context. -func (h *ServerHandler) statsTagRPC(ctx context.Context, info *stats.RPCTagInfo) context.Context { - startTime := time.Now() - if info == nil { - if grpclog.V(2) { - grpclog.Infof("opencensus: TagRPC called with nil info.") - } - return ctx - } - d := &rpcData{ - startTime: startTime, - method: info.FullMethodName, - } - propagated := h.extractPropagatedTags(ctx) - ctx = tag.NewContext(ctx, propagated) - ctx, _ = tag.New(ctx, tag.Upsert(KeyServerMethod, methodName(info.FullMethodName))) - return context.WithValue(ctx, rpcDataKey, d) -} - -// extractPropagatedTags creates a new tag map containing the tags extracted from the -// gRPC metadata. -func (h *ServerHandler) extractPropagatedTags(ctx context.Context) *tag.Map { - buf := stats.Tags(ctx) - if buf == nil { - return nil - } - propagated, err := tag.Decode(buf) - if err != nil { - if grpclog.V(2) { - grpclog.Warningf("opencensus: Failed to decode tags from gRPC metadata failed to decode: %v", err) - } - return nil - } - return propagated -} diff --git a/vendor/go.opencensus.io/plugin/ocgrpc/stats_common.go b/vendor/go.opencensus.io/plugin/ocgrpc/stats_common.go deleted file mode 100644 index 89cac9c4ec..0000000000 --- a/vendor/go.opencensus.io/plugin/ocgrpc/stats_common.go +++ /dev/null @@ -1,227 +0,0 @@ -// Copyright 2017, OpenCensus 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 ocgrpc - -import ( - "context" - "strconv" - "strings" - "sync/atomic" - "time" - - "go.opencensus.io/metric/metricdata" - ocstats "go.opencensus.io/stats" - "go.opencensus.io/stats/view" - "go.opencensus.io/tag" - "go.opencensus.io/trace" - "google.golang.org/grpc/codes" - "google.golang.org/grpc/grpclog" - "google.golang.org/grpc/stats" - "google.golang.org/grpc/status" -) - -type grpcInstrumentationKey string - -// rpcData holds the instrumentation RPC data that is needed between the start -// and end of an call. It holds the info that this package needs to keep track -// of between the various GRPC events. -type rpcData struct { - // reqCount and respCount has to be the first words - // in order to be 64-aligned on 32-bit architectures. - sentCount, sentBytes, recvCount, recvBytes int64 // access atomically - - // startTime represents the time at which TagRPC was invoked at the - // beginning of an RPC. It is an appoximation of the time when the - // application code invoked GRPC code. - startTime time.Time - method string -} - -// The following variables define the default hard-coded auxiliary data used by -// both the default GRPC client and GRPC server metrics. -var ( - DefaultBytesDistribution = view.Distribution(1024, 2048, 4096, 16384, 65536, 262144, 1048576, 4194304, 16777216, 67108864, 268435456, 1073741824, 4294967296) - DefaultMillisecondsDistribution = view.Distribution(0.01, 0.05, 0.1, 0.3, 0.6, 0.8, 1, 2, 3, 4, 5, 6, 8, 10, 13, 16, 20, 25, 30, 40, 50, 65, 80, 100, 130, 160, 200, 250, 300, 400, 500, 650, 800, 1000, 2000, 5000, 10000, 20000, 50000, 100000) - DefaultMessageCountDistribution = view.Distribution(1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536) -) - -// Server tags are applied to the context used to process each RPC, as well as -// the measures at the end of each RPC. -var ( - KeyServerMethod = tag.MustNewKey("grpc_server_method") - KeyServerStatus = tag.MustNewKey("grpc_server_status") -) - -// Client tags are applied to measures at the end of each RPC. -var ( - KeyClientMethod = tag.MustNewKey("grpc_client_method") - KeyClientStatus = tag.MustNewKey("grpc_client_status") -) - -var ( - rpcDataKey = grpcInstrumentationKey("opencensus-rpcData") -) - -func methodName(fullname string) string { - return strings.TrimLeft(fullname, "/") -} - -// statsHandleRPC processes the RPC events. -func statsHandleRPC(ctx context.Context, s stats.RPCStats) { - switch st := s.(type) { - case *stats.Begin, *stats.OutHeader, *stats.InHeader, *stats.InTrailer, *stats.OutTrailer: - // do nothing for client - case *stats.OutPayload: - handleRPCOutPayload(ctx, st) - case *stats.InPayload: - handleRPCInPayload(ctx, st) - case *stats.End: - handleRPCEnd(ctx, st) - default: - grpclog.Infof("unexpected stats: %T", st) - } -} - -func handleRPCOutPayload(ctx context.Context, s *stats.OutPayload) { - d, ok := ctx.Value(rpcDataKey).(*rpcData) - if !ok { - if grpclog.V(2) { - grpclog.Infoln("Failed to retrieve *rpcData from context.") - } - return - } - - atomic.AddInt64(&d.sentBytes, int64(s.Length)) - atomic.AddInt64(&d.sentCount, 1) -} - -func handleRPCInPayload(ctx context.Context, s *stats.InPayload) { - d, ok := ctx.Value(rpcDataKey).(*rpcData) - if !ok { - if grpclog.V(2) { - grpclog.Infoln("Failed to retrieve *rpcData from context.") - } - return - } - - atomic.AddInt64(&d.recvBytes, int64(s.Length)) - atomic.AddInt64(&d.recvCount, 1) -} - -func handleRPCEnd(ctx context.Context, s *stats.End) { - d, ok := ctx.Value(rpcDataKey).(*rpcData) - if !ok { - if grpclog.V(2) { - grpclog.Infoln("Failed to retrieve *rpcData from context.") - } - return - } - - elapsedTime := time.Since(d.startTime) - - var st string - if s.Error != nil { - s, ok := status.FromError(s.Error) - if ok { - st = statusCodeToString(s) - } - } else { - st = "OK" - } - - latencyMillis := float64(elapsedTime) / float64(time.Millisecond) - attachments := getSpanCtxAttachment(ctx) - if s.Client { - ocstats.RecordWithOptions(ctx, - ocstats.WithTags( - tag.Upsert(KeyClientMethod, methodName(d.method)), - tag.Upsert(KeyClientStatus, st)), - ocstats.WithAttachments(attachments), - ocstats.WithMeasurements( - ClientSentBytesPerRPC.M(atomic.LoadInt64(&d.sentBytes)), - ClientSentMessagesPerRPC.M(atomic.LoadInt64(&d.sentCount)), - ClientReceivedMessagesPerRPC.M(atomic.LoadInt64(&d.recvCount)), - ClientReceivedBytesPerRPC.M(atomic.LoadInt64(&d.recvBytes)), - ClientRoundtripLatency.M(latencyMillis))) - } else { - ocstats.RecordWithOptions(ctx, - ocstats.WithTags( - tag.Upsert(KeyServerStatus, st), - ), - ocstats.WithAttachments(attachments), - ocstats.WithMeasurements( - ServerSentBytesPerRPC.M(atomic.LoadInt64(&d.sentBytes)), - ServerSentMessagesPerRPC.M(atomic.LoadInt64(&d.sentCount)), - ServerReceivedMessagesPerRPC.M(atomic.LoadInt64(&d.recvCount)), - ServerReceivedBytesPerRPC.M(atomic.LoadInt64(&d.recvBytes)), - ServerLatency.M(latencyMillis))) - } -} - -func statusCodeToString(s *status.Status) string { - // see https://github.com/grpc/grpc/blob/master/doc/statuscodes.md - switch c := s.Code(); c { - case codes.OK: - return "OK" - case codes.Canceled: - return "CANCELLED" - case codes.Unknown: - return "UNKNOWN" - case codes.InvalidArgument: - return "INVALID_ARGUMENT" - case codes.DeadlineExceeded: - return "DEADLINE_EXCEEDED" - case codes.NotFound: - return "NOT_FOUND" - case codes.AlreadyExists: - return "ALREADY_EXISTS" - case codes.PermissionDenied: - return "PERMISSION_DENIED" - case codes.ResourceExhausted: - return "RESOURCE_EXHAUSTED" - case codes.FailedPrecondition: - return "FAILED_PRECONDITION" - case codes.Aborted: - return "ABORTED" - case codes.OutOfRange: - return "OUT_OF_RANGE" - case codes.Unimplemented: - return "UNIMPLEMENTED" - case codes.Internal: - return "INTERNAL" - case codes.Unavailable: - return "UNAVAILABLE" - case codes.DataLoss: - return "DATA_LOSS" - case codes.Unauthenticated: - return "UNAUTHENTICATED" - default: - return "CODE_" + strconv.FormatInt(int64(c), 10) - } -} - -func getSpanCtxAttachment(ctx context.Context) metricdata.Attachments { - attachments := map[string]interface{}{} - span := trace.FromContext(ctx) - if span == nil { - return attachments - } - spanCtx := span.SpanContext() - if spanCtx.IsSampled() { - attachments[metricdata.AttachmentKeySpanContext] = spanCtx - } - return attachments -} diff --git a/vendor/go.opencensus.io/plugin/ocgrpc/trace_common.go b/vendor/go.opencensus.io/plugin/ocgrpc/trace_common.go deleted file mode 100644 index fef5827566..0000000000 --- a/vendor/go.opencensus.io/plugin/ocgrpc/trace_common.go +++ /dev/null @@ -1,107 +0,0 @@ -// Copyright 2017, OpenCensus 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 ocgrpc - -import ( - "strings" - - "google.golang.org/grpc/codes" - - "context" - "go.opencensus.io/trace" - "go.opencensus.io/trace/propagation" - "google.golang.org/grpc/metadata" - "google.golang.org/grpc/stats" - "google.golang.org/grpc/status" -) - -const traceContextKey = "grpc-trace-bin" - -// TagRPC creates a new trace span for the client side of the RPC. -// -// It returns ctx with the new trace span added and a serialization of the -// SpanContext added to the outgoing gRPC metadata. -func (c *ClientHandler) traceTagRPC(ctx context.Context, rti *stats.RPCTagInfo) context.Context { - name := strings.TrimPrefix(rti.FullMethodName, "/") - name = strings.Replace(name, "/", ".", -1) - ctx, span := trace.StartSpan(ctx, name, - trace.WithSampler(c.StartOptions.Sampler), - trace.WithSpanKind(trace.SpanKindClient)) // span is ended by traceHandleRPC - traceContextBinary := propagation.Binary(span.SpanContext()) - return metadata.AppendToOutgoingContext(ctx, traceContextKey, string(traceContextBinary)) -} - -// TagRPC creates a new trace span for the server side of the RPC. -// -// It checks the incoming gRPC metadata in ctx for a SpanContext, and if -// it finds one, uses that SpanContext as the parent context of the new span. -// -// It returns ctx, with the new trace span added. -func (s *ServerHandler) traceTagRPC(ctx context.Context, rti *stats.RPCTagInfo) context.Context { - md, _ := metadata.FromIncomingContext(ctx) - name := strings.TrimPrefix(rti.FullMethodName, "/") - name = strings.Replace(name, "/", ".", -1) - traceContext := md[traceContextKey] - var ( - parent trace.SpanContext - haveParent bool - ) - if len(traceContext) > 0 { - // Metadata with keys ending in -bin are actually binary. They are base64 - // encoded before being put on the wire, see: - // https://github.com/grpc/grpc-go/blob/08d6261/Documentation/grpc-metadata.md#storing-binary-data-in-metadata - traceContextBinary := []byte(traceContext[0]) - parent, haveParent = propagation.FromBinary(traceContextBinary) - if haveParent && !s.IsPublicEndpoint { - ctx, _ := trace.StartSpanWithRemoteParent(ctx, name, parent, - trace.WithSpanKind(trace.SpanKindServer), - trace.WithSampler(s.StartOptions.Sampler), - ) - return ctx - } - } - ctx, span := trace.StartSpan(ctx, name, - trace.WithSpanKind(trace.SpanKindServer), - trace.WithSampler(s.StartOptions.Sampler)) - if haveParent { - span.AddLink(trace.Link{TraceID: parent.TraceID, SpanID: parent.SpanID, Type: trace.LinkTypeChild}) - } - return ctx -} - -func traceHandleRPC(ctx context.Context, rs stats.RPCStats) { - span := trace.FromContext(ctx) - // TODO: compressed and uncompressed sizes are not populated in every message. - switch rs := rs.(type) { - case *stats.Begin: - span.AddAttributes( - trace.BoolAttribute("Client", rs.Client), - trace.BoolAttribute("FailFast", rs.FailFast)) - case *stats.InPayload: - span.AddMessageReceiveEvent(0 /* TODO: messageID */, int64(rs.Length), int64(rs.WireLength)) - case *stats.OutPayload: - span.AddMessageSendEvent(0, int64(rs.Length), int64(rs.WireLength)) - case *stats.End: - if rs.Error != nil { - s, ok := status.FromError(rs.Error) - if ok { - span.SetStatus(trace.Status{Code: int32(s.Code()), Message: s.Message()}) - } else { - span.SetStatus(trace.Status{Code: int32(codes.Internal), Message: rs.Error.Error()}) - } - } - span.End() - } -} diff --git a/vendor/google.golang.org/api/transport/dial.go b/vendor/google.golang.org/api/transport/dial.go deleted file mode 100644 index 2c495ad538..0000000000 --- a/vendor/google.golang.org/api/transport/dial.go +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright 2015 Google LLC. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package transport - -import ( - "context" - "net/http" - - "google.golang.org/grpc" - - "google.golang.org/api/option" - gtransport "google.golang.org/api/transport/grpc" - htransport "google.golang.org/api/transport/http" -) - -// NewHTTPClient returns an HTTP client for use communicating with a Google cloud -// service, configured with the given ClientOptions. It also returns the endpoint -// for the service as specified in the options. -func NewHTTPClient(ctx context.Context, opts ...option.ClientOption) (*http.Client, string, error) { - return htransport.NewClient(ctx, opts...) -} - -// DialGRPC returns a GRPC connection for use communicating with a Google cloud -// service, configured with the given ClientOptions. -func DialGRPC(ctx context.Context, opts ...option.ClientOption) (*grpc.ClientConn, error) { - return gtransport.Dial(ctx, opts...) -} - -// DialGRPCInsecure returns an insecure GRPC connection for use communicating -// with fake or mock Google cloud service implementations, such as emulators. -// The connection is configured with the given ClientOptions. -func DialGRPCInsecure(ctx context.Context, opts ...option.ClientOption) (*grpc.ClientConn, error) { - return gtransport.DialInsecure(ctx, opts...) -} diff --git a/vendor/google.golang.org/api/transport/doc.go b/vendor/google.golang.org/api/transport/doc.go deleted file mode 100644 index 7143abee45..0000000000 --- a/vendor/google.golang.org/api/transport/doc.go +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright 2019 Google LLC. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// Package transport provides utility methods for creating authenticated -// transports to Google's HTTP and gRPC APIs. It is intended to be used in -// conjunction with google.golang.org/api/option. -// -// This package is not intended for use by end developers. Use the -// google.golang.org/api/option package to configure API clients. -package transport diff --git a/vendor/google.golang.org/api/transport/go19.go b/vendor/google.golang.org/api/transport/go19.go deleted file mode 100644 index abaa633f4e..0000000000 --- a/vendor/google.golang.org/api/transport/go19.go +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2018 Google LLC. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build go1.9 - -package transport - -import ( - "context" - - "golang.org/x/oauth2/google" - "google.golang.org/api/internal" - "google.golang.org/api/option" -) - -// Creds constructs a google.Credentials from the information in the options, -// or obtains the default credentials in the same way as google.FindDefaultCredentials. -func Creds(ctx context.Context, opts ...option.ClientOption) (*google.Credentials, error) { - var ds internal.DialSettings - for _, opt := range opts { - opt.Apply(&ds) - } - return internal.Creds(ctx, &ds) -} diff --git a/vendor/google.golang.org/api/transport/grpc/dial.go b/vendor/google.golang.org/api/transport/grpc/dial.go deleted file mode 100644 index 7526e6820c..0000000000 --- a/vendor/google.golang.org/api/transport/grpc/dial.go +++ /dev/null @@ -1,202 +0,0 @@ -// Copyright 2015 Google LLC. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// Package grpc supports network connections to GRPC servers. -// This package is not intended for use by end developers. Use the -// google.golang.org/api/option package to configure API clients. -package grpc - -import ( - "context" - "errors" - "log" - "os" - "strings" - - "go.opencensus.io/plugin/ocgrpc" - "golang.org/x/oauth2" - "google.golang.org/api/internal" - "google.golang.org/api/option" - "google.golang.org/grpc" - "google.golang.org/grpc/credentials" - grpcgoogle "google.golang.org/grpc/credentials/google" - "google.golang.org/grpc/credentials/oauth" - - // Install grpclb, which is required for direct path. - _ "google.golang.org/grpc/balancer/grpclb" -) - -// Set at init time by dial_appengine.go. If nil, we're not on App Engine. -var appengineDialerHook func(context.Context) grpc.DialOption - -// Set at init time by dial_socketopt.go. If nil, socketopt is not supported. -var timeoutDialerOption grpc.DialOption - -// Dial returns a GRPC connection for use communicating with a Google cloud -// service, configured with the given ClientOptions. -func Dial(ctx context.Context, opts ...option.ClientOption) (*grpc.ClientConn, error) { - return dial(ctx, false, opts) -} - -// DialInsecure returns an insecure GRPC connection for use communicating -// with fake or mock Google cloud service implementations, such as emulators. -// The connection is configured with the given ClientOptions. -func DialInsecure(ctx context.Context, opts ...option.ClientOption) (*grpc.ClientConn, error) { - return dial(ctx, true, opts) -} - -func dial(ctx context.Context, insecure bool, opts []option.ClientOption) (*grpc.ClientConn, error) { - var o internal.DialSettings - for _, opt := range opts { - opt.Apply(&o) - } - if err := o.Validate(); err != nil { - return nil, err - } - if o.HTTPClient != nil { - return nil, errors.New("unsupported HTTP client specified") - } - if o.GRPCConn != nil { - return o.GRPCConn, nil - } - var grpcOpts []grpc.DialOption - if insecure { - grpcOpts = []grpc.DialOption{grpc.WithInsecure()} - } else if !o.NoAuth { - if o.APIKey != "" { - log.Print("API keys are not supported for gRPC APIs. Remove the WithAPIKey option from your client-creating call.") - } - creds, err := internal.Creds(ctx, &o) - if err != nil { - return nil, err - } - // Attempt Direct Path only if: - // * The endpoint is a host:port (or dns:///host:port). - // * Credentials are obtained via GCE metadata server, using the default - // service account. - // * Opted in via GOOGLE_CLOUD_ENABLE_DIRECT_PATH environment variable. - // For example, GOOGLE_CLOUD_ENABLE_DIRECT_PATH=spanner,pubsub - if isDirectPathEnabled(o.Endpoint) && isTokenSourceDirectPathCompatible(creds.TokenSource) { - if !strings.HasPrefix(o.Endpoint, "dns:///") { - o.Endpoint = "dns:///" + o.Endpoint - } - grpcOpts = []grpc.DialOption{ - grpc.WithCredentialsBundle( - grpcgoogle.NewComputeEngineCredentials(), - ), - } - // TODO(cbro): add support for system parameters (quota project, request reason) via chained interceptor. - } else { - grpcOpts = []grpc.DialOption{ - grpc.WithPerRPCCredentials(grpcTokenSource{ - TokenSource: oauth.TokenSource{creds.TokenSource}, - quotaProject: o.QuotaProject, - requestReason: o.RequestReason, - }), - grpc.WithTransportCredentials(credentials.NewClientTLSFromCert(nil, "")), - } - } - } - - if appengineDialerHook != nil { - // Use the Socket API on App Engine. - // appengine dialer will override socketopt dialer - grpcOpts = append(grpcOpts, appengineDialerHook(ctx)) - } - - // Add tracing, but before the other options, so that clients can override the - // gRPC stats handler. - // This assumes that gRPC options are processed in order, left to right. - grpcOpts = addOCStatsHandler(grpcOpts, o) - grpcOpts = append(grpcOpts, o.GRPCDialOpts...) - if o.UserAgent != "" { - grpcOpts = append(grpcOpts, grpc.WithUserAgent(o.UserAgent)) - } - - // TODO(weiranf): This socketopt dialer will be used by default at some - // point when isDirectPathEnabled will default to true, we guard it by - // the Directpath env var for now once we can introspect user defined - // dialer (https://github.com/grpc/grpc-go/issues/2795). - if timeoutDialerOption != nil && isDirectPathEnabled(o.Endpoint) { - grpcOpts = append(grpcOpts, timeoutDialerOption) - } - - return grpc.DialContext(ctx, o.Endpoint, grpcOpts...) -} - -func addOCStatsHandler(opts []grpc.DialOption, settings internal.DialSettings) []grpc.DialOption { - if settings.TelemetryDisabled { - return opts - } - return append(opts, grpc.WithStatsHandler(&ocgrpc.ClientHandler{})) -} - -// grpcTokenSource supplies PerRPCCredentials from an oauth.TokenSource. -type grpcTokenSource struct { - oauth.TokenSource - - // Additional metadata attached as headers. - quotaProject string - requestReason string -} - -// GetRequestMetadata gets the request metadata as a map from a grpcTokenSource. -func (ts grpcTokenSource) GetRequestMetadata(ctx context.Context, uri ...string) ( - map[string]string, error) { - metadata, err := ts.TokenSource.GetRequestMetadata(ctx, uri...) - if err != nil { - return nil, err - } - - // Attach system parameter - if ts.quotaProject != "" { - metadata["X-goog-user-project"] = ts.quotaProject - } - if ts.requestReason != "" { - metadata["X-goog-request-reason"] = ts.requestReason - } - return metadata, nil -} - -func isTokenSourceDirectPathCompatible(ts oauth2.TokenSource) bool { - if ts == nil { - return false - } - tok, err := ts.Token() - if err != nil { - return false - } - if tok == nil { - return false - } - if source, _ := tok.Extra("oauth2.google.tokenSource").(string); source != "compute-metadata" { - return false - } - if acct, _ := tok.Extra("oauth2.google.serviceAccount").(string); acct != "default" { - return false - } - return true -} - -func isDirectPathEnabled(endpoint string) bool { - // Only host:port is supported, not other schemes (e.g., "tcp://" or "unix://"). - // Also don't try direct path if the user has chosen an alternate name resolver - // (i.e., via ":///" prefix). - // - // TODO(cbro): once gRPC has introspectible options, check the user hasn't - // provided a custom dialer in gRPC options. - if strings.Contains(endpoint, "://") && !strings.HasPrefix(endpoint, "dns:///") { - return false - } - - // Only try direct path if the user has opted in via the environment variable. - whitelist := strings.Split(os.Getenv("GOOGLE_CLOUD_ENABLE_DIRECT_PATH"), ",") - for _, api := range whitelist { - // Ignore empty string since an empty env variable splits into [""] - if api != "" && strings.Contains(endpoint, api) { - return true - } - } - return false -} diff --git a/vendor/google.golang.org/api/transport/grpc/dial_appengine.go b/vendor/google.golang.org/api/transport/grpc/dial_appengine.go deleted file mode 100644 index 2c6aef2264..0000000000 --- a/vendor/google.golang.org/api/transport/grpc/dial_appengine.go +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright 2016 Google LLC. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build appengine - -package grpc - -import ( - "context" - "net" - "time" - - "google.golang.org/appengine" - "google.golang.org/appengine/socket" - "google.golang.org/grpc" -) - -func init() { - // NOTE: dev_appserver doesn't currently support SSL. - // When it does, this code can be removed. - if appengine.IsDevAppServer() { - return - } - - appengineDialerHook = func(ctx context.Context) grpc.DialOption { - return grpc.WithDialer(func(addr string, timeout time.Duration) (net.Conn, error) { - return socket.DialTimeout(ctx, "tcp", addr, timeout) - }) - } -} diff --git a/vendor/google.golang.org/api/transport/grpc/dial_socketopt.go b/vendor/google.golang.org/api/transport/grpc/dial_socketopt.go deleted file mode 100644 index 0e4f388968..0000000000 --- a/vendor/google.golang.org/api/transport/grpc/dial_socketopt.go +++ /dev/null @@ -1,49 +0,0 @@ -// Copyright 2019 Google LLC. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build go1.11,linux - -package grpc - -import ( - "context" - "net" - "syscall" - - "golang.org/x/sys/unix" - "google.golang.org/grpc" -) - -const ( - // defaultTCPUserTimeout is the default TCP_USER_TIMEOUT socket option. By - // default is 20 seconds. - tcpUserTimeoutMilliseconds = 20000 -) - -func init() { - // timeoutDialerOption is a grpc.DialOption that contains dialer with - // socket option TCP_USER_TIMEOUT. This dialer requires go versions 1.11+. - timeoutDialerOption = grpc.WithContextDialer(dialTCPUserTimeout) -} - -func dialTCPUserTimeout(ctx context.Context, addr string) (net.Conn, error) { - control := func(network, address string, c syscall.RawConn) error { - var syscallErr error - controlErr := c.Control(func(fd uintptr) { - syscallErr = syscall.SetsockoptInt( - int(fd), syscall.IPPROTO_TCP, unix.TCP_USER_TIMEOUT, tcpUserTimeoutMilliseconds) - }) - if syscallErr != nil { - return syscallErr - } - if controlErr != nil { - return controlErr - } - return nil - } - d := &net.Dialer{ - Control: control, - } - return d.DialContext(ctx, "tcp", addr) -} diff --git a/vendor/google.golang.org/api/transport/not_go19.go b/vendor/google.golang.org/api/transport/not_go19.go deleted file mode 100644 index 657bb6b2e9..0000000000 --- a/vendor/google.golang.org/api/transport/not_go19.go +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2018 Google LLC. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build !go1.9 - -package transport - -import ( - "context" - - "golang.org/x/oauth2/google" - "google.golang.org/api/internal" - "google.golang.org/api/option" -) - -// Creds constructs a google.DefaultCredentials from the information in the options, -// or obtains the default credentials in the same way as google.FindDefaultCredentials. -func Creds(ctx context.Context, opts ...option.ClientOption) (*google.DefaultCredentials, error) { - var ds internal.DialSettings - for _, opt := range opts { - opt.Apply(&ds) - } - return internal.Creds(ctx, &ds) -} diff --git a/vendor/google.golang.org/appengine/internal/socket/socket_service.pb.go b/vendor/google.golang.org/appengine/internal/socket/socket_service.pb.go deleted file mode 100644 index 4ec872e460..0000000000 --- a/vendor/google.golang.org/appengine/internal/socket/socket_service.pb.go +++ /dev/null @@ -1,2822 +0,0 @@ -// Code generated by protoc-gen-go. DO NOT EDIT. -// source: google.golang.org/appengine/internal/socket/socket_service.proto - -package socket - -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 - -type RemoteSocketServiceError_ErrorCode int32 - -const ( - RemoteSocketServiceError_SYSTEM_ERROR RemoteSocketServiceError_ErrorCode = 1 - RemoteSocketServiceError_GAI_ERROR RemoteSocketServiceError_ErrorCode = 2 - RemoteSocketServiceError_FAILURE RemoteSocketServiceError_ErrorCode = 4 - RemoteSocketServiceError_PERMISSION_DENIED RemoteSocketServiceError_ErrorCode = 5 - RemoteSocketServiceError_INVALID_REQUEST RemoteSocketServiceError_ErrorCode = 6 - RemoteSocketServiceError_SOCKET_CLOSED RemoteSocketServiceError_ErrorCode = 7 -) - -var RemoteSocketServiceError_ErrorCode_name = map[int32]string{ - 1: "SYSTEM_ERROR", - 2: "GAI_ERROR", - 4: "FAILURE", - 5: "PERMISSION_DENIED", - 6: "INVALID_REQUEST", - 7: "SOCKET_CLOSED", -} -var RemoteSocketServiceError_ErrorCode_value = map[string]int32{ - "SYSTEM_ERROR": 1, - "GAI_ERROR": 2, - "FAILURE": 4, - "PERMISSION_DENIED": 5, - "INVALID_REQUEST": 6, - "SOCKET_CLOSED": 7, -} - -func (x RemoteSocketServiceError_ErrorCode) Enum() *RemoteSocketServiceError_ErrorCode { - p := new(RemoteSocketServiceError_ErrorCode) - *p = x - return p -} -func (x RemoteSocketServiceError_ErrorCode) String() string { - return proto.EnumName(RemoteSocketServiceError_ErrorCode_name, int32(x)) -} -func (x *RemoteSocketServiceError_ErrorCode) UnmarshalJSON(data []byte) error { - value, err := proto.UnmarshalJSONEnum(RemoteSocketServiceError_ErrorCode_value, data, "RemoteSocketServiceError_ErrorCode") - if err != nil { - return err - } - *x = RemoteSocketServiceError_ErrorCode(value) - return nil -} -func (RemoteSocketServiceError_ErrorCode) EnumDescriptor() ([]byte, []int) { - return fileDescriptor_socket_service_b5f8f233dc327808, []int{0, 0} -} - -type RemoteSocketServiceError_SystemError int32 - -const ( - RemoteSocketServiceError_SYS_SUCCESS RemoteSocketServiceError_SystemError = 0 - RemoteSocketServiceError_SYS_EPERM RemoteSocketServiceError_SystemError = 1 - RemoteSocketServiceError_SYS_ENOENT RemoteSocketServiceError_SystemError = 2 - RemoteSocketServiceError_SYS_ESRCH RemoteSocketServiceError_SystemError = 3 - RemoteSocketServiceError_SYS_EINTR RemoteSocketServiceError_SystemError = 4 - RemoteSocketServiceError_SYS_EIO RemoteSocketServiceError_SystemError = 5 - RemoteSocketServiceError_SYS_ENXIO RemoteSocketServiceError_SystemError = 6 - RemoteSocketServiceError_SYS_E2BIG RemoteSocketServiceError_SystemError = 7 - RemoteSocketServiceError_SYS_ENOEXEC RemoteSocketServiceError_SystemError = 8 - RemoteSocketServiceError_SYS_EBADF RemoteSocketServiceError_SystemError = 9 - RemoteSocketServiceError_SYS_ECHILD RemoteSocketServiceError_SystemError = 10 - RemoteSocketServiceError_SYS_EAGAIN RemoteSocketServiceError_SystemError = 11 - RemoteSocketServiceError_SYS_EWOULDBLOCK RemoteSocketServiceError_SystemError = 11 - RemoteSocketServiceError_SYS_ENOMEM RemoteSocketServiceError_SystemError = 12 - RemoteSocketServiceError_SYS_EACCES RemoteSocketServiceError_SystemError = 13 - RemoteSocketServiceError_SYS_EFAULT RemoteSocketServiceError_SystemError = 14 - RemoteSocketServiceError_SYS_ENOTBLK RemoteSocketServiceError_SystemError = 15 - RemoteSocketServiceError_SYS_EBUSY RemoteSocketServiceError_SystemError = 16 - RemoteSocketServiceError_SYS_EEXIST RemoteSocketServiceError_SystemError = 17 - RemoteSocketServiceError_SYS_EXDEV RemoteSocketServiceError_SystemError = 18 - RemoteSocketServiceError_SYS_ENODEV RemoteSocketServiceError_SystemError = 19 - RemoteSocketServiceError_SYS_ENOTDIR RemoteSocketServiceError_SystemError = 20 - RemoteSocketServiceError_SYS_EISDIR RemoteSocketServiceError_SystemError = 21 - RemoteSocketServiceError_SYS_EINVAL RemoteSocketServiceError_SystemError = 22 - RemoteSocketServiceError_SYS_ENFILE RemoteSocketServiceError_SystemError = 23 - RemoteSocketServiceError_SYS_EMFILE RemoteSocketServiceError_SystemError = 24 - RemoteSocketServiceError_SYS_ENOTTY RemoteSocketServiceError_SystemError = 25 - RemoteSocketServiceError_SYS_ETXTBSY RemoteSocketServiceError_SystemError = 26 - RemoteSocketServiceError_SYS_EFBIG RemoteSocketServiceError_SystemError = 27 - RemoteSocketServiceError_SYS_ENOSPC RemoteSocketServiceError_SystemError = 28 - RemoteSocketServiceError_SYS_ESPIPE RemoteSocketServiceError_SystemError = 29 - RemoteSocketServiceError_SYS_EROFS RemoteSocketServiceError_SystemError = 30 - RemoteSocketServiceError_SYS_EMLINK RemoteSocketServiceError_SystemError = 31 - RemoteSocketServiceError_SYS_EPIPE RemoteSocketServiceError_SystemError = 32 - RemoteSocketServiceError_SYS_EDOM RemoteSocketServiceError_SystemError = 33 - RemoteSocketServiceError_SYS_ERANGE RemoteSocketServiceError_SystemError = 34 - RemoteSocketServiceError_SYS_EDEADLK RemoteSocketServiceError_SystemError = 35 - RemoteSocketServiceError_SYS_EDEADLOCK RemoteSocketServiceError_SystemError = 35 - RemoteSocketServiceError_SYS_ENAMETOOLONG RemoteSocketServiceError_SystemError = 36 - RemoteSocketServiceError_SYS_ENOLCK RemoteSocketServiceError_SystemError = 37 - RemoteSocketServiceError_SYS_ENOSYS RemoteSocketServiceError_SystemError = 38 - RemoteSocketServiceError_SYS_ENOTEMPTY RemoteSocketServiceError_SystemError = 39 - RemoteSocketServiceError_SYS_ELOOP RemoteSocketServiceError_SystemError = 40 - RemoteSocketServiceError_SYS_ENOMSG RemoteSocketServiceError_SystemError = 42 - RemoteSocketServiceError_SYS_EIDRM RemoteSocketServiceError_SystemError = 43 - RemoteSocketServiceError_SYS_ECHRNG RemoteSocketServiceError_SystemError = 44 - RemoteSocketServiceError_SYS_EL2NSYNC RemoteSocketServiceError_SystemError = 45 - RemoteSocketServiceError_SYS_EL3HLT RemoteSocketServiceError_SystemError = 46 - RemoteSocketServiceError_SYS_EL3RST RemoteSocketServiceError_SystemError = 47 - RemoteSocketServiceError_SYS_ELNRNG RemoteSocketServiceError_SystemError = 48 - RemoteSocketServiceError_SYS_EUNATCH RemoteSocketServiceError_SystemError = 49 - RemoteSocketServiceError_SYS_ENOCSI RemoteSocketServiceError_SystemError = 50 - RemoteSocketServiceError_SYS_EL2HLT RemoteSocketServiceError_SystemError = 51 - RemoteSocketServiceError_SYS_EBADE RemoteSocketServiceError_SystemError = 52 - RemoteSocketServiceError_SYS_EBADR RemoteSocketServiceError_SystemError = 53 - RemoteSocketServiceError_SYS_EXFULL RemoteSocketServiceError_SystemError = 54 - RemoteSocketServiceError_SYS_ENOANO RemoteSocketServiceError_SystemError = 55 - RemoteSocketServiceError_SYS_EBADRQC RemoteSocketServiceError_SystemError = 56 - RemoteSocketServiceError_SYS_EBADSLT RemoteSocketServiceError_SystemError = 57 - RemoteSocketServiceError_SYS_EBFONT RemoteSocketServiceError_SystemError = 59 - RemoteSocketServiceError_SYS_ENOSTR RemoteSocketServiceError_SystemError = 60 - RemoteSocketServiceError_SYS_ENODATA RemoteSocketServiceError_SystemError = 61 - RemoteSocketServiceError_SYS_ETIME RemoteSocketServiceError_SystemError = 62 - RemoteSocketServiceError_SYS_ENOSR RemoteSocketServiceError_SystemError = 63 - RemoteSocketServiceError_SYS_ENONET RemoteSocketServiceError_SystemError = 64 - RemoteSocketServiceError_SYS_ENOPKG RemoteSocketServiceError_SystemError = 65 - RemoteSocketServiceError_SYS_EREMOTE RemoteSocketServiceError_SystemError = 66 - RemoteSocketServiceError_SYS_ENOLINK RemoteSocketServiceError_SystemError = 67 - RemoteSocketServiceError_SYS_EADV RemoteSocketServiceError_SystemError = 68 - RemoteSocketServiceError_SYS_ESRMNT RemoteSocketServiceError_SystemError = 69 - RemoteSocketServiceError_SYS_ECOMM RemoteSocketServiceError_SystemError = 70 - RemoteSocketServiceError_SYS_EPROTO RemoteSocketServiceError_SystemError = 71 - RemoteSocketServiceError_SYS_EMULTIHOP RemoteSocketServiceError_SystemError = 72 - RemoteSocketServiceError_SYS_EDOTDOT RemoteSocketServiceError_SystemError = 73 - RemoteSocketServiceError_SYS_EBADMSG RemoteSocketServiceError_SystemError = 74 - RemoteSocketServiceError_SYS_EOVERFLOW RemoteSocketServiceError_SystemError = 75 - RemoteSocketServiceError_SYS_ENOTUNIQ RemoteSocketServiceError_SystemError = 76 - RemoteSocketServiceError_SYS_EBADFD RemoteSocketServiceError_SystemError = 77 - RemoteSocketServiceError_SYS_EREMCHG RemoteSocketServiceError_SystemError = 78 - RemoteSocketServiceError_SYS_ELIBACC RemoteSocketServiceError_SystemError = 79 - RemoteSocketServiceError_SYS_ELIBBAD RemoteSocketServiceError_SystemError = 80 - RemoteSocketServiceError_SYS_ELIBSCN RemoteSocketServiceError_SystemError = 81 - RemoteSocketServiceError_SYS_ELIBMAX RemoteSocketServiceError_SystemError = 82 - RemoteSocketServiceError_SYS_ELIBEXEC RemoteSocketServiceError_SystemError = 83 - RemoteSocketServiceError_SYS_EILSEQ RemoteSocketServiceError_SystemError = 84 - RemoteSocketServiceError_SYS_ERESTART RemoteSocketServiceError_SystemError = 85 - RemoteSocketServiceError_SYS_ESTRPIPE RemoteSocketServiceError_SystemError = 86 - RemoteSocketServiceError_SYS_EUSERS RemoteSocketServiceError_SystemError = 87 - RemoteSocketServiceError_SYS_ENOTSOCK RemoteSocketServiceError_SystemError = 88 - RemoteSocketServiceError_SYS_EDESTADDRREQ RemoteSocketServiceError_SystemError = 89 - RemoteSocketServiceError_SYS_EMSGSIZE RemoteSocketServiceError_SystemError = 90 - RemoteSocketServiceError_SYS_EPROTOTYPE RemoteSocketServiceError_SystemError = 91 - RemoteSocketServiceError_SYS_ENOPROTOOPT RemoteSocketServiceError_SystemError = 92 - RemoteSocketServiceError_SYS_EPROTONOSUPPORT RemoteSocketServiceError_SystemError = 93 - RemoteSocketServiceError_SYS_ESOCKTNOSUPPORT RemoteSocketServiceError_SystemError = 94 - RemoteSocketServiceError_SYS_EOPNOTSUPP RemoteSocketServiceError_SystemError = 95 - RemoteSocketServiceError_SYS_ENOTSUP RemoteSocketServiceError_SystemError = 95 - RemoteSocketServiceError_SYS_EPFNOSUPPORT RemoteSocketServiceError_SystemError = 96 - RemoteSocketServiceError_SYS_EAFNOSUPPORT RemoteSocketServiceError_SystemError = 97 - RemoteSocketServiceError_SYS_EADDRINUSE RemoteSocketServiceError_SystemError = 98 - RemoteSocketServiceError_SYS_EADDRNOTAVAIL RemoteSocketServiceError_SystemError = 99 - RemoteSocketServiceError_SYS_ENETDOWN RemoteSocketServiceError_SystemError = 100 - RemoteSocketServiceError_SYS_ENETUNREACH RemoteSocketServiceError_SystemError = 101 - RemoteSocketServiceError_SYS_ENETRESET RemoteSocketServiceError_SystemError = 102 - RemoteSocketServiceError_SYS_ECONNABORTED RemoteSocketServiceError_SystemError = 103 - RemoteSocketServiceError_SYS_ECONNRESET RemoteSocketServiceError_SystemError = 104 - RemoteSocketServiceError_SYS_ENOBUFS RemoteSocketServiceError_SystemError = 105 - RemoteSocketServiceError_SYS_EISCONN RemoteSocketServiceError_SystemError = 106 - RemoteSocketServiceError_SYS_ENOTCONN RemoteSocketServiceError_SystemError = 107 - RemoteSocketServiceError_SYS_ESHUTDOWN RemoteSocketServiceError_SystemError = 108 - RemoteSocketServiceError_SYS_ETOOMANYREFS RemoteSocketServiceError_SystemError = 109 - RemoteSocketServiceError_SYS_ETIMEDOUT RemoteSocketServiceError_SystemError = 110 - RemoteSocketServiceError_SYS_ECONNREFUSED RemoteSocketServiceError_SystemError = 111 - RemoteSocketServiceError_SYS_EHOSTDOWN RemoteSocketServiceError_SystemError = 112 - RemoteSocketServiceError_SYS_EHOSTUNREACH RemoteSocketServiceError_SystemError = 113 - RemoteSocketServiceError_SYS_EALREADY RemoteSocketServiceError_SystemError = 114 - RemoteSocketServiceError_SYS_EINPROGRESS RemoteSocketServiceError_SystemError = 115 - RemoteSocketServiceError_SYS_ESTALE RemoteSocketServiceError_SystemError = 116 - RemoteSocketServiceError_SYS_EUCLEAN RemoteSocketServiceError_SystemError = 117 - RemoteSocketServiceError_SYS_ENOTNAM RemoteSocketServiceError_SystemError = 118 - RemoteSocketServiceError_SYS_ENAVAIL RemoteSocketServiceError_SystemError = 119 - RemoteSocketServiceError_SYS_EISNAM RemoteSocketServiceError_SystemError = 120 - RemoteSocketServiceError_SYS_EREMOTEIO RemoteSocketServiceError_SystemError = 121 - RemoteSocketServiceError_SYS_EDQUOT RemoteSocketServiceError_SystemError = 122 - RemoteSocketServiceError_SYS_ENOMEDIUM RemoteSocketServiceError_SystemError = 123 - RemoteSocketServiceError_SYS_EMEDIUMTYPE RemoteSocketServiceError_SystemError = 124 - RemoteSocketServiceError_SYS_ECANCELED RemoteSocketServiceError_SystemError = 125 - RemoteSocketServiceError_SYS_ENOKEY RemoteSocketServiceError_SystemError = 126 - RemoteSocketServiceError_SYS_EKEYEXPIRED RemoteSocketServiceError_SystemError = 127 - RemoteSocketServiceError_SYS_EKEYREVOKED RemoteSocketServiceError_SystemError = 128 - RemoteSocketServiceError_SYS_EKEYREJECTED RemoteSocketServiceError_SystemError = 129 - RemoteSocketServiceError_SYS_EOWNERDEAD RemoteSocketServiceError_SystemError = 130 - RemoteSocketServiceError_SYS_ENOTRECOVERABLE RemoteSocketServiceError_SystemError = 131 - RemoteSocketServiceError_SYS_ERFKILL RemoteSocketServiceError_SystemError = 132 -) - -var RemoteSocketServiceError_SystemError_name = map[int32]string{ - 0: "SYS_SUCCESS", - 1: "SYS_EPERM", - 2: "SYS_ENOENT", - 3: "SYS_ESRCH", - 4: "SYS_EINTR", - 5: "SYS_EIO", - 6: "SYS_ENXIO", - 7: "SYS_E2BIG", - 8: "SYS_ENOEXEC", - 9: "SYS_EBADF", - 10: "SYS_ECHILD", - 11: "SYS_EAGAIN", - // Duplicate value: 11: "SYS_EWOULDBLOCK", - 12: "SYS_ENOMEM", - 13: "SYS_EACCES", - 14: "SYS_EFAULT", - 15: "SYS_ENOTBLK", - 16: "SYS_EBUSY", - 17: "SYS_EEXIST", - 18: "SYS_EXDEV", - 19: "SYS_ENODEV", - 20: "SYS_ENOTDIR", - 21: "SYS_EISDIR", - 22: "SYS_EINVAL", - 23: "SYS_ENFILE", - 24: "SYS_EMFILE", - 25: "SYS_ENOTTY", - 26: "SYS_ETXTBSY", - 27: "SYS_EFBIG", - 28: "SYS_ENOSPC", - 29: "SYS_ESPIPE", - 30: "SYS_EROFS", - 31: "SYS_EMLINK", - 32: "SYS_EPIPE", - 33: "SYS_EDOM", - 34: "SYS_ERANGE", - 35: "SYS_EDEADLK", - // Duplicate value: 35: "SYS_EDEADLOCK", - 36: "SYS_ENAMETOOLONG", - 37: "SYS_ENOLCK", - 38: "SYS_ENOSYS", - 39: "SYS_ENOTEMPTY", - 40: "SYS_ELOOP", - 42: "SYS_ENOMSG", - 43: "SYS_EIDRM", - 44: "SYS_ECHRNG", - 45: "SYS_EL2NSYNC", - 46: "SYS_EL3HLT", - 47: "SYS_EL3RST", - 48: "SYS_ELNRNG", - 49: "SYS_EUNATCH", - 50: "SYS_ENOCSI", - 51: "SYS_EL2HLT", - 52: "SYS_EBADE", - 53: "SYS_EBADR", - 54: "SYS_EXFULL", - 55: "SYS_ENOANO", - 56: "SYS_EBADRQC", - 57: "SYS_EBADSLT", - 59: "SYS_EBFONT", - 60: "SYS_ENOSTR", - 61: "SYS_ENODATA", - 62: "SYS_ETIME", - 63: "SYS_ENOSR", - 64: "SYS_ENONET", - 65: "SYS_ENOPKG", - 66: "SYS_EREMOTE", - 67: "SYS_ENOLINK", - 68: "SYS_EADV", - 69: "SYS_ESRMNT", - 70: "SYS_ECOMM", - 71: "SYS_EPROTO", - 72: "SYS_EMULTIHOP", - 73: "SYS_EDOTDOT", - 74: "SYS_EBADMSG", - 75: "SYS_EOVERFLOW", - 76: "SYS_ENOTUNIQ", - 77: "SYS_EBADFD", - 78: "SYS_EREMCHG", - 79: "SYS_ELIBACC", - 80: "SYS_ELIBBAD", - 81: "SYS_ELIBSCN", - 82: "SYS_ELIBMAX", - 83: "SYS_ELIBEXEC", - 84: "SYS_EILSEQ", - 85: "SYS_ERESTART", - 86: "SYS_ESTRPIPE", - 87: "SYS_EUSERS", - 88: "SYS_ENOTSOCK", - 89: "SYS_EDESTADDRREQ", - 90: "SYS_EMSGSIZE", - 91: "SYS_EPROTOTYPE", - 92: "SYS_ENOPROTOOPT", - 93: "SYS_EPROTONOSUPPORT", - 94: "SYS_ESOCKTNOSUPPORT", - 95: "SYS_EOPNOTSUPP", - // Duplicate value: 95: "SYS_ENOTSUP", - 96: "SYS_EPFNOSUPPORT", - 97: "SYS_EAFNOSUPPORT", - 98: "SYS_EADDRINUSE", - 99: "SYS_EADDRNOTAVAIL", - 100: "SYS_ENETDOWN", - 101: "SYS_ENETUNREACH", - 102: "SYS_ENETRESET", - 103: "SYS_ECONNABORTED", - 104: "SYS_ECONNRESET", - 105: "SYS_ENOBUFS", - 106: "SYS_EISCONN", - 107: "SYS_ENOTCONN", - 108: "SYS_ESHUTDOWN", - 109: "SYS_ETOOMANYREFS", - 110: "SYS_ETIMEDOUT", - 111: "SYS_ECONNREFUSED", - 112: "SYS_EHOSTDOWN", - 113: "SYS_EHOSTUNREACH", - 114: "SYS_EALREADY", - 115: "SYS_EINPROGRESS", - 116: "SYS_ESTALE", - 117: "SYS_EUCLEAN", - 118: "SYS_ENOTNAM", - 119: "SYS_ENAVAIL", - 120: "SYS_EISNAM", - 121: "SYS_EREMOTEIO", - 122: "SYS_EDQUOT", - 123: "SYS_ENOMEDIUM", - 124: "SYS_EMEDIUMTYPE", - 125: "SYS_ECANCELED", - 126: "SYS_ENOKEY", - 127: "SYS_EKEYEXPIRED", - 128: "SYS_EKEYREVOKED", - 129: "SYS_EKEYREJECTED", - 130: "SYS_EOWNERDEAD", - 131: "SYS_ENOTRECOVERABLE", - 132: "SYS_ERFKILL", -} -var RemoteSocketServiceError_SystemError_value = map[string]int32{ - "SYS_SUCCESS": 0, - "SYS_EPERM": 1, - "SYS_ENOENT": 2, - "SYS_ESRCH": 3, - "SYS_EINTR": 4, - "SYS_EIO": 5, - "SYS_ENXIO": 6, - "SYS_E2BIG": 7, - "SYS_ENOEXEC": 8, - "SYS_EBADF": 9, - "SYS_ECHILD": 10, - "SYS_EAGAIN": 11, - "SYS_EWOULDBLOCK": 11, - "SYS_ENOMEM": 12, - "SYS_EACCES": 13, - "SYS_EFAULT": 14, - "SYS_ENOTBLK": 15, - "SYS_EBUSY": 16, - "SYS_EEXIST": 17, - "SYS_EXDEV": 18, - "SYS_ENODEV": 19, - "SYS_ENOTDIR": 20, - "SYS_EISDIR": 21, - "SYS_EINVAL": 22, - "SYS_ENFILE": 23, - "SYS_EMFILE": 24, - "SYS_ENOTTY": 25, - "SYS_ETXTBSY": 26, - "SYS_EFBIG": 27, - "SYS_ENOSPC": 28, - "SYS_ESPIPE": 29, - "SYS_EROFS": 30, - "SYS_EMLINK": 31, - "SYS_EPIPE": 32, - "SYS_EDOM": 33, - "SYS_ERANGE": 34, - "SYS_EDEADLK": 35, - "SYS_EDEADLOCK": 35, - "SYS_ENAMETOOLONG": 36, - "SYS_ENOLCK": 37, - "SYS_ENOSYS": 38, - "SYS_ENOTEMPTY": 39, - "SYS_ELOOP": 40, - "SYS_ENOMSG": 42, - "SYS_EIDRM": 43, - "SYS_ECHRNG": 44, - "SYS_EL2NSYNC": 45, - "SYS_EL3HLT": 46, - "SYS_EL3RST": 47, - "SYS_ELNRNG": 48, - "SYS_EUNATCH": 49, - "SYS_ENOCSI": 50, - "SYS_EL2HLT": 51, - "SYS_EBADE": 52, - "SYS_EBADR": 53, - "SYS_EXFULL": 54, - "SYS_ENOANO": 55, - "SYS_EBADRQC": 56, - "SYS_EBADSLT": 57, - "SYS_EBFONT": 59, - "SYS_ENOSTR": 60, - "SYS_ENODATA": 61, - "SYS_ETIME": 62, - "SYS_ENOSR": 63, - "SYS_ENONET": 64, - "SYS_ENOPKG": 65, - "SYS_EREMOTE": 66, - "SYS_ENOLINK": 67, - "SYS_EADV": 68, - "SYS_ESRMNT": 69, - "SYS_ECOMM": 70, - "SYS_EPROTO": 71, - "SYS_EMULTIHOP": 72, - "SYS_EDOTDOT": 73, - "SYS_EBADMSG": 74, - "SYS_EOVERFLOW": 75, - "SYS_ENOTUNIQ": 76, - "SYS_EBADFD": 77, - "SYS_EREMCHG": 78, - "SYS_ELIBACC": 79, - "SYS_ELIBBAD": 80, - "SYS_ELIBSCN": 81, - "SYS_ELIBMAX": 82, - "SYS_ELIBEXEC": 83, - "SYS_EILSEQ": 84, - "SYS_ERESTART": 85, - "SYS_ESTRPIPE": 86, - "SYS_EUSERS": 87, - "SYS_ENOTSOCK": 88, - "SYS_EDESTADDRREQ": 89, - "SYS_EMSGSIZE": 90, - "SYS_EPROTOTYPE": 91, - "SYS_ENOPROTOOPT": 92, - "SYS_EPROTONOSUPPORT": 93, - "SYS_ESOCKTNOSUPPORT": 94, - "SYS_EOPNOTSUPP": 95, - "SYS_ENOTSUP": 95, - "SYS_EPFNOSUPPORT": 96, - "SYS_EAFNOSUPPORT": 97, - "SYS_EADDRINUSE": 98, - "SYS_EADDRNOTAVAIL": 99, - "SYS_ENETDOWN": 100, - "SYS_ENETUNREACH": 101, - "SYS_ENETRESET": 102, - "SYS_ECONNABORTED": 103, - "SYS_ECONNRESET": 104, - "SYS_ENOBUFS": 105, - "SYS_EISCONN": 106, - "SYS_ENOTCONN": 107, - "SYS_ESHUTDOWN": 108, - "SYS_ETOOMANYREFS": 109, - "SYS_ETIMEDOUT": 110, - "SYS_ECONNREFUSED": 111, - "SYS_EHOSTDOWN": 112, - "SYS_EHOSTUNREACH": 113, - "SYS_EALREADY": 114, - "SYS_EINPROGRESS": 115, - "SYS_ESTALE": 116, - "SYS_EUCLEAN": 117, - "SYS_ENOTNAM": 118, - "SYS_ENAVAIL": 119, - "SYS_EISNAM": 120, - "SYS_EREMOTEIO": 121, - "SYS_EDQUOT": 122, - "SYS_ENOMEDIUM": 123, - "SYS_EMEDIUMTYPE": 124, - "SYS_ECANCELED": 125, - "SYS_ENOKEY": 126, - "SYS_EKEYEXPIRED": 127, - "SYS_EKEYREVOKED": 128, - "SYS_EKEYREJECTED": 129, - "SYS_EOWNERDEAD": 130, - "SYS_ENOTRECOVERABLE": 131, - "SYS_ERFKILL": 132, -} - -func (x RemoteSocketServiceError_SystemError) Enum() *RemoteSocketServiceError_SystemError { - p := new(RemoteSocketServiceError_SystemError) - *p = x - return p -} -func (x RemoteSocketServiceError_SystemError) String() string { - return proto.EnumName(RemoteSocketServiceError_SystemError_name, int32(x)) -} -func (x *RemoteSocketServiceError_SystemError) UnmarshalJSON(data []byte) error { - value, err := proto.UnmarshalJSONEnum(RemoteSocketServiceError_SystemError_value, data, "RemoteSocketServiceError_SystemError") - if err != nil { - return err - } - *x = RemoteSocketServiceError_SystemError(value) - return nil -} -func (RemoteSocketServiceError_SystemError) EnumDescriptor() ([]byte, []int) { - return fileDescriptor_socket_service_b5f8f233dc327808, []int{0, 1} -} - -type CreateSocketRequest_SocketFamily int32 - -const ( - CreateSocketRequest_IPv4 CreateSocketRequest_SocketFamily = 1 - CreateSocketRequest_IPv6 CreateSocketRequest_SocketFamily = 2 -) - -var CreateSocketRequest_SocketFamily_name = map[int32]string{ - 1: "IPv4", - 2: "IPv6", -} -var CreateSocketRequest_SocketFamily_value = map[string]int32{ - "IPv4": 1, - "IPv6": 2, -} - -func (x CreateSocketRequest_SocketFamily) Enum() *CreateSocketRequest_SocketFamily { - p := new(CreateSocketRequest_SocketFamily) - *p = x - return p -} -func (x CreateSocketRequest_SocketFamily) String() string { - return proto.EnumName(CreateSocketRequest_SocketFamily_name, int32(x)) -} -func (x *CreateSocketRequest_SocketFamily) UnmarshalJSON(data []byte) error { - value, err := proto.UnmarshalJSONEnum(CreateSocketRequest_SocketFamily_value, data, "CreateSocketRequest_SocketFamily") - if err != nil { - return err - } - *x = CreateSocketRequest_SocketFamily(value) - return nil -} -func (CreateSocketRequest_SocketFamily) EnumDescriptor() ([]byte, []int) { - return fileDescriptor_socket_service_b5f8f233dc327808, []int{2, 0} -} - -type CreateSocketRequest_SocketProtocol int32 - -const ( - CreateSocketRequest_TCP CreateSocketRequest_SocketProtocol = 1 - CreateSocketRequest_UDP CreateSocketRequest_SocketProtocol = 2 -) - -var CreateSocketRequest_SocketProtocol_name = map[int32]string{ - 1: "TCP", - 2: "UDP", -} -var CreateSocketRequest_SocketProtocol_value = map[string]int32{ - "TCP": 1, - "UDP": 2, -} - -func (x CreateSocketRequest_SocketProtocol) Enum() *CreateSocketRequest_SocketProtocol { - p := new(CreateSocketRequest_SocketProtocol) - *p = x - return p -} -func (x CreateSocketRequest_SocketProtocol) String() string { - return proto.EnumName(CreateSocketRequest_SocketProtocol_name, int32(x)) -} -func (x *CreateSocketRequest_SocketProtocol) UnmarshalJSON(data []byte) error { - value, err := proto.UnmarshalJSONEnum(CreateSocketRequest_SocketProtocol_value, data, "CreateSocketRequest_SocketProtocol") - if err != nil { - return err - } - *x = CreateSocketRequest_SocketProtocol(value) - return nil -} -func (CreateSocketRequest_SocketProtocol) EnumDescriptor() ([]byte, []int) { - return fileDescriptor_socket_service_b5f8f233dc327808, []int{2, 1} -} - -type SocketOption_SocketOptionLevel int32 - -const ( - SocketOption_SOCKET_SOL_IP SocketOption_SocketOptionLevel = 0 - SocketOption_SOCKET_SOL_SOCKET SocketOption_SocketOptionLevel = 1 - SocketOption_SOCKET_SOL_TCP SocketOption_SocketOptionLevel = 6 - SocketOption_SOCKET_SOL_UDP SocketOption_SocketOptionLevel = 17 -) - -var SocketOption_SocketOptionLevel_name = map[int32]string{ - 0: "SOCKET_SOL_IP", - 1: "SOCKET_SOL_SOCKET", - 6: "SOCKET_SOL_TCP", - 17: "SOCKET_SOL_UDP", -} -var SocketOption_SocketOptionLevel_value = map[string]int32{ - "SOCKET_SOL_IP": 0, - "SOCKET_SOL_SOCKET": 1, - "SOCKET_SOL_TCP": 6, - "SOCKET_SOL_UDP": 17, -} - -func (x SocketOption_SocketOptionLevel) Enum() *SocketOption_SocketOptionLevel { - p := new(SocketOption_SocketOptionLevel) - *p = x - return p -} -func (x SocketOption_SocketOptionLevel) String() string { - return proto.EnumName(SocketOption_SocketOptionLevel_name, int32(x)) -} -func (x *SocketOption_SocketOptionLevel) UnmarshalJSON(data []byte) error { - value, err := proto.UnmarshalJSONEnum(SocketOption_SocketOptionLevel_value, data, "SocketOption_SocketOptionLevel") - if err != nil { - return err - } - *x = SocketOption_SocketOptionLevel(value) - return nil -} -func (SocketOption_SocketOptionLevel) EnumDescriptor() ([]byte, []int) { - return fileDescriptor_socket_service_b5f8f233dc327808, []int{10, 0} -} - -type SocketOption_SocketOptionName int32 - -const ( - SocketOption_SOCKET_SO_DEBUG SocketOption_SocketOptionName = 1 - SocketOption_SOCKET_SO_REUSEADDR SocketOption_SocketOptionName = 2 - SocketOption_SOCKET_SO_TYPE SocketOption_SocketOptionName = 3 - SocketOption_SOCKET_SO_ERROR SocketOption_SocketOptionName = 4 - SocketOption_SOCKET_SO_DONTROUTE SocketOption_SocketOptionName = 5 - SocketOption_SOCKET_SO_BROADCAST SocketOption_SocketOptionName = 6 - SocketOption_SOCKET_SO_SNDBUF SocketOption_SocketOptionName = 7 - SocketOption_SOCKET_SO_RCVBUF SocketOption_SocketOptionName = 8 - SocketOption_SOCKET_SO_KEEPALIVE SocketOption_SocketOptionName = 9 - SocketOption_SOCKET_SO_OOBINLINE SocketOption_SocketOptionName = 10 - SocketOption_SOCKET_SO_LINGER SocketOption_SocketOptionName = 13 - SocketOption_SOCKET_SO_RCVTIMEO SocketOption_SocketOptionName = 20 - SocketOption_SOCKET_SO_SNDTIMEO SocketOption_SocketOptionName = 21 - SocketOption_SOCKET_IP_TOS SocketOption_SocketOptionName = 1 - SocketOption_SOCKET_IP_TTL SocketOption_SocketOptionName = 2 - SocketOption_SOCKET_IP_HDRINCL SocketOption_SocketOptionName = 3 - SocketOption_SOCKET_IP_OPTIONS SocketOption_SocketOptionName = 4 - SocketOption_SOCKET_TCP_NODELAY SocketOption_SocketOptionName = 1 - SocketOption_SOCKET_TCP_MAXSEG SocketOption_SocketOptionName = 2 - SocketOption_SOCKET_TCP_CORK SocketOption_SocketOptionName = 3 - SocketOption_SOCKET_TCP_KEEPIDLE SocketOption_SocketOptionName = 4 - SocketOption_SOCKET_TCP_KEEPINTVL SocketOption_SocketOptionName = 5 - SocketOption_SOCKET_TCP_KEEPCNT SocketOption_SocketOptionName = 6 - SocketOption_SOCKET_TCP_SYNCNT SocketOption_SocketOptionName = 7 - SocketOption_SOCKET_TCP_LINGER2 SocketOption_SocketOptionName = 8 - SocketOption_SOCKET_TCP_DEFER_ACCEPT SocketOption_SocketOptionName = 9 - SocketOption_SOCKET_TCP_WINDOW_CLAMP SocketOption_SocketOptionName = 10 - SocketOption_SOCKET_TCP_INFO SocketOption_SocketOptionName = 11 - SocketOption_SOCKET_TCP_QUICKACK SocketOption_SocketOptionName = 12 -) - -var SocketOption_SocketOptionName_name = map[int32]string{ - 1: "SOCKET_SO_DEBUG", - 2: "SOCKET_SO_REUSEADDR", - 3: "SOCKET_SO_TYPE", - 4: "SOCKET_SO_ERROR", - 5: "SOCKET_SO_DONTROUTE", - 6: "SOCKET_SO_BROADCAST", - 7: "SOCKET_SO_SNDBUF", - 8: "SOCKET_SO_RCVBUF", - 9: "SOCKET_SO_KEEPALIVE", - 10: "SOCKET_SO_OOBINLINE", - 13: "SOCKET_SO_LINGER", - 20: "SOCKET_SO_RCVTIMEO", - 21: "SOCKET_SO_SNDTIMEO", - // Duplicate value: 1: "SOCKET_IP_TOS", - // Duplicate value: 2: "SOCKET_IP_TTL", - // Duplicate value: 3: "SOCKET_IP_HDRINCL", - // Duplicate value: 4: "SOCKET_IP_OPTIONS", - // Duplicate value: 1: "SOCKET_TCP_NODELAY", - // Duplicate value: 2: "SOCKET_TCP_MAXSEG", - // Duplicate value: 3: "SOCKET_TCP_CORK", - // Duplicate value: 4: "SOCKET_TCP_KEEPIDLE", - // Duplicate value: 5: "SOCKET_TCP_KEEPINTVL", - // Duplicate value: 6: "SOCKET_TCP_KEEPCNT", - // Duplicate value: 7: "SOCKET_TCP_SYNCNT", - // Duplicate value: 8: "SOCKET_TCP_LINGER2", - // Duplicate value: 9: "SOCKET_TCP_DEFER_ACCEPT", - // Duplicate value: 10: "SOCKET_TCP_WINDOW_CLAMP", - 11: "SOCKET_TCP_INFO", - 12: "SOCKET_TCP_QUICKACK", -} -var SocketOption_SocketOptionName_value = map[string]int32{ - "SOCKET_SO_DEBUG": 1, - "SOCKET_SO_REUSEADDR": 2, - "SOCKET_SO_TYPE": 3, - "SOCKET_SO_ERROR": 4, - "SOCKET_SO_DONTROUTE": 5, - "SOCKET_SO_BROADCAST": 6, - "SOCKET_SO_SNDBUF": 7, - "SOCKET_SO_RCVBUF": 8, - "SOCKET_SO_KEEPALIVE": 9, - "SOCKET_SO_OOBINLINE": 10, - "SOCKET_SO_LINGER": 13, - "SOCKET_SO_RCVTIMEO": 20, - "SOCKET_SO_SNDTIMEO": 21, - "SOCKET_IP_TOS": 1, - "SOCKET_IP_TTL": 2, - "SOCKET_IP_HDRINCL": 3, - "SOCKET_IP_OPTIONS": 4, - "SOCKET_TCP_NODELAY": 1, - "SOCKET_TCP_MAXSEG": 2, - "SOCKET_TCP_CORK": 3, - "SOCKET_TCP_KEEPIDLE": 4, - "SOCKET_TCP_KEEPINTVL": 5, - "SOCKET_TCP_KEEPCNT": 6, - "SOCKET_TCP_SYNCNT": 7, - "SOCKET_TCP_LINGER2": 8, - "SOCKET_TCP_DEFER_ACCEPT": 9, - "SOCKET_TCP_WINDOW_CLAMP": 10, - "SOCKET_TCP_INFO": 11, - "SOCKET_TCP_QUICKACK": 12, -} - -func (x SocketOption_SocketOptionName) Enum() *SocketOption_SocketOptionName { - p := new(SocketOption_SocketOptionName) - *p = x - return p -} -func (x SocketOption_SocketOptionName) String() string { - return proto.EnumName(SocketOption_SocketOptionName_name, int32(x)) -} -func (x *SocketOption_SocketOptionName) UnmarshalJSON(data []byte) error { - value, err := proto.UnmarshalJSONEnum(SocketOption_SocketOptionName_value, data, "SocketOption_SocketOptionName") - if err != nil { - return err - } - *x = SocketOption_SocketOptionName(value) - return nil -} -func (SocketOption_SocketOptionName) EnumDescriptor() ([]byte, []int) { - return fileDescriptor_socket_service_b5f8f233dc327808, []int{10, 1} -} - -type ShutDownRequest_How int32 - -const ( - ShutDownRequest_SOCKET_SHUT_RD ShutDownRequest_How = 1 - ShutDownRequest_SOCKET_SHUT_WR ShutDownRequest_How = 2 - ShutDownRequest_SOCKET_SHUT_RDWR ShutDownRequest_How = 3 -) - -var ShutDownRequest_How_name = map[int32]string{ - 1: "SOCKET_SHUT_RD", - 2: "SOCKET_SHUT_WR", - 3: "SOCKET_SHUT_RDWR", -} -var ShutDownRequest_How_value = map[string]int32{ - "SOCKET_SHUT_RD": 1, - "SOCKET_SHUT_WR": 2, - "SOCKET_SHUT_RDWR": 3, -} - -func (x ShutDownRequest_How) Enum() *ShutDownRequest_How { - p := new(ShutDownRequest_How) - *p = x - return p -} -func (x ShutDownRequest_How) String() string { - return proto.EnumName(ShutDownRequest_How_name, int32(x)) -} -func (x *ShutDownRequest_How) UnmarshalJSON(data []byte) error { - value, err := proto.UnmarshalJSONEnum(ShutDownRequest_How_value, data, "ShutDownRequest_How") - if err != nil { - return err - } - *x = ShutDownRequest_How(value) - return nil -} -func (ShutDownRequest_How) EnumDescriptor() ([]byte, []int) { - return fileDescriptor_socket_service_b5f8f233dc327808, []int{21, 0} -} - -type ReceiveRequest_Flags int32 - -const ( - ReceiveRequest_MSG_OOB ReceiveRequest_Flags = 1 - ReceiveRequest_MSG_PEEK ReceiveRequest_Flags = 2 -) - -var ReceiveRequest_Flags_name = map[int32]string{ - 1: "MSG_OOB", - 2: "MSG_PEEK", -} -var ReceiveRequest_Flags_value = map[string]int32{ - "MSG_OOB": 1, - "MSG_PEEK": 2, -} - -func (x ReceiveRequest_Flags) Enum() *ReceiveRequest_Flags { - p := new(ReceiveRequest_Flags) - *p = x - return p -} -func (x ReceiveRequest_Flags) String() string { - return proto.EnumName(ReceiveRequest_Flags_name, int32(x)) -} -func (x *ReceiveRequest_Flags) UnmarshalJSON(data []byte) error { - value, err := proto.UnmarshalJSONEnum(ReceiveRequest_Flags_value, data, "ReceiveRequest_Flags") - if err != nil { - return err - } - *x = ReceiveRequest_Flags(value) - return nil -} -func (ReceiveRequest_Flags) EnumDescriptor() ([]byte, []int) { - return fileDescriptor_socket_service_b5f8f233dc327808, []int{27, 0} -} - -type PollEvent_PollEventFlag int32 - -const ( - PollEvent_SOCKET_POLLNONE PollEvent_PollEventFlag = 0 - PollEvent_SOCKET_POLLIN PollEvent_PollEventFlag = 1 - PollEvent_SOCKET_POLLPRI PollEvent_PollEventFlag = 2 - PollEvent_SOCKET_POLLOUT PollEvent_PollEventFlag = 4 - PollEvent_SOCKET_POLLERR PollEvent_PollEventFlag = 8 - PollEvent_SOCKET_POLLHUP PollEvent_PollEventFlag = 16 - PollEvent_SOCKET_POLLNVAL PollEvent_PollEventFlag = 32 - PollEvent_SOCKET_POLLRDNORM PollEvent_PollEventFlag = 64 - PollEvent_SOCKET_POLLRDBAND PollEvent_PollEventFlag = 128 - PollEvent_SOCKET_POLLWRNORM PollEvent_PollEventFlag = 256 - PollEvent_SOCKET_POLLWRBAND PollEvent_PollEventFlag = 512 - PollEvent_SOCKET_POLLMSG PollEvent_PollEventFlag = 1024 - PollEvent_SOCKET_POLLREMOVE PollEvent_PollEventFlag = 4096 - PollEvent_SOCKET_POLLRDHUP PollEvent_PollEventFlag = 8192 -) - -var PollEvent_PollEventFlag_name = map[int32]string{ - 0: "SOCKET_POLLNONE", - 1: "SOCKET_POLLIN", - 2: "SOCKET_POLLPRI", - 4: "SOCKET_POLLOUT", - 8: "SOCKET_POLLERR", - 16: "SOCKET_POLLHUP", - 32: "SOCKET_POLLNVAL", - 64: "SOCKET_POLLRDNORM", - 128: "SOCKET_POLLRDBAND", - 256: "SOCKET_POLLWRNORM", - 512: "SOCKET_POLLWRBAND", - 1024: "SOCKET_POLLMSG", - 4096: "SOCKET_POLLREMOVE", - 8192: "SOCKET_POLLRDHUP", -} -var PollEvent_PollEventFlag_value = map[string]int32{ - "SOCKET_POLLNONE": 0, - "SOCKET_POLLIN": 1, - "SOCKET_POLLPRI": 2, - "SOCKET_POLLOUT": 4, - "SOCKET_POLLERR": 8, - "SOCKET_POLLHUP": 16, - "SOCKET_POLLNVAL": 32, - "SOCKET_POLLRDNORM": 64, - "SOCKET_POLLRDBAND": 128, - "SOCKET_POLLWRNORM": 256, - "SOCKET_POLLWRBAND": 512, - "SOCKET_POLLMSG": 1024, - "SOCKET_POLLREMOVE": 4096, - "SOCKET_POLLRDHUP": 8192, -} - -func (x PollEvent_PollEventFlag) Enum() *PollEvent_PollEventFlag { - p := new(PollEvent_PollEventFlag) - *p = x - return p -} -func (x PollEvent_PollEventFlag) String() string { - return proto.EnumName(PollEvent_PollEventFlag_name, int32(x)) -} -func (x *PollEvent_PollEventFlag) UnmarshalJSON(data []byte) error { - value, err := proto.UnmarshalJSONEnum(PollEvent_PollEventFlag_value, data, "PollEvent_PollEventFlag") - if err != nil { - return err - } - *x = PollEvent_PollEventFlag(value) - return nil -} -func (PollEvent_PollEventFlag) EnumDescriptor() ([]byte, []int) { - return fileDescriptor_socket_service_b5f8f233dc327808, []int{29, 0} -} - -type ResolveReply_ErrorCode int32 - -const ( - ResolveReply_SOCKET_EAI_ADDRFAMILY ResolveReply_ErrorCode = 1 - ResolveReply_SOCKET_EAI_AGAIN ResolveReply_ErrorCode = 2 - ResolveReply_SOCKET_EAI_BADFLAGS ResolveReply_ErrorCode = 3 - ResolveReply_SOCKET_EAI_FAIL ResolveReply_ErrorCode = 4 - ResolveReply_SOCKET_EAI_FAMILY ResolveReply_ErrorCode = 5 - ResolveReply_SOCKET_EAI_MEMORY ResolveReply_ErrorCode = 6 - ResolveReply_SOCKET_EAI_NODATA ResolveReply_ErrorCode = 7 - ResolveReply_SOCKET_EAI_NONAME ResolveReply_ErrorCode = 8 - ResolveReply_SOCKET_EAI_SERVICE ResolveReply_ErrorCode = 9 - ResolveReply_SOCKET_EAI_SOCKTYPE ResolveReply_ErrorCode = 10 - ResolveReply_SOCKET_EAI_SYSTEM ResolveReply_ErrorCode = 11 - ResolveReply_SOCKET_EAI_BADHINTS ResolveReply_ErrorCode = 12 - ResolveReply_SOCKET_EAI_PROTOCOL ResolveReply_ErrorCode = 13 - ResolveReply_SOCKET_EAI_OVERFLOW ResolveReply_ErrorCode = 14 - ResolveReply_SOCKET_EAI_MAX ResolveReply_ErrorCode = 15 -) - -var ResolveReply_ErrorCode_name = map[int32]string{ - 1: "SOCKET_EAI_ADDRFAMILY", - 2: "SOCKET_EAI_AGAIN", - 3: "SOCKET_EAI_BADFLAGS", - 4: "SOCKET_EAI_FAIL", - 5: "SOCKET_EAI_FAMILY", - 6: "SOCKET_EAI_MEMORY", - 7: "SOCKET_EAI_NODATA", - 8: "SOCKET_EAI_NONAME", - 9: "SOCKET_EAI_SERVICE", - 10: "SOCKET_EAI_SOCKTYPE", - 11: "SOCKET_EAI_SYSTEM", - 12: "SOCKET_EAI_BADHINTS", - 13: "SOCKET_EAI_PROTOCOL", - 14: "SOCKET_EAI_OVERFLOW", - 15: "SOCKET_EAI_MAX", -} -var ResolveReply_ErrorCode_value = map[string]int32{ - "SOCKET_EAI_ADDRFAMILY": 1, - "SOCKET_EAI_AGAIN": 2, - "SOCKET_EAI_BADFLAGS": 3, - "SOCKET_EAI_FAIL": 4, - "SOCKET_EAI_FAMILY": 5, - "SOCKET_EAI_MEMORY": 6, - "SOCKET_EAI_NODATA": 7, - "SOCKET_EAI_NONAME": 8, - "SOCKET_EAI_SERVICE": 9, - "SOCKET_EAI_SOCKTYPE": 10, - "SOCKET_EAI_SYSTEM": 11, - "SOCKET_EAI_BADHINTS": 12, - "SOCKET_EAI_PROTOCOL": 13, - "SOCKET_EAI_OVERFLOW": 14, - "SOCKET_EAI_MAX": 15, -} - -func (x ResolveReply_ErrorCode) Enum() *ResolveReply_ErrorCode { - p := new(ResolveReply_ErrorCode) - *p = x - return p -} -func (x ResolveReply_ErrorCode) String() string { - return proto.EnumName(ResolveReply_ErrorCode_name, int32(x)) -} -func (x *ResolveReply_ErrorCode) UnmarshalJSON(data []byte) error { - value, err := proto.UnmarshalJSONEnum(ResolveReply_ErrorCode_value, data, "ResolveReply_ErrorCode") - if err != nil { - return err - } - *x = ResolveReply_ErrorCode(value) - return nil -} -func (ResolveReply_ErrorCode) EnumDescriptor() ([]byte, []int) { - return fileDescriptor_socket_service_b5f8f233dc327808, []int{33, 0} -} - -type RemoteSocketServiceError struct { - SystemError *int32 `protobuf:"varint,1,opt,name=system_error,json=systemError,def=0" json:"system_error,omitempty"` - ErrorDetail *string `protobuf:"bytes,2,opt,name=error_detail,json=errorDetail" json:"error_detail,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *RemoteSocketServiceError) Reset() { *m = RemoteSocketServiceError{} } -func (m *RemoteSocketServiceError) String() string { return proto.CompactTextString(m) } -func (*RemoteSocketServiceError) ProtoMessage() {} -func (*RemoteSocketServiceError) Descriptor() ([]byte, []int) { - return fileDescriptor_socket_service_b5f8f233dc327808, []int{0} -} -func (m *RemoteSocketServiceError) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_RemoteSocketServiceError.Unmarshal(m, b) -} -func (m *RemoteSocketServiceError) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_RemoteSocketServiceError.Marshal(b, m, deterministic) -} -func (dst *RemoteSocketServiceError) XXX_Merge(src proto.Message) { - xxx_messageInfo_RemoteSocketServiceError.Merge(dst, src) -} -func (m *RemoteSocketServiceError) XXX_Size() int { - return xxx_messageInfo_RemoteSocketServiceError.Size(m) -} -func (m *RemoteSocketServiceError) XXX_DiscardUnknown() { - xxx_messageInfo_RemoteSocketServiceError.DiscardUnknown(m) -} - -var xxx_messageInfo_RemoteSocketServiceError proto.InternalMessageInfo - -const Default_RemoteSocketServiceError_SystemError int32 = 0 - -func (m *RemoteSocketServiceError) GetSystemError() int32 { - if m != nil && m.SystemError != nil { - return *m.SystemError - } - return Default_RemoteSocketServiceError_SystemError -} - -func (m *RemoteSocketServiceError) GetErrorDetail() string { - if m != nil && m.ErrorDetail != nil { - return *m.ErrorDetail - } - return "" -} - -type AddressPort struct { - Port *int32 `protobuf:"varint,1,req,name=port" json:"port,omitempty"` - PackedAddress []byte `protobuf:"bytes,2,opt,name=packed_address,json=packedAddress" json:"packed_address,omitempty"` - HostnameHint *string `protobuf:"bytes,3,opt,name=hostname_hint,json=hostnameHint" json:"hostname_hint,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *AddressPort) Reset() { *m = AddressPort{} } -func (m *AddressPort) String() string { return proto.CompactTextString(m) } -func (*AddressPort) ProtoMessage() {} -func (*AddressPort) Descriptor() ([]byte, []int) { - return fileDescriptor_socket_service_b5f8f233dc327808, []int{1} -} -func (m *AddressPort) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_AddressPort.Unmarshal(m, b) -} -func (m *AddressPort) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_AddressPort.Marshal(b, m, deterministic) -} -func (dst *AddressPort) XXX_Merge(src proto.Message) { - xxx_messageInfo_AddressPort.Merge(dst, src) -} -func (m *AddressPort) XXX_Size() int { - return xxx_messageInfo_AddressPort.Size(m) -} -func (m *AddressPort) XXX_DiscardUnknown() { - xxx_messageInfo_AddressPort.DiscardUnknown(m) -} - -var xxx_messageInfo_AddressPort proto.InternalMessageInfo - -func (m *AddressPort) GetPort() int32 { - if m != nil && m.Port != nil { - return *m.Port - } - return 0 -} - -func (m *AddressPort) GetPackedAddress() []byte { - if m != nil { - return m.PackedAddress - } - return nil -} - -func (m *AddressPort) GetHostnameHint() string { - if m != nil && m.HostnameHint != nil { - return *m.HostnameHint - } - return "" -} - -type CreateSocketRequest struct { - Family *CreateSocketRequest_SocketFamily `protobuf:"varint,1,req,name=family,enum=appengine.CreateSocketRequest_SocketFamily" json:"family,omitempty"` - Protocol *CreateSocketRequest_SocketProtocol `protobuf:"varint,2,req,name=protocol,enum=appengine.CreateSocketRequest_SocketProtocol" json:"protocol,omitempty"` - SocketOptions []*SocketOption `protobuf:"bytes,3,rep,name=socket_options,json=socketOptions" json:"socket_options,omitempty"` - ProxyExternalIp *AddressPort `protobuf:"bytes,4,opt,name=proxy_external_ip,json=proxyExternalIp" json:"proxy_external_ip,omitempty"` - ListenBacklog *int32 `protobuf:"varint,5,opt,name=listen_backlog,json=listenBacklog,def=0" json:"listen_backlog,omitempty"` - RemoteIp *AddressPort `protobuf:"bytes,6,opt,name=remote_ip,json=remoteIp" json:"remote_ip,omitempty"` - AppId *string `protobuf:"bytes,9,opt,name=app_id,json=appId" json:"app_id,omitempty"` - ProjectId *int64 `protobuf:"varint,10,opt,name=project_id,json=projectId" json:"project_id,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *CreateSocketRequest) Reset() { *m = CreateSocketRequest{} } -func (m *CreateSocketRequest) String() string { return proto.CompactTextString(m) } -func (*CreateSocketRequest) ProtoMessage() {} -func (*CreateSocketRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_socket_service_b5f8f233dc327808, []int{2} -} -func (m *CreateSocketRequest) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_CreateSocketRequest.Unmarshal(m, b) -} -func (m *CreateSocketRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_CreateSocketRequest.Marshal(b, m, deterministic) -} -func (dst *CreateSocketRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_CreateSocketRequest.Merge(dst, src) -} -func (m *CreateSocketRequest) XXX_Size() int { - return xxx_messageInfo_CreateSocketRequest.Size(m) -} -func (m *CreateSocketRequest) XXX_DiscardUnknown() { - xxx_messageInfo_CreateSocketRequest.DiscardUnknown(m) -} - -var xxx_messageInfo_CreateSocketRequest proto.InternalMessageInfo - -const Default_CreateSocketRequest_ListenBacklog int32 = 0 - -func (m *CreateSocketRequest) GetFamily() CreateSocketRequest_SocketFamily { - if m != nil && m.Family != nil { - return *m.Family - } - return CreateSocketRequest_IPv4 -} - -func (m *CreateSocketRequest) GetProtocol() CreateSocketRequest_SocketProtocol { - if m != nil && m.Protocol != nil { - return *m.Protocol - } - return CreateSocketRequest_TCP -} - -func (m *CreateSocketRequest) GetSocketOptions() []*SocketOption { - if m != nil { - return m.SocketOptions - } - return nil -} - -func (m *CreateSocketRequest) GetProxyExternalIp() *AddressPort { - if m != nil { - return m.ProxyExternalIp - } - return nil -} - -func (m *CreateSocketRequest) GetListenBacklog() int32 { - if m != nil && m.ListenBacklog != nil { - return *m.ListenBacklog - } - return Default_CreateSocketRequest_ListenBacklog -} - -func (m *CreateSocketRequest) GetRemoteIp() *AddressPort { - if m != nil { - return m.RemoteIp - } - return nil -} - -func (m *CreateSocketRequest) GetAppId() string { - if m != nil && m.AppId != nil { - return *m.AppId - } - return "" -} - -func (m *CreateSocketRequest) GetProjectId() int64 { - if m != nil && m.ProjectId != nil { - return *m.ProjectId - } - return 0 -} - -type CreateSocketReply struct { - SocketDescriptor *string `protobuf:"bytes,1,opt,name=socket_descriptor,json=socketDescriptor" json:"socket_descriptor,omitempty"` - ServerAddress *AddressPort `protobuf:"bytes,3,opt,name=server_address,json=serverAddress" json:"server_address,omitempty"` - ProxyExternalIp *AddressPort `protobuf:"bytes,4,opt,name=proxy_external_ip,json=proxyExternalIp" json:"proxy_external_ip,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - proto.XXX_InternalExtensions `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *CreateSocketReply) Reset() { *m = CreateSocketReply{} } -func (m *CreateSocketReply) String() string { return proto.CompactTextString(m) } -func (*CreateSocketReply) ProtoMessage() {} -func (*CreateSocketReply) Descriptor() ([]byte, []int) { - return fileDescriptor_socket_service_b5f8f233dc327808, []int{3} -} - -var extRange_CreateSocketReply = []proto.ExtensionRange{ - {Start: 1000, End: 536870911}, -} - -func (*CreateSocketReply) ExtensionRangeArray() []proto.ExtensionRange { - return extRange_CreateSocketReply -} -func (m *CreateSocketReply) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_CreateSocketReply.Unmarshal(m, b) -} -func (m *CreateSocketReply) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_CreateSocketReply.Marshal(b, m, deterministic) -} -func (dst *CreateSocketReply) XXX_Merge(src proto.Message) { - xxx_messageInfo_CreateSocketReply.Merge(dst, src) -} -func (m *CreateSocketReply) XXX_Size() int { - return xxx_messageInfo_CreateSocketReply.Size(m) -} -func (m *CreateSocketReply) XXX_DiscardUnknown() { - xxx_messageInfo_CreateSocketReply.DiscardUnknown(m) -} - -var xxx_messageInfo_CreateSocketReply proto.InternalMessageInfo - -func (m *CreateSocketReply) GetSocketDescriptor() string { - if m != nil && m.SocketDescriptor != nil { - return *m.SocketDescriptor - } - return "" -} - -func (m *CreateSocketReply) GetServerAddress() *AddressPort { - if m != nil { - return m.ServerAddress - } - return nil -} - -func (m *CreateSocketReply) GetProxyExternalIp() *AddressPort { - if m != nil { - return m.ProxyExternalIp - } - return nil -} - -type BindRequest struct { - SocketDescriptor *string `protobuf:"bytes,1,req,name=socket_descriptor,json=socketDescriptor" json:"socket_descriptor,omitempty"` - ProxyExternalIp *AddressPort `protobuf:"bytes,2,req,name=proxy_external_ip,json=proxyExternalIp" json:"proxy_external_ip,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *BindRequest) Reset() { *m = BindRequest{} } -func (m *BindRequest) String() string { return proto.CompactTextString(m) } -func (*BindRequest) ProtoMessage() {} -func (*BindRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_socket_service_b5f8f233dc327808, []int{4} -} -func (m *BindRequest) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_BindRequest.Unmarshal(m, b) -} -func (m *BindRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_BindRequest.Marshal(b, m, deterministic) -} -func (dst *BindRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_BindRequest.Merge(dst, src) -} -func (m *BindRequest) XXX_Size() int { - return xxx_messageInfo_BindRequest.Size(m) -} -func (m *BindRequest) XXX_DiscardUnknown() { - xxx_messageInfo_BindRequest.DiscardUnknown(m) -} - -var xxx_messageInfo_BindRequest proto.InternalMessageInfo - -func (m *BindRequest) GetSocketDescriptor() string { - if m != nil && m.SocketDescriptor != nil { - return *m.SocketDescriptor - } - return "" -} - -func (m *BindRequest) GetProxyExternalIp() *AddressPort { - if m != nil { - return m.ProxyExternalIp - } - return nil -} - -type BindReply struct { - ProxyExternalIp *AddressPort `protobuf:"bytes,1,opt,name=proxy_external_ip,json=proxyExternalIp" json:"proxy_external_ip,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *BindReply) Reset() { *m = BindReply{} } -func (m *BindReply) String() string { return proto.CompactTextString(m) } -func (*BindReply) ProtoMessage() {} -func (*BindReply) Descriptor() ([]byte, []int) { - return fileDescriptor_socket_service_b5f8f233dc327808, []int{5} -} -func (m *BindReply) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_BindReply.Unmarshal(m, b) -} -func (m *BindReply) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_BindReply.Marshal(b, m, deterministic) -} -func (dst *BindReply) XXX_Merge(src proto.Message) { - xxx_messageInfo_BindReply.Merge(dst, src) -} -func (m *BindReply) XXX_Size() int { - return xxx_messageInfo_BindReply.Size(m) -} -func (m *BindReply) XXX_DiscardUnknown() { - xxx_messageInfo_BindReply.DiscardUnknown(m) -} - -var xxx_messageInfo_BindReply proto.InternalMessageInfo - -func (m *BindReply) GetProxyExternalIp() *AddressPort { - if m != nil { - return m.ProxyExternalIp - } - return nil -} - -type GetSocketNameRequest struct { - SocketDescriptor *string `protobuf:"bytes,1,req,name=socket_descriptor,json=socketDescriptor" json:"socket_descriptor,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *GetSocketNameRequest) Reset() { *m = GetSocketNameRequest{} } -func (m *GetSocketNameRequest) String() string { return proto.CompactTextString(m) } -func (*GetSocketNameRequest) ProtoMessage() {} -func (*GetSocketNameRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_socket_service_b5f8f233dc327808, []int{6} -} -func (m *GetSocketNameRequest) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_GetSocketNameRequest.Unmarshal(m, b) -} -func (m *GetSocketNameRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_GetSocketNameRequest.Marshal(b, m, deterministic) -} -func (dst *GetSocketNameRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_GetSocketNameRequest.Merge(dst, src) -} -func (m *GetSocketNameRequest) XXX_Size() int { - return xxx_messageInfo_GetSocketNameRequest.Size(m) -} -func (m *GetSocketNameRequest) XXX_DiscardUnknown() { - xxx_messageInfo_GetSocketNameRequest.DiscardUnknown(m) -} - -var xxx_messageInfo_GetSocketNameRequest proto.InternalMessageInfo - -func (m *GetSocketNameRequest) GetSocketDescriptor() string { - if m != nil && m.SocketDescriptor != nil { - return *m.SocketDescriptor - } - return "" -} - -type GetSocketNameReply struct { - ProxyExternalIp *AddressPort `protobuf:"bytes,2,opt,name=proxy_external_ip,json=proxyExternalIp" json:"proxy_external_ip,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *GetSocketNameReply) Reset() { *m = GetSocketNameReply{} } -func (m *GetSocketNameReply) String() string { return proto.CompactTextString(m) } -func (*GetSocketNameReply) ProtoMessage() {} -func (*GetSocketNameReply) Descriptor() ([]byte, []int) { - return fileDescriptor_socket_service_b5f8f233dc327808, []int{7} -} -func (m *GetSocketNameReply) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_GetSocketNameReply.Unmarshal(m, b) -} -func (m *GetSocketNameReply) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_GetSocketNameReply.Marshal(b, m, deterministic) -} -func (dst *GetSocketNameReply) XXX_Merge(src proto.Message) { - xxx_messageInfo_GetSocketNameReply.Merge(dst, src) -} -func (m *GetSocketNameReply) XXX_Size() int { - return xxx_messageInfo_GetSocketNameReply.Size(m) -} -func (m *GetSocketNameReply) XXX_DiscardUnknown() { - xxx_messageInfo_GetSocketNameReply.DiscardUnknown(m) -} - -var xxx_messageInfo_GetSocketNameReply proto.InternalMessageInfo - -func (m *GetSocketNameReply) GetProxyExternalIp() *AddressPort { - if m != nil { - return m.ProxyExternalIp - } - return nil -} - -type GetPeerNameRequest struct { - SocketDescriptor *string `protobuf:"bytes,1,req,name=socket_descriptor,json=socketDescriptor" json:"socket_descriptor,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *GetPeerNameRequest) Reset() { *m = GetPeerNameRequest{} } -func (m *GetPeerNameRequest) String() string { return proto.CompactTextString(m) } -func (*GetPeerNameRequest) ProtoMessage() {} -func (*GetPeerNameRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_socket_service_b5f8f233dc327808, []int{8} -} -func (m *GetPeerNameRequest) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_GetPeerNameRequest.Unmarshal(m, b) -} -func (m *GetPeerNameRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_GetPeerNameRequest.Marshal(b, m, deterministic) -} -func (dst *GetPeerNameRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_GetPeerNameRequest.Merge(dst, src) -} -func (m *GetPeerNameRequest) XXX_Size() int { - return xxx_messageInfo_GetPeerNameRequest.Size(m) -} -func (m *GetPeerNameRequest) XXX_DiscardUnknown() { - xxx_messageInfo_GetPeerNameRequest.DiscardUnknown(m) -} - -var xxx_messageInfo_GetPeerNameRequest proto.InternalMessageInfo - -func (m *GetPeerNameRequest) GetSocketDescriptor() string { - if m != nil && m.SocketDescriptor != nil { - return *m.SocketDescriptor - } - return "" -} - -type GetPeerNameReply struct { - PeerIp *AddressPort `protobuf:"bytes,2,opt,name=peer_ip,json=peerIp" json:"peer_ip,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *GetPeerNameReply) Reset() { *m = GetPeerNameReply{} } -func (m *GetPeerNameReply) String() string { return proto.CompactTextString(m) } -func (*GetPeerNameReply) ProtoMessage() {} -func (*GetPeerNameReply) Descriptor() ([]byte, []int) { - return fileDescriptor_socket_service_b5f8f233dc327808, []int{9} -} -func (m *GetPeerNameReply) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_GetPeerNameReply.Unmarshal(m, b) -} -func (m *GetPeerNameReply) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_GetPeerNameReply.Marshal(b, m, deterministic) -} -func (dst *GetPeerNameReply) XXX_Merge(src proto.Message) { - xxx_messageInfo_GetPeerNameReply.Merge(dst, src) -} -func (m *GetPeerNameReply) XXX_Size() int { - return xxx_messageInfo_GetPeerNameReply.Size(m) -} -func (m *GetPeerNameReply) XXX_DiscardUnknown() { - xxx_messageInfo_GetPeerNameReply.DiscardUnknown(m) -} - -var xxx_messageInfo_GetPeerNameReply proto.InternalMessageInfo - -func (m *GetPeerNameReply) GetPeerIp() *AddressPort { - if m != nil { - return m.PeerIp - } - return nil -} - -type SocketOption struct { - Level *SocketOption_SocketOptionLevel `protobuf:"varint,1,req,name=level,enum=appengine.SocketOption_SocketOptionLevel" json:"level,omitempty"` - Option *SocketOption_SocketOptionName `protobuf:"varint,2,req,name=option,enum=appengine.SocketOption_SocketOptionName" json:"option,omitempty"` - Value []byte `protobuf:"bytes,3,req,name=value" json:"value,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *SocketOption) Reset() { *m = SocketOption{} } -func (m *SocketOption) String() string { return proto.CompactTextString(m) } -func (*SocketOption) ProtoMessage() {} -func (*SocketOption) Descriptor() ([]byte, []int) { - return fileDescriptor_socket_service_b5f8f233dc327808, []int{10} -} -func (m *SocketOption) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_SocketOption.Unmarshal(m, b) -} -func (m *SocketOption) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_SocketOption.Marshal(b, m, deterministic) -} -func (dst *SocketOption) XXX_Merge(src proto.Message) { - xxx_messageInfo_SocketOption.Merge(dst, src) -} -func (m *SocketOption) XXX_Size() int { - return xxx_messageInfo_SocketOption.Size(m) -} -func (m *SocketOption) XXX_DiscardUnknown() { - xxx_messageInfo_SocketOption.DiscardUnknown(m) -} - -var xxx_messageInfo_SocketOption proto.InternalMessageInfo - -func (m *SocketOption) GetLevel() SocketOption_SocketOptionLevel { - if m != nil && m.Level != nil { - return *m.Level - } - return SocketOption_SOCKET_SOL_IP -} - -func (m *SocketOption) GetOption() SocketOption_SocketOptionName { - if m != nil && m.Option != nil { - return *m.Option - } - return SocketOption_SOCKET_SO_DEBUG -} - -func (m *SocketOption) GetValue() []byte { - if m != nil { - return m.Value - } - return nil -} - -type SetSocketOptionsRequest struct { - SocketDescriptor *string `protobuf:"bytes,1,req,name=socket_descriptor,json=socketDescriptor" json:"socket_descriptor,omitempty"` - Options []*SocketOption `protobuf:"bytes,2,rep,name=options" json:"options,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *SetSocketOptionsRequest) Reset() { *m = SetSocketOptionsRequest{} } -func (m *SetSocketOptionsRequest) String() string { return proto.CompactTextString(m) } -func (*SetSocketOptionsRequest) ProtoMessage() {} -func (*SetSocketOptionsRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_socket_service_b5f8f233dc327808, []int{11} -} -func (m *SetSocketOptionsRequest) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_SetSocketOptionsRequest.Unmarshal(m, b) -} -func (m *SetSocketOptionsRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_SetSocketOptionsRequest.Marshal(b, m, deterministic) -} -func (dst *SetSocketOptionsRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_SetSocketOptionsRequest.Merge(dst, src) -} -func (m *SetSocketOptionsRequest) XXX_Size() int { - return xxx_messageInfo_SetSocketOptionsRequest.Size(m) -} -func (m *SetSocketOptionsRequest) XXX_DiscardUnknown() { - xxx_messageInfo_SetSocketOptionsRequest.DiscardUnknown(m) -} - -var xxx_messageInfo_SetSocketOptionsRequest proto.InternalMessageInfo - -func (m *SetSocketOptionsRequest) GetSocketDescriptor() string { - if m != nil && m.SocketDescriptor != nil { - return *m.SocketDescriptor - } - return "" -} - -func (m *SetSocketOptionsRequest) GetOptions() []*SocketOption { - if m != nil { - return m.Options - } - return nil -} - -type SetSocketOptionsReply struct { - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *SetSocketOptionsReply) Reset() { *m = SetSocketOptionsReply{} } -func (m *SetSocketOptionsReply) String() string { return proto.CompactTextString(m) } -func (*SetSocketOptionsReply) ProtoMessage() {} -func (*SetSocketOptionsReply) Descriptor() ([]byte, []int) { - return fileDescriptor_socket_service_b5f8f233dc327808, []int{12} -} -func (m *SetSocketOptionsReply) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_SetSocketOptionsReply.Unmarshal(m, b) -} -func (m *SetSocketOptionsReply) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_SetSocketOptionsReply.Marshal(b, m, deterministic) -} -func (dst *SetSocketOptionsReply) XXX_Merge(src proto.Message) { - xxx_messageInfo_SetSocketOptionsReply.Merge(dst, src) -} -func (m *SetSocketOptionsReply) XXX_Size() int { - return xxx_messageInfo_SetSocketOptionsReply.Size(m) -} -func (m *SetSocketOptionsReply) XXX_DiscardUnknown() { - xxx_messageInfo_SetSocketOptionsReply.DiscardUnknown(m) -} - -var xxx_messageInfo_SetSocketOptionsReply proto.InternalMessageInfo - -type GetSocketOptionsRequest struct { - SocketDescriptor *string `protobuf:"bytes,1,req,name=socket_descriptor,json=socketDescriptor" json:"socket_descriptor,omitempty"` - Options []*SocketOption `protobuf:"bytes,2,rep,name=options" json:"options,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *GetSocketOptionsRequest) Reset() { *m = GetSocketOptionsRequest{} } -func (m *GetSocketOptionsRequest) String() string { return proto.CompactTextString(m) } -func (*GetSocketOptionsRequest) ProtoMessage() {} -func (*GetSocketOptionsRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_socket_service_b5f8f233dc327808, []int{13} -} -func (m *GetSocketOptionsRequest) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_GetSocketOptionsRequest.Unmarshal(m, b) -} -func (m *GetSocketOptionsRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_GetSocketOptionsRequest.Marshal(b, m, deterministic) -} -func (dst *GetSocketOptionsRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_GetSocketOptionsRequest.Merge(dst, src) -} -func (m *GetSocketOptionsRequest) XXX_Size() int { - return xxx_messageInfo_GetSocketOptionsRequest.Size(m) -} -func (m *GetSocketOptionsRequest) XXX_DiscardUnknown() { - xxx_messageInfo_GetSocketOptionsRequest.DiscardUnknown(m) -} - -var xxx_messageInfo_GetSocketOptionsRequest proto.InternalMessageInfo - -func (m *GetSocketOptionsRequest) GetSocketDescriptor() string { - if m != nil && m.SocketDescriptor != nil { - return *m.SocketDescriptor - } - return "" -} - -func (m *GetSocketOptionsRequest) GetOptions() []*SocketOption { - if m != nil { - return m.Options - } - return nil -} - -type GetSocketOptionsReply struct { - Options []*SocketOption `protobuf:"bytes,2,rep,name=options" json:"options,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *GetSocketOptionsReply) Reset() { *m = GetSocketOptionsReply{} } -func (m *GetSocketOptionsReply) String() string { return proto.CompactTextString(m) } -func (*GetSocketOptionsReply) ProtoMessage() {} -func (*GetSocketOptionsReply) Descriptor() ([]byte, []int) { - return fileDescriptor_socket_service_b5f8f233dc327808, []int{14} -} -func (m *GetSocketOptionsReply) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_GetSocketOptionsReply.Unmarshal(m, b) -} -func (m *GetSocketOptionsReply) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_GetSocketOptionsReply.Marshal(b, m, deterministic) -} -func (dst *GetSocketOptionsReply) XXX_Merge(src proto.Message) { - xxx_messageInfo_GetSocketOptionsReply.Merge(dst, src) -} -func (m *GetSocketOptionsReply) XXX_Size() int { - return xxx_messageInfo_GetSocketOptionsReply.Size(m) -} -func (m *GetSocketOptionsReply) XXX_DiscardUnknown() { - xxx_messageInfo_GetSocketOptionsReply.DiscardUnknown(m) -} - -var xxx_messageInfo_GetSocketOptionsReply proto.InternalMessageInfo - -func (m *GetSocketOptionsReply) GetOptions() []*SocketOption { - if m != nil { - return m.Options - } - return nil -} - -type ConnectRequest struct { - SocketDescriptor *string `protobuf:"bytes,1,req,name=socket_descriptor,json=socketDescriptor" json:"socket_descriptor,omitempty"` - RemoteIp *AddressPort `protobuf:"bytes,2,req,name=remote_ip,json=remoteIp" json:"remote_ip,omitempty"` - TimeoutSeconds *float64 `protobuf:"fixed64,3,opt,name=timeout_seconds,json=timeoutSeconds,def=-1" json:"timeout_seconds,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *ConnectRequest) Reset() { *m = ConnectRequest{} } -func (m *ConnectRequest) String() string { return proto.CompactTextString(m) } -func (*ConnectRequest) ProtoMessage() {} -func (*ConnectRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_socket_service_b5f8f233dc327808, []int{15} -} -func (m *ConnectRequest) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_ConnectRequest.Unmarshal(m, b) -} -func (m *ConnectRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_ConnectRequest.Marshal(b, m, deterministic) -} -func (dst *ConnectRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_ConnectRequest.Merge(dst, src) -} -func (m *ConnectRequest) XXX_Size() int { - return xxx_messageInfo_ConnectRequest.Size(m) -} -func (m *ConnectRequest) XXX_DiscardUnknown() { - xxx_messageInfo_ConnectRequest.DiscardUnknown(m) -} - -var xxx_messageInfo_ConnectRequest proto.InternalMessageInfo - -const Default_ConnectRequest_TimeoutSeconds float64 = -1 - -func (m *ConnectRequest) GetSocketDescriptor() string { - if m != nil && m.SocketDescriptor != nil { - return *m.SocketDescriptor - } - return "" -} - -func (m *ConnectRequest) GetRemoteIp() *AddressPort { - if m != nil { - return m.RemoteIp - } - return nil -} - -func (m *ConnectRequest) GetTimeoutSeconds() float64 { - if m != nil && m.TimeoutSeconds != nil { - return *m.TimeoutSeconds - } - return Default_ConnectRequest_TimeoutSeconds -} - -type ConnectReply struct { - ProxyExternalIp *AddressPort `protobuf:"bytes,1,opt,name=proxy_external_ip,json=proxyExternalIp" json:"proxy_external_ip,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - proto.XXX_InternalExtensions `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *ConnectReply) Reset() { *m = ConnectReply{} } -func (m *ConnectReply) String() string { return proto.CompactTextString(m) } -func (*ConnectReply) ProtoMessage() {} -func (*ConnectReply) Descriptor() ([]byte, []int) { - return fileDescriptor_socket_service_b5f8f233dc327808, []int{16} -} - -var extRange_ConnectReply = []proto.ExtensionRange{ - {Start: 1000, End: 536870911}, -} - -func (*ConnectReply) ExtensionRangeArray() []proto.ExtensionRange { - return extRange_ConnectReply -} -func (m *ConnectReply) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_ConnectReply.Unmarshal(m, b) -} -func (m *ConnectReply) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_ConnectReply.Marshal(b, m, deterministic) -} -func (dst *ConnectReply) XXX_Merge(src proto.Message) { - xxx_messageInfo_ConnectReply.Merge(dst, src) -} -func (m *ConnectReply) XXX_Size() int { - return xxx_messageInfo_ConnectReply.Size(m) -} -func (m *ConnectReply) XXX_DiscardUnknown() { - xxx_messageInfo_ConnectReply.DiscardUnknown(m) -} - -var xxx_messageInfo_ConnectReply proto.InternalMessageInfo - -func (m *ConnectReply) GetProxyExternalIp() *AddressPort { - if m != nil { - return m.ProxyExternalIp - } - return nil -} - -type ListenRequest struct { - SocketDescriptor *string `protobuf:"bytes,1,req,name=socket_descriptor,json=socketDescriptor" json:"socket_descriptor,omitempty"` - Backlog *int32 `protobuf:"varint,2,req,name=backlog" json:"backlog,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *ListenRequest) Reset() { *m = ListenRequest{} } -func (m *ListenRequest) String() string { return proto.CompactTextString(m) } -func (*ListenRequest) ProtoMessage() {} -func (*ListenRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_socket_service_b5f8f233dc327808, []int{17} -} -func (m *ListenRequest) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_ListenRequest.Unmarshal(m, b) -} -func (m *ListenRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_ListenRequest.Marshal(b, m, deterministic) -} -func (dst *ListenRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_ListenRequest.Merge(dst, src) -} -func (m *ListenRequest) XXX_Size() int { - return xxx_messageInfo_ListenRequest.Size(m) -} -func (m *ListenRequest) XXX_DiscardUnknown() { - xxx_messageInfo_ListenRequest.DiscardUnknown(m) -} - -var xxx_messageInfo_ListenRequest proto.InternalMessageInfo - -func (m *ListenRequest) GetSocketDescriptor() string { - if m != nil && m.SocketDescriptor != nil { - return *m.SocketDescriptor - } - return "" -} - -func (m *ListenRequest) GetBacklog() int32 { - if m != nil && m.Backlog != nil { - return *m.Backlog - } - return 0 -} - -type ListenReply struct { - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *ListenReply) Reset() { *m = ListenReply{} } -func (m *ListenReply) String() string { return proto.CompactTextString(m) } -func (*ListenReply) ProtoMessage() {} -func (*ListenReply) Descriptor() ([]byte, []int) { - return fileDescriptor_socket_service_b5f8f233dc327808, []int{18} -} -func (m *ListenReply) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_ListenReply.Unmarshal(m, b) -} -func (m *ListenReply) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_ListenReply.Marshal(b, m, deterministic) -} -func (dst *ListenReply) XXX_Merge(src proto.Message) { - xxx_messageInfo_ListenReply.Merge(dst, src) -} -func (m *ListenReply) XXX_Size() int { - return xxx_messageInfo_ListenReply.Size(m) -} -func (m *ListenReply) XXX_DiscardUnknown() { - xxx_messageInfo_ListenReply.DiscardUnknown(m) -} - -var xxx_messageInfo_ListenReply proto.InternalMessageInfo - -type AcceptRequest struct { - SocketDescriptor *string `protobuf:"bytes,1,req,name=socket_descriptor,json=socketDescriptor" json:"socket_descriptor,omitempty"` - TimeoutSeconds *float64 `protobuf:"fixed64,2,opt,name=timeout_seconds,json=timeoutSeconds,def=-1" json:"timeout_seconds,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *AcceptRequest) Reset() { *m = AcceptRequest{} } -func (m *AcceptRequest) String() string { return proto.CompactTextString(m) } -func (*AcceptRequest) ProtoMessage() {} -func (*AcceptRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_socket_service_b5f8f233dc327808, []int{19} -} -func (m *AcceptRequest) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_AcceptRequest.Unmarshal(m, b) -} -func (m *AcceptRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_AcceptRequest.Marshal(b, m, deterministic) -} -func (dst *AcceptRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_AcceptRequest.Merge(dst, src) -} -func (m *AcceptRequest) XXX_Size() int { - return xxx_messageInfo_AcceptRequest.Size(m) -} -func (m *AcceptRequest) XXX_DiscardUnknown() { - xxx_messageInfo_AcceptRequest.DiscardUnknown(m) -} - -var xxx_messageInfo_AcceptRequest proto.InternalMessageInfo - -const Default_AcceptRequest_TimeoutSeconds float64 = -1 - -func (m *AcceptRequest) GetSocketDescriptor() string { - if m != nil && m.SocketDescriptor != nil { - return *m.SocketDescriptor - } - return "" -} - -func (m *AcceptRequest) GetTimeoutSeconds() float64 { - if m != nil && m.TimeoutSeconds != nil { - return *m.TimeoutSeconds - } - return Default_AcceptRequest_TimeoutSeconds -} - -type AcceptReply struct { - NewSocketDescriptor []byte `protobuf:"bytes,2,opt,name=new_socket_descriptor,json=newSocketDescriptor" json:"new_socket_descriptor,omitempty"` - RemoteAddress *AddressPort `protobuf:"bytes,3,opt,name=remote_address,json=remoteAddress" json:"remote_address,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *AcceptReply) Reset() { *m = AcceptReply{} } -func (m *AcceptReply) String() string { return proto.CompactTextString(m) } -func (*AcceptReply) ProtoMessage() {} -func (*AcceptReply) Descriptor() ([]byte, []int) { - return fileDescriptor_socket_service_b5f8f233dc327808, []int{20} -} -func (m *AcceptReply) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_AcceptReply.Unmarshal(m, b) -} -func (m *AcceptReply) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_AcceptReply.Marshal(b, m, deterministic) -} -func (dst *AcceptReply) XXX_Merge(src proto.Message) { - xxx_messageInfo_AcceptReply.Merge(dst, src) -} -func (m *AcceptReply) XXX_Size() int { - return xxx_messageInfo_AcceptReply.Size(m) -} -func (m *AcceptReply) XXX_DiscardUnknown() { - xxx_messageInfo_AcceptReply.DiscardUnknown(m) -} - -var xxx_messageInfo_AcceptReply proto.InternalMessageInfo - -func (m *AcceptReply) GetNewSocketDescriptor() []byte { - if m != nil { - return m.NewSocketDescriptor - } - return nil -} - -func (m *AcceptReply) GetRemoteAddress() *AddressPort { - if m != nil { - return m.RemoteAddress - } - return nil -} - -type ShutDownRequest struct { - SocketDescriptor *string `protobuf:"bytes,1,req,name=socket_descriptor,json=socketDescriptor" json:"socket_descriptor,omitempty"` - How *ShutDownRequest_How `protobuf:"varint,2,req,name=how,enum=appengine.ShutDownRequest_How" json:"how,omitempty"` - SendOffset *int64 `protobuf:"varint,3,req,name=send_offset,json=sendOffset" json:"send_offset,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *ShutDownRequest) Reset() { *m = ShutDownRequest{} } -func (m *ShutDownRequest) String() string { return proto.CompactTextString(m) } -func (*ShutDownRequest) ProtoMessage() {} -func (*ShutDownRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_socket_service_b5f8f233dc327808, []int{21} -} -func (m *ShutDownRequest) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_ShutDownRequest.Unmarshal(m, b) -} -func (m *ShutDownRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_ShutDownRequest.Marshal(b, m, deterministic) -} -func (dst *ShutDownRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_ShutDownRequest.Merge(dst, src) -} -func (m *ShutDownRequest) XXX_Size() int { - return xxx_messageInfo_ShutDownRequest.Size(m) -} -func (m *ShutDownRequest) XXX_DiscardUnknown() { - xxx_messageInfo_ShutDownRequest.DiscardUnknown(m) -} - -var xxx_messageInfo_ShutDownRequest proto.InternalMessageInfo - -func (m *ShutDownRequest) GetSocketDescriptor() string { - if m != nil && m.SocketDescriptor != nil { - return *m.SocketDescriptor - } - return "" -} - -func (m *ShutDownRequest) GetHow() ShutDownRequest_How { - if m != nil && m.How != nil { - return *m.How - } - return ShutDownRequest_SOCKET_SHUT_RD -} - -func (m *ShutDownRequest) GetSendOffset() int64 { - if m != nil && m.SendOffset != nil { - return *m.SendOffset - } - return 0 -} - -type ShutDownReply struct { - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *ShutDownReply) Reset() { *m = ShutDownReply{} } -func (m *ShutDownReply) String() string { return proto.CompactTextString(m) } -func (*ShutDownReply) ProtoMessage() {} -func (*ShutDownReply) Descriptor() ([]byte, []int) { - return fileDescriptor_socket_service_b5f8f233dc327808, []int{22} -} -func (m *ShutDownReply) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_ShutDownReply.Unmarshal(m, b) -} -func (m *ShutDownReply) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_ShutDownReply.Marshal(b, m, deterministic) -} -func (dst *ShutDownReply) XXX_Merge(src proto.Message) { - xxx_messageInfo_ShutDownReply.Merge(dst, src) -} -func (m *ShutDownReply) XXX_Size() int { - return xxx_messageInfo_ShutDownReply.Size(m) -} -func (m *ShutDownReply) XXX_DiscardUnknown() { - xxx_messageInfo_ShutDownReply.DiscardUnknown(m) -} - -var xxx_messageInfo_ShutDownReply proto.InternalMessageInfo - -type CloseRequest struct { - SocketDescriptor *string `protobuf:"bytes,1,req,name=socket_descriptor,json=socketDescriptor" json:"socket_descriptor,omitempty"` - SendOffset *int64 `protobuf:"varint,2,opt,name=send_offset,json=sendOffset,def=-1" json:"send_offset,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *CloseRequest) Reset() { *m = CloseRequest{} } -func (m *CloseRequest) String() string { return proto.CompactTextString(m) } -func (*CloseRequest) ProtoMessage() {} -func (*CloseRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_socket_service_b5f8f233dc327808, []int{23} -} -func (m *CloseRequest) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_CloseRequest.Unmarshal(m, b) -} -func (m *CloseRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_CloseRequest.Marshal(b, m, deterministic) -} -func (dst *CloseRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_CloseRequest.Merge(dst, src) -} -func (m *CloseRequest) XXX_Size() int { - return xxx_messageInfo_CloseRequest.Size(m) -} -func (m *CloseRequest) XXX_DiscardUnknown() { - xxx_messageInfo_CloseRequest.DiscardUnknown(m) -} - -var xxx_messageInfo_CloseRequest proto.InternalMessageInfo - -const Default_CloseRequest_SendOffset int64 = -1 - -func (m *CloseRequest) GetSocketDescriptor() string { - if m != nil && m.SocketDescriptor != nil { - return *m.SocketDescriptor - } - return "" -} - -func (m *CloseRequest) GetSendOffset() int64 { - if m != nil && m.SendOffset != nil { - return *m.SendOffset - } - return Default_CloseRequest_SendOffset -} - -type CloseReply struct { - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *CloseReply) Reset() { *m = CloseReply{} } -func (m *CloseReply) String() string { return proto.CompactTextString(m) } -func (*CloseReply) ProtoMessage() {} -func (*CloseReply) Descriptor() ([]byte, []int) { - return fileDescriptor_socket_service_b5f8f233dc327808, []int{24} -} -func (m *CloseReply) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_CloseReply.Unmarshal(m, b) -} -func (m *CloseReply) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_CloseReply.Marshal(b, m, deterministic) -} -func (dst *CloseReply) XXX_Merge(src proto.Message) { - xxx_messageInfo_CloseReply.Merge(dst, src) -} -func (m *CloseReply) XXX_Size() int { - return xxx_messageInfo_CloseReply.Size(m) -} -func (m *CloseReply) XXX_DiscardUnknown() { - xxx_messageInfo_CloseReply.DiscardUnknown(m) -} - -var xxx_messageInfo_CloseReply proto.InternalMessageInfo - -type SendRequest struct { - SocketDescriptor *string `protobuf:"bytes,1,req,name=socket_descriptor,json=socketDescriptor" json:"socket_descriptor,omitempty"` - Data []byte `protobuf:"bytes,2,req,name=data" json:"data,omitempty"` - StreamOffset *int64 `protobuf:"varint,3,req,name=stream_offset,json=streamOffset" json:"stream_offset,omitempty"` - Flags *int32 `protobuf:"varint,4,opt,name=flags,def=0" json:"flags,omitempty"` - SendTo *AddressPort `protobuf:"bytes,5,opt,name=send_to,json=sendTo" json:"send_to,omitempty"` - TimeoutSeconds *float64 `protobuf:"fixed64,6,opt,name=timeout_seconds,json=timeoutSeconds,def=-1" json:"timeout_seconds,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *SendRequest) Reset() { *m = SendRequest{} } -func (m *SendRequest) String() string { return proto.CompactTextString(m) } -func (*SendRequest) ProtoMessage() {} -func (*SendRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_socket_service_b5f8f233dc327808, []int{25} -} -func (m *SendRequest) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_SendRequest.Unmarshal(m, b) -} -func (m *SendRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_SendRequest.Marshal(b, m, deterministic) -} -func (dst *SendRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_SendRequest.Merge(dst, src) -} -func (m *SendRequest) XXX_Size() int { - return xxx_messageInfo_SendRequest.Size(m) -} -func (m *SendRequest) XXX_DiscardUnknown() { - xxx_messageInfo_SendRequest.DiscardUnknown(m) -} - -var xxx_messageInfo_SendRequest proto.InternalMessageInfo - -const Default_SendRequest_Flags int32 = 0 -const Default_SendRequest_TimeoutSeconds float64 = -1 - -func (m *SendRequest) GetSocketDescriptor() string { - if m != nil && m.SocketDescriptor != nil { - return *m.SocketDescriptor - } - return "" -} - -func (m *SendRequest) GetData() []byte { - if m != nil { - return m.Data - } - return nil -} - -func (m *SendRequest) GetStreamOffset() int64 { - if m != nil && m.StreamOffset != nil { - return *m.StreamOffset - } - return 0 -} - -func (m *SendRequest) GetFlags() int32 { - if m != nil && m.Flags != nil { - return *m.Flags - } - return Default_SendRequest_Flags -} - -func (m *SendRequest) GetSendTo() *AddressPort { - if m != nil { - return m.SendTo - } - return nil -} - -func (m *SendRequest) GetTimeoutSeconds() float64 { - if m != nil && m.TimeoutSeconds != nil { - return *m.TimeoutSeconds - } - return Default_SendRequest_TimeoutSeconds -} - -type SendReply struct { - DataSent *int32 `protobuf:"varint,1,opt,name=data_sent,json=dataSent" json:"data_sent,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *SendReply) Reset() { *m = SendReply{} } -func (m *SendReply) String() string { return proto.CompactTextString(m) } -func (*SendReply) ProtoMessage() {} -func (*SendReply) Descriptor() ([]byte, []int) { - return fileDescriptor_socket_service_b5f8f233dc327808, []int{26} -} -func (m *SendReply) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_SendReply.Unmarshal(m, b) -} -func (m *SendReply) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_SendReply.Marshal(b, m, deterministic) -} -func (dst *SendReply) XXX_Merge(src proto.Message) { - xxx_messageInfo_SendReply.Merge(dst, src) -} -func (m *SendReply) XXX_Size() int { - return xxx_messageInfo_SendReply.Size(m) -} -func (m *SendReply) XXX_DiscardUnknown() { - xxx_messageInfo_SendReply.DiscardUnknown(m) -} - -var xxx_messageInfo_SendReply proto.InternalMessageInfo - -func (m *SendReply) GetDataSent() int32 { - if m != nil && m.DataSent != nil { - return *m.DataSent - } - return 0 -} - -type ReceiveRequest struct { - SocketDescriptor *string `protobuf:"bytes,1,req,name=socket_descriptor,json=socketDescriptor" json:"socket_descriptor,omitempty"` - DataSize *int32 `protobuf:"varint,2,req,name=data_size,json=dataSize" json:"data_size,omitempty"` - Flags *int32 `protobuf:"varint,3,opt,name=flags,def=0" json:"flags,omitempty"` - TimeoutSeconds *float64 `protobuf:"fixed64,5,opt,name=timeout_seconds,json=timeoutSeconds,def=-1" json:"timeout_seconds,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *ReceiveRequest) Reset() { *m = ReceiveRequest{} } -func (m *ReceiveRequest) String() string { return proto.CompactTextString(m) } -func (*ReceiveRequest) ProtoMessage() {} -func (*ReceiveRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_socket_service_b5f8f233dc327808, []int{27} -} -func (m *ReceiveRequest) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_ReceiveRequest.Unmarshal(m, b) -} -func (m *ReceiveRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_ReceiveRequest.Marshal(b, m, deterministic) -} -func (dst *ReceiveRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_ReceiveRequest.Merge(dst, src) -} -func (m *ReceiveRequest) XXX_Size() int { - return xxx_messageInfo_ReceiveRequest.Size(m) -} -func (m *ReceiveRequest) XXX_DiscardUnknown() { - xxx_messageInfo_ReceiveRequest.DiscardUnknown(m) -} - -var xxx_messageInfo_ReceiveRequest proto.InternalMessageInfo - -const Default_ReceiveRequest_Flags int32 = 0 -const Default_ReceiveRequest_TimeoutSeconds float64 = -1 - -func (m *ReceiveRequest) GetSocketDescriptor() string { - if m != nil && m.SocketDescriptor != nil { - return *m.SocketDescriptor - } - return "" -} - -func (m *ReceiveRequest) GetDataSize() int32 { - if m != nil && m.DataSize != nil { - return *m.DataSize - } - return 0 -} - -func (m *ReceiveRequest) GetFlags() int32 { - if m != nil && m.Flags != nil { - return *m.Flags - } - return Default_ReceiveRequest_Flags -} - -func (m *ReceiveRequest) GetTimeoutSeconds() float64 { - if m != nil && m.TimeoutSeconds != nil { - return *m.TimeoutSeconds - } - return Default_ReceiveRequest_TimeoutSeconds -} - -type ReceiveReply struct { - StreamOffset *int64 `protobuf:"varint,2,opt,name=stream_offset,json=streamOffset" json:"stream_offset,omitempty"` - Data []byte `protobuf:"bytes,3,opt,name=data" json:"data,omitempty"` - ReceivedFrom *AddressPort `protobuf:"bytes,4,opt,name=received_from,json=receivedFrom" json:"received_from,omitempty"` - BufferSize *int32 `protobuf:"varint,5,opt,name=buffer_size,json=bufferSize" json:"buffer_size,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *ReceiveReply) Reset() { *m = ReceiveReply{} } -func (m *ReceiveReply) String() string { return proto.CompactTextString(m) } -func (*ReceiveReply) ProtoMessage() {} -func (*ReceiveReply) Descriptor() ([]byte, []int) { - return fileDescriptor_socket_service_b5f8f233dc327808, []int{28} -} -func (m *ReceiveReply) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_ReceiveReply.Unmarshal(m, b) -} -func (m *ReceiveReply) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_ReceiveReply.Marshal(b, m, deterministic) -} -func (dst *ReceiveReply) XXX_Merge(src proto.Message) { - xxx_messageInfo_ReceiveReply.Merge(dst, src) -} -func (m *ReceiveReply) XXX_Size() int { - return xxx_messageInfo_ReceiveReply.Size(m) -} -func (m *ReceiveReply) XXX_DiscardUnknown() { - xxx_messageInfo_ReceiveReply.DiscardUnknown(m) -} - -var xxx_messageInfo_ReceiveReply proto.InternalMessageInfo - -func (m *ReceiveReply) GetStreamOffset() int64 { - if m != nil && m.StreamOffset != nil { - return *m.StreamOffset - } - return 0 -} - -func (m *ReceiveReply) GetData() []byte { - if m != nil { - return m.Data - } - return nil -} - -func (m *ReceiveReply) GetReceivedFrom() *AddressPort { - if m != nil { - return m.ReceivedFrom - } - return nil -} - -func (m *ReceiveReply) GetBufferSize() int32 { - if m != nil && m.BufferSize != nil { - return *m.BufferSize - } - return 0 -} - -type PollEvent struct { - SocketDescriptor *string `protobuf:"bytes,1,req,name=socket_descriptor,json=socketDescriptor" json:"socket_descriptor,omitempty"` - RequestedEvents *int32 `protobuf:"varint,2,req,name=requested_events,json=requestedEvents" json:"requested_events,omitempty"` - ObservedEvents *int32 `protobuf:"varint,3,req,name=observed_events,json=observedEvents" json:"observed_events,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *PollEvent) Reset() { *m = PollEvent{} } -func (m *PollEvent) String() string { return proto.CompactTextString(m) } -func (*PollEvent) ProtoMessage() {} -func (*PollEvent) Descriptor() ([]byte, []int) { - return fileDescriptor_socket_service_b5f8f233dc327808, []int{29} -} -func (m *PollEvent) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_PollEvent.Unmarshal(m, b) -} -func (m *PollEvent) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_PollEvent.Marshal(b, m, deterministic) -} -func (dst *PollEvent) XXX_Merge(src proto.Message) { - xxx_messageInfo_PollEvent.Merge(dst, src) -} -func (m *PollEvent) XXX_Size() int { - return xxx_messageInfo_PollEvent.Size(m) -} -func (m *PollEvent) XXX_DiscardUnknown() { - xxx_messageInfo_PollEvent.DiscardUnknown(m) -} - -var xxx_messageInfo_PollEvent proto.InternalMessageInfo - -func (m *PollEvent) GetSocketDescriptor() string { - if m != nil && m.SocketDescriptor != nil { - return *m.SocketDescriptor - } - return "" -} - -func (m *PollEvent) GetRequestedEvents() int32 { - if m != nil && m.RequestedEvents != nil { - return *m.RequestedEvents - } - return 0 -} - -func (m *PollEvent) GetObservedEvents() int32 { - if m != nil && m.ObservedEvents != nil { - return *m.ObservedEvents - } - return 0 -} - -type PollRequest struct { - Events []*PollEvent `protobuf:"bytes,1,rep,name=events" json:"events,omitempty"` - TimeoutSeconds *float64 `protobuf:"fixed64,2,opt,name=timeout_seconds,json=timeoutSeconds,def=-1" json:"timeout_seconds,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *PollRequest) Reset() { *m = PollRequest{} } -func (m *PollRequest) String() string { return proto.CompactTextString(m) } -func (*PollRequest) ProtoMessage() {} -func (*PollRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_socket_service_b5f8f233dc327808, []int{30} -} -func (m *PollRequest) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_PollRequest.Unmarshal(m, b) -} -func (m *PollRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_PollRequest.Marshal(b, m, deterministic) -} -func (dst *PollRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_PollRequest.Merge(dst, src) -} -func (m *PollRequest) XXX_Size() int { - return xxx_messageInfo_PollRequest.Size(m) -} -func (m *PollRequest) XXX_DiscardUnknown() { - xxx_messageInfo_PollRequest.DiscardUnknown(m) -} - -var xxx_messageInfo_PollRequest proto.InternalMessageInfo - -const Default_PollRequest_TimeoutSeconds float64 = -1 - -func (m *PollRequest) GetEvents() []*PollEvent { - if m != nil { - return m.Events - } - return nil -} - -func (m *PollRequest) GetTimeoutSeconds() float64 { - if m != nil && m.TimeoutSeconds != nil { - return *m.TimeoutSeconds - } - return Default_PollRequest_TimeoutSeconds -} - -type PollReply struct { - Events []*PollEvent `protobuf:"bytes,2,rep,name=events" json:"events,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *PollReply) Reset() { *m = PollReply{} } -func (m *PollReply) String() string { return proto.CompactTextString(m) } -func (*PollReply) ProtoMessage() {} -func (*PollReply) Descriptor() ([]byte, []int) { - return fileDescriptor_socket_service_b5f8f233dc327808, []int{31} -} -func (m *PollReply) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_PollReply.Unmarshal(m, b) -} -func (m *PollReply) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_PollReply.Marshal(b, m, deterministic) -} -func (dst *PollReply) XXX_Merge(src proto.Message) { - xxx_messageInfo_PollReply.Merge(dst, src) -} -func (m *PollReply) XXX_Size() int { - return xxx_messageInfo_PollReply.Size(m) -} -func (m *PollReply) XXX_DiscardUnknown() { - xxx_messageInfo_PollReply.DiscardUnknown(m) -} - -var xxx_messageInfo_PollReply proto.InternalMessageInfo - -func (m *PollReply) GetEvents() []*PollEvent { - if m != nil { - return m.Events - } - return nil -} - -type ResolveRequest struct { - Name *string `protobuf:"bytes,1,req,name=name" json:"name,omitempty"` - AddressFamilies []CreateSocketRequest_SocketFamily `protobuf:"varint,2,rep,name=address_families,json=addressFamilies,enum=appengine.CreateSocketRequest_SocketFamily" json:"address_families,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *ResolveRequest) Reset() { *m = ResolveRequest{} } -func (m *ResolveRequest) String() string { return proto.CompactTextString(m) } -func (*ResolveRequest) ProtoMessage() {} -func (*ResolveRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_socket_service_b5f8f233dc327808, []int{32} -} -func (m *ResolveRequest) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_ResolveRequest.Unmarshal(m, b) -} -func (m *ResolveRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_ResolveRequest.Marshal(b, m, deterministic) -} -func (dst *ResolveRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_ResolveRequest.Merge(dst, src) -} -func (m *ResolveRequest) XXX_Size() int { - return xxx_messageInfo_ResolveRequest.Size(m) -} -func (m *ResolveRequest) XXX_DiscardUnknown() { - xxx_messageInfo_ResolveRequest.DiscardUnknown(m) -} - -var xxx_messageInfo_ResolveRequest proto.InternalMessageInfo - -func (m *ResolveRequest) GetName() string { - if m != nil && m.Name != nil { - return *m.Name - } - return "" -} - -func (m *ResolveRequest) GetAddressFamilies() []CreateSocketRequest_SocketFamily { - if m != nil { - return m.AddressFamilies - } - return nil -} - -type ResolveReply struct { - PackedAddress [][]byte `protobuf:"bytes,2,rep,name=packed_address,json=packedAddress" json:"packed_address,omitempty"` - CanonicalName *string `protobuf:"bytes,3,opt,name=canonical_name,json=canonicalName" json:"canonical_name,omitempty"` - Aliases []string `protobuf:"bytes,4,rep,name=aliases" json:"aliases,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *ResolveReply) Reset() { *m = ResolveReply{} } -func (m *ResolveReply) String() string { return proto.CompactTextString(m) } -func (*ResolveReply) ProtoMessage() {} -func (*ResolveReply) Descriptor() ([]byte, []int) { - return fileDescriptor_socket_service_b5f8f233dc327808, []int{33} -} -func (m *ResolveReply) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_ResolveReply.Unmarshal(m, b) -} -func (m *ResolveReply) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_ResolveReply.Marshal(b, m, deterministic) -} -func (dst *ResolveReply) XXX_Merge(src proto.Message) { - xxx_messageInfo_ResolveReply.Merge(dst, src) -} -func (m *ResolveReply) XXX_Size() int { - return xxx_messageInfo_ResolveReply.Size(m) -} -func (m *ResolveReply) XXX_DiscardUnknown() { - xxx_messageInfo_ResolveReply.DiscardUnknown(m) -} - -var xxx_messageInfo_ResolveReply proto.InternalMessageInfo - -func (m *ResolveReply) GetPackedAddress() [][]byte { - if m != nil { - return m.PackedAddress - } - return nil -} - -func (m *ResolveReply) GetCanonicalName() string { - if m != nil && m.CanonicalName != nil { - return *m.CanonicalName - } - return "" -} - -func (m *ResolveReply) GetAliases() []string { - if m != nil { - return m.Aliases - } - return nil -} - -func init() { - proto.RegisterType((*RemoteSocketServiceError)(nil), "appengine.RemoteSocketServiceError") - proto.RegisterType((*AddressPort)(nil), "appengine.AddressPort") - proto.RegisterType((*CreateSocketRequest)(nil), "appengine.CreateSocketRequest") - proto.RegisterType((*CreateSocketReply)(nil), "appengine.CreateSocketReply") - proto.RegisterType((*BindRequest)(nil), "appengine.BindRequest") - proto.RegisterType((*BindReply)(nil), "appengine.BindReply") - proto.RegisterType((*GetSocketNameRequest)(nil), "appengine.GetSocketNameRequest") - proto.RegisterType((*GetSocketNameReply)(nil), "appengine.GetSocketNameReply") - proto.RegisterType((*GetPeerNameRequest)(nil), "appengine.GetPeerNameRequest") - proto.RegisterType((*GetPeerNameReply)(nil), "appengine.GetPeerNameReply") - proto.RegisterType((*SocketOption)(nil), "appengine.SocketOption") - proto.RegisterType((*SetSocketOptionsRequest)(nil), "appengine.SetSocketOptionsRequest") - proto.RegisterType((*SetSocketOptionsReply)(nil), "appengine.SetSocketOptionsReply") - proto.RegisterType((*GetSocketOptionsRequest)(nil), "appengine.GetSocketOptionsRequest") - proto.RegisterType((*GetSocketOptionsReply)(nil), "appengine.GetSocketOptionsReply") - proto.RegisterType((*ConnectRequest)(nil), "appengine.ConnectRequest") - proto.RegisterType((*ConnectReply)(nil), "appengine.ConnectReply") - proto.RegisterType((*ListenRequest)(nil), "appengine.ListenRequest") - proto.RegisterType((*ListenReply)(nil), "appengine.ListenReply") - proto.RegisterType((*AcceptRequest)(nil), "appengine.AcceptRequest") - proto.RegisterType((*AcceptReply)(nil), "appengine.AcceptReply") - proto.RegisterType((*ShutDownRequest)(nil), "appengine.ShutDownRequest") - proto.RegisterType((*ShutDownReply)(nil), "appengine.ShutDownReply") - proto.RegisterType((*CloseRequest)(nil), "appengine.CloseRequest") - proto.RegisterType((*CloseReply)(nil), "appengine.CloseReply") - proto.RegisterType((*SendRequest)(nil), "appengine.SendRequest") - proto.RegisterType((*SendReply)(nil), "appengine.SendReply") - proto.RegisterType((*ReceiveRequest)(nil), "appengine.ReceiveRequest") - proto.RegisterType((*ReceiveReply)(nil), "appengine.ReceiveReply") - proto.RegisterType((*PollEvent)(nil), "appengine.PollEvent") - proto.RegisterType((*PollRequest)(nil), "appengine.PollRequest") - proto.RegisterType((*PollReply)(nil), "appengine.PollReply") - proto.RegisterType((*ResolveRequest)(nil), "appengine.ResolveRequest") - proto.RegisterType((*ResolveReply)(nil), "appengine.ResolveReply") -} - -func init() { - proto.RegisterFile("google.golang.org/appengine/internal/socket/socket_service.proto", fileDescriptor_socket_service_b5f8f233dc327808) -} - -var fileDescriptor_socket_service_b5f8f233dc327808 = []byte{ - // 3088 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xc4, 0x59, 0x5f, 0x77, 0xe3, 0xc6, - 0x75, 0x37, 0x48, 0xfd, 0xe3, 0x90, 0x94, 0xee, 0x62, 0xa5, 0x5d, 0x25, 0x6e, 0x12, 0x05, 0x8e, - 0x1b, 0x25, 0x8e, 0x77, 0x6d, 0x39, 0x4d, 0x9b, 0xa4, 0x49, 0x16, 0x04, 0x86, 0x24, 0x4c, 0x00, - 0x03, 0xcd, 0x0c, 0x25, 0xd1, 0x6d, 0x8a, 0xd0, 0x22, 0xa4, 0x65, 0x4c, 0x11, 0x0c, 0xc9, 0xdd, - 0xf5, 0xba, 0x69, 0xaa, 0xfe, 0x39, 0xfd, 0x12, 0x7d, 0xe8, 0x73, 0x3f, 0x43, 0x4f, 0x4f, 0x5f, - 0xfa, 0xec, 0xc7, 0x7e, 0x84, 0x9e, 0xbe, 0xb4, 0x9f, 0xa1, 0x67, 0x06, 0xe0, 0x60, 0xc8, 0xd5, - 0xae, 0x77, 0x75, 0x72, 0x4e, 0x9e, 0xa4, 0xfb, 0xbb, 0x77, 0xee, 0xff, 0x99, 0xb9, 0x03, 0xa2, - 0x47, 0x97, 0x69, 0x7a, 0x39, 0x4a, 0x1e, 0x5c, 0xa6, 0xa3, 0xfe, 0xf8, 0xf2, 0x41, 0x3a, 0xbd, - 0x7c, 0xd8, 0x9f, 0x4c, 0x92, 0xf1, 0xe5, 0x70, 0x9c, 0x3c, 0x1c, 0x8e, 0xe7, 0xc9, 0x74, 0xdc, - 0x1f, 0x3d, 0x9c, 0xa5, 0xe7, 0x9f, 0x25, 0xf3, 0xfc, 0x4f, 0x3c, 0x4b, 0xa6, 0x4f, 0x87, 0xe7, - 0xc9, 0x83, 0xc9, 0x34, 0x9d, 0xa7, 0x66, 0x45, 0xc9, 0x5b, 0xff, 0xbc, 0x8b, 0xf6, 0x69, 0x72, - 0x95, 0xce, 0x13, 0x26, 0x25, 0x59, 0x26, 0x88, 0xa7, 0xd3, 0x74, 0x6a, 0x7e, 0x07, 0xd5, 0x66, - 0xcf, 0x67, 0xf3, 0xe4, 0x2a, 0x4e, 0x04, 0xbd, 0x6f, 0x1c, 0x18, 0x87, 0xeb, 0x3f, 0x31, 0x3e, - 0xa0, 0xd5, 0x0c, 0xce, 0xa4, 0xbe, 0x8d, 0x6a, 0x92, 0x1d, 0x0f, 0x92, 0x79, 0x7f, 0x38, 0xda, - 0x2f, 0x1d, 0x18, 0x87, 0x15, 0x5a, 0x95, 0x98, 0x2b, 0x21, 0xeb, 0x73, 0x54, 0x91, 0xb2, 0x4e, - 0x3a, 0x48, 0x4c, 0x40, 0x35, 0xd6, 0x63, 0x1c, 0x07, 0x31, 0xa6, 0x94, 0x50, 0x30, 0xcc, 0x3a, - 0xaa, 0xb4, 0x6c, 0x2f, 0x27, 0x4b, 0x66, 0x15, 0x6d, 0x36, 0x6d, 0xcf, 0xef, 0x52, 0x0c, 0x6b, - 0xe6, 0x1e, 0xba, 0x13, 0x61, 0x1a, 0x78, 0x8c, 0x79, 0x24, 0x8c, 0x5d, 0x1c, 0x7a, 0xd8, 0x85, - 0x75, 0xf3, 0x2e, 0xda, 0xf1, 0xc2, 0x13, 0xdb, 0xf7, 0xdc, 0x98, 0xe2, 0xe3, 0x2e, 0x66, 0x1c, - 0x36, 0xcc, 0x3b, 0xa8, 0xce, 0x88, 0xd3, 0xc1, 0x3c, 0x76, 0x7c, 0xc2, 0xb0, 0x0b, 0x9b, 0xd6, - 0xbf, 0x99, 0xa8, 0xca, 0x34, 0x67, 0x77, 0x50, 0x95, 0xf5, 0x58, 0xcc, 0xba, 0x8e, 0x83, 0x19, - 0x83, 0xb7, 0x84, 0x6d, 0x01, 0x60, 0x61, 0x04, 0x0c, 0x73, 0x1b, 0x21, 0x49, 0x86, 0x04, 0x87, - 0x1c, 0x4a, 0x8a, 0xcd, 0xa8, 0xd3, 0x86, 0xb2, 0x22, 0xbd, 0x90, 0x53, 0x58, 0x13, 0x9e, 0x66, - 0x24, 0x81, 0x75, 0xc5, 0x0b, 0xcf, 0x3c, 0x02, 0x1b, 0x8a, 0x3c, 0x6a, 0x78, 0x2d, 0xd8, 0x5c, - 0x18, 0x16, 0x8a, 0xcf, 0xb0, 0x03, 0x5b, 0x8a, 0xdf, 0xb0, 0xdd, 0x26, 0x54, 0x94, 0x61, 0xa7, - 0xed, 0xf9, 0x2e, 0x20, 0x45, 0xdb, 0x2d, 0xdb, 0x0b, 0xa1, 0x2a, 0x02, 0x96, 0xf4, 0x29, 0xe9, - 0xfa, 0x6e, 0xc3, 0x27, 0x4e, 0x07, 0xaa, 0x9a, 0xb7, 0x01, 0x0e, 0xa0, 0x56, 0x2c, 0x12, 0xd1, - 0x41, 0x5d, 0xd1, 0x4d, 0xbb, 0xeb, 0x73, 0xd8, 0xd6, 0x9c, 0xe0, 0x0d, 0xbf, 0x03, 0x3b, 0x85, - 0x13, 0x5d, 0xd6, 0x03, 0x50, 0xf2, 0xf8, 0xcc, 0x63, 0x1c, 0xee, 0x28, 0xf6, 0x99, 0x8b, 0x4f, - 0xc0, 0xd4, 0xcc, 0x09, 0xfa, 0xae, 0xae, 0xce, 0xf5, 0x28, 0xec, 0x2a, 0x01, 0x8f, 0x09, 0x7a, - 0xaf, 0xa0, 0x45, 0xa9, 0xe0, 0x5e, 0xa1, 0xa0, 0xe9, 0xf9, 0x18, 0xee, 0x2b, 0x3a, 0x90, 0xf4, - 0xbe, 0x66, 0x80, 0xf3, 0x1e, 0x7c, 0x4d, 0x19, 0xe0, 0x67, 0xbc, 0xc1, 0x7a, 0xf0, 0x75, 0xe5, - 0x50, 0x53, 0x24, 0xf5, 0x6d, 0x4d, 0x9e, 0x45, 0x0e, 0xfc, 0x91, 0xa2, 0x59, 0xe4, 0x45, 0x18, - 0xbe, 0xa1, 0xc4, 0x29, 0x69, 0x32, 0xf8, 0x66, 0x61, 0xce, 0xf7, 0xc2, 0x0e, 0x7c, 0xab, 0xa8, - 0xbd, 0x90, 0x3e, 0x30, 0x6b, 0x68, 0x4b, 0x92, 0x2e, 0x09, 0xe0, 0xdb, 0x4a, 0x98, 0xda, 0x61, - 0x0b, 0x83, 0xa5, 0x7c, 0x71, 0xb1, 0xed, 0xfa, 0x1d, 0x78, 0x47, 0x76, 0x9b, 0x02, 0x44, 0x3d, - 0xde, 0x31, 0x77, 0x11, 0x64, 0xfe, 0xd8, 0x01, 0xe6, 0x84, 0xf8, 0x24, 0x6c, 0xc1, 0x77, 0x34, - 0x2f, 0x7d, 0xa7, 0x03, 0xef, 0xea, 0x5e, 0xf7, 0x18, 0xfc, 0xb1, 0x52, 0x14, 0x12, 0x8e, 0x83, - 0x88, 0xf7, 0xe0, 0xbb, 0xca, 0x33, 0x9f, 0x90, 0x08, 0x0e, 0xf5, 0x3a, 0xb3, 0x16, 0x7c, 0xbf, - 0x68, 0x43, 0x97, 0x06, 0xf0, 0x9e, 0xd6, 0x3b, 0x34, 0x6c, 0xc1, 0x0f, 0xf2, 0x1d, 0x16, 0x63, - 0xff, 0x28, 0x64, 0xbd, 0xd0, 0x81, 0xf7, 0x95, 0x84, 0xff, 0x51, 0xdb, 0xe7, 0xf0, 0x40, 0xa3, - 0x29, 0xe3, 0xf0, 0xb0, 0xa0, 0x43, 0xa1, 0xe1, 0x03, 0x15, 0x6c, 0x37, 0xb4, 0xb9, 0xd3, 0x86, - 0x0f, 0x35, 0x0f, 0x1c, 0xe6, 0xc1, 0x51, 0xb1, 0xe0, 0x48, 0x28, 0xfc, 0x48, 0xef, 0x66, 0x0c, - 0x3f, 0xd4, 0x49, 0x0a, 0x7f, 0xa2, 0xa4, 0xcf, 0x9a, 0x5d, 0xdf, 0x87, 0x1f, 0x69, 0xda, 0xec, - 0x90, 0xc0, 0x9f, 0x2a, 0x73, 0x42, 0xfc, 0xd8, 0x81, 0x3f, 0xd3, 0x01, 0xe6, 0x73, 0xf8, 0xb1, - 0x5a, 0xd1, 0x68, 0x92, 0x90, 0xc3, 0x4f, 0xf5, 0x1c, 0x72, 0x0a, 0x7f, 0xae, 0xb5, 0xa2, 0x6b, - 0x73, 0x1b, 0x7e, 0xa6, 0x3c, 0xe0, 0x5e, 0x80, 0xe1, 0xe7, 0xc5, 0xe6, 0x24, 0x8c, 0xc2, 0x2f, - 0xb4, 0xe5, 0x21, 0xe6, 0xf0, 0x48, 0xa3, 0xa3, 0x4e, 0x0b, 0x6c, 0xa5, 0x8e, 0xe2, 0x80, 0x70, - 0x0c, 0x0d, 0x4d, 0xbf, 0xec, 0x1d, 0x47, 0x35, 0x8b, 0xed, 0x9e, 0x80, 0x5b, 0x34, 0x1e, 0x0d, - 0x42, 0x0e, 0x58, 0x99, 0x73, 0x48, 0x10, 0x40, 0x53, 0xb1, 0x23, 0x4a, 0x38, 0x81, 0x96, 0xaa, - 0x78, 0xd0, 0xf5, 0xb9, 0xd7, 0x26, 0x11, 0xb4, 0x8b, 0xf6, 0x22, 0xdc, 0x25, 0x1c, 0x3c, 0x3d, - 0x05, 0xa2, 0xe8, 0x1f, 0xab, 0x45, 0xe4, 0x04, 0xd3, 0xa6, 0x4f, 0x4e, 0xa1, 0xa3, 0x0a, 0x1d, - 0x12, 0xde, 0x0d, 0xbd, 0x63, 0xf0, 0x8b, 0x3c, 0xd9, 0x6e, 0xd3, 0x85, 0x40, 0x0f, 0xc4, 0x69, - 0xb7, 0x20, 0x54, 0x80, 0xef, 0x35, 0x6c, 0xc7, 0x01, 0xa2, 0x03, 0x0d, 0xdb, 0x85, 0x48, 0x07, - 0x98, 0x13, 0xc2, 0xb1, 0x0e, 0x04, 0xf6, 0x19, 0xd0, 0xa2, 0xbf, 0xbc, 0x86, 0x3c, 0xcc, 0x58, - 0xb1, 0xd1, 0x7d, 0x86, 0x8f, 0x81, 0x2b, 0x09, 0x8a, 0x19, 0xb7, 0x29, 0x87, 0xae, 0x42, 0x18, - 0xa7, 0x72, 0xbb, 0x9d, 0xa8, 0x35, 0x5d, 0x86, 0x29, 0x83, 0x53, 0x3d, 0x18, 0x71, 0x8a, 0xc3, - 0x99, 0xda, 0x4e, 0xae, 0xd0, 0xe2, 0xba, 0x94, 0xe2, 0x63, 0xe8, 0x29, 0xb9, 0x80, 0xb5, 0x98, - 0xf7, 0x09, 0x86, 0x4f, 0x4c, 0x13, 0x6d, 0x17, 0xe9, 0xe5, 0xbd, 0x08, 0xc3, 0x5f, 0xa8, 0xf3, - 0x32, 0x24, 0x12, 0x25, 0x11, 0x87, 0xbf, 0x34, 0xef, 0xa3, 0xbb, 0x85, 0x60, 0x48, 0x58, 0x37, - 0x8a, 0x08, 0xe5, 0xf0, 0x4b, 0xc5, 0x10, 0x86, 0x79, 0xc1, 0xf8, 0x2b, 0xa5, 0x9a, 0x44, 0xc2, - 0xad, 0x6e, 0x14, 0x41, 0xac, 0x1f, 0x7b, 0xac, 0x2b, 0x80, 0x85, 0x9f, 0x51, 0xb3, 0x58, 0xfa, - 0x2b, 0x85, 0xda, 0x1a, 0xda, 0x57, 0x0a, 0x45, 0x3c, 0x5e, 0xd8, 0x65, 0x18, 0x3e, 0x15, 0x77, - 0x9c, 0xc2, 0x42, 0xc2, 0xed, 0x13, 0xdb, 0xf3, 0xe1, 0xbc, 0x48, 0x08, 0xe6, 0x2e, 0x39, 0x0d, - 0x61, 0x50, 0x04, 0x85, 0x79, 0x37, 0xa4, 0xd8, 0x76, 0xda, 0x90, 0x14, 0xc7, 0x07, 0xe6, 0x14, - 0x33, 0xcc, 0xe1, 0x42, 0x99, 0x76, 0x48, 0x18, 0xda, 0x0d, 0x42, 0x39, 0x76, 0xe1, 0x52, 0x99, - 0x16, 0x68, 0x26, 0xf9, 0x58, 0x8b, 0xa5, 0xd1, 0x6d, 0x32, 0x18, 0x2a, 0xc0, 0x63, 0x42, 0x0c, - 0x7e, 0xad, 0x97, 0x45, 0x22, 0x9f, 0x29, 0x83, 0xac, 0xdd, 0xcd, 0x1c, 0x1b, 0x29, 0x83, 0x9c, - 0x90, 0xc0, 0x0e, 0x7b, 0x14, 0x37, 0x19, 0x5c, 0x29, 0x41, 0xb1, 0x07, 0x5d, 0xd2, 0xe5, 0x30, - 0x5e, 0xf2, 0x8c, 0xe2, 0x66, 0x57, 0xdc, 0xd2, 0xa9, 0x12, 0x6c, 0x13, 0x96, 0x69, 0x9c, 0x28, - 0x41, 0x01, 0x2d, 0x62, 0xfd, 0x8d, 0x72, 0xc6, 0xf6, 0x29, 0xb6, 0xdd, 0x1e, 0x4c, 0x55, 0x4a, - 0xbc, 0x30, 0xa2, 0xa4, 0x45, 0xc5, 0xa5, 0x3e, 0x2b, 0xb6, 0x23, 0xb7, 0x7d, 0x0c, 0xf3, 0xe2, - 0x38, 0x73, 0x7c, 0x6c, 0x87, 0xf0, 0x44, 0x2f, 0x61, 0x68, 0x07, 0xf0, 0xb4, 0x00, 0xb2, 0xe4, - 0x3f, 0xd3, 0xae, 0x32, 0x21, 0xf0, 0xb9, 0x72, 0x31, 0x3b, 0x11, 0x3c, 0x02, 0xcf, 0x95, 0x88, - 0x7b, 0xdc, 0x25, 0x1c, 0xbe, 0xd0, 0xce, 0xf1, 0x00, 0xbb, 0x5e, 0x37, 0x80, 0xbf, 0x56, 0xde, - 0x65, 0x80, 0x6c, 0xcd, 0xdf, 0x2a, 0x39, 0xc7, 0x0e, 0x1d, 0xec, 0x63, 0x17, 0xfe, 0x46, 0x3b, - 0x7f, 0x3a, 0xb8, 0x07, 0xbf, 0x53, 0xeb, 0x3a, 0xb8, 0x87, 0xcf, 0x22, 0x8f, 0x62, 0x17, 0xfe, - 0xd6, 0xdc, 0x2d, 0x40, 0x8a, 0x4f, 0x48, 0x07, 0xbb, 0x70, 0x6d, 0x98, 0x7b, 0x79, 0xa2, 0x24, - 0xfa, 0x31, 0x76, 0x44, 0xad, 0xff, 0xce, 0x30, 0xef, 0x2e, 0x1a, 0xf7, 0x34, 0xc4, 0x54, 0x5c, - 0x51, 0xf0, 0xf7, 0x86, 0xb9, 0x9f, 0xb7, 0x79, 0x48, 0x38, 0xc5, 0x8e, 0x38, 0x48, 0xec, 0x86, - 0x8f, 0xe1, 0x1f, 0x0c, 0x13, 0x16, 0xe7, 0x44, 0xb3, 0xe3, 0xf9, 0x3e, 0xfc, 0xa3, 0xf1, 0xf5, - 0x12, 0x18, 0xd6, 0x15, 0xaa, 0xda, 0x83, 0xc1, 0x34, 0x99, 0xcd, 0xa2, 0x74, 0x3a, 0x37, 0x4d, - 0xb4, 0x36, 0x49, 0xa7, 0xf3, 0x7d, 0xe3, 0xa0, 0x74, 0xb8, 0x4e, 0xe5, 0xff, 0xe6, 0xbb, 0x68, - 0x7b, 0xd2, 0x3f, 0xff, 0x2c, 0x19, 0xc4, 0xfd, 0x4c, 0x52, 0xce, 0x7f, 0x35, 0x5a, 0xcf, 0xd0, - 0x7c, 0xb9, 0xf9, 0x0e, 0xaa, 0x3f, 0x4e, 0x67, 0xf3, 0x71, 0xff, 0x2a, 0x89, 0x1f, 0x0f, 0xc7, - 0xf3, 0xfd, 0xb2, 0x9c, 0x12, 0x6b, 0x0b, 0xb0, 0x3d, 0x1c, 0xcf, 0xad, 0x7f, 0x5a, 0x43, 0x77, - 0x9d, 0x69, 0xd2, 0x5f, 0x0c, 0xa3, 0x34, 0xf9, 0xcd, 0x93, 0x64, 0x36, 0x37, 0x1d, 0xb4, 0x71, - 0xd1, 0xbf, 0x1a, 0x8e, 0x9e, 0x4b, 0xcb, 0xdb, 0x47, 0xef, 0x3d, 0x50, 0x03, 0xec, 0x83, 0x1b, - 0xe4, 0x1f, 0x64, 0x54, 0x53, 0x2e, 0xa1, 0xf9, 0x52, 0xd3, 0x43, 0x5b, 0x72, 0xfa, 0x3d, 0x4f, - 0xc5, 0x88, 0x2a, 0xd4, 0xbc, 0xff, 0x5a, 0x6a, 0xa2, 0x7c, 0x11, 0x55, 0xcb, 0xcd, 0x9f, 0xa3, - 0xed, 0x7c, 0xae, 0x4e, 0x27, 0xf3, 0x61, 0x3a, 0x9e, 0xed, 0x97, 0x0f, 0xca, 0x87, 0xd5, 0xa3, - 0xfb, 0x9a, 0xc2, 0x6c, 0x31, 0x91, 0x7c, 0x5a, 0x9f, 0x69, 0xd4, 0xcc, 0x6c, 0xa0, 0x3b, 0x93, - 0x69, 0xfa, 0xf9, 0xf3, 0x38, 0xf9, 0x3c, 0x9b, 0xd6, 0xe3, 0xe1, 0x64, 0x7f, 0xed, 0xc0, 0x38, - 0xac, 0x1e, 0xdd, 0xd3, 0x54, 0x68, 0xa9, 0xa7, 0x3b, 0x72, 0x01, 0xce, 0xe5, 0xbd, 0x89, 0x79, - 0x88, 0xb6, 0x47, 0xc3, 0xd9, 0x3c, 0x19, 0xc7, 0x9f, 0xf6, 0xcf, 0x3f, 0x1b, 0xa5, 0x97, 0xfb, - 0xeb, 0x8b, 0xe9, 0xbc, 0x9e, 0x31, 0x1a, 0x19, 0x6e, 0x7e, 0x84, 0x2a, 0x53, 0x39, 0xe1, 0x0b, - 0x2b, 0x1b, 0xaf, 0xb4, 0xb2, 0x95, 0x09, 0x7a, 0x13, 0x73, 0x0f, 0x6d, 0xf4, 0x27, 0x93, 0x78, - 0x38, 0xd8, 0xaf, 0xc8, 0x42, 0xad, 0xf7, 0x27, 0x13, 0x6f, 0x60, 0x7e, 0x03, 0xa1, 0xc9, 0x34, - 0xfd, 0x75, 0x72, 0x3e, 0x17, 0x2c, 0x74, 0x60, 0x1c, 0x96, 0x69, 0x25, 0x47, 0xbc, 0x81, 0x65, - 0xa1, 0x9a, 0x9e, 0x7b, 0x73, 0x0b, 0xad, 0x79, 0xd1, 0xd3, 0x1f, 0x82, 0x91, 0xff, 0xf7, 0x23, - 0x28, 0x59, 0x16, 0xda, 0x5e, 0x4e, 0xac, 0xb9, 0x89, 0xca, 0xdc, 0x89, 0xc0, 0x10, 0xff, 0x74, - 0xdd, 0x08, 0x4a, 0xd6, 0x97, 0x06, 0xba, 0xb3, 0x5c, 0x91, 0xc9, 0xe8, 0xb9, 0xf9, 0x1e, 0xba, - 0x93, 0xa7, 0x7d, 0x90, 0xcc, 0xce, 0xa7, 0xc3, 0xc9, 0x3c, 0x7f, 0x93, 0x54, 0x28, 0x64, 0x0c, - 0x57, 0xe1, 0xe6, 0xcf, 0xd0, 0xb6, 0x78, 0xf4, 0x24, 0x53, 0xd5, 0x97, 0xe5, 0x57, 0x86, 0x5e, - 0xcf, 0xa4, 0x17, 0xfd, 0xfa, 0x7b, 0x28, 0xd1, 0xf7, 0x2b, 0x5b, 0xff, 0xb3, 0x09, 0xd7, 0xd7, - 0xd7, 0xd7, 0x25, 0xeb, 0x77, 0xa8, 0xda, 0x18, 0x8e, 0x07, 0x8b, 0x86, 0x7e, 0x49, 0x24, 0xa5, - 0x1b, 0x23, 0xb9, 0xd1, 0x15, 0xd1, 0xc1, 0xaf, 0xef, 0x8a, 0x45, 0x50, 0x25, 0xb3, 0x2f, 0xf2, - 0x78, 0xa3, 0x42, 0xe3, 0x8d, 0x62, 0xb3, 0x1c, 0xb4, 0xdb, 0x4a, 0xe6, 0x59, 0x75, 0xc2, 0xfe, - 0x55, 0x72, 0x9b, 0xc8, 0xac, 0x33, 0x64, 0xae, 0x28, 0x79, 0xa9, 0x7b, 0xa5, 0x37, 0x73, 0xcf, - 0x96, 0x9a, 0xa3, 0x24, 0x99, 0xde, 0xda, 0x39, 0x07, 0xc1, 0x92, 0x0a, 0xe1, 0xda, 0x43, 0xb4, - 0x39, 0x49, 0x92, 0xe9, 0x57, 0x3b, 0xb4, 0x21, 0xc4, 0xbc, 0x89, 0xf5, 0xe5, 0xe6, 0x62, 0x47, - 0x64, 0x7b, 0xdf, 0xfc, 0x05, 0x5a, 0x1f, 0x25, 0x4f, 0x93, 0x51, 0x7e, 0x92, 0x7d, 0xef, 0x25, - 0x27, 0xc6, 0x12, 0xe1, 0x8b, 0x05, 0x34, 0x5b, 0x67, 0x3e, 0x42, 0x1b, 0xd9, 0xa1, 0x93, 0x1f, - 0x62, 0x87, 0xaf, 0xa3, 0x41, 0x46, 0x90, 0xaf, 0x33, 0x77, 0xd1, 0xfa, 0xd3, 0xfe, 0xe8, 0x49, - 0xb2, 0x5f, 0x3e, 0x28, 0x1d, 0xd6, 0x68, 0x46, 0x58, 0x09, 0xba, 0xf3, 0x82, 0x4d, 0xed, 0x41, - 0xcd, 0x88, 0x1f, 0x7b, 0x11, 0xbc, 0x25, 0x67, 0x95, 0x02, 0xca, 0xfe, 0x05, 0x43, 0xce, 0x16, - 0x05, 0x2c, 0xb6, 0xf3, 0xc6, 0x0a, 0x26, 0x76, 0xf6, 0x1d, 0xeb, 0xdf, 0xd7, 0x11, 0xac, 0x7a, - 0x26, 0x6f, 0xbb, 0x85, 0x60, 0xec, 0xe2, 0x46, 0xb7, 0x05, 0x86, 0x1c, 0xc9, 0x14, 0x48, 0xc5, - 0x94, 0x28, 0xc6, 0x23, 0x28, 0x2d, 0xa9, 0x8d, 0xe5, 0x95, 0x5a, 0x5e, 0xd6, 0x90, 0x7d, 0x47, - 0x58, 0x5b, 0xd6, 0xe0, 0x92, 0x90, 0x53, 0xd2, 0xe5, 0x18, 0xd6, 0x97, 0x19, 0x0d, 0x4a, 0x6c, - 0xd7, 0xb1, 0xe5, 0x07, 0x04, 0x31, 0x74, 0x28, 0x06, 0x0b, 0xdd, 0x46, 0xb7, 0x09, 0x9b, 0xcb, - 0x28, 0x75, 0x4e, 0x04, 0xba, 0xb5, 0xac, 0xa4, 0x83, 0x71, 0x64, 0xfb, 0xde, 0x09, 0x86, 0xca, - 0x32, 0x83, 0x90, 0x86, 0x17, 0xfa, 0x5e, 0x88, 0x01, 0x2d, 0xeb, 0xf1, 0xbd, 0xb0, 0x85, 0x29, - 0xd4, 0xcd, 0x7b, 0xc8, 0x5c, 0xd2, 0x2e, 0x86, 0x25, 0x02, 0xbb, 0xcb, 0x38, 0x0b, 0xdd, 0x0c, - 0xdf, 0xd3, 0x6a, 0xe2, 0x45, 0x31, 0x27, 0x0c, 0x8c, 0x15, 0x88, 0xfb, 0x50, 0xd2, 0xca, 0xe4, - 0x45, 0x71, 0x5b, 0x8c, 0x9a, 0x8e, 0x0f, 0xe5, 0x65, 0x98, 0x44, 0xdc, 0x23, 0x21, 0x83, 0x35, - 0xcd, 0x16, 0x77, 0xa2, 0x58, 0x3c, 0xef, 0x7d, 0xbb, 0x07, 0x86, 0x26, 0x2e, 0xf0, 0xc0, 0x3e, - 0x63, 0xb8, 0x05, 0x25, 0x2d, 0xdb, 0x02, 0x76, 0x08, 0xed, 0x40, 0x59, 0x0b, 0x5b, 0x80, 0x22, - 0x21, 0x9e, 0xeb, 0x63, 0x58, 0x33, 0xf7, 0xd1, 0xee, 0x2a, 0x23, 0xe4, 0x27, 0x3e, 0xac, 0xaf, - 0x98, 0x15, 0x1c, 0x27, 0x14, 0x65, 0x58, 0x36, 0x2b, 0x9e, 0xb0, 0x21, 0x87, 0xcd, 0x15, 0xf1, - 0x2c, 0x81, 0x47, 0xb0, 0x65, 0xbe, 0x8d, 0xee, 0x6b, 0xb8, 0x8b, 0x9b, 0x98, 0xc6, 0xb6, 0xe3, - 0xe0, 0x88, 0x43, 0x65, 0x85, 0x79, 0xea, 0x85, 0x2e, 0x39, 0x8d, 0x1d, 0xdf, 0x0e, 0x22, 0x40, - 0x2b, 0x81, 0x78, 0x61, 0x93, 0x40, 0x75, 0x25, 0x90, 0xe3, 0xae, 0xe7, 0x74, 0x6c, 0xa7, 0x03, - 0x35, 0x39, 0x11, 0x3d, 0x47, 0xf7, 0xd9, 0xe2, 0xc8, 0xca, 0xaf, 0xf3, 0x5b, 0x1d, 0xea, 0x1f, - 0xa2, 0xcd, 0xc5, 0xec, 0x50, 0x7a, 0xf5, 0xec, 0xb0, 0x90, 0xb3, 0xee, 0xa3, 0xbd, 0x17, 0x4d, - 0x4f, 0x46, 0xcf, 0x85, 0x4f, 0xad, 0x3f, 0x90, 0x4f, 0x1f, 0xa3, 0xbd, 0xd6, 0x4d, 0x3e, 0xdd, - 0x46, 0xd7, 0xbf, 0x18, 0x68, 0xdb, 0x49, 0xc7, 0xe3, 0xe4, 0x7c, 0x7e, 0x2b, 0xf7, 0x97, 0xe6, - 0x9c, 0x57, 0xdf, 0x8f, 0xc5, 0x9c, 0xf3, 0x1e, 0xda, 0x99, 0x0f, 0xaf, 0x92, 0xf4, 0xc9, 0x3c, - 0x9e, 0x25, 0xe7, 0xe9, 0x78, 0x90, 0xcd, 0x09, 0xc6, 0x4f, 0x4a, 0xef, 0x7f, 0x48, 0xb7, 0x73, - 0x16, 0xcb, 0x38, 0xd6, 0x2f, 0x51, 0x4d, 0x39, 0xf8, 0x7b, 0xba, 0x48, 0xf5, 0x21, 0xe1, 0x04, - 0xd5, 0x7d, 0x39, 0xb9, 0xdd, 0x2a, 0xfc, 0x7d, 0xb4, 0xb9, 0x98, 0x04, 0x4b, 0x72, 0x3e, 0x5f, - 0x90, 0x56, 0x1d, 0x55, 0x17, 0x7a, 0x45, 0xbb, 0x0c, 0x51, 0xdd, 0x3e, 0x3f, 0x4f, 0x26, 0xb7, - 0xcb, 0xf2, 0x0d, 0x09, 0x2b, 0xbd, 0x34, 0x61, 0xd7, 0x06, 0xaa, 0x2e, 0x6c, 0x89, 0x84, 0x1d, - 0xa1, 0xbd, 0x71, 0xf2, 0x2c, 0x7e, 0xd1, 0x5a, 0xf6, 0x66, 0xb8, 0x3b, 0x4e, 0x9e, 0xb1, 0x1b, - 0x06, 0xb9, 0xbc, 0xac, 0xaf, 0x39, 0xc8, 0x65, 0xd2, 0x39, 0x64, 0xfd, 0x97, 0x81, 0x76, 0xd8, - 0xe3, 0x27, 0x73, 0x37, 0x7d, 0x76, 0xbb, 0xbc, 0x7e, 0x80, 0xca, 0x8f, 0xd3, 0x67, 0xf9, 0x6d, - 0xfb, 0x4d, 0xbd, 0x8b, 0x97, 0xb5, 0x3e, 0x68, 0xa7, 0xcf, 0xa8, 0x10, 0x35, 0xbf, 0x85, 0xaa, - 0xb3, 0x64, 0x3c, 0x88, 0xd3, 0x8b, 0x8b, 0x59, 0x32, 0x97, 0xd7, 0x6c, 0x99, 0x22, 0x01, 0x11, - 0x89, 0x58, 0x0e, 0x2a, 0xb7, 0xd3, 0x67, 0xfa, 0x45, 0xd6, 0xee, 0xf2, 0x98, 0xba, 0xcb, 0xf7, - 0xa8, 0xc0, 0x4e, 0xc5, 0x85, 0xa7, 0xdd, 0x1b, 0x99, 0xdc, 0x29, 0x85, 0xb2, 0xb5, 0x83, 0xea, - 0x85, 0x07, 0xa2, 0xae, 0xbf, 0x42, 0x35, 0x67, 0x94, 0xce, 0x6e, 0x35, 0xed, 0x98, 0xef, 0x2c, - 0xfb, 0x2c, 0xea, 0x51, 0x96, 0x25, 0xd5, 0xfd, 0xae, 0x21, 0x94, 0x5b, 0x10, 0xf6, 0xfe, 0xcf, - 0x40, 0x55, 0x96, 0xdc, 0x72, 0xa8, 0xbd, 0x87, 0xd6, 0x06, 0xfd, 0x79, 0x5f, 0xa6, 0xb5, 0xd6, - 0x28, 0x6d, 0x19, 0x54, 0xd2, 0xe2, 0x9d, 0x38, 0x9b, 0x4f, 0x93, 0xfe, 0xd5, 0x72, 0xf6, 0x6a, - 0x19, 0x98, 0xf9, 0x61, 0xde, 0x47, 0xeb, 0x17, 0xa3, 0xfe, 0xe5, 0x4c, 0x0e, 0xe4, 0xf2, 0xc9, - 0x93, 0xd1, 0x62, 0x3e, 0x93, 0x51, 0xcc, 0x53, 0xf9, 0x1a, 0x7a, 0xc5, 0x7c, 0x26, 0xc4, 0x78, - 0x7a, 0x53, 0x37, 0x6f, 0xbc, 0xb4, 0x9b, 0x0f, 0x51, 0x25, 0x8b, 0x57, 0xb4, 0xf2, 0xdb, 0xa8, - 0x22, 0x1c, 0x8e, 0x67, 0xc9, 0x78, 0x9e, 0xfd, 0x30, 0x42, 0xb7, 0x04, 0xc0, 0x92, 0xf1, 0xdc, - 0xfa, 0x4f, 0x03, 0x6d, 0xd3, 0xe4, 0x3c, 0x19, 0x3e, 0xbd, 0x5d, 0x35, 0x94, 0xf2, 0xe1, 0x17, - 0x49, 0xbe, 0x9b, 0x33, 0xe5, 0xc3, 0x2f, 0x92, 0x22, 0xfa, 0xf2, 0x4a, 0xf4, 0x37, 0x04, 0xb3, - 0xfe, 0xd2, 0x60, 0x2c, 0xb4, 0xde, 0x94, 0xab, 0xaa, 0x68, 0x33, 0x60, 0x2d, 0x31, 0xa8, 0x80, - 0x61, 0xd6, 0xd0, 0x96, 0x20, 0x22, 0x8c, 0x3b, 0x50, 0xb2, 0xfe, 0xd5, 0x40, 0x35, 0x15, 0x86, - 0x08, 0xfa, 0x85, 0xea, 0xc8, 0x3e, 0x59, 0xa9, 0xce, 0xa2, 0xb4, 0xc2, 0x3d, 0xbd, 0xb4, 0x3f, - 0x45, 0xf5, 0x69, 0xa6, 0x6c, 0x10, 0x5f, 0x4c, 0xd3, 0xab, 0xaf, 0x78, 0x4e, 0xd5, 0x16, 0xc2, - 0xcd, 0x69, 0x7a, 0x25, 0xf6, 0xd4, 0xa7, 0x4f, 0x2e, 0x2e, 0x92, 0x69, 0x96, 0x13, 0xf9, 0xd6, - 0xa5, 0x28, 0x83, 0x44, 0x56, 0xac, 0x2f, 0xcb, 0xa8, 0x12, 0xa5, 0xa3, 0x11, 0x7e, 0x9a, 0x8c, - 0xdf, 0x30, 0xdb, 0xdf, 0x43, 0x30, 0xcd, 0xaa, 0x94, 0x0c, 0xe2, 0x44, 0xac, 0x9f, 0xe5, 0x49, - 0xdf, 0x51, 0xb8, 0x54, 0x3b, 0x33, 0xbf, 0x8b, 0x76, 0xd2, 0x4f, 0xe5, 0x4b, 0x51, 0x49, 0x96, - 0xa5, 0xe4, 0xf6, 0x02, 0xce, 0x04, 0xad, 0xff, 0x28, 0xa1, 0xba, 0x72, 0x47, 0x24, 0x5a, 0x9b, - 0x35, 0x22, 0xe2, 0xfb, 0x21, 0x09, 0x31, 0xbc, 0xa5, 0x4d, 0x6e, 0x02, 0xf4, 0xc2, 0xa5, 0x13, - 0x40, 0x40, 0x11, 0xf5, 0x96, 0x46, 0x5e, 0x81, 0x91, 0x2e, 0x87, 0xb5, 0x15, 0x0c, 0x53, 0x0a, - 0x5b, 0x2b, 0x58, 0xbb, 0x1b, 0x01, 0xac, 0xda, 0x3d, 0xb1, 0x7d, 0x38, 0xd0, 0x26, 0x2c, 0x01, - 0x52, 0x37, 0x24, 0x34, 0x80, 0x47, 0xe6, 0xbd, 0x15, 0xb8, 0x61, 0x87, 0xf2, 0x1b, 0xd3, 0x32, - 0x7e, 0x4a, 0xa5, 0xf8, 0x75, 0xe9, 0x05, 0x3c, 0x93, 0x5f, 0x93, 0x1f, 0x9f, 0x0a, 0x3c, 0x60, - 0x2d, 0xb8, 0xde, 0x5a, 0x55, 0x8e, 0x03, 0x72, 0x82, 0xe1, 0xfa, 0x40, 0x7e, 0xc0, 0xd2, 0x8d, - 0x0a, 0xb7, 0xaf, 0x1f, 0x59, 0x8f, 0x51, 0x55, 0x24, 0x70, 0xb1, 0x7f, 0x7e, 0x80, 0x36, 0xf2, - 0x84, 0x1b, 0x72, 0x9e, 0xd8, 0xd5, 0xda, 0x46, 0x25, 0x9a, 0xe6, 0x32, 0x6f, 0x76, 0x4b, 0xfd, - 0x38, 0xeb, 0x9c, 0xac, 0xc5, 0x0b, 0x3b, 0xa5, 0xaf, 0xb6, 0x63, 0xfd, 0x56, 0xec, 0xf3, 0x59, - 0x3a, 0x2a, 0xf6, 0xb9, 0x89, 0xd6, 0xc6, 0xfd, 0xab, 0x24, 0x6f, 0x36, 0xf9, 0xbf, 0x79, 0x82, - 0x20, 0xbf, 0xbb, 0x62, 0xf9, 0x31, 0x6a, 0x98, 0x64, 0xda, 0xdf, 0xf0, 0x4b, 0xd6, 0x4e, 0xae, - 0xa4, 0x99, 0xeb, 0xb0, 0xfe, 0xbb, 0x2c, 0xf6, 0x67, 0x6e, 0x5e, 0x38, 0x7f, 0xd3, 0xc7, 0xb8, - 0xf2, 0x8b, 0x1f, 0xe3, 0xde, 0x45, 0xdb, 0xe7, 0xfd, 0x71, 0x3a, 0x1e, 0x9e, 0xf7, 0x47, 0xb1, - 0xf4, 0x36, 0xfb, 0x1a, 0x57, 0x57, 0xa8, 0x7c, 0x96, 0xed, 0xa3, 0xcd, 0xfe, 0x68, 0xd8, 0x9f, - 0x25, 0xe2, 0xa0, 0x2d, 0x1f, 0x56, 0xe8, 0x82, 0xb4, 0xfe, 0xb7, 0xa4, 0xff, 0xa0, 0xfb, 0x35, - 0xb4, 0x97, 0x17, 0x10, 0xdb, 0x5e, 0x2c, 0x5e, 0x69, 0x4d, 0x3b, 0xf0, 0x7c, 0xf1, 0x80, 0x28, - 0xae, 0x2e, 0xc9, 0x92, 0xbf, 0x65, 0x96, 0xb4, 0x09, 0x5b, 0xa0, 0x0d, 0xdb, 0x6d, 0xfa, 0x76, - 0x8b, 0x2d, 0x3d, 0xe3, 0x04, 0xa3, 0x69, 0x7b, 0x7e, 0xf6, 0x0b, 0xf0, 0x12, 0x28, 0x55, 0xaf, - 0xaf, 0xc0, 0x01, 0x0e, 0x08, 0xed, 0x2d, 0xbd, 0x1d, 0x04, 0x9c, 0xff, 0x1c, 0xb4, 0xf9, 0x02, - 0x1c, 0xda, 0x01, 0x86, 0x2d, 0xed, 0x49, 0x21, 0x60, 0x86, 0xe9, 0x89, 0xe7, 0x2c, 0xbf, 0xe1, - 0x24, 0x4e, 0x9c, 0x8e, 0x7c, 0x68, 0xa2, 0x15, 0x3d, 0xd9, 0xef, 0xd8, 0x4b, 0x6f, 0x86, 0x3c, - 0xa2, 0xb6, 0x17, 0x72, 0x06, 0xb5, 0x15, 0x86, 0xfc, 0xdd, 0xc1, 0x21, 0x3e, 0xd4, 0x57, 0x18, - 0xea, 0x37, 0x9d, 0x6d, 0x6d, 0x0f, 0xcb, 0xb8, 0xec, 0x33, 0xd8, 0x69, 0x6c, 0x7d, 0xb2, 0x91, - 0x9d, 0x5a, 0xff, 0x1f, 0x00, 0x00, 0xff, 0xff, 0x31, 0x03, 0x4e, 0xbd, 0xfd, 0x1f, 0x00, 0x00, -} diff --git a/vendor/google.golang.org/appengine/internal/socket/socket_service.proto b/vendor/google.golang.org/appengine/internal/socket/socket_service.proto deleted file mode 100644 index 2fcc7953dc..0000000000 --- a/vendor/google.golang.org/appengine/internal/socket/socket_service.proto +++ /dev/null @@ -1,460 +0,0 @@ -syntax = "proto2"; -option go_package = "socket"; - -package appengine; - -message RemoteSocketServiceError { - enum ErrorCode { - SYSTEM_ERROR = 1; - GAI_ERROR = 2; - FAILURE = 4; - PERMISSION_DENIED = 5; - INVALID_REQUEST = 6; - SOCKET_CLOSED = 7; - } - - enum SystemError { - option allow_alias = true; - - SYS_SUCCESS = 0; - SYS_EPERM = 1; - SYS_ENOENT = 2; - SYS_ESRCH = 3; - SYS_EINTR = 4; - SYS_EIO = 5; - SYS_ENXIO = 6; - SYS_E2BIG = 7; - SYS_ENOEXEC = 8; - SYS_EBADF = 9; - SYS_ECHILD = 10; - SYS_EAGAIN = 11; - SYS_EWOULDBLOCK = 11; - SYS_ENOMEM = 12; - SYS_EACCES = 13; - SYS_EFAULT = 14; - SYS_ENOTBLK = 15; - SYS_EBUSY = 16; - SYS_EEXIST = 17; - SYS_EXDEV = 18; - SYS_ENODEV = 19; - SYS_ENOTDIR = 20; - SYS_EISDIR = 21; - SYS_EINVAL = 22; - SYS_ENFILE = 23; - SYS_EMFILE = 24; - SYS_ENOTTY = 25; - SYS_ETXTBSY = 26; - SYS_EFBIG = 27; - SYS_ENOSPC = 28; - SYS_ESPIPE = 29; - SYS_EROFS = 30; - SYS_EMLINK = 31; - SYS_EPIPE = 32; - SYS_EDOM = 33; - SYS_ERANGE = 34; - SYS_EDEADLK = 35; - SYS_EDEADLOCK = 35; - SYS_ENAMETOOLONG = 36; - SYS_ENOLCK = 37; - SYS_ENOSYS = 38; - SYS_ENOTEMPTY = 39; - SYS_ELOOP = 40; - SYS_ENOMSG = 42; - SYS_EIDRM = 43; - SYS_ECHRNG = 44; - SYS_EL2NSYNC = 45; - SYS_EL3HLT = 46; - SYS_EL3RST = 47; - SYS_ELNRNG = 48; - SYS_EUNATCH = 49; - SYS_ENOCSI = 50; - SYS_EL2HLT = 51; - SYS_EBADE = 52; - SYS_EBADR = 53; - SYS_EXFULL = 54; - SYS_ENOANO = 55; - SYS_EBADRQC = 56; - SYS_EBADSLT = 57; - SYS_EBFONT = 59; - SYS_ENOSTR = 60; - SYS_ENODATA = 61; - SYS_ETIME = 62; - SYS_ENOSR = 63; - SYS_ENONET = 64; - SYS_ENOPKG = 65; - SYS_EREMOTE = 66; - SYS_ENOLINK = 67; - SYS_EADV = 68; - SYS_ESRMNT = 69; - SYS_ECOMM = 70; - SYS_EPROTO = 71; - SYS_EMULTIHOP = 72; - SYS_EDOTDOT = 73; - SYS_EBADMSG = 74; - SYS_EOVERFLOW = 75; - SYS_ENOTUNIQ = 76; - SYS_EBADFD = 77; - SYS_EREMCHG = 78; - SYS_ELIBACC = 79; - SYS_ELIBBAD = 80; - SYS_ELIBSCN = 81; - SYS_ELIBMAX = 82; - SYS_ELIBEXEC = 83; - SYS_EILSEQ = 84; - SYS_ERESTART = 85; - SYS_ESTRPIPE = 86; - SYS_EUSERS = 87; - SYS_ENOTSOCK = 88; - SYS_EDESTADDRREQ = 89; - SYS_EMSGSIZE = 90; - SYS_EPROTOTYPE = 91; - SYS_ENOPROTOOPT = 92; - SYS_EPROTONOSUPPORT = 93; - SYS_ESOCKTNOSUPPORT = 94; - SYS_EOPNOTSUPP = 95; - SYS_ENOTSUP = 95; - SYS_EPFNOSUPPORT = 96; - SYS_EAFNOSUPPORT = 97; - SYS_EADDRINUSE = 98; - SYS_EADDRNOTAVAIL = 99; - SYS_ENETDOWN = 100; - SYS_ENETUNREACH = 101; - SYS_ENETRESET = 102; - SYS_ECONNABORTED = 103; - SYS_ECONNRESET = 104; - SYS_ENOBUFS = 105; - SYS_EISCONN = 106; - SYS_ENOTCONN = 107; - SYS_ESHUTDOWN = 108; - SYS_ETOOMANYREFS = 109; - SYS_ETIMEDOUT = 110; - SYS_ECONNREFUSED = 111; - SYS_EHOSTDOWN = 112; - SYS_EHOSTUNREACH = 113; - SYS_EALREADY = 114; - SYS_EINPROGRESS = 115; - SYS_ESTALE = 116; - SYS_EUCLEAN = 117; - SYS_ENOTNAM = 118; - SYS_ENAVAIL = 119; - SYS_EISNAM = 120; - SYS_EREMOTEIO = 121; - SYS_EDQUOT = 122; - SYS_ENOMEDIUM = 123; - SYS_EMEDIUMTYPE = 124; - SYS_ECANCELED = 125; - SYS_ENOKEY = 126; - SYS_EKEYEXPIRED = 127; - SYS_EKEYREVOKED = 128; - SYS_EKEYREJECTED = 129; - SYS_EOWNERDEAD = 130; - SYS_ENOTRECOVERABLE = 131; - SYS_ERFKILL = 132; - } - - optional int32 system_error = 1 [default=0]; - optional string error_detail = 2; -} - -message AddressPort { - required int32 port = 1; - optional bytes packed_address = 2; - - optional string hostname_hint = 3; -} - - - -message CreateSocketRequest { - enum SocketFamily { - IPv4 = 1; - IPv6 = 2; - } - - enum SocketProtocol { - TCP = 1; - UDP = 2; - } - - required SocketFamily family = 1; - required SocketProtocol protocol = 2; - - repeated SocketOption socket_options = 3; - - optional AddressPort proxy_external_ip = 4; - - optional int32 listen_backlog = 5 [default=0]; - - optional AddressPort remote_ip = 6; - - optional string app_id = 9; - - optional int64 project_id = 10; -} - -message CreateSocketReply { - optional string socket_descriptor = 1; - - optional AddressPort server_address = 3; - - optional AddressPort proxy_external_ip = 4; - - extensions 1000 to max; -} - - - -message BindRequest { - required string socket_descriptor = 1; - required AddressPort proxy_external_ip = 2; -} - -message BindReply { - optional AddressPort proxy_external_ip = 1; -} - - - -message GetSocketNameRequest { - required string socket_descriptor = 1; -} - -message GetSocketNameReply { - optional AddressPort proxy_external_ip = 2; -} - - - -message GetPeerNameRequest { - required string socket_descriptor = 1; -} - -message GetPeerNameReply { - optional AddressPort peer_ip = 2; -} - - -message SocketOption { - - enum SocketOptionLevel { - SOCKET_SOL_IP = 0; - SOCKET_SOL_SOCKET = 1; - SOCKET_SOL_TCP = 6; - SOCKET_SOL_UDP = 17; - } - - enum SocketOptionName { - option allow_alias = true; - - SOCKET_SO_DEBUG = 1; - SOCKET_SO_REUSEADDR = 2; - SOCKET_SO_TYPE = 3; - SOCKET_SO_ERROR = 4; - SOCKET_SO_DONTROUTE = 5; - SOCKET_SO_BROADCAST = 6; - SOCKET_SO_SNDBUF = 7; - SOCKET_SO_RCVBUF = 8; - SOCKET_SO_KEEPALIVE = 9; - SOCKET_SO_OOBINLINE = 10; - SOCKET_SO_LINGER = 13; - SOCKET_SO_RCVTIMEO = 20; - SOCKET_SO_SNDTIMEO = 21; - - SOCKET_IP_TOS = 1; - SOCKET_IP_TTL = 2; - SOCKET_IP_HDRINCL = 3; - SOCKET_IP_OPTIONS = 4; - - SOCKET_TCP_NODELAY = 1; - SOCKET_TCP_MAXSEG = 2; - SOCKET_TCP_CORK = 3; - SOCKET_TCP_KEEPIDLE = 4; - SOCKET_TCP_KEEPINTVL = 5; - SOCKET_TCP_KEEPCNT = 6; - SOCKET_TCP_SYNCNT = 7; - SOCKET_TCP_LINGER2 = 8; - SOCKET_TCP_DEFER_ACCEPT = 9; - SOCKET_TCP_WINDOW_CLAMP = 10; - SOCKET_TCP_INFO = 11; - SOCKET_TCP_QUICKACK = 12; - } - - required SocketOptionLevel level = 1; - required SocketOptionName option = 2; - required bytes value = 3; -} - - -message SetSocketOptionsRequest { - required string socket_descriptor = 1; - repeated SocketOption options = 2; -} - -message SetSocketOptionsReply { -} - -message GetSocketOptionsRequest { - required string socket_descriptor = 1; - repeated SocketOption options = 2; -} - -message GetSocketOptionsReply { - repeated SocketOption options = 2; -} - - -message ConnectRequest { - required string socket_descriptor = 1; - required AddressPort remote_ip = 2; - optional double timeout_seconds = 3 [default=-1]; -} - -message ConnectReply { - optional AddressPort proxy_external_ip = 1; - - extensions 1000 to max; -} - - -message ListenRequest { - required string socket_descriptor = 1; - required int32 backlog = 2; -} - -message ListenReply { -} - - -message AcceptRequest { - required string socket_descriptor = 1; - optional double timeout_seconds = 2 [default=-1]; -} - -message AcceptReply { - optional bytes new_socket_descriptor = 2; - optional AddressPort remote_address = 3; -} - - - -message ShutDownRequest { - enum How { - SOCKET_SHUT_RD = 1; - SOCKET_SHUT_WR = 2; - SOCKET_SHUT_RDWR = 3; - } - required string socket_descriptor = 1; - required How how = 2; - required int64 send_offset = 3; -} - -message ShutDownReply { -} - - - -message CloseRequest { - required string socket_descriptor = 1; - optional int64 send_offset = 2 [default=-1]; -} - -message CloseReply { -} - - - -message SendRequest { - required string socket_descriptor = 1; - required bytes data = 2 [ctype=CORD]; - required int64 stream_offset = 3; - optional int32 flags = 4 [default=0]; - optional AddressPort send_to = 5; - optional double timeout_seconds = 6 [default=-1]; -} - -message SendReply { - optional int32 data_sent = 1; -} - - -message ReceiveRequest { - enum Flags { - MSG_OOB = 1; - MSG_PEEK = 2; - } - required string socket_descriptor = 1; - required int32 data_size = 2; - optional int32 flags = 3 [default=0]; - optional double timeout_seconds = 5 [default=-1]; -} - -message ReceiveReply { - optional int64 stream_offset = 2; - optional bytes data = 3 [ctype=CORD]; - optional AddressPort received_from = 4; - optional int32 buffer_size = 5; -} - - - -message PollEvent { - - enum PollEventFlag { - SOCKET_POLLNONE = 0; - SOCKET_POLLIN = 1; - SOCKET_POLLPRI = 2; - SOCKET_POLLOUT = 4; - SOCKET_POLLERR = 8; - SOCKET_POLLHUP = 16; - SOCKET_POLLNVAL = 32; - SOCKET_POLLRDNORM = 64; - SOCKET_POLLRDBAND = 128; - SOCKET_POLLWRNORM = 256; - SOCKET_POLLWRBAND = 512; - SOCKET_POLLMSG = 1024; - SOCKET_POLLREMOVE = 4096; - SOCKET_POLLRDHUP = 8192; - }; - - required string socket_descriptor = 1; - required int32 requested_events = 2; - required int32 observed_events = 3; -} - -message PollRequest { - repeated PollEvent events = 1; - optional double timeout_seconds = 2 [default=-1]; -} - -message PollReply { - repeated PollEvent events = 2; -} - -message ResolveRequest { - required string name = 1; - repeated CreateSocketRequest.SocketFamily address_families = 2; -} - -message ResolveReply { - enum ErrorCode { - SOCKET_EAI_ADDRFAMILY = 1; - SOCKET_EAI_AGAIN = 2; - SOCKET_EAI_BADFLAGS = 3; - SOCKET_EAI_FAIL = 4; - SOCKET_EAI_FAMILY = 5; - SOCKET_EAI_MEMORY = 6; - SOCKET_EAI_NODATA = 7; - SOCKET_EAI_NONAME = 8; - SOCKET_EAI_SERVICE = 9; - SOCKET_EAI_SOCKTYPE = 10; - SOCKET_EAI_SYSTEM = 11; - SOCKET_EAI_BADHINTS = 12; - SOCKET_EAI_PROTOCOL = 13; - SOCKET_EAI_OVERFLOW = 14; - SOCKET_EAI_MAX = 15; - }; - - repeated bytes packed_address = 2; - optional string canonical_name = 3; - repeated string aliases = 4; -} diff --git a/vendor/google.golang.org/appengine/socket/doc.go b/vendor/google.golang.org/appengine/socket/doc.go deleted file mode 100644 index 3de46df826..0000000000 --- a/vendor/google.golang.org/appengine/socket/doc.go +++ /dev/null @@ -1,10 +0,0 @@ -// Copyright 2012 Google Inc. All rights reserved. -// Use of this source code is governed by the Apache 2.0 -// license that can be found in the LICENSE file. - -// Package socket provides outbound network sockets. -// -// This package is only required in the classic App Engine environment. -// Applications running only in App Engine "flexible environment" should -// use the standard library's net package. -package socket diff --git a/vendor/google.golang.org/appengine/socket/socket_classic.go b/vendor/google.golang.org/appengine/socket/socket_classic.go deleted file mode 100644 index 0ad50e2d36..0000000000 --- a/vendor/google.golang.org/appengine/socket/socket_classic.go +++ /dev/null @@ -1,290 +0,0 @@ -// Copyright 2012 Google Inc. All rights reserved. -// Use of this source code is governed by the Apache 2.0 -// license that can be found in the LICENSE file. - -// +build appengine - -package socket - -import ( - "fmt" - "io" - "net" - "strconv" - "time" - - "github.com/golang/protobuf/proto" - "golang.org/x/net/context" - "google.golang.org/appengine/internal" - - pb "google.golang.org/appengine/internal/socket" -) - -// Dial connects to the address addr on the network protocol. -// The address format is host:port, where host may be a hostname or an IP address. -// Known protocols are "tcp" and "udp". -// The returned connection satisfies net.Conn, and is valid while ctx is valid; -// if the connection is to be used after ctx becomes invalid, invoke SetContext -// with the new context. -func Dial(ctx context.Context, protocol, addr string) (*Conn, error) { - return DialTimeout(ctx, protocol, addr, 0) -} - -var ipFamilies = []pb.CreateSocketRequest_SocketFamily{ - pb.CreateSocketRequest_IPv4, - pb.CreateSocketRequest_IPv6, -} - -// DialTimeout is like Dial but takes a timeout. -// The timeout includes name resolution, if required. -func DialTimeout(ctx context.Context, protocol, addr string, timeout time.Duration) (*Conn, error) { - dialCtx := ctx // Used for dialing and name resolution, but not stored in the *Conn. - if timeout > 0 { - var cancel context.CancelFunc - dialCtx, cancel = context.WithTimeout(ctx, timeout) - defer cancel() - } - - host, portStr, err := net.SplitHostPort(addr) - if err != nil { - return nil, err - } - port, err := strconv.Atoi(portStr) - if err != nil { - return nil, fmt.Errorf("socket: bad port %q: %v", portStr, err) - } - - var prot pb.CreateSocketRequest_SocketProtocol - switch protocol { - case "tcp": - prot = pb.CreateSocketRequest_TCP - case "udp": - prot = pb.CreateSocketRequest_UDP - default: - return nil, fmt.Errorf("socket: unknown protocol %q", protocol) - } - - packedAddrs, resolved, err := resolve(dialCtx, ipFamilies, host) - if err != nil { - return nil, fmt.Errorf("socket: failed resolving %q: %v", host, err) - } - if len(packedAddrs) == 0 { - return nil, fmt.Errorf("no addresses for %q", host) - } - - packedAddr := packedAddrs[0] // use first address - fam := pb.CreateSocketRequest_IPv4 - if len(packedAddr) == net.IPv6len { - fam = pb.CreateSocketRequest_IPv6 - } - - req := &pb.CreateSocketRequest{ - Family: fam.Enum(), - Protocol: prot.Enum(), - RemoteIp: &pb.AddressPort{ - Port: proto.Int32(int32(port)), - PackedAddress: packedAddr, - }, - } - if resolved { - req.RemoteIp.HostnameHint = &host - } - res := &pb.CreateSocketReply{} - if err := internal.Call(dialCtx, "remote_socket", "CreateSocket", req, res); err != nil { - return nil, err - } - - return &Conn{ - ctx: ctx, - desc: res.GetSocketDescriptor(), - prot: prot, - local: res.ProxyExternalIp, - remote: req.RemoteIp, - }, nil -} - -// LookupIP returns the given host's IP addresses. -func LookupIP(ctx context.Context, host string) (addrs []net.IP, err error) { - packedAddrs, _, err := resolve(ctx, ipFamilies, host) - if err != nil { - return nil, fmt.Errorf("socket: failed resolving %q: %v", host, err) - } - addrs = make([]net.IP, len(packedAddrs)) - for i, pa := range packedAddrs { - addrs[i] = net.IP(pa) - } - return addrs, nil -} - -func resolve(ctx context.Context, fams []pb.CreateSocketRequest_SocketFamily, host string) ([][]byte, bool, error) { - // Check if it's an IP address. - if ip := net.ParseIP(host); ip != nil { - if ip := ip.To4(); ip != nil { - return [][]byte{ip}, false, nil - } - return [][]byte{ip}, false, nil - } - - req := &pb.ResolveRequest{ - Name: &host, - AddressFamilies: fams, - } - res := &pb.ResolveReply{} - if err := internal.Call(ctx, "remote_socket", "Resolve", req, res); err != nil { - // XXX: need to map to pb.ResolveReply_ErrorCode? - return nil, false, err - } - return res.PackedAddress, true, nil -} - -// withDeadline is like context.WithDeadline, except it ignores the zero deadline. -func withDeadline(parent context.Context, deadline time.Time) (context.Context, context.CancelFunc) { - if deadline.IsZero() { - return parent, func() {} - } - return context.WithDeadline(parent, deadline) -} - -// Conn represents a socket connection. -// It implements net.Conn. -type Conn struct { - ctx context.Context - desc string - offset int64 - - prot pb.CreateSocketRequest_SocketProtocol - local, remote *pb.AddressPort - - readDeadline, writeDeadline time.Time // optional -} - -// SetContext sets the context that is used by this Conn. -// It is usually used only when using a Conn that was created in a different context, -// such as when a connection is created during a warmup request but used while -// servicing a user request. -func (cn *Conn) SetContext(ctx context.Context) { - cn.ctx = ctx -} - -func (cn *Conn) Read(b []byte) (n int, err error) { - const maxRead = 1 << 20 - if len(b) > maxRead { - b = b[:maxRead] - } - - req := &pb.ReceiveRequest{ - SocketDescriptor: &cn.desc, - DataSize: proto.Int32(int32(len(b))), - } - res := &pb.ReceiveReply{} - if !cn.readDeadline.IsZero() { - req.TimeoutSeconds = proto.Float64(cn.readDeadline.Sub(time.Now()).Seconds()) - } - ctx, cancel := withDeadline(cn.ctx, cn.readDeadline) - defer cancel() - if err := internal.Call(ctx, "remote_socket", "Receive", req, res); err != nil { - return 0, err - } - if len(res.Data) == 0 { - return 0, io.EOF - } - if len(res.Data) > len(b) { - return 0, fmt.Errorf("socket: internal error: read too much data: %d > %d", len(res.Data), len(b)) - } - return copy(b, res.Data), nil -} - -func (cn *Conn) Write(b []byte) (n int, err error) { - const lim = 1 << 20 // max per chunk - - for n < len(b) { - chunk := b[n:] - if len(chunk) > lim { - chunk = chunk[:lim] - } - - req := &pb.SendRequest{ - SocketDescriptor: &cn.desc, - Data: chunk, - StreamOffset: &cn.offset, - } - res := &pb.SendReply{} - if !cn.writeDeadline.IsZero() { - req.TimeoutSeconds = proto.Float64(cn.writeDeadline.Sub(time.Now()).Seconds()) - } - ctx, cancel := withDeadline(cn.ctx, cn.writeDeadline) - defer cancel() - if err = internal.Call(ctx, "remote_socket", "Send", req, res); err != nil { - // assume zero bytes were sent in this RPC - break - } - n += int(res.GetDataSent()) - cn.offset += int64(res.GetDataSent()) - } - - return -} - -func (cn *Conn) Close() error { - req := &pb.CloseRequest{ - SocketDescriptor: &cn.desc, - } - res := &pb.CloseReply{} - if err := internal.Call(cn.ctx, "remote_socket", "Close", req, res); err != nil { - return err - } - cn.desc = "CLOSED" - return nil -} - -func addr(prot pb.CreateSocketRequest_SocketProtocol, ap *pb.AddressPort) net.Addr { - if ap == nil { - return nil - } - switch prot { - case pb.CreateSocketRequest_TCP: - return &net.TCPAddr{ - IP: net.IP(ap.PackedAddress), - Port: int(*ap.Port), - } - case pb.CreateSocketRequest_UDP: - return &net.UDPAddr{ - IP: net.IP(ap.PackedAddress), - Port: int(*ap.Port), - } - } - panic("unknown protocol " + prot.String()) -} - -func (cn *Conn) LocalAddr() net.Addr { return addr(cn.prot, cn.local) } -func (cn *Conn) RemoteAddr() net.Addr { return addr(cn.prot, cn.remote) } - -func (cn *Conn) SetDeadline(t time.Time) error { - cn.readDeadline = t - cn.writeDeadline = t - return nil -} - -func (cn *Conn) SetReadDeadline(t time.Time) error { - cn.readDeadline = t - return nil -} - -func (cn *Conn) SetWriteDeadline(t time.Time) error { - cn.writeDeadline = t - return nil -} - -// KeepAlive signals that the connection is still in use. -// It may be called to prevent the socket being closed due to inactivity. -func (cn *Conn) KeepAlive() error { - req := &pb.GetSocketNameRequest{ - SocketDescriptor: &cn.desc, - } - res := &pb.GetSocketNameReply{} - return internal.Call(cn.ctx, "remote_socket", "GetSocketName", req, res) -} - -func init() { - internal.RegisterErrorCodeMap("remote_socket", pb.RemoteSocketServiceError_ErrorCode_name) -} diff --git a/vendor/google.golang.org/appengine/socket/socket_vm.go b/vendor/google.golang.org/appengine/socket/socket_vm.go deleted file mode 100644 index c804169a1c..0000000000 --- a/vendor/google.golang.org/appengine/socket/socket_vm.go +++ /dev/null @@ -1,64 +0,0 @@ -// Copyright 2015 Google Inc. All rights reserved. -// Use of this source code is governed by the Apache 2.0 -// license that can be found in the LICENSE file. - -// +build !appengine - -package socket - -import ( - "net" - "time" - - "golang.org/x/net/context" -) - -// Dial connects to the address addr on the network protocol. -// The address format is host:port, where host may be a hostname or an IP address. -// Known protocols are "tcp" and "udp". -// The returned connection satisfies net.Conn, and is valid while ctx is valid; -// if the connection is to be used after ctx becomes invalid, invoke SetContext -// with the new context. -func Dial(ctx context.Context, protocol, addr string) (*Conn, error) { - conn, err := net.Dial(protocol, addr) - if err != nil { - return nil, err - } - return &Conn{conn}, nil -} - -// DialTimeout is like Dial but takes a timeout. -// The timeout includes name resolution, if required. -func DialTimeout(ctx context.Context, protocol, addr string, timeout time.Duration) (*Conn, error) { - conn, err := net.DialTimeout(protocol, addr, timeout) - if err != nil { - return nil, err - } - return &Conn{conn}, nil -} - -// LookupIP returns the given host's IP addresses. -func LookupIP(ctx context.Context, host string) (addrs []net.IP, err error) { - return net.LookupIP(host) -} - -// Conn represents a socket connection. -// It implements net.Conn. -type Conn struct { - net.Conn -} - -// SetContext sets the context that is used by this Conn. -// It is usually used only when using a Conn that was created in a different context, -// such as when a connection is created during a warmup request but used while -// servicing a user request. -func (cn *Conn) SetContext(ctx context.Context) { - // This function is not required in App Engine "flexible environment". -} - -// KeepAlive signals that the connection is still in use. -// It may be called to prevent the socket being closed due to inactivity. -func (cn *Conn) KeepAlive() error { - // This function is not required in App Engine "flexible environment". - return nil -} diff --git a/vendor/google.golang.org/grpc/balancer/grpclb/grpc_lb_v1/load_balancer.pb.go b/vendor/google.golang.org/grpc/balancer/grpclb/grpc_lb_v1/load_balancer.pb.go deleted file mode 100644 index 1723e4a387..0000000000 --- a/vendor/google.golang.org/grpc/balancer/grpclb/grpc_lb_v1/load_balancer.pb.go +++ /dev/null @@ -1,722 +0,0 @@ -// Code generated by protoc-gen-go. DO NOT EDIT. -// source: grpc/lb/v1/load_balancer.proto - -package grpc_lb_v1 - -import ( - context "context" - fmt "fmt" - proto "github.com/golang/protobuf/proto" - duration "github.com/golang/protobuf/ptypes/duration" - timestamp "github.com/golang/protobuf/ptypes/timestamp" - grpc "google.golang.org/grpc" - codes "google.golang.org/grpc/codes" - status "google.golang.org/grpc/status" - 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.ProtoPackageIsVersion3 // please upgrade the proto package - -type LoadBalanceRequest struct { - // Types that are valid to be assigned to LoadBalanceRequestType: - // *LoadBalanceRequest_InitialRequest - // *LoadBalanceRequest_ClientStats - LoadBalanceRequestType isLoadBalanceRequest_LoadBalanceRequestType `protobuf_oneof:"load_balance_request_type"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *LoadBalanceRequest) Reset() { *m = LoadBalanceRequest{} } -func (m *LoadBalanceRequest) String() string { return proto.CompactTextString(m) } -func (*LoadBalanceRequest) ProtoMessage() {} -func (*LoadBalanceRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_7cd3f6d792743fdf, []int{0} -} - -func (m *LoadBalanceRequest) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_LoadBalanceRequest.Unmarshal(m, b) -} -func (m *LoadBalanceRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_LoadBalanceRequest.Marshal(b, m, deterministic) -} -func (m *LoadBalanceRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_LoadBalanceRequest.Merge(m, src) -} -func (m *LoadBalanceRequest) XXX_Size() int { - return xxx_messageInfo_LoadBalanceRequest.Size(m) -} -func (m *LoadBalanceRequest) XXX_DiscardUnknown() { - xxx_messageInfo_LoadBalanceRequest.DiscardUnknown(m) -} - -var xxx_messageInfo_LoadBalanceRequest proto.InternalMessageInfo - -type isLoadBalanceRequest_LoadBalanceRequestType interface { - isLoadBalanceRequest_LoadBalanceRequestType() -} - -type LoadBalanceRequest_InitialRequest struct { - InitialRequest *InitialLoadBalanceRequest `protobuf:"bytes,1,opt,name=initial_request,json=initialRequest,proto3,oneof"` -} - -type LoadBalanceRequest_ClientStats struct { - ClientStats *ClientStats `protobuf:"bytes,2,opt,name=client_stats,json=clientStats,proto3,oneof"` -} - -func (*LoadBalanceRequest_InitialRequest) isLoadBalanceRequest_LoadBalanceRequestType() {} - -func (*LoadBalanceRequest_ClientStats) isLoadBalanceRequest_LoadBalanceRequestType() {} - -func (m *LoadBalanceRequest) GetLoadBalanceRequestType() isLoadBalanceRequest_LoadBalanceRequestType { - if m != nil { - return m.LoadBalanceRequestType - } - return nil -} - -func (m *LoadBalanceRequest) GetInitialRequest() *InitialLoadBalanceRequest { - if x, ok := m.GetLoadBalanceRequestType().(*LoadBalanceRequest_InitialRequest); ok { - return x.InitialRequest - } - return nil -} - -func (m *LoadBalanceRequest) GetClientStats() *ClientStats { - if x, ok := m.GetLoadBalanceRequestType().(*LoadBalanceRequest_ClientStats); ok { - return x.ClientStats - } - return nil -} - -// XXX_OneofWrappers is for the internal use of the proto package. -func (*LoadBalanceRequest) XXX_OneofWrappers() []interface{} { - return []interface{}{ - (*LoadBalanceRequest_InitialRequest)(nil), - (*LoadBalanceRequest_ClientStats)(nil), - } -} - -type InitialLoadBalanceRequest struct { - // The name of the load balanced service (e.g., service.googleapis.com). Its - // length should be less than 256 bytes. - // The name might include a port number. How to handle the port number is up - // to the balancer. - Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *InitialLoadBalanceRequest) Reset() { *m = InitialLoadBalanceRequest{} } -func (m *InitialLoadBalanceRequest) String() string { return proto.CompactTextString(m) } -func (*InitialLoadBalanceRequest) ProtoMessage() {} -func (*InitialLoadBalanceRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_7cd3f6d792743fdf, []int{1} -} - -func (m *InitialLoadBalanceRequest) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_InitialLoadBalanceRequest.Unmarshal(m, b) -} -func (m *InitialLoadBalanceRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_InitialLoadBalanceRequest.Marshal(b, m, deterministic) -} -func (m *InitialLoadBalanceRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_InitialLoadBalanceRequest.Merge(m, src) -} -func (m *InitialLoadBalanceRequest) XXX_Size() int { - return xxx_messageInfo_InitialLoadBalanceRequest.Size(m) -} -func (m *InitialLoadBalanceRequest) XXX_DiscardUnknown() { - xxx_messageInfo_InitialLoadBalanceRequest.DiscardUnknown(m) -} - -var xxx_messageInfo_InitialLoadBalanceRequest proto.InternalMessageInfo - -func (m *InitialLoadBalanceRequest) GetName() string { - if m != nil { - return m.Name - } - return "" -} - -// Contains the number of calls finished for a particular load balance token. -type ClientStatsPerToken struct { - // See Server.load_balance_token. - LoadBalanceToken string `protobuf:"bytes,1,opt,name=load_balance_token,json=loadBalanceToken,proto3" json:"load_balance_token,omitempty"` - // The total number of RPCs that finished associated with the token. - NumCalls int64 `protobuf:"varint,2,opt,name=num_calls,json=numCalls,proto3" json:"num_calls,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *ClientStatsPerToken) Reset() { *m = ClientStatsPerToken{} } -func (m *ClientStatsPerToken) String() string { return proto.CompactTextString(m) } -func (*ClientStatsPerToken) ProtoMessage() {} -func (*ClientStatsPerToken) Descriptor() ([]byte, []int) { - return fileDescriptor_7cd3f6d792743fdf, []int{2} -} - -func (m *ClientStatsPerToken) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_ClientStatsPerToken.Unmarshal(m, b) -} -func (m *ClientStatsPerToken) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_ClientStatsPerToken.Marshal(b, m, deterministic) -} -func (m *ClientStatsPerToken) XXX_Merge(src proto.Message) { - xxx_messageInfo_ClientStatsPerToken.Merge(m, src) -} -func (m *ClientStatsPerToken) XXX_Size() int { - return xxx_messageInfo_ClientStatsPerToken.Size(m) -} -func (m *ClientStatsPerToken) XXX_DiscardUnknown() { - xxx_messageInfo_ClientStatsPerToken.DiscardUnknown(m) -} - -var xxx_messageInfo_ClientStatsPerToken proto.InternalMessageInfo - -func (m *ClientStatsPerToken) GetLoadBalanceToken() string { - if m != nil { - return m.LoadBalanceToken - } - return "" -} - -func (m *ClientStatsPerToken) GetNumCalls() int64 { - if m != nil { - return m.NumCalls - } - return 0 -} - -// Contains client level statistics that are useful to load balancing. Each -// count except the timestamp should be reset to zero after reporting the stats. -type ClientStats struct { - // The timestamp of generating the report. - Timestamp *timestamp.Timestamp `protobuf:"bytes,1,opt,name=timestamp,proto3" json:"timestamp,omitempty"` - // The total number of RPCs that started. - NumCallsStarted int64 `protobuf:"varint,2,opt,name=num_calls_started,json=numCallsStarted,proto3" json:"num_calls_started,omitempty"` - // The total number of RPCs that finished. - NumCallsFinished int64 `protobuf:"varint,3,opt,name=num_calls_finished,json=numCallsFinished,proto3" json:"num_calls_finished,omitempty"` - // The total number of RPCs that failed to reach a server except dropped RPCs. - NumCallsFinishedWithClientFailedToSend int64 `protobuf:"varint,6,opt,name=num_calls_finished_with_client_failed_to_send,json=numCallsFinishedWithClientFailedToSend,proto3" json:"num_calls_finished_with_client_failed_to_send,omitempty"` - // The total number of RPCs that finished and are known to have been received - // by a server. - NumCallsFinishedKnownReceived int64 `protobuf:"varint,7,opt,name=num_calls_finished_known_received,json=numCallsFinishedKnownReceived,proto3" json:"num_calls_finished_known_received,omitempty"` - // The list of dropped calls. - CallsFinishedWithDrop []*ClientStatsPerToken `protobuf:"bytes,8,rep,name=calls_finished_with_drop,json=callsFinishedWithDrop,proto3" json:"calls_finished_with_drop,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *ClientStats) Reset() { *m = ClientStats{} } -func (m *ClientStats) String() string { return proto.CompactTextString(m) } -func (*ClientStats) ProtoMessage() {} -func (*ClientStats) Descriptor() ([]byte, []int) { - return fileDescriptor_7cd3f6d792743fdf, []int{3} -} - -func (m *ClientStats) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_ClientStats.Unmarshal(m, b) -} -func (m *ClientStats) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_ClientStats.Marshal(b, m, deterministic) -} -func (m *ClientStats) XXX_Merge(src proto.Message) { - xxx_messageInfo_ClientStats.Merge(m, src) -} -func (m *ClientStats) XXX_Size() int { - return xxx_messageInfo_ClientStats.Size(m) -} -func (m *ClientStats) XXX_DiscardUnknown() { - xxx_messageInfo_ClientStats.DiscardUnknown(m) -} - -var xxx_messageInfo_ClientStats proto.InternalMessageInfo - -func (m *ClientStats) GetTimestamp() *timestamp.Timestamp { - if m != nil { - return m.Timestamp - } - return nil -} - -func (m *ClientStats) GetNumCallsStarted() int64 { - if m != nil { - return m.NumCallsStarted - } - return 0 -} - -func (m *ClientStats) GetNumCallsFinished() int64 { - if m != nil { - return m.NumCallsFinished - } - return 0 -} - -func (m *ClientStats) GetNumCallsFinishedWithClientFailedToSend() int64 { - if m != nil { - return m.NumCallsFinishedWithClientFailedToSend - } - return 0 -} - -func (m *ClientStats) GetNumCallsFinishedKnownReceived() int64 { - if m != nil { - return m.NumCallsFinishedKnownReceived - } - return 0 -} - -func (m *ClientStats) GetCallsFinishedWithDrop() []*ClientStatsPerToken { - if m != nil { - return m.CallsFinishedWithDrop - } - return nil -} - -type LoadBalanceResponse struct { - // Types that are valid to be assigned to LoadBalanceResponseType: - // *LoadBalanceResponse_InitialResponse - // *LoadBalanceResponse_ServerList - LoadBalanceResponseType isLoadBalanceResponse_LoadBalanceResponseType `protobuf_oneof:"load_balance_response_type"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *LoadBalanceResponse) Reset() { *m = LoadBalanceResponse{} } -func (m *LoadBalanceResponse) String() string { return proto.CompactTextString(m) } -func (*LoadBalanceResponse) ProtoMessage() {} -func (*LoadBalanceResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_7cd3f6d792743fdf, []int{4} -} - -func (m *LoadBalanceResponse) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_LoadBalanceResponse.Unmarshal(m, b) -} -func (m *LoadBalanceResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_LoadBalanceResponse.Marshal(b, m, deterministic) -} -func (m *LoadBalanceResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_LoadBalanceResponse.Merge(m, src) -} -func (m *LoadBalanceResponse) XXX_Size() int { - return xxx_messageInfo_LoadBalanceResponse.Size(m) -} -func (m *LoadBalanceResponse) XXX_DiscardUnknown() { - xxx_messageInfo_LoadBalanceResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_LoadBalanceResponse proto.InternalMessageInfo - -type isLoadBalanceResponse_LoadBalanceResponseType interface { - isLoadBalanceResponse_LoadBalanceResponseType() -} - -type LoadBalanceResponse_InitialResponse struct { - InitialResponse *InitialLoadBalanceResponse `protobuf:"bytes,1,opt,name=initial_response,json=initialResponse,proto3,oneof"` -} - -type LoadBalanceResponse_ServerList struct { - ServerList *ServerList `protobuf:"bytes,2,opt,name=server_list,json=serverList,proto3,oneof"` -} - -func (*LoadBalanceResponse_InitialResponse) isLoadBalanceResponse_LoadBalanceResponseType() {} - -func (*LoadBalanceResponse_ServerList) isLoadBalanceResponse_LoadBalanceResponseType() {} - -func (m *LoadBalanceResponse) GetLoadBalanceResponseType() isLoadBalanceResponse_LoadBalanceResponseType { - if m != nil { - return m.LoadBalanceResponseType - } - return nil -} - -func (m *LoadBalanceResponse) GetInitialResponse() *InitialLoadBalanceResponse { - if x, ok := m.GetLoadBalanceResponseType().(*LoadBalanceResponse_InitialResponse); ok { - return x.InitialResponse - } - return nil -} - -func (m *LoadBalanceResponse) GetServerList() *ServerList { - if x, ok := m.GetLoadBalanceResponseType().(*LoadBalanceResponse_ServerList); ok { - return x.ServerList - } - return nil -} - -// XXX_OneofWrappers is for the internal use of the proto package. -func (*LoadBalanceResponse) XXX_OneofWrappers() []interface{} { - return []interface{}{ - (*LoadBalanceResponse_InitialResponse)(nil), - (*LoadBalanceResponse_ServerList)(nil), - } -} - -type InitialLoadBalanceResponse struct { - // This is an application layer redirect that indicates the client should use - // the specified server for load balancing. When this field is non-empty in - // the response, the client should open a separate connection to the - // load_balancer_delegate and call the BalanceLoad method. Its length should - // be less than 64 bytes. - LoadBalancerDelegate string `protobuf:"bytes,1,opt,name=load_balancer_delegate,json=loadBalancerDelegate,proto3" json:"load_balancer_delegate,omitempty"` - // This interval defines how often the client should send the client stats - // to the load balancer. Stats should only be reported when the duration is - // positive. - ClientStatsReportInterval *duration.Duration `protobuf:"bytes,2,opt,name=client_stats_report_interval,json=clientStatsReportInterval,proto3" json:"client_stats_report_interval,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *InitialLoadBalanceResponse) Reset() { *m = InitialLoadBalanceResponse{} } -func (m *InitialLoadBalanceResponse) String() string { return proto.CompactTextString(m) } -func (*InitialLoadBalanceResponse) ProtoMessage() {} -func (*InitialLoadBalanceResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_7cd3f6d792743fdf, []int{5} -} - -func (m *InitialLoadBalanceResponse) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_InitialLoadBalanceResponse.Unmarshal(m, b) -} -func (m *InitialLoadBalanceResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_InitialLoadBalanceResponse.Marshal(b, m, deterministic) -} -func (m *InitialLoadBalanceResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_InitialLoadBalanceResponse.Merge(m, src) -} -func (m *InitialLoadBalanceResponse) XXX_Size() int { - return xxx_messageInfo_InitialLoadBalanceResponse.Size(m) -} -func (m *InitialLoadBalanceResponse) XXX_DiscardUnknown() { - xxx_messageInfo_InitialLoadBalanceResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_InitialLoadBalanceResponse proto.InternalMessageInfo - -func (m *InitialLoadBalanceResponse) GetLoadBalancerDelegate() string { - if m != nil { - return m.LoadBalancerDelegate - } - return "" -} - -func (m *InitialLoadBalanceResponse) GetClientStatsReportInterval() *duration.Duration { - if m != nil { - return m.ClientStatsReportInterval - } - return nil -} - -type ServerList struct { - // Contains a list of servers selected by the load balancer. The list will - // be updated when server resolutions change or as needed to balance load - // across more servers. The client should consume the server list in order - // unless instructed otherwise via the client_config. - Servers []*Server `protobuf:"bytes,1,rep,name=servers,proto3" json:"servers,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *ServerList) Reset() { *m = ServerList{} } -func (m *ServerList) String() string { return proto.CompactTextString(m) } -func (*ServerList) ProtoMessage() {} -func (*ServerList) Descriptor() ([]byte, []int) { - return fileDescriptor_7cd3f6d792743fdf, []int{6} -} - -func (m *ServerList) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_ServerList.Unmarshal(m, b) -} -func (m *ServerList) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_ServerList.Marshal(b, m, deterministic) -} -func (m *ServerList) XXX_Merge(src proto.Message) { - xxx_messageInfo_ServerList.Merge(m, src) -} -func (m *ServerList) XXX_Size() int { - return xxx_messageInfo_ServerList.Size(m) -} -func (m *ServerList) XXX_DiscardUnknown() { - xxx_messageInfo_ServerList.DiscardUnknown(m) -} - -var xxx_messageInfo_ServerList proto.InternalMessageInfo - -func (m *ServerList) GetServers() []*Server { - if m != nil { - return m.Servers - } - return nil -} - -// Contains server information. When the drop field is not true, use the other -// fields. -type Server struct { - // A resolved address for the server, serialized in network-byte-order. It may - // either be an IPv4 or IPv6 address. - IpAddress []byte `protobuf:"bytes,1,opt,name=ip_address,json=ipAddress,proto3" json:"ip_address,omitempty"` - // A resolved port number for the server. - Port int32 `protobuf:"varint,2,opt,name=port,proto3" json:"port,omitempty"` - // An opaque but printable token for load reporting. The client must include - // the token of the picked server into the initial metadata when it starts a - // call to that server. The token is used by the server to verify the request - // and to allow the server to report load to the gRPC LB system. The token is - // also used in client stats for reporting dropped calls. - // - // Its length can be variable but must be less than 50 bytes. - LoadBalanceToken string `protobuf:"bytes,3,opt,name=load_balance_token,json=loadBalanceToken,proto3" json:"load_balance_token,omitempty"` - // Indicates whether this particular request should be dropped by the client. - // If the request is dropped, there will be a corresponding entry in - // ClientStats.calls_finished_with_drop. - Drop bool `protobuf:"varint,4,opt,name=drop,proto3" json:"drop,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *Server) Reset() { *m = Server{} } -func (m *Server) String() string { return proto.CompactTextString(m) } -func (*Server) ProtoMessage() {} -func (*Server) Descriptor() ([]byte, []int) { - return fileDescriptor_7cd3f6d792743fdf, []int{7} -} - -func (m *Server) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_Server.Unmarshal(m, b) -} -func (m *Server) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_Server.Marshal(b, m, deterministic) -} -func (m *Server) XXX_Merge(src proto.Message) { - xxx_messageInfo_Server.Merge(m, src) -} -func (m *Server) XXX_Size() int { - return xxx_messageInfo_Server.Size(m) -} -func (m *Server) XXX_DiscardUnknown() { - xxx_messageInfo_Server.DiscardUnknown(m) -} - -var xxx_messageInfo_Server proto.InternalMessageInfo - -func (m *Server) GetIpAddress() []byte { - if m != nil { - return m.IpAddress - } - return nil -} - -func (m *Server) GetPort() int32 { - if m != nil { - return m.Port - } - return 0 -} - -func (m *Server) GetLoadBalanceToken() string { - if m != nil { - return m.LoadBalanceToken - } - return "" -} - -func (m *Server) GetDrop() bool { - if m != nil { - return m.Drop - } - return false -} - -func init() { - proto.RegisterType((*LoadBalanceRequest)(nil), "grpc.lb.v1.LoadBalanceRequest") - proto.RegisterType((*InitialLoadBalanceRequest)(nil), "grpc.lb.v1.InitialLoadBalanceRequest") - proto.RegisterType((*ClientStatsPerToken)(nil), "grpc.lb.v1.ClientStatsPerToken") - proto.RegisterType((*ClientStats)(nil), "grpc.lb.v1.ClientStats") - proto.RegisterType((*LoadBalanceResponse)(nil), "grpc.lb.v1.LoadBalanceResponse") - proto.RegisterType((*InitialLoadBalanceResponse)(nil), "grpc.lb.v1.InitialLoadBalanceResponse") - proto.RegisterType((*ServerList)(nil), "grpc.lb.v1.ServerList") - proto.RegisterType((*Server)(nil), "grpc.lb.v1.Server") -} - -func init() { proto.RegisterFile("grpc/lb/v1/load_balancer.proto", fileDescriptor_7cd3f6d792743fdf) } - -var fileDescriptor_7cd3f6d792743fdf = []byte{ - // 752 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x55, 0xdd, 0x6e, 0x23, 0x35, - 0x14, 0xee, 0x90, 0x69, 0x36, 0x39, 0x29, 0x34, 0xeb, 0x85, 0x65, 0x92, 0xdd, 0x6d, 0x4b, 0x24, - 0x56, 0x11, 0x2a, 0x13, 0x52, 0xb8, 0x00, 0x89, 0x0b, 0x48, 0xab, 0x2a, 0x2d, 0xbd, 0x88, 0x9c, - 0x4a, 0x45, 0x95, 0x90, 0x99, 0xc9, 0xb8, 0xa9, 0x55, 0xc7, 0x1e, 0x3c, 0x4e, 0x2a, 0xae, 0x79, - 0x1f, 0xc4, 0x2b, 0x20, 0x5e, 0x0c, 0x8d, 0xed, 0x49, 0xa6, 0x49, 0xa3, 0xbd, 0xca, 0xf8, 0x9c, - 0xcf, 0xdf, 0xf9, 0xfd, 0x1c, 0x38, 0x98, 0xaa, 0x74, 0xd2, 0xe3, 0x71, 0x6f, 0xd1, 0xef, 0x71, - 0x19, 0x25, 0x24, 0x8e, 0x78, 0x24, 0x26, 0x54, 0x85, 0xa9, 0x92, 0x5a, 0x22, 0xc8, 0xfd, 0x21, - 0x8f, 0xc3, 0x45, 0xbf, 0x7d, 0x30, 0x95, 0x72, 0xca, 0x69, 0xcf, 0x78, 0xe2, 0xf9, 0x5d, 0x2f, - 0x99, 0xab, 0x48, 0x33, 0x29, 0x2c, 0xb6, 0x7d, 0xb8, 0xee, 0xd7, 0x6c, 0x46, 0x33, 0x1d, 0xcd, - 0x52, 0x0b, 0xe8, 0xfc, 0xeb, 0x01, 0xba, 0x92, 0x51, 0x32, 0xb0, 0x31, 0x30, 0xfd, 0x63, 0x4e, - 0x33, 0x8d, 0x46, 0xb0, 0xcf, 0x04, 0xd3, 0x2c, 0xe2, 0x44, 0x59, 0x53, 0xe0, 0x1d, 0x79, 0xdd, - 0xc6, 0xc9, 0x97, 0xe1, 0x2a, 0x7a, 0x78, 0x61, 0x21, 0x9b, 0xf7, 0x87, 0x3b, 0xf8, 0x13, 0x77, - 0xbf, 0x60, 0xfc, 0x11, 0xf6, 0x26, 0x9c, 0x51, 0xa1, 0x49, 0xa6, 0x23, 0x9d, 0x05, 0x1f, 0x19, - 0xba, 0xcf, 0xcb, 0x74, 0xa7, 0xc6, 0x3f, 0xce, 0xdd, 0xc3, 0x1d, 0xdc, 0x98, 0xac, 0x8e, 0x83, - 0x37, 0xd0, 0x2a, 0xb7, 0xa2, 0x48, 0x8a, 0xe8, 0x3f, 0x53, 0xda, 0xe9, 0x41, 0x6b, 0x6b, 0x26, - 0x08, 0x81, 0x2f, 0xa2, 0x19, 0x35, 0xe9, 0xd7, 0xb1, 0xf9, 0xee, 0xfc, 0x0e, 0xaf, 0x4a, 0xb1, - 0x46, 0x54, 0x5d, 0xcb, 0x07, 0x2a, 0xd0, 0x31, 0xa0, 0x27, 0x41, 0x74, 0x6e, 0x75, 0x17, 0x9b, - 0x7c, 0x45, 0x6d, 0xd1, 0x6f, 0xa0, 0x2e, 0xe6, 0x33, 0x32, 0x89, 0x38, 0xb7, 0xd5, 0x54, 0x70, - 0x4d, 0xcc, 0x67, 0xa7, 0xf9, 0xb9, 0xf3, 0x4f, 0x05, 0x1a, 0xa5, 0x10, 0xe8, 0x7b, 0xa8, 0x2f, - 0x3b, 0xef, 0x3a, 0xd9, 0x0e, 0xed, 0x6c, 0xc2, 0x62, 0x36, 0xe1, 0x75, 0x81, 0xc0, 0x2b, 0x30, - 0xfa, 0x0a, 0x5e, 0x2e, 0xc3, 0xe4, 0xad, 0x53, 0x9a, 0x26, 0x2e, 0xdc, 0x7e, 0x11, 0x6e, 0x6c, - 0xcd, 0x79, 0x01, 0x2b, 0xec, 0x1d, 0x13, 0x2c, 0xbb, 0xa7, 0x49, 0x50, 0x31, 0xe0, 0x66, 0x01, - 0x3e, 0x77, 0x76, 0xf4, 0x1b, 0x7c, 0xbd, 0x89, 0x26, 0x8f, 0x4c, 0xdf, 0x13, 0x37, 0xa9, 0xbb, - 0x88, 0x71, 0x9a, 0x10, 0x2d, 0x49, 0x46, 0x45, 0x12, 0x54, 0x0d, 0xd1, 0xfb, 0x75, 0xa2, 0x1b, - 0xa6, 0xef, 0x6d, 0xad, 0xe7, 0x06, 0x7f, 0x2d, 0xc7, 0x54, 0x24, 0x68, 0x08, 0x5f, 0x3c, 0x43, - 0xff, 0x20, 0xe4, 0xa3, 0x20, 0x8a, 0x4e, 0x28, 0x5b, 0xd0, 0x24, 0x78, 0x61, 0x28, 0xdf, 0xad, - 0x53, 0xfe, 0x92, 0xa3, 0xb0, 0x03, 0xa1, 0x5f, 0x21, 0x78, 0x2e, 0xc9, 0x44, 0xc9, 0x34, 0xa8, - 0x1d, 0x55, 0xba, 0x8d, 0x93, 0xc3, 0x2d, 0x6b, 0x54, 0x8c, 0x16, 0x7f, 0x36, 0x59, 0xcf, 0xf8, - 0x4c, 0xc9, 0xf4, 0xd2, 0xaf, 0xf9, 0xcd, 0xdd, 0x4b, 0xbf, 0xb6, 0xdb, 0xac, 0x76, 0xfe, 0xf3, - 0xe0, 0xd5, 0x93, 0xfd, 0xc9, 0x52, 0x29, 0x32, 0x8a, 0xc6, 0xd0, 0x5c, 0x49, 0xc1, 0xda, 0xdc, - 0x04, 0xdf, 0x7f, 0x48, 0x0b, 0x16, 0x3d, 0xdc, 0xc1, 0xfb, 0x4b, 0x31, 0x38, 0xd2, 0x1f, 0xa0, - 0x91, 0x51, 0xb5, 0xa0, 0x8a, 0x70, 0x96, 0x69, 0x27, 0x86, 0xd7, 0x65, 0xbe, 0xb1, 0x71, 0x5f, - 0x31, 0x23, 0x26, 0xc8, 0x96, 0xa7, 0xc1, 0x5b, 0x68, 0xaf, 0x49, 0xc1, 0x72, 0x5a, 0x2d, 0xfc, - 0xed, 0x41, 0x7b, 0x7b, 0x2a, 0xe8, 0x3b, 0x78, 0xfd, 0xe4, 0x49, 0x21, 0x09, 0xe5, 0x74, 0x1a, - 0xe9, 0x42, 0x1f, 0x9f, 0x96, 0xd6, 0x5c, 0x9d, 0x39, 0x1f, 0xba, 0x85, 0xb7, 0x65, 0xed, 0x12, - 0x45, 0x53, 0xa9, 0x34, 0x61, 0x42, 0x53, 0xb5, 0x88, 0xb8, 0x4b, 0xbf, 0xb5, 0xb1, 0xd0, 0x67, - 0xee, 0x31, 0xc2, 0xad, 0x92, 0x96, 0xb1, 0xb9, 0x7c, 0xe1, 0xee, 0x76, 0x7e, 0x02, 0x58, 0x95, - 0x8a, 0x8e, 0xe1, 0x85, 0x2d, 0x35, 0x0b, 0x3c, 0x33, 0x59, 0xb4, 0xd9, 0x13, 0x5c, 0x40, 0x2e, - 0xfd, 0x5a, 0xa5, 0xe9, 0x77, 0xfe, 0xf2, 0xa0, 0x6a, 0x3d, 0xe8, 0x1d, 0x00, 0x4b, 0x49, 0x94, - 0x24, 0x8a, 0x66, 0x99, 0x29, 0x69, 0x0f, 0xd7, 0x59, 0xfa, 0xb3, 0x35, 0xe4, 0x6f, 0x41, 0x1e, - 0xdb, 0xe4, 0xbb, 0x8b, 0xcd, 0xf7, 0x16, 0xd1, 0x57, 0xb6, 0x88, 0x1e, 0x81, 0x6f, 0xd6, 0xce, - 0x3f, 0xf2, 0xba, 0x35, 0x6c, 0xbe, 0xed, 0xfa, 0x9c, 0xc4, 0xb0, 0x57, 0x6a, 0xb8, 0x42, 0x18, - 0x1a, 0xee, 0x3b, 0x37, 0xa3, 0x83, 0x72, 0x1d, 0x9b, 0xcf, 0x54, 0xfb, 0x70, 0xab, 0xdf, 0x4e, - 0xae, 0xeb, 0x7d, 0xe3, 0x0d, 0x6e, 0xe0, 0x63, 0x26, 0x4b, 0xc0, 0xc1, 0xcb, 0x72, 0xc8, 0x51, - 0xde, 0xf6, 0x91, 0x77, 0xdb, 0x77, 0x63, 0x98, 0x4a, 0x1e, 0x89, 0x69, 0x28, 0xd5, 0xb4, 0x67, - 0xfe, 0x51, 0x8a, 0x99, 0x9b, 0x13, 0x8f, 0xcd, 0x0f, 0xe1, 0x31, 0x59, 0xf4, 0xe3, 0xaa, 0x19, - 0xd9, 0xb7, 0xff, 0x07, 0x00, 0x00, 0xff, 0xff, 0x81, 0x14, 0xee, 0xd1, 0x7b, 0x06, 0x00, 0x00, -} - -// Reference imports to suppress errors if they are not otherwise used. -var _ context.Context -var _ grpc.ClientConn - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the grpc package it is being compiled against. -const _ = grpc.SupportPackageIsVersion4 - -// LoadBalancerClient is the client API for LoadBalancer service. -// -// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. -type LoadBalancerClient interface { - // Bidirectional rpc to get a list of servers. - BalanceLoad(ctx context.Context, opts ...grpc.CallOption) (LoadBalancer_BalanceLoadClient, error) -} - -type loadBalancerClient struct { - cc *grpc.ClientConn -} - -func NewLoadBalancerClient(cc *grpc.ClientConn) LoadBalancerClient { - return &loadBalancerClient{cc} -} - -func (c *loadBalancerClient) BalanceLoad(ctx context.Context, opts ...grpc.CallOption) (LoadBalancer_BalanceLoadClient, error) { - stream, err := c.cc.NewStream(ctx, &_LoadBalancer_serviceDesc.Streams[0], "/grpc.lb.v1.LoadBalancer/BalanceLoad", opts...) - if err != nil { - return nil, err - } - x := &loadBalancerBalanceLoadClient{stream} - return x, nil -} - -type LoadBalancer_BalanceLoadClient interface { - Send(*LoadBalanceRequest) error - Recv() (*LoadBalanceResponse, error) - grpc.ClientStream -} - -type loadBalancerBalanceLoadClient struct { - grpc.ClientStream -} - -func (x *loadBalancerBalanceLoadClient) Send(m *LoadBalanceRequest) error { - return x.ClientStream.SendMsg(m) -} - -func (x *loadBalancerBalanceLoadClient) Recv() (*LoadBalanceResponse, error) { - m := new(LoadBalanceResponse) - if err := x.ClientStream.RecvMsg(m); err != nil { - return nil, err - } - return m, nil -} - -// LoadBalancerServer is the server API for LoadBalancer service. -type LoadBalancerServer interface { - // Bidirectional rpc to get a list of servers. - BalanceLoad(LoadBalancer_BalanceLoadServer) error -} - -// UnimplementedLoadBalancerServer can be embedded to have forward compatible implementations. -type UnimplementedLoadBalancerServer struct { -} - -func (*UnimplementedLoadBalancerServer) BalanceLoad(srv LoadBalancer_BalanceLoadServer) error { - return status.Errorf(codes.Unimplemented, "method BalanceLoad not implemented") -} - -func RegisterLoadBalancerServer(s *grpc.Server, srv LoadBalancerServer) { - s.RegisterService(&_LoadBalancer_serviceDesc, srv) -} - -func _LoadBalancer_BalanceLoad_Handler(srv interface{}, stream grpc.ServerStream) error { - return srv.(LoadBalancerServer).BalanceLoad(&loadBalancerBalanceLoadServer{stream}) -} - -type LoadBalancer_BalanceLoadServer interface { - Send(*LoadBalanceResponse) error - Recv() (*LoadBalanceRequest, error) - grpc.ServerStream -} - -type loadBalancerBalanceLoadServer struct { - grpc.ServerStream -} - -func (x *loadBalancerBalanceLoadServer) Send(m *LoadBalanceResponse) error { - return x.ServerStream.SendMsg(m) -} - -func (x *loadBalancerBalanceLoadServer) Recv() (*LoadBalanceRequest, error) { - m := new(LoadBalanceRequest) - if err := x.ServerStream.RecvMsg(m); err != nil { - return nil, err - } - return m, nil -} - -var _LoadBalancer_serviceDesc = grpc.ServiceDesc{ - ServiceName: "grpc.lb.v1.LoadBalancer", - HandlerType: (*LoadBalancerServer)(nil), - Methods: []grpc.MethodDesc{}, - Streams: []grpc.StreamDesc{ - { - StreamName: "BalanceLoad", - Handler: _LoadBalancer_BalanceLoad_Handler, - ServerStreams: true, - ClientStreams: true, - }, - }, - Metadata: "grpc/lb/v1/load_balancer.proto", -} diff --git a/vendor/google.golang.org/grpc/balancer/grpclb/grpclb.go b/vendor/google.golang.org/grpc/balancer/grpclb/grpclb.go deleted file mode 100644 index 1e34786834..0000000000 --- a/vendor/google.golang.org/grpc/balancer/grpclb/grpclb.go +++ /dev/null @@ -1,490 +0,0 @@ -/* - * - * Copyright 2016 gRPC 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. - * - */ - -//go:generate ./regenerate.sh - -// Package grpclb defines a grpclb balancer. -// -// To install grpclb balancer, import this package as: -// import _ "google.golang.org/grpc/balancer/grpclb" -package grpclb - -import ( - "context" - "errors" - "strconv" - "sync" - "time" - - durationpb "github.com/golang/protobuf/ptypes/duration" - "google.golang.org/grpc" - "google.golang.org/grpc/balancer" - lbpb "google.golang.org/grpc/balancer/grpclb/grpc_lb_v1" - "google.golang.org/grpc/connectivity" - "google.golang.org/grpc/credentials" - "google.golang.org/grpc/grpclog" - "google.golang.org/grpc/internal" - "google.golang.org/grpc/internal/backoff" - "google.golang.org/grpc/internal/resolver/dns" - "google.golang.org/grpc/resolver" -) - -const ( - lbTokenKey = "lb-token" - defaultFallbackTimeout = 10 * time.Second - grpclbName = "grpclb" -) - -var errServerTerminatedConnection = errors.New("grpclb: failed to recv server list: server terminated connection") - -func convertDuration(d *durationpb.Duration) time.Duration { - if d == nil { - return 0 - } - return time.Duration(d.Seconds)*time.Second + time.Duration(d.Nanos)*time.Nanosecond -} - -// Client API for LoadBalancer service. -// Mostly copied from generated pb.go file. -// To avoid circular dependency. -type loadBalancerClient struct { - cc *grpc.ClientConn -} - -func (c *loadBalancerClient) BalanceLoad(ctx context.Context, opts ...grpc.CallOption) (*balanceLoadClientStream, error) { - desc := &grpc.StreamDesc{ - StreamName: "BalanceLoad", - ServerStreams: true, - ClientStreams: true, - } - stream, err := c.cc.NewStream(ctx, desc, "/grpc.lb.v1.LoadBalancer/BalanceLoad", opts...) - if err != nil { - return nil, err - } - x := &balanceLoadClientStream{stream} - return x, nil -} - -type balanceLoadClientStream struct { - grpc.ClientStream -} - -func (x *balanceLoadClientStream) Send(m *lbpb.LoadBalanceRequest) error { - return x.ClientStream.SendMsg(m) -} - -func (x *balanceLoadClientStream) Recv() (*lbpb.LoadBalanceResponse, error) { - m := new(lbpb.LoadBalanceResponse) - if err := x.ClientStream.RecvMsg(m); err != nil { - return nil, err - } - return m, nil -} - -func init() { - balancer.Register(newLBBuilder()) - dns.EnableSRVLookups = true -} - -// newLBBuilder creates a builder for grpclb. -func newLBBuilder() balancer.Builder { - return newLBBuilderWithFallbackTimeout(defaultFallbackTimeout) -} - -// newLBBuilderWithFallbackTimeout creates a grpclb builder with the given -// fallbackTimeout. If no response is received from the remote balancer within -// fallbackTimeout, the backend addresses from the resolved address list will be -// used. -// -// Only call this function when a non-default fallback timeout is needed. -func newLBBuilderWithFallbackTimeout(fallbackTimeout time.Duration) balancer.Builder { - return &lbBuilder{ - fallbackTimeout: fallbackTimeout, - } -} - -type lbBuilder struct { - fallbackTimeout time.Duration -} - -func (b *lbBuilder) Name() string { - return grpclbName -} - -func (b *lbBuilder) Build(cc balancer.ClientConn, opt balancer.BuildOptions) balancer.Balancer { - // This generates a manual resolver builder with a random scheme. This - // scheme will be used to dial to remote LB, so we can send filtered address - // updates to remote LB ClientConn using this manual resolver. - scheme := "grpclb_internal_" + strconv.FormatInt(time.Now().UnixNano(), 36) - r := &lbManualResolver{scheme: scheme, ccb: cc} - - lb := &lbBalancer{ - cc: newLBCacheClientConn(cc), - target: opt.Target.Endpoint, - opt: opt, - fallbackTimeout: b.fallbackTimeout, - doneCh: make(chan struct{}), - - manualResolver: r, - subConns: make(map[resolver.Address]balancer.SubConn), - scStates: make(map[balancer.SubConn]connectivity.State), - picker: &errPicker{err: balancer.ErrNoSubConnAvailable}, - clientStats: newRPCStats(), - backoff: backoff.DefaultExponential, // TODO: make backoff configurable. - } - - var err error - if opt.CredsBundle != nil { - lb.grpclbClientConnCreds, err = opt.CredsBundle.NewWithMode(internal.CredsBundleModeBalancer) - if err != nil { - grpclog.Warningf("lbBalancer: client connection creds NewWithMode failed: %v", err) - } - lb.grpclbBackendCreds, err = opt.CredsBundle.NewWithMode(internal.CredsBundleModeBackendFromBalancer) - if err != nil { - grpclog.Warningf("lbBalancer: backend creds NewWithMode failed: %v", err) - } - } - - return lb -} - -var _ balancer.V2Balancer = (*lbBalancer)(nil) // Assert that we implement V2Balancer - -type lbBalancer struct { - cc *lbCacheClientConn - target string - opt balancer.BuildOptions - - usePickFirst bool - - // grpclbClientConnCreds is the creds bundle to be used to connect to grpclb - // servers. If it's nil, use the TransportCredentials from BuildOptions - // instead. - grpclbClientConnCreds credentials.Bundle - // grpclbBackendCreds is the creds bundle to be used for addresses that are - // returned by grpclb server. If it's nil, don't set anything when creating - // SubConns. - grpclbBackendCreds credentials.Bundle - - fallbackTimeout time.Duration - doneCh chan struct{} - - // manualResolver is used in the remote LB ClientConn inside grpclb. When - // resolved address updates are received by grpclb, filtered updates will be - // send to remote LB ClientConn through this resolver. - manualResolver *lbManualResolver - // The ClientConn to talk to the remote balancer. - ccRemoteLB *remoteBalancerCCWrapper - // backoff for calling remote balancer. - backoff backoff.Strategy - - // Support client side load reporting. Each picker gets a reference to this, - // and will update its content. - clientStats *rpcStats - - mu sync.Mutex // guards everything following. - // The full server list including drops, used to check if the newly received - // serverList contains anything new. Each generate picker will also have - // reference to this list to do the first layer pick. - fullServerList []*lbpb.Server - // Backend addresses. It's kept so the addresses are available when - // switching between round_robin and pickfirst. - backendAddrs []resolver.Address - // All backends addresses, with metadata set to nil. This list contains all - // backend addresses in the same order and with the same duplicates as in - // serverlist. When generating picker, a SubConn slice with the same order - // but with only READY SCs will be gerenated. - backendAddrsWithoutMetadata []resolver.Address - // Roundrobin functionalities. - state connectivity.State - subConns map[resolver.Address]balancer.SubConn // Used to new/remove SubConn. - scStates map[balancer.SubConn]connectivity.State // Used to filter READY SubConns. - picker balancer.V2Picker - // Support fallback to resolved backend addresses if there's no response - // from remote balancer within fallbackTimeout. - remoteBalancerConnected bool - serverListReceived bool - inFallback bool - // resolvedBackendAddrs is resolvedAddrs minus remote balancers. It's set - // when resolved address updates are received, and read in the goroutine - // handling fallback. - resolvedBackendAddrs []resolver.Address -} - -// regeneratePicker takes a snapshot of the balancer, and generates a picker from -// it. The picker -// - always returns ErrTransientFailure if the balancer is in TransientFailure, -// - does two layer roundrobin pick otherwise. -// Caller must hold lb.mu. -func (lb *lbBalancer) regeneratePicker(resetDrop bool) { - if lb.state == connectivity.TransientFailure { - lb.picker = &errPicker{err: balancer.ErrTransientFailure} - return - } - - if lb.state == connectivity.Connecting { - lb.picker = &errPicker{err: balancer.ErrNoSubConnAvailable} - return - } - - var readySCs []balancer.SubConn - if lb.usePickFirst { - for _, sc := range lb.subConns { - readySCs = append(readySCs, sc) - break - } - } else { - for _, a := range lb.backendAddrsWithoutMetadata { - if sc, ok := lb.subConns[a]; ok { - if st, ok := lb.scStates[sc]; ok && st == connectivity.Ready { - readySCs = append(readySCs, sc) - } - } - } - } - - if len(readySCs) <= 0 { - // If there's no ready SubConns, always re-pick. This is to avoid drops - // unless at least one SubConn is ready. Otherwise we may drop more - // often than want because of drops + re-picks(which become re-drops). - // - // This doesn't seem to be necessary after the connecting check above. - // Kept for safety. - lb.picker = &errPicker{err: balancer.ErrNoSubConnAvailable} - return - } - if lb.inFallback { - lb.picker = newRRPicker(readySCs) - return - } - if resetDrop { - lb.picker = newLBPicker(lb.fullServerList, readySCs, lb.clientStats) - return - } - prevLBPicker, ok := lb.picker.(*lbPicker) - if !ok { - lb.picker = newLBPicker(lb.fullServerList, readySCs, lb.clientStats) - return - } - prevLBPicker.updateReadySCs(readySCs) -} - -// aggregateSubConnStats calculate the aggregated state of SubConns in -// lb.SubConns. These SubConns are subconns in use (when switching between -// fallback and grpclb). lb.scState contains states for all SubConns, including -// those in cache (SubConns are cached for 10 seconds after remove). -// -// The aggregated state is: -// - If at least one SubConn in Ready, the aggregated state is Ready; -// - Else if at least one SubConn in Connecting, the aggregated state is Connecting; -// - Else the aggregated state is TransientFailure. -func (lb *lbBalancer) aggregateSubConnStates() connectivity.State { - var numConnecting uint64 - - for _, sc := range lb.subConns { - if state, ok := lb.scStates[sc]; ok { - switch state { - case connectivity.Ready: - return connectivity.Ready - case connectivity.Connecting: - numConnecting++ - } - } - } - if numConnecting > 0 { - return connectivity.Connecting - } - return connectivity.TransientFailure -} - -func (lb *lbBalancer) HandleSubConnStateChange(sc balancer.SubConn, s connectivity.State) { - panic("not used") -} - -func (lb *lbBalancer) UpdateSubConnState(sc balancer.SubConn, scs balancer.SubConnState) { - s := scs.ConnectivityState - if grpclog.V(2) { - grpclog.Infof("lbBalancer: handle SubConn state change: %p, %v", sc, s) - } - lb.mu.Lock() - defer lb.mu.Unlock() - - oldS, ok := lb.scStates[sc] - if !ok { - if grpclog.V(2) { - grpclog.Infof("lbBalancer: got state changes for an unknown SubConn: %p, %v", sc, s) - } - return - } - lb.scStates[sc] = s - switch s { - case connectivity.Idle: - sc.Connect() - case connectivity.Shutdown: - // When an address was removed by resolver, b called RemoveSubConn but - // kept the sc's state in scStates. Remove state for this sc here. - delete(lb.scStates, sc) - } - // Force regenerate picker if - // - this sc became ready from not-ready - // - this sc became not-ready from ready - lb.updateStateAndPicker((oldS == connectivity.Ready) != (s == connectivity.Ready), false) - - // Enter fallback when the aggregated state is not Ready and the connection - // to remote balancer is lost. - if lb.state != connectivity.Ready { - if !lb.inFallback && !lb.remoteBalancerConnected { - // Enter fallback. - lb.refreshSubConns(lb.resolvedBackendAddrs, true, lb.usePickFirst) - } - } -} - -// updateStateAndPicker re-calculate the aggregated state, and regenerate picker -// if overall state is changed. -// -// If forceRegeneratePicker is true, picker will be regenerated. -func (lb *lbBalancer) updateStateAndPicker(forceRegeneratePicker bool, resetDrop bool) { - oldAggrState := lb.state - lb.state = lb.aggregateSubConnStates() - // Regenerate picker when one of the following happens: - // - caller wants to regenerate - // - the aggregated state changed - if forceRegeneratePicker || (lb.state != oldAggrState) { - lb.regeneratePicker(resetDrop) - } - - lb.cc.UpdateState(balancer.State{ConnectivityState: lb.state, Picker: lb.picker}) -} - -// fallbackToBackendsAfter blocks for fallbackTimeout and falls back to use -// resolved backends (backends received from resolver, not from remote balancer) -// if no connection to remote balancers was successful. -func (lb *lbBalancer) fallbackToBackendsAfter(fallbackTimeout time.Duration) { - timer := time.NewTimer(fallbackTimeout) - defer timer.Stop() - select { - case <-timer.C: - case <-lb.doneCh: - return - } - lb.mu.Lock() - if lb.inFallback || lb.serverListReceived { - lb.mu.Unlock() - return - } - // Enter fallback. - lb.refreshSubConns(lb.resolvedBackendAddrs, true, lb.usePickFirst) - lb.mu.Unlock() -} - -// HandleResolvedAddrs sends the updated remoteLB addresses to remoteLB -// clientConn. The remoteLB clientConn will handle creating/removing remoteLB -// connections. -func (lb *lbBalancer) HandleResolvedAddrs(addrs []resolver.Address, err error) { - panic("not used") -} - -func (lb *lbBalancer) handleServiceConfig(gc *grpclbServiceConfig) { - lb.mu.Lock() - defer lb.mu.Unlock() - - newUsePickFirst := childIsPickFirst(gc) - if lb.usePickFirst == newUsePickFirst { - return - } - if grpclog.V(2) { - grpclog.Infof("lbBalancer: switching mode, new usePickFirst: %+v", newUsePickFirst) - } - lb.refreshSubConns(lb.backendAddrs, lb.inFallback, newUsePickFirst) -} - -func (lb *lbBalancer) ResolverError(error) { - // Ignore resolver errors. GRPCLB is not selected unless the resolver - // works at least once. -} - -func (lb *lbBalancer) UpdateClientConnState(ccs balancer.ClientConnState) error { - if grpclog.V(2) { - grpclog.Infof("lbBalancer: UpdateClientConnState: %+v", ccs) - } - gc, _ := ccs.BalancerConfig.(*grpclbServiceConfig) - lb.handleServiceConfig(gc) - - addrs := ccs.ResolverState.Addresses - if len(addrs) == 0 { - // There should be at least one address, either grpclb server or - // fallback. Empty address is not valid. - return balancer.ErrBadResolverState - } - - var remoteBalancerAddrs, backendAddrs []resolver.Address - for _, a := range addrs { - if a.Type == resolver.GRPCLB { - a.Type = resolver.Backend - remoteBalancerAddrs = append(remoteBalancerAddrs, a) - } else { - backendAddrs = append(backendAddrs, a) - } - } - - if len(remoteBalancerAddrs) == 0 { - if lb.ccRemoteLB != nil { - lb.ccRemoteLB.close() - lb.ccRemoteLB = nil - } - } else if lb.ccRemoteLB == nil { - // First time receiving resolved addresses, create a cc to remote - // balancers. - lb.newRemoteBalancerCCWrapper() - // Start the fallback goroutine. - go lb.fallbackToBackendsAfter(lb.fallbackTimeout) - } - - if lb.ccRemoteLB != nil { - // cc to remote balancers uses lb.manualResolver. Send the updated remote - // balancer addresses to it through manualResolver. - lb.manualResolver.UpdateState(resolver.State{Addresses: remoteBalancerAddrs}) - } - - lb.mu.Lock() - lb.resolvedBackendAddrs = backendAddrs - if len(remoteBalancerAddrs) == 0 || lb.inFallback { - // If there's no remote balancer address in ClientConn update, grpclb - // enters fallback mode immediately. - // - // If a new update is received while grpclb is in fallback, update the - // list of backends being used to the new fallback backends. - lb.refreshSubConns(lb.resolvedBackendAddrs, true, lb.usePickFirst) - } - lb.mu.Unlock() - return nil -} - -func (lb *lbBalancer) Close() { - select { - case <-lb.doneCh: - return - default: - } - close(lb.doneCh) - if lb.ccRemoteLB != nil { - lb.ccRemoteLB.close() - } - lb.cc.close() -} diff --git a/vendor/google.golang.org/grpc/balancer/grpclb/grpclb_config.go b/vendor/google.golang.org/grpc/balancer/grpclb/grpclb_config.go deleted file mode 100644 index aac3719631..0000000000 --- a/vendor/google.golang.org/grpc/balancer/grpclb/grpclb_config.go +++ /dev/null @@ -1,66 +0,0 @@ -/* - * - * Copyright 2019 gRPC 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 grpclb - -import ( - "encoding/json" - - "google.golang.org/grpc" - "google.golang.org/grpc/balancer/roundrobin" - "google.golang.org/grpc/serviceconfig" -) - -const ( - roundRobinName = roundrobin.Name - pickFirstName = grpc.PickFirstBalancerName -) - -type grpclbServiceConfig struct { - serviceconfig.LoadBalancingConfig - ChildPolicy *[]map[string]json.RawMessage -} - -func (b *lbBuilder) ParseConfig(lbConfig json.RawMessage) (serviceconfig.LoadBalancingConfig, error) { - ret := &grpclbServiceConfig{} - if err := json.Unmarshal(lbConfig, ret); err != nil { - return nil, err - } - return ret, nil -} - -func childIsPickFirst(sc *grpclbServiceConfig) bool { - if sc == nil { - return false - } - childConfigs := sc.ChildPolicy - if childConfigs == nil { - return false - } - for _, childC := range *childConfigs { - // If round_robin exists before pick_first, return false - if _, ok := childC[roundRobinName]; ok { - return false - } - // If pick_first is before round_robin, return true - if _, ok := childC[pickFirstName]; ok { - return true - } - } - return false -} diff --git a/vendor/google.golang.org/grpc/balancer/grpclb/grpclb_picker.go b/vendor/google.golang.org/grpc/balancer/grpclb/grpclb_picker.go deleted file mode 100644 index 22213cc0be..0000000000 --- a/vendor/google.golang.org/grpc/balancer/grpclb/grpclb_picker.go +++ /dev/null @@ -1,202 +0,0 @@ -/* - * - * Copyright 2017 gRPC 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 grpclb - -import ( - "sync" - "sync/atomic" - - "google.golang.org/grpc/balancer" - lbpb "google.golang.org/grpc/balancer/grpclb/grpc_lb_v1" - "google.golang.org/grpc/codes" - "google.golang.org/grpc/internal/grpcrand" - "google.golang.org/grpc/status" -) - -// rpcStats is same as lbmpb.ClientStats, except that numCallsDropped is a map -// instead of a slice. -type rpcStats struct { - // Only access the following fields atomically. - numCallsStarted int64 - numCallsFinished int64 - numCallsFinishedWithClientFailedToSend int64 - numCallsFinishedKnownReceived int64 - - mu sync.Mutex - // map load_balance_token -> num_calls_dropped - numCallsDropped map[string]int64 -} - -func newRPCStats() *rpcStats { - return &rpcStats{ - numCallsDropped: make(map[string]int64), - } -} - -func isZeroStats(stats *lbpb.ClientStats) bool { - return len(stats.CallsFinishedWithDrop) == 0 && - stats.NumCallsStarted == 0 && - stats.NumCallsFinished == 0 && - stats.NumCallsFinishedWithClientFailedToSend == 0 && - stats.NumCallsFinishedKnownReceived == 0 -} - -// toClientStats converts rpcStats to lbpb.ClientStats, and clears rpcStats. -func (s *rpcStats) toClientStats() *lbpb.ClientStats { - stats := &lbpb.ClientStats{ - NumCallsStarted: atomic.SwapInt64(&s.numCallsStarted, 0), - NumCallsFinished: atomic.SwapInt64(&s.numCallsFinished, 0), - NumCallsFinishedWithClientFailedToSend: atomic.SwapInt64(&s.numCallsFinishedWithClientFailedToSend, 0), - NumCallsFinishedKnownReceived: atomic.SwapInt64(&s.numCallsFinishedKnownReceived, 0), - } - s.mu.Lock() - dropped := s.numCallsDropped - s.numCallsDropped = make(map[string]int64) - s.mu.Unlock() - for token, count := range dropped { - stats.CallsFinishedWithDrop = append(stats.CallsFinishedWithDrop, &lbpb.ClientStatsPerToken{ - LoadBalanceToken: token, - NumCalls: count, - }) - } - return stats -} - -func (s *rpcStats) drop(token string) { - atomic.AddInt64(&s.numCallsStarted, 1) - s.mu.Lock() - s.numCallsDropped[token]++ - s.mu.Unlock() - atomic.AddInt64(&s.numCallsFinished, 1) -} - -func (s *rpcStats) failedToSend() { - atomic.AddInt64(&s.numCallsStarted, 1) - atomic.AddInt64(&s.numCallsFinishedWithClientFailedToSend, 1) - atomic.AddInt64(&s.numCallsFinished, 1) -} - -func (s *rpcStats) knownReceived() { - atomic.AddInt64(&s.numCallsStarted, 1) - atomic.AddInt64(&s.numCallsFinishedKnownReceived, 1) - atomic.AddInt64(&s.numCallsFinished, 1) -} - -type errPicker struct { - // Pick always returns this err. - err error -} - -func (p *errPicker) Pick(balancer.PickInfo) (balancer.PickResult, error) { - return balancer.PickResult{}, p.err -} - -// rrPicker does roundrobin on subConns. It's typically used when there's no -// response from remote balancer, and grpclb falls back to the resolved -// backends. -// -// It guaranteed that len(subConns) > 0. -type rrPicker struct { - mu sync.Mutex - subConns []balancer.SubConn // The subConns that were READY when taking the snapshot. - subConnsNext int -} - -func newRRPicker(readySCs []balancer.SubConn) *rrPicker { - return &rrPicker{ - subConns: readySCs, - subConnsNext: grpcrand.Intn(len(readySCs)), - } -} - -func (p *rrPicker) Pick(balancer.PickInfo) (balancer.PickResult, error) { - p.mu.Lock() - defer p.mu.Unlock() - sc := p.subConns[p.subConnsNext] - p.subConnsNext = (p.subConnsNext + 1) % len(p.subConns) - return balancer.PickResult{SubConn: sc}, nil -} - -// lbPicker does two layers of picks: -// -// First layer: roundrobin on all servers in serverList, including drops and backends. -// - If it picks a drop, the RPC will fail as being dropped. -// - If it picks a backend, do a second layer pick to pick the real backend. -// -// Second layer: roundrobin on all READY backends. -// -// It's guaranteed that len(serverList) > 0. -type lbPicker struct { - mu sync.Mutex - serverList []*lbpb.Server - serverListNext int - subConns []balancer.SubConn // The subConns that were READY when taking the snapshot. - subConnsNext int - - stats *rpcStats -} - -func newLBPicker(serverList []*lbpb.Server, readySCs []balancer.SubConn, stats *rpcStats) *lbPicker { - return &lbPicker{ - serverList: serverList, - subConns: readySCs, - subConnsNext: grpcrand.Intn(len(readySCs)), - stats: stats, - } -} - -func (p *lbPicker) Pick(balancer.PickInfo) (balancer.PickResult, error) { - p.mu.Lock() - defer p.mu.Unlock() - - // Layer one roundrobin on serverList. - s := p.serverList[p.serverListNext] - p.serverListNext = (p.serverListNext + 1) % len(p.serverList) - - // If it's a drop, return an error and fail the RPC. - if s.Drop { - p.stats.drop(s.LoadBalanceToken) - return balancer.PickResult{}, status.Errorf(codes.Unavailable, "request dropped by grpclb") - } - - // If not a drop but there's no ready subConns. - if len(p.subConns) <= 0 { - return balancer.PickResult{}, balancer.ErrNoSubConnAvailable - } - - // Return the next ready subConn in the list, also collect rpc stats. - sc := p.subConns[p.subConnsNext] - p.subConnsNext = (p.subConnsNext + 1) % len(p.subConns) - done := func(info balancer.DoneInfo) { - if !info.BytesSent { - p.stats.failedToSend() - } else if info.BytesReceived { - p.stats.knownReceived() - } - } - return balancer.PickResult{SubConn: sc, Done: done}, nil -} - -func (p *lbPicker) updateReadySCs(readySCs []balancer.SubConn) { - p.mu.Lock() - defer p.mu.Unlock() - - p.subConns = readySCs - p.subConnsNext = p.subConnsNext % len(readySCs) -} diff --git a/vendor/google.golang.org/grpc/balancer/grpclb/grpclb_remote_balancer.go b/vendor/google.golang.org/grpc/balancer/grpclb/grpclb_remote_balancer.go deleted file mode 100644 index ecaa1e7878..0000000000 --- a/vendor/google.golang.org/grpc/balancer/grpclb/grpclb_remote_balancer.go +++ /dev/null @@ -1,409 +0,0 @@ -/* - * - * Copyright 2017 gRPC 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 grpclb - -import ( - "context" - "fmt" - "io" - "net" - "sync" - "time" - - "github.com/golang/protobuf/proto" - timestamppb "github.com/golang/protobuf/ptypes/timestamp" - "github.com/google/go-cmp/cmp" - "google.golang.org/grpc" - "google.golang.org/grpc/balancer" - lbpb "google.golang.org/grpc/balancer/grpclb/grpc_lb_v1" - "google.golang.org/grpc/connectivity" - "google.golang.org/grpc/grpclog" - "google.golang.org/grpc/internal" - "google.golang.org/grpc/internal/backoff" - "google.golang.org/grpc/internal/channelz" - "google.golang.org/grpc/keepalive" - "google.golang.org/grpc/metadata" - "google.golang.org/grpc/resolver" -) - -// processServerList updates balaner's internal state, create/remove SubConns -// and regenerates picker using the received serverList. -func (lb *lbBalancer) processServerList(l *lbpb.ServerList) { - if grpclog.V(2) { - grpclog.Infof("lbBalancer: processing server list: %+v", l) - } - lb.mu.Lock() - defer lb.mu.Unlock() - - // Set serverListReceived to true so fallback will not take effect if it has - // not hit timeout. - lb.serverListReceived = true - - // If the new server list == old server list, do nothing. - if cmp.Equal(lb.fullServerList, l.Servers, cmp.Comparer(proto.Equal)) { - if grpclog.V(2) { - grpclog.Infof("lbBalancer: new serverlist same as the previous one, ignoring") - } - return - } - lb.fullServerList = l.Servers - - var backendAddrs []resolver.Address - for i, s := range l.Servers { - if s.Drop { - continue - } - - md := metadata.Pairs(lbTokenKey, s.LoadBalanceToken) - ip := net.IP(s.IpAddress) - ipStr := ip.String() - if ip.To4() == nil { - // Add square brackets to ipv6 addresses, otherwise net.Dial() and - // net.SplitHostPort() will return too many colons error. - ipStr = fmt.Sprintf("[%s]", ipStr) - } - addr := resolver.Address{ - Addr: fmt.Sprintf("%s:%d", ipStr, s.Port), - Metadata: &md, - } - if grpclog.V(2) { - grpclog.Infof("lbBalancer: server list entry[%d]: ipStr:|%s|, port:|%d|, load balancer token:|%v|", - i, ipStr, s.Port, s.LoadBalanceToken) - } - backendAddrs = append(backendAddrs, addr) - } - - // Call refreshSubConns to create/remove SubConns. If we are in fallback, - // this is also exiting fallback. - lb.refreshSubConns(backendAddrs, false, lb.usePickFirst) -} - -// refreshSubConns creates/removes SubConns with backendAddrs, and refreshes -// balancer state and picker. -// -// Caller must hold lb.mu. -func (lb *lbBalancer) refreshSubConns(backendAddrs []resolver.Address, fallback bool, pickFirst bool) { - opts := balancer.NewSubConnOptions{} - if !fallback { - opts.CredsBundle = lb.grpclbBackendCreds - } - - lb.backendAddrs = backendAddrs - lb.backendAddrsWithoutMetadata = nil - - fallbackModeChanged := lb.inFallback != fallback - lb.inFallback = fallback - if fallbackModeChanged && lb.inFallback { - // Clear previous received list when entering fallback, so if the server - // comes back and sends the same list again, the new addresses will be - // used. - lb.fullServerList = nil - } - - balancingPolicyChanged := lb.usePickFirst != pickFirst - oldUsePickFirst := lb.usePickFirst - lb.usePickFirst = pickFirst - - if fallbackModeChanged || balancingPolicyChanged { - // Remove all SubConns when switching balancing policy or switching - // fallback mode. - // - // For fallback mode switching with pickfirst, we want to recreate the - // SubConn because the creds could be different. - for a, sc := range lb.subConns { - if oldUsePickFirst { - // If old SubConn were created for pickfirst, bypass cache and - // remove directly. - lb.cc.cc.RemoveSubConn(sc) - } else { - lb.cc.RemoveSubConn(sc) - } - delete(lb.subConns, a) - } - } - - if lb.usePickFirst { - var sc balancer.SubConn - for _, sc = range lb.subConns { - break - } - if sc != nil { - sc.UpdateAddresses(backendAddrs) - sc.Connect() - return - } - // This bypasses the cc wrapper with SubConn cache. - sc, err := lb.cc.cc.NewSubConn(backendAddrs, opts) - if err != nil { - grpclog.Warningf("grpclb: failed to create new SubConn: %v", err) - return - } - sc.Connect() - lb.subConns[backendAddrs[0]] = sc - lb.scStates[sc] = connectivity.Idle - return - } - - // addrsSet is the set converted from backendAddrsWithoutMetadata, it's used to quick - // lookup for an address. - addrsSet := make(map[resolver.Address]struct{}) - // Create new SubConns. - for _, addr := range backendAddrs { - addrWithoutMD := addr - addrWithoutMD.Metadata = nil - addrsSet[addrWithoutMD] = struct{}{} - lb.backendAddrsWithoutMetadata = append(lb.backendAddrsWithoutMetadata, addrWithoutMD) - - if _, ok := lb.subConns[addrWithoutMD]; !ok { - // Use addrWithMD to create the SubConn. - sc, err := lb.cc.NewSubConn([]resolver.Address{addr}, opts) - if err != nil { - grpclog.Warningf("grpclb: failed to create new SubConn: %v", err) - continue - } - lb.subConns[addrWithoutMD] = sc // Use the addr without MD as key for the map. - if _, ok := lb.scStates[sc]; !ok { - // Only set state of new sc to IDLE. The state could already be - // READY for cached SubConns. - lb.scStates[sc] = connectivity.Idle - } - sc.Connect() - } - } - - for a, sc := range lb.subConns { - // a was removed by resolver. - if _, ok := addrsSet[a]; !ok { - lb.cc.RemoveSubConn(sc) - delete(lb.subConns, a) - // Keep the state of this sc in b.scStates until sc's state becomes Shutdown. - // The entry will be deleted in HandleSubConnStateChange. - } - } - - // Regenerate and update picker after refreshing subconns because with - // cache, even if SubConn was newed/removed, there might be no state - // changes (the subconn will be kept in cache, not actually - // newed/removed). - lb.updateStateAndPicker(true, true) -} - -type remoteBalancerCCWrapper struct { - cc *grpc.ClientConn - lb *lbBalancer - backoff backoff.Strategy - done chan struct{} - - // waitgroup to wait for all goroutines to exit. - wg sync.WaitGroup -} - -func (lb *lbBalancer) newRemoteBalancerCCWrapper() { - var dopts []grpc.DialOption - if creds := lb.opt.DialCreds; creds != nil { - dopts = append(dopts, grpc.WithTransportCredentials(creds)) - } else if bundle := lb.grpclbClientConnCreds; bundle != nil { - dopts = append(dopts, grpc.WithCredentialsBundle(bundle)) - } else { - dopts = append(dopts, grpc.WithInsecure()) - } - if lb.opt.Dialer != nil { - dopts = append(dopts, grpc.WithContextDialer(lb.opt.Dialer)) - } - // Explicitly set pickfirst as the balancer. - dopts = append(dopts, grpc.WithDefaultServiceConfig(`{"loadBalancingPolicy":"pick_first"}`)) - wrb := internal.WithResolverBuilder.(func(resolver.Builder) grpc.DialOption) - dopts = append(dopts, wrb(lb.manualResolver)) - if channelz.IsOn() { - dopts = append(dopts, grpc.WithChannelzParentID(lb.opt.ChannelzParentID)) - } - - // Enable Keepalive for grpclb client. - dopts = append(dopts, grpc.WithKeepaliveParams(keepalive.ClientParameters{ - Time: 20 * time.Second, - Timeout: 10 * time.Second, - PermitWithoutStream: true, - })) - - // The dial target is not important. - // - // The grpclb server addresses will set field ServerName, and creds will - // receive ServerName as authority. - cc, err := grpc.DialContext(context.Background(), "grpclb.subClientConn", dopts...) - if err != nil { - grpclog.Fatalf("failed to dial: %v", err) - } - ccw := &remoteBalancerCCWrapper{ - cc: cc, - lb: lb, - backoff: lb.backoff, - done: make(chan struct{}), - } - lb.ccRemoteLB = ccw - ccw.wg.Add(1) - go ccw.watchRemoteBalancer() -} - -// close closed the ClientConn to remote balancer, and waits until all -// goroutines to finish. -func (ccw *remoteBalancerCCWrapper) close() { - close(ccw.done) - ccw.cc.Close() - ccw.wg.Wait() -} - -func (ccw *remoteBalancerCCWrapper) readServerList(s *balanceLoadClientStream) error { - for { - reply, err := s.Recv() - if err != nil { - if err == io.EOF { - return errServerTerminatedConnection - } - return fmt.Errorf("grpclb: failed to recv server list: %v", err) - } - if serverList := reply.GetServerList(); serverList != nil { - ccw.lb.processServerList(serverList) - } - } -} - -func (ccw *remoteBalancerCCWrapper) sendLoadReport(s *balanceLoadClientStream, interval time.Duration) { - ticker := time.NewTicker(interval) - defer ticker.Stop() - lastZero := false - for { - select { - case <-ticker.C: - case <-s.Context().Done(): - return - } - stats := ccw.lb.clientStats.toClientStats() - zero := isZeroStats(stats) - if zero && lastZero { - // Quash redundant empty load reports. - continue - } - lastZero = zero - t := time.Now() - stats.Timestamp = ×tamppb.Timestamp{ - Seconds: t.Unix(), - Nanos: int32(t.Nanosecond()), - } - if err := s.Send(&lbpb.LoadBalanceRequest{ - LoadBalanceRequestType: &lbpb.LoadBalanceRequest_ClientStats{ - ClientStats: stats, - }, - }); err != nil { - return - } - } -} - -func (ccw *remoteBalancerCCWrapper) callRemoteBalancer() (backoff bool, _ error) { - lbClient := &loadBalancerClient{cc: ccw.cc} - ctx, cancel := context.WithCancel(context.Background()) - defer cancel() - stream, err := lbClient.BalanceLoad(ctx, grpc.WaitForReady(true)) - if err != nil { - return true, fmt.Errorf("grpclb: failed to perform RPC to the remote balancer %v", err) - } - ccw.lb.mu.Lock() - ccw.lb.remoteBalancerConnected = true - ccw.lb.mu.Unlock() - - // grpclb handshake on the stream. - initReq := &lbpb.LoadBalanceRequest{ - LoadBalanceRequestType: &lbpb.LoadBalanceRequest_InitialRequest{ - InitialRequest: &lbpb.InitialLoadBalanceRequest{ - Name: ccw.lb.target, - }, - }, - } - if err := stream.Send(initReq); err != nil { - return true, fmt.Errorf("grpclb: failed to send init request: %v", err) - } - reply, err := stream.Recv() - if err != nil { - return true, fmt.Errorf("grpclb: failed to recv init response: %v", err) - } - initResp := reply.GetInitialResponse() - if initResp == nil { - return true, fmt.Errorf("grpclb: reply from remote balancer did not include initial response") - } - if initResp.LoadBalancerDelegate != "" { - return true, fmt.Errorf("grpclb: Delegation is not supported") - } - - ccw.wg.Add(1) - go func() { - defer ccw.wg.Done() - if d := convertDuration(initResp.ClientStatsReportInterval); d > 0 { - ccw.sendLoadReport(stream, d) - } - }() - // No backoff if init req/resp handshake was successful. - return false, ccw.readServerList(stream) -} - -func (ccw *remoteBalancerCCWrapper) watchRemoteBalancer() { - defer ccw.wg.Done() - var retryCount int - for { - doBackoff, err := ccw.callRemoteBalancer() - select { - case <-ccw.done: - return - default: - if err != nil { - if err == errServerTerminatedConnection { - grpclog.Info(err) - } else { - grpclog.Warning(err) - } - } - } - // Trigger a re-resolve when the stream errors. - ccw.lb.cc.cc.ResolveNow(resolver.ResolveNowOptions{}) - - ccw.lb.mu.Lock() - ccw.lb.remoteBalancerConnected = false - ccw.lb.fullServerList = nil - // Enter fallback when connection to remote balancer is lost, and the - // aggregated state is not Ready. - if !ccw.lb.inFallback && ccw.lb.state != connectivity.Ready { - // Entering fallback. - ccw.lb.refreshSubConns(ccw.lb.resolvedBackendAddrs, true, ccw.lb.usePickFirst) - } - ccw.lb.mu.Unlock() - - if !doBackoff { - retryCount = 0 - continue - } - - timer := time.NewTimer(ccw.backoff.Backoff(retryCount)) // Copy backoff - select { - case <-timer.C: - case <-ccw.done: - timer.Stop() - return - } - retryCount++ - } -} diff --git a/vendor/google.golang.org/grpc/balancer/grpclb/grpclb_util.go b/vendor/google.golang.org/grpc/balancer/grpclb/grpclb_util.go deleted file mode 100644 index 636725e541..0000000000 --- a/vendor/google.golang.org/grpc/balancer/grpclb/grpclb_util.go +++ /dev/null @@ -1,208 +0,0 @@ -/* - * - * Copyright 2016 gRPC 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 grpclb - -import ( - "fmt" - "sync" - "time" - - "google.golang.org/grpc/balancer" - "google.golang.org/grpc/resolver" -) - -// The parent ClientConn should re-resolve when grpclb loses connection to the -// remote balancer. When the ClientConn inside grpclb gets a TransientFailure, -// it calls lbManualResolver.ResolveNow(), which calls parent ClientConn's -// ResolveNow, and eventually results in re-resolve happening in parent -// ClientConn's resolver (DNS for example). -// -// parent -// ClientConn -// +-----------------------------------------------------------------+ -// | parent +---------------------------------+ | -// | DNS ClientConn | grpclb | | -// | resolver balancerWrapper | | | -// | + + | grpclb grpclb | | -// | | | | ManualResolver ClientConn | | -// | | | | + + | | -// | | | | | | Transient | | -// | | | | | | Failure | | -// | | | | | <--------- | | | -// | | | <--------------- | ResolveNow | | | -// | | <--------- | ResolveNow | | | | | -// | | ResolveNow | | | | | | -// | | | | | | | | -// | + + | + + | | -// | +---------------------------------+ | -// +-----------------------------------------------------------------+ - -// lbManualResolver is used by the ClientConn inside grpclb. It's a manual -// resolver with a special ResolveNow() function. -// -// When ResolveNow() is called, it calls ResolveNow() on the parent ClientConn, -// so when grpclb client lose contact with remote balancers, the parent -// ClientConn's resolver will re-resolve. -type lbManualResolver struct { - scheme string - ccr resolver.ClientConn - - ccb balancer.ClientConn -} - -func (r *lbManualResolver) Build(_ resolver.Target, cc resolver.ClientConn, _ resolver.BuildOptions) (resolver.Resolver, error) { - r.ccr = cc - return r, nil -} - -func (r *lbManualResolver) Scheme() string { - return r.scheme -} - -// ResolveNow calls resolveNow on the parent ClientConn. -func (r *lbManualResolver) ResolveNow(o resolver.ResolveNowOptions) { - r.ccb.ResolveNow(o) -} - -// Close is a noop for Resolver. -func (*lbManualResolver) Close() {} - -// UpdateState calls cc.UpdateState. -func (r *lbManualResolver) UpdateState(s resolver.State) { - r.ccr.UpdateState(s) -} - -const subConnCacheTime = time.Second * 10 - -// lbCacheClientConn is a wrapper balancer.ClientConn with a SubConn cache. -// SubConns will be kept in cache for subConnCacheTime before being removed. -// -// Its new and remove methods are updated to do cache first. -type lbCacheClientConn struct { - cc balancer.ClientConn - timeout time.Duration - - mu sync.Mutex - // subConnCache only keeps subConns that are being deleted. - subConnCache map[resolver.Address]*subConnCacheEntry - subConnToAddr map[balancer.SubConn]resolver.Address -} - -type subConnCacheEntry struct { - sc balancer.SubConn - - cancel func() - abortDeleting bool -} - -func newLBCacheClientConn(cc balancer.ClientConn) *lbCacheClientConn { - return &lbCacheClientConn{ - cc: cc, - timeout: subConnCacheTime, - subConnCache: make(map[resolver.Address]*subConnCacheEntry), - subConnToAddr: make(map[balancer.SubConn]resolver.Address), - } -} - -func (ccc *lbCacheClientConn) NewSubConn(addrs []resolver.Address, opts balancer.NewSubConnOptions) (balancer.SubConn, error) { - if len(addrs) != 1 { - return nil, fmt.Errorf("grpclb calling NewSubConn with addrs of length %v", len(addrs)) - } - addrWithoutMD := addrs[0] - addrWithoutMD.Metadata = nil - - ccc.mu.Lock() - defer ccc.mu.Unlock() - if entry, ok := ccc.subConnCache[addrWithoutMD]; ok { - // If entry is in subConnCache, the SubConn was being deleted. - // cancel function will never be nil. - entry.cancel() - delete(ccc.subConnCache, addrWithoutMD) - return entry.sc, nil - } - - scNew, err := ccc.cc.NewSubConn(addrs, opts) - if err != nil { - return nil, err - } - - ccc.subConnToAddr[scNew] = addrWithoutMD - return scNew, nil -} - -func (ccc *lbCacheClientConn) RemoveSubConn(sc balancer.SubConn) { - ccc.mu.Lock() - defer ccc.mu.Unlock() - addr, ok := ccc.subConnToAddr[sc] - if !ok { - return - } - - if entry, ok := ccc.subConnCache[addr]; ok { - if entry.sc != sc { - // This could happen if NewSubConn was called multiple times for the - // same address, and those SubConns are all removed. We remove sc - // immediately here. - delete(ccc.subConnToAddr, sc) - ccc.cc.RemoveSubConn(sc) - } - return - } - - entry := &subConnCacheEntry{ - sc: sc, - } - ccc.subConnCache[addr] = entry - - timer := time.AfterFunc(ccc.timeout, func() { - ccc.mu.Lock() - defer ccc.mu.Unlock() - if entry.abortDeleting { - return - } - ccc.cc.RemoveSubConn(sc) - delete(ccc.subConnToAddr, sc) - delete(ccc.subConnCache, addr) - }) - entry.cancel = func() { - if !timer.Stop() { - // If stop was not successful, the timer has fired (this can only - // happen in a race). But the deleting function is blocked on ccc.mu - // because the mutex was held by the caller of this function. - // - // Set abortDeleting to true to abort the deleting function. When - // the lock is released, the deleting function will acquire the - // lock, check the value of abortDeleting and return. - entry.abortDeleting = true - } - } -} - -func (ccc *lbCacheClientConn) UpdateState(s balancer.State) { - ccc.cc.UpdateState(s) -} - -func (ccc *lbCacheClientConn) close() { - ccc.mu.Lock() - // Only cancel all existing timers. There's no need to remove SubConns. - for _, entry := range ccc.subConnCache { - entry.cancel() - } - ccc.mu.Unlock() -} diff --git a/vendor/google.golang.org/grpc/balancer/grpclb/regenerate.sh b/vendor/google.golang.org/grpc/balancer/grpclb/regenerate.sh deleted file mode 100644 index b8978e11b3..0000000000 --- a/vendor/google.golang.org/grpc/balancer/grpclb/regenerate.sh +++ /dev/null @@ -1,33 +0,0 @@ -#!/bin/bash -# Copyright 2018 gRPC 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. - -set -eux -o pipefail - -TMP=$(mktemp -d) - -function finish { - rm -rf "$TMP" -} -trap finish EXIT - -pushd "$TMP" -mkdir -p grpc/lb/v1 -curl https://raw.githubusercontent.com/grpc/grpc-proto/master/grpc/lb/v1/load_balancer.proto > grpc/lb/v1/load_balancer.proto - -protoc --go_out=plugins=grpc,paths=source_relative:. -I. grpc/lb/v1/*.proto -popd -rm -f grpc_lb_v1/*.pb.go -cp "$TMP"/grpc/lb/v1/*.pb.go grpc_lb_v1/ - diff --git a/vendor/google.golang.org/grpc/credentials/alts/alts.go b/vendor/google.golang.org/grpc/credentials/alts/alts.go deleted file mode 100644 index 72c7f0b23f..0000000000 --- a/vendor/google.golang.org/grpc/credentials/alts/alts.go +++ /dev/null @@ -1,330 +0,0 @@ -/* - * - * Copyright 2018 gRPC 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 alts implements the ALTS credential support by gRPC library, which -// encapsulates all the state needed by a client to authenticate with a server -// using ALTS and make various assertions, e.g., about the client's identity, -// role, or whether it is authorized to make a particular call. -// This package is experimental. -package alts - -import ( - "context" - "errors" - "fmt" - "net" - "sync" - "time" - - "google.golang.org/grpc/credentials" - core "google.golang.org/grpc/credentials/alts/internal" - "google.golang.org/grpc/credentials/alts/internal/handshaker" - "google.golang.org/grpc/credentials/alts/internal/handshaker/service" - altspb "google.golang.org/grpc/credentials/alts/internal/proto/grpc_gcp" - "google.golang.org/grpc/grpclog" -) - -const ( - // hypervisorHandshakerServiceAddress represents the default ALTS gRPC - // handshaker service address in the hypervisor. - hypervisorHandshakerServiceAddress = "metadata.google.internal:8080" - // defaultTimeout specifies the server handshake timeout. - defaultTimeout = 30.0 * time.Second - // The following constants specify the minimum and maximum acceptable - // protocol versions. - protocolVersionMaxMajor = 2 - protocolVersionMaxMinor = 1 - protocolVersionMinMajor = 2 - protocolVersionMinMinor = 1 -) - -var ( - once sync.Once - maxRPCVersion = &altspb.RpcProtocolVersions_Version{ - Major: protocolVersionMaxMajor, - Minor: protocolVersionMaxMinor, - } - minRPCVersion = &altspb.RpcProtocolVersions_Version{ - Major: protocolVersionMinMajor, - Minor: protocolVersionMinMinor, - } - // ErrUntrustedPlatform is returned from ClientHandshake and - // ServerHandshake is running on a platform where the trustworthiness of - // the handshaker service is not guaranteed. - ErrUntrustedPlatform = errors.New("ALTS: untrusted platform. ALTS is only supported on GCP") -) - -// AuthInfo exposes security information from the ALTS handshake to the -// application. This interface is to be implemented by ALTS. Users should not -// need a brand new implementation of this interface. For situations like -// testing, any new implementation should embed this interface. This allows -// ALTS to add new methods to this interface. -type AuthInfo interface { - // ApplicationProtocol returns application protocol negotiated for the - // ALTS connection. - ApplicationProtocol() string - // RecordProtocol returns the record protocol negotiated for the ALTS - // connection. - RecordProtocol() string - // SecurityLevel returns the security level of the created ALTS secure - // channel. - SecurityLevel() altspb.SecurityLevel - // PeerServiceAccount returns the peer service account. - PeerServiceAccount() string - // LocalServiceAccount returns the local service account. - LocalServiceAccount() string - // PeerRPCVersions returns the RPC version supported by the peer. - PeerRPCVersions() *altspb.RpcProtocolVersions -} - -// ClientOptions contains the client-side options of an ALTS channel. These -// options will be passed to the underlying ALTS handshaker. -type ClientOptions struct { - // TargetServiceAccounts contains a list of expected target service - // accounts. - TargetServiceAccounts []string - // HandshakerServiceAddress represents the ALTS handshaker gRPC service - // address to connect to. - HandshakerServiceAddress string -} - -// DefaultClientOptions creates a new ClientOptions object with the default -// values. -func DefaultClientOptions() *ClientOptions { - return &ClientOptions{ - HandshakerServiceAddress: hypervisorHandshakerServiceAddress, - } -} - -// ServerOptions contains the server-side options of an ALTS channel. These -// options will be passed to the underlying ALTS handshaker. -type ServerOptions struct { - // HandshakerServiceAddress represents the ALTS handshaker gRPC service - // address to connect to. - HandshakerServiceAddress string -} - -// DefaultServerOptions creates a new ServerOptions object with the default -// values. -func DefaultServerOptions() *ServerOptions { - return &ServerOptions{ - HandshakerServiceAddress: hypervisorHandshakerServiceAddress, - } -} - -// altsTC is the credentials required for authenticating a connection using ALTS. -// It implements credentials.TransportCredentials interface. -type altsTC struct { - info *credentials.ProtocolInfo - side core.Side - accounts []string - hsAddress string -} - -// NewClientCreds constructs a client-side ALTS TransportCredentials object. -func NewClientCreds(opts *ClientOptions) credentials.TransportCredentials { - return newALTS(core.ClientSide, opts.TargetServiceAccounts, opts.HandshakerServiceAddress) -} - -// NewServerCreds constructs a server-side ALTS TransportCredentials object. -func NewServerCreds(opts *ServerOptions) credentials.TransportCredentials { - return newALTS(core.ServerSide, nil, opts.HandshakerServiceAddress) -} - -func newALTS(side core.Side, accounts []string, hsAddress string) credentials.TransportCredentials { - once.Do(func() { - vmOnGCP = isRunningOnGCP() - }) - - if hsAddress == "" { - hsAddress = hypervisorHandshakerServiceAddress - } - return &altsTC{ - info: &credentials.ProtocolInfo{ - SecurityProtocol: "alts", - SecurityVersion: "1.0", - }, - side: side, - accounts: accounts, - hsAddress: hsAddress, - } -} - -// ClientHandshake implements the client side handshake protocol. -func (g *altsTC) ClientHandshake(ctx context.Context, addr string, rawConn net.Conn) (_ net.Conn, _ credentials.AuthInfo, err error) { - if !vmOnGCP { - return nil, nil, ErrUntrustedPlatform - } - - // Connecting to ALTS handshaker service. - hsConn, err := service.Dial(g.hsAddress) - if err != nil { - return nil, nil, err - } - // Do not close hsConn since it is shared with other handshakes. - - // Possible context leak: - // The cancel function for the child context we create will only be - // called a non-nil error is returned. - var cancel context.CancelFunc - ctx, cancel = context.WithCancel(ctx) - defer func() { - if err != nil { - cancel() - } - }() - - opts := handshaker.DefaultClientHandshakerOptions() - opts.TargetName = addr - opts.TargetServiceAccounts = g.accounts - opts.RPCVersions = &altspb.RpcProtocolVersions{ - MaxRpcVersion: maxRPCVersion, - MinRpcVersion: minRPCVersion, - } - chs, err := handshaker.NewClientHandshaker(ctx, hsConn, rawConn, opts) - if err != nil { - return nil, nil, err - } - defer func() { - if err != nil { - chs.Close() - } - }() - secConn, authInfo, err := chs.ClientHandshake(ctx) - if err != nil { - return nil, nil, err - } - altsAuthInfo, ok := authInfo.(AuthInfo) - if !ok { - return nil, nil, errors.New("client-side auth info is not of type alts.AuthInfo") - } - match, _ := checkRPCVersions(opts.RPCVersions, altsAuthInfo.PeerRPCVersions()) - if !match { - return nil, nil, fmt.Errorf("server-side RPC versions are not compatible with this client, local versions: %v, peer versions: %v", opts.RPCVersions, altsAuthInfo.PeerRPCVersions()) - } - return secConn, authInfo, nil -} - -// ServerHandshake implements the server side ALTS handshaker. -func (g *altsTC) ServerHandshake(rawConn net.Conn) (_ net.Conn, _ credentials.AuthInfo, err error) { - if !vmOnGCP { - return nil, nil, ErrUntrustedPlatform - } - // Connecting to ALTS handshaker service. - hsConn, err := service.Dial(g.hsAddress) - if err != nil { - return nil, nil, err - } - // Do not close hsConn since it's shared with other handshakes. - - ctx, cancel := context.WithTimeout(context.Background(), defaultTimeout) - defer cancel() - opts := handshaker.DefaultServerHandshakerOptions() - opts.RPCVersions = &altspb.RpcProtocolVersions{ - MaxRpcVersion: maxRPCVersion, - MinRpcVersion: minRPCVersion, - } - shs, err := handshaker.NewServerHandshaker(ctx, hsConn, rawConn, opts) - if err != nil { - return nil, nil, err - } - defer func() { - if err != nil { - shs.Close() - } - }() - secConn, authInfo, err := shs.ServerHandshake(ctx) - if err != nil { - return nil, nil, err - } - altsAuthInfo, ok := authInfo.(AuthInfo) - if !ok { - return nil, nil, errors.New("server-side auth info is not of type alts.AuthInfo") - } - match, _ := checkRPCVersions(opts.RPCVersions, altsAuthInfo.PeerRPCVersions()) - if !match { - return nil, nil, fmt.Errorf("client-side RPC versions is not compatible with this server, local versions: %v, peer versions: %v", opts.RPCVersions, altsAuthInfo.PeerRPCVersions()) - } - return secConn, authInfo, nil -} - -func (g *altsTC) Info() credentials.ProtocolInfo { - return *g.info -} - -func (g *altsTC) Clone() credentials.TransportCredentials { - info := *g.info - var accounts []string - if g.accounts != nil { - accounts = make([]string, len(g.accounts)) - copy(accounts, g.accounts) - } - return &altsTC{ - info: &info, - side: g.side, - hsAddress: g.hsAddress, - accounts: accounts, - } -} - -func (g *altsTC) OverrideServerName(serverNameOverride string) error { - g.info.ServerName = serverNameOverride - return nil -} - -// compareRPCVersion returns 0 if v1 == v2, 1 if v1 > v2 and -1 if v1 < v2. -func compareRPCVersions(v1, v2 *altspb.RpcProtocolVersions_Version) int { - switch { - case v1.GetMajor() > v2.GetMajor(), - v1.GetMajor() == v2.GetMajor() && v1.GetMinor() > v2.GetMinor(): - return 1 - case v1.GetMajor() < v2.GetMajor(), - v1.GetMajor() == v2.GetMajor() && v1.GetMinor() < v2.GetMinor(): - return -1 - } - return 0 -} - -// checkRPCVersions performs a version check between local and peer rpc protocol -// versions. This function returns true if the check passes which means both -// parties agreed on a common rpc protocol to use, and false otherwise. The -// function also returns the highest common RPC protocol version both parties -// agreed on. -func checkRPCVersions(local, peer *altspb.RpcProtocolVersions) (bool, *altspb.RpcProtocolVersions_Version) { - if local == nil || peer == nil { - grpclog.Error("invalid checkRPCVersions argument, either local or peer is nil.") - return false, nil - } - - // maxCommonVersion is MIN(local.max, peer.max). - maxCommonVersion := local.GetMaxRpcVersion() - if compareRPCVersions(local.GetMaxRpcVersion(), peer.GetMaxRpcVersion()) > 0 { - maxCommonVersion = peer.GetMaxRpcVersion() - } - - // minCommonVersion is MAX(local.min, peer.min). - minCommonVersion := peer.GetMinRpcVersion() - if compareRPCVersions(local.GetMinRpcVersion(), peer.GetMinRpcVersion()) > 0 { - minCommonVersion = local.GetMinRpcVersion() - } - - if compareRPCVersions(maxCommonVersion, minCommonVersion) < 0 { - return false, nil - } - return true, maxCommonVersion -} diff --git a/vendor/google.golang.org/grpc/credentials/alts/internal/authinfo/authinfo.go b/vendor/google.golang.org/grpc/credentials/alts/internal/authinfo/authinfo.go deleted file mode 100644 index ed628dc7cd..0000000000 --- a/vendor/google.golang.org/grpc/credentials/alts/internal/authinfo/authinfo.go +++ /dev/null @@ -1,87 +0,0 @@ -/* - * - * Copyright 2018 gRPC 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 authinfo provide authentication information returned by handshakers. -package authinfo - -import ( - "google.golang.org/grpc/credentials" - altspb "google.golang.org/grpc/credentials/alts/internal/proto/grpc_gcp" -) - -var _ credentials.AuthInfo = (*altsAuthInfo)(nil) - -// altsAuthInfo exposes security information from the ALTS handshake to the -// application. altsAuthInfo is immutable and implements credentials.AuthInfo. -type altsAuthInfo struct { - p *altspb.AltsContext -} - -// New returns a new altsAuthInfo object given handshaker results. -func New(result *altspb.HandshakerResult) credentials.AuthInfo { - return newAuthInfo(result) -} - -func newAuthInfo(result *altspb.HandshakerResult) *altsAuthInfo { - return &altsAuthInfo{ - p: &altspb.AltsContext{ - ApplicationProtocol: result.GetApplicationProtocol(), - RecordProtocol: result.GetRecordProtocol(), - // TODO: assign security level from result. - SecurityLevel: altspb.SecurityLevel_INTEGRITY_AND_PRIVACY, - PeerServiceAccount: result.GetPeerIdentity().GetServiceAccount(), - LocalServiceAccount: result.GetLocalIdentity().GetServiceAccount(), - PeerRpcVersions: result.GetPeerRpcVersions(), - }, - } -} - -// AuthType identifies the context as providing ALTS authentication information. -func (s *altsAuthInfo) AuthType() string { - return "alts" -} - -// ApplicationProtocol returns the context's application protocol. -func (s *altsAuthInfo) ApplicationProtocol() string { - return s.p.GetApplicationProtocol() -} - -// RecordProtocol returns the context's record protocol. -func (s *altsAuthInfo) RecordProtocol() string { - return s.p.GetRecordProtocol() -} - -// SecurityLevel returns the context's security level. -func (s *altsAuthInfo) SecurityLevel() altspb.SecurityLevel { - return s.p.GetSecurityLevel() -} - -// PeerServiceAccount returns the context's peer service account. -func (s *altsAuthInfo) PeerServiceAccount() string { - return s.p.GetPeerServiceAccount() -} - -// LocalServiceAccount returns the context's local service account. -func (s *altsAuthInfo) LocalServiceAccount() string { - return s.p.GetLocalServiceAccount() -} - -// PeerRPCVersions returns the context's peer RPC versions. -func (s *altsAuthInfo) PeerRPCVersions() *altspb.RpcProtocolVersions { - return s.p.GetPeerRpcVersions() -} diff --git a/vendor/google.golang.org/grpc/credentials/alts/internal/common.go b/vendor/google.golang.org/grpc/credentials/alts/internal/common.go deleted file mode 100644 index 33fba81239..0000000000 --- a/vendor/google.golang.org/grpc/credentials/alts/internal/common.go +++ /dev/null @@ -1,69 +0,0 @@ -/* - * - * Copyright 2018 gRPC 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. - * - */ - -//go:generate ./regenerate.sh - -// Package internal contains common core functionality for ALTS. -package internal - -import ( - "context" - "net" - - "google.golang.org/grpc/credentials" -) - -const ( - // ClientSide identifies the client in this communication. - ClientSide Side = iota - // ServerSide identifies the server in this communication. - ServerSide -) - -// PeerNotRespondingError is returned when a peer server is not responding -// after a channel has been established. It is treated as a temporary connection -// error and re-connection to the server should be attempted. -var PeerNotRespondingError = &peerNotRespondingError{} - -// Side identifies the party's role: client or server. -type Side int - -type peerNotRespondingError struct{} - -// Return an error message for the purpose of logging. -func (e *peerNotRespondingError) Error() string { - return "peer server is not responding and re-connection should be attempted." -} - -// Temporary indicates if this connection error is temporary or fatal. -func (e *peerNotRespondingError) Temporary() bool { - return true -} - -// Handshaker defines a ALTS handshaker interface. -type Handshaker interface { - // ClientHandshake starts and completes a client-side handshaking and - // returns a secure connection and corresponding auth information. - ClientHandshake(ctx context.Context) (net.Conn, credentials.AuthInfo, error) - // ServerHandshake starts and completes a server-side handshaking and - // returns a secure connection and corresponding auth information. - ServerHandshake(ctx context.Context) (net.Conn, credentials.AuthInfo, error) - // Close terminates the Handshaker. It should be called when the caller - // obtains the secure connection. - Close() -} diff --git a/vendor/google.golang.org/grpc/credentials/alts/internal/conn/aeadrekey.go b/vendor/google.golang.org/grpc/credentials/alts/internal/conn/aeadrekey.go deleted file mode 100644 index 43726e877b..0000000000 --- a/vendor/google.golang.org/grpc/credentials/alts/internal/conn/aeadrekey.go +++ /dev/null @@ -1,131 +0,0 @@ -/* - * - * Copyright 2018 gRPC 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 conn - -import ( - "bytes" - "crypto/aes" - "crypto/cipher" - "crypto/hmac" - "crypto/sha256" - "encoding/binary" - "fmt" - "strconv" -) - -// rekeyAEAD holds the necessary information for an AEAD based on -// AES-GCM that performs nonce-based key derivation and XORs the -// nonce with a random mask. -type rekeyAEAD struct { - kdfKey []byte - kdfCounter []byte - nonceMask []byte - nonceBuf []byte - gcmAEAD cipher.AEAD -} - -// KeySizeError signals that the given key does not have the correct size. -type KeySizeError int - -func (k KeySizeError) Error() string { - return "alts/conn: invalid key size " + strconv.Itoa(int(k)) -} - -// newRekeyAEAD creates a new instance of aes128gcm with rekeying. -// The key argument should be 44 bytes, the first 32 bytes are used as a key -// for HKDF-expand and the remainining 12 bytes are used as a random mask for -// the counter. -func newRekeyAEAD(key []byte) (*rekeyAEAD, error) { - k := len(key) - if k != kdfKeyLen+nonceLen { - return nil, KeySizeError(k) - } - return &rekeyAEAD{ - kdfKey: key[:kdfKeyLen], - kdfCounter: make([]byte, kdfCounterLen), - nonceMask: key[kdfKeyLen:], - nonceBuf: make([]byte, nonceLen), - gcmAEAD: nil, - }, nil -} - -// Seal rekeys if nonce[2:8] is different than in the last call, masks the nonce, -// and calls Seal for aes128gcm. -func (s *rekeyAEAD) Seal(dst, nonce, plaintext, additionalData []byte) []byte { - if err := s.rekeyIfRequired(nonce); err != nil { - panic(fmt.Sprintf("Rekeying failed with: %s", err.Error())) - } - maskNonce(s.nonceBuf, nonce, s.nonceMask) - return s.gcmAEAD.Seal(dst, s.nonceBuf, plaintext, additionalData) -} - -// Open rekeys if nonce[2:8] is different than in the last call, masks the nonce, -// and calls Open for aes128gcm. -func (s *rekeyAEAD) Open(dst, nonce, ciphertext, additionalData []byte) ([]byte, error) { - if err := s.rekeyIfRequired(nonce); err != nil { - return nil, err - } - maskNonce(s.nonceBuf, nonce, s.nonceMask) - return s.gcmAEAD.Open(dst, s.nonceBuf, ciphertext, additionalData) -} - -// rekeyIfRequired creates a new aes128gcm AEAD if the existing AEAD is nil -// or cannot be used with given nonce. -func (s *rekeyAEAD) rekeyIfRequired(nonce []byte) error { - newKdfCounter := nonce[kdfCounterOffset : kdfCounterOffset+kdfCounterLen] - if s.gcmAEAD != nil && bytes.Equal(newKdfCounter, s.kdfCounter) { - return nil - } - copy(s.kdfCounter, newKdfCounter) - a, err := aes.NewCipher(hkdfExpand(s.kdfKey, s.kdfCounter)) - if err != nil { - return err - } - s.gcmAEAD, err = cipher.NewGCM(a) - return err -} - -// maskNonce XORs the given nonce with the mask and stores the result in dst. -func maskNonce(dst, nonce, mask []byte) { - nonce1 := binary.LittleEndian.Uint64(nonce[:sizeUint64]) - nonce2 := binary.LittleEndian.Uint32(nonce[sizeUint64:]) - mask1 := binary.LittleEndian.Uint64(mask[:sizeUint64]) - mask2 := binary.LittleEndian.Uint32(mask[sizeUint64:]) - binary.LittleEndian.PutUint64(dst[:sizeUint64], nonce1^mask1) - binary.LittleEndian.PutUint32(dst[sizeUint64:], nonce2^mask2) -} - -// NonceSize returns the required nonce size. -func (s *rekeyAEAD) NonceSize() int { - return s.gcmAEAD.NonceSize() -} - -// Overhead returns the ciphertext overhead. -func (s *rekeyAEAD) Overhead() int { - return s.gcmAEAD.Overhead() -} - -// hkdfExpand computes the first 16 bytes of the HKDF-expand function -// defined in RFC5869. -func hkdfExpand(key, info []byte) []byte { - mac := hmac.New(sha256.New, key) - mac.Write(info) - mac.Write([]byte{0x01}[:]) - return mac.Sum(nil)[:aeadKeyLen] -} diff --git a/vendor/google.golang.org/grpc/credentials/alts/internal/conn/aes128gcm.go b/vendor/google.golang.org/grpc/credentials/alts/internal/conn/aes128gcm.go deleted file mode 100644 index 04e0adb6c9..0000000000 --- a/vendor/google.golang.org/grpc/credentials/alts/internal/conn/aes128gcm.go +++ /dev/null @@ -1,105 +0,0 @@ -/* - * - * Copyright 2018 gRPC 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 conn - -import ( - "crypto/aes" - "crypto/cipher" - - core "google.golang.org/grpc/credentials/alts/internal" -) - -const ( - // Overflow length n in bytes, never encrypt more than 2^(n*8) frames (in - // each direction). - overflowLenAES128GCM = 5 -) - -// aes128gcm is the struct that holds necessary information for ALTS record. -// The counter value is NOT included in the payload during the encryption and -// decryption operations. -type aes128gcm struct { - // inCounter is used in ALTS record to check that incoming counters are - // as expected, since ALTS record guarantees that messages are unwrapped - // in the same order that the peer wrapped them. - inCounter Counter - outCounter Counter - aead cipher.AEAD -} - -// NewAES128GCM creates an instance that uses aes128gcm for ALTS record. -func NewAES128GCM(side core.Side, key []byte) (ALTSRecordCrypto, error) { - c, err := aes.NewCipher(key) - if err != nil { - return nil, err - } - a, err := cipher.NewGCM(c) - if err != nil { - return nil, err - } - return &aes128gcm{ - inCounter: NewInCounter(side, overflowLenAES128GCM), - outCounter: NewOutCounter(side, overflowLenAES128GCM), - aead: a, - }, nil -} - -// Encrypt is the encryption function. dst can contain bytes at the beginning of -// the ciphertext that will not be encrypted but will be authenticated. If dst -// has enough capacity to hold these bytes, the ciphertext and the tag, no -// allocation and copy operations will be performed. dst and plaintext do not -// overlap. -func (s *aes128gcm) Encrypt(dst, plaintext []byte) ([]byte, error) { - // If we need to allocate an output buffer, we want to include space for - // GCM tag to avoid forcing ALTS record to reallocate as well. - dlen := len(dst) - dst, out := SliceForAppend(dst, len(plaintext)+GcmTagSize) - seq, err := s.outCounter.Value() - if err != nil { - return nil, err - } - data := out[:len(plaintext)] - copy(data, plaintext) // data may alias plaintext - - // Seal appends the ciphertext and the tag to its first argument and - // returns the updated slice. However, SliceForAppend above ensures that - // dst has enough capacity to avoid a reallocation and copy due to the - // append. - dst = s.aead.Seal(dst[:dlen], seq, data, nil) - s.outCounter.Inc() - return dst, nil -} - -func (s *aes128gcm) EncryptionOverhead() int { - return GcmTagSize -} - -func (s *aes128gcm) Decrypt(dst, ciphertext []byte) ([]byte, error) { - seq, err := s.inCounter.Value() - if err != nil { - return nil, err - } - // If dst is equal to ciphertext[:0], ciphertext storage is reused. - plaintext, err := s.aead.Open(dst, seq, ciphertext, nil) - if err != nil { - return nil, ErrAuth - } - s.inCounter.Inc() - return plaintext, nil -} diff --git a/vendor/google.golang.org/grpc/credentials/alts/internal/conn/aes128gcmrekey.go b/vendor/google.golang.org/grpc/credentials/alts/internal/conn/aes128gcmrekey.go deleted file mode 100644 index 6a9035ea25..0000000000 --- a/vendor/google.golang.org/grpc/credentials/alts/internal/conn/aes128gcmrekey.go +++ /dev/null @@ -1,116 +0,0 @@ -/* - * - * Copyright 2018 gRPC 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 conn - -import ( - "crypto/cipher" - - core "google.golang.org/grpc/credentials/alts/internal" -) - -const ( - // Overflow length n in bytes, never encrypt more than 2^(n*8) frames (in - // each direction). - overflowLenAES128GCMRekey = 8 - nonceLen = 12 - aeadKeyLen = 16 - kdfKeyLen = 32 - kdfCounterOffset = 2 - kdfCounterLen = 6 - sizeUint64 = 8 -) - -// aes128gcmRekey is the struct that holds necessary information for ALTS record. -// The counter value is NOT included in the payload during the encryption and -// decryption operations. -type aes128gcmRekey struct { - // inCounter is used in ALTS record to check that incoming counters are - // as expected, since ALTS record guarantees that messages are unwrapped - // in the same order that the peer wrapped them. - inCounter Counter - outCounter Counter - inAEAD cipher.AEAD - outAEAD cipher.AEAD -} - -// NewAES128GCMRekey creates an instance that uses aes128gcm with rekeying -// for ALTS record. The key argument should be 44 bytes, the first 32 bytes -// are used as a key for HKDF-expand and the remainining 12 bytes are used -// as a random mask for the counter. -func NewAES128GCMRekey(side core.Side, key []byte) (ALTSRecordCrypto, error) { - inCounter := NewInCounter(side, overflowLenAES128GCMRekey) - outCounter := NewOutCounter(side, overflowLenAES128GCMRekey) - inAEAD, err := newRekeyAEAD(key) - if err != nil { - return nil, err - } - outAEAD, err := newRekeyAEAD(key) - if err != nil { - return nil, err - } - return &aes128gcmRekey{ - inCounter, - outCounter, - inAEAD, - outAEAD, - }, nil -} - -// Encrypt is the encryption function. dst can contain bytes at the beginning of -// the ciphertext that will not be encrypted but will be authenticated. If dst -// has enough capacity to hold these bytes, the ciphertext and the tag, no -// allocation and copy operations will be performed. dst and plaintext do not -// overlap. -func (s *aes128gcmRekey) Encrypt(dst, plaintext []byte) ([]byte, error) { - // If we need to allocate an output buffer, we want to include space for - // GCM tag to avoid forcing ALTS record to reallocate as well. - dlen := len(dst) - dst, out := SliceForAppend(dst, len(plaintext)+GcmTagSize) - seq, err := s.outCounter.Value() - if err != nil { - return nil, err - } - data := out[:len(plaintext)] - copy(data, plaintext) // data may alias plaintext - - // Seal appends the ciphertext and the tag to its first argument and - // returns the updated slice. However, SliceForAppend above ensures that - // dst has enough capacity to avoid a reallocation and copy due to the - // append. - dst = s.outAEAD.Seal(dst[:dlen], seq, data, nil) - s.outCounter.Inc() - return dst, nil -} - -func (s *aes128gcmRekey) EncryptionOverhead() int { - return GcmTagSize -} - -func (s *aes128gcmRekey) Decrypt(dst, ciphertext []byte) ([]byte, error) { - seq, err := s.inCounter.Value() - if err != nil { - return nil, err - } - plaintext, err := s.inAEAD.Open(dst, seq, ciphertext, nil) - if err != nil { - return nil, ErrAuth - } - s.inCounter.Inc() - return plaintext, nil -} diff --git a/vendor/google.golang.org/grpc/credentials/alts/internal/conn/common.go b/vendor/google.golang.org/grpc/credentials/alts/internal/conn/common.go deleted file mode 100644 index 1795d0c9e3..0000000000 --- a/vendor/google.golang.org/grpc/credentials/alts/internal/conn/common.go +++ /dev/null @@ -1,70 +0,0 @@ -/* - * - * Copyright 2018 gRPC 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 conn - -import ( - "encoding/binary" - "errors" - "fmt" -) - -const ( - // GcmTagSize is the GCM tag size is the difference in length between - // plaintext and ciphertext. From crypto/cipher/gcm.go in Go crypto - // library. - GcmTagSize = 16 -) - -// ErrAuth occurs on authentication failure. -var ErrAuth = errors.New("message authentication failed") - -// SliceForAppend takes a slice and a requested number of bytes. It returns a -// slice with the contents of the given slice followed by that many bytes and a -// second slice that aliases into it and contains only the extra bytes. If the -// original slice has sufficient capacity then no allocation is performed. -func SliceForAppend(in []byte, n int) (head, tail []byte) { - if total := len(in) + n; cap(in) >= total { - head = in[:total] - } else { - head = make([]byte, total) - copy(head, in) - } - tail = head[len(in):] - return head, tail -} - -// ParseFramedMsg parse the provided buffer and returns a frame of the format -// msgLength+msg and any remaining bytes in that buffer. -func ParseFramedMsg(b []byte, maxLen uint32) ([]byte, []byte, error) { - // If the size field is not complete, return the provided buffer as - // remaining buffer. - if len(b) < MsgLenFieldSize { - return nil, b, nil - } - msgLenField := b[:MsgLenFieldSize] - length := binary.LittleEndian.Uint32(msgLenField) - if length > maxLen { - return nil, nil, fmt.Errorf("received the frame length %d larger than the limit %d", length, maxLen) - } - if len(b) < int(length)+4 { // account for the first 4 msg length bytes. - // Frame is not complete yet. - return nil, b, nil - } - return b[:MsgLenFieldSize+length], b[MsgLenFieldSize+length:], nil -} diff --git a/vendor/google.golang.org/grpc/credentials/alts/internal/conn/counter.go b/vendor/google.golang.org/grpc/credentials/alts/internal/conn/counter.go deleted file mode 100644 index 9f00aca0b6..0000000000 --- a/vendor/google.golang.org/grpc/credentials/alts/internal/conn/counter.go +++ /dev/null @@ -1,62 +0,0 @@ -/* - * - * Copyright 2018 gRPC 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 conn - -import ( - "errors" -) - -const counterLen = 12 - -var ( - errInvalidCounter = errors.New("invalid counter") -) - -// Counter is a 96-bit, little-endian counter. -type Counter struct { - value [counterLen]byte - invalid bool - overflowLen int -} - -// Value returns the current value of the counter as a byte slice. -func (c *Counter) Value() ([]byte, error) { - if c.invalid { - return nil, errInvalidCounter - } - return c.value[:], nil -} - -// Inc increments the counter and checks for overflow. -func (c *Counter) Inc() { - // If the counter is already invalid, there is no need to increase it. - if c.invalid { - return - } - i := 0 - for ; i < c.overflowLen; i++ { - c.value[i]++ - if c.value[i] != 0 { - break - } - } - if i == c.overflowLen { - c.invalid = true - } -} diff --git a/vendor/google.golang.org/grpc/credentials/alts/internal/conn/record.go b/vendor/google.golang.org/grpc/credentials/alts/internal/conn/record.go deleted file mode 100644 index fd5a53d9a7..0000000000 --- a/vendor/google.golang.org/grpc/credentials/alts/internal/conn/record.go +++ /dev/null @@ -1,271 +0,0 @@ -/* - * - * Copyright 2018 gRPC 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 conn contains an implementation of a secure channel created by gRPC -// handshakers. -package conn - -import ( - "encoding/binary" - "fmt" - "math" - "net" - - core "google.golang.org/grpc/credentials/alts/internal" -) - -// ALTSRecordCrypto is the interface for gRPC ALTS record protocol. -type ALTSRecordCrypto interface { - // Encrypt encrypts the plaintext and computes the tag (if any) of dst - // and plaintext, dst and plaintext do not overlap. - Encrypt(dst, plaintext []byte) ([]byte, error) - // EncryptionOverhead returns the tag size (if any) in bytes. - EncryptionOverhead() int - // Decrypt decrypts ciphertext and verify the tag (if any). dst and - // ciphertext may alias exactly or not at all. To reuse ciphertext's - // storage for the decrypted output, use ciphertext[:0] as dst. - Decrypt(dst, ciphertext []byte) ([]byte, error) -} - -// ALTSRecordFunc is a function type for factory functions that create -// ALTSRecordCrypto instances. -type ALTSRecordFunc func(s core.Side, keyData []byte) (ALTSRecordCrypto, error) - -const ( - // MsgLenFieldSize is the byte size of the frame length field of a - // framed message. - MsgLenFieldSize = 4 - // The byte size of the message type field of a framed message. - msgTypeFieldSize = 4 - // The bytes size limit for a ALTS record message. - altsRecordLengthLimit = 1024 * 1024 // 1 MiB - // The default bytes size of a ALTS record message. - altsRecordDefaultLength = 4 * 1024 // 4KiB - // Message type value included in ALTS record framing. - altsRecordMsgType = uint32(0x06) - // The initial write buffer size. - altsWriteBufferInitialSize = 32 * 1024 // 32KiB - // The maximum write buffer size. This *must* be multiple of - // altsRecordDefaultLength. - altsWriteBufferMaxSize = 512 * 1024 // 512KiB -) - -var ( - protocols = make(map[string]ALTSRecordFunc) -) - -// RegisterProtocol register a ALTS record encryption protocol. -func RegisterProtocol(protocol string, f ALTSRecordFunc) error { - if _, ok := protocols[protocol]; ok { - return fmt.Errorf("protocol %v is already registered", protocol) - } - protocols[protocol] = f - return nil -} - -// conn represents a secured connection. It implements the net.Conn interface. -type conn struct { - net.Conn - crypto ALTSRecordCrypto - // buf holds data that has been read from the connection and decrypted, - // but has not yet been returned by Read. - buf []byte - payloadLengthLimit int - // protected holds data read from the network but have not yet been - // decrypted. This data might not compose a complete frame. - protected []byte - // writeBuf is a buffer used to contain encrypted frames before being - // written to the network. - writeBuf []byte - // nextFrame stores the next frame (in protected buffer) info. - nextFrame []byte - // overhead is the calculated overhead of each frame. - overhead int -} - -// NewConn creates a new secure channel instance given the other party role and -// handshaking result. -func NewConn(c net.Conn, side core.Side, recordProtocol string, key []byte, protected []byte) (net.Conn, error) { - newCrypto := protocols[recordProtocol] - if newCrypto == nil { - return nil, fmt.Errorf("negotiated unknown next_protocol %q", recordProtocol) - } - crypto, err := newCrypto(side, key) - if err != nil { - return nil, fmt.Errorf("protocol %q: %v", recordProtocol, err) - } - overhead := MsgLenFieldSize + msgTypeFieldSize + crypto.EncryptionOverhead() - payloadLengthLimit := altsRecordDefaultLength - overhead - if protected == nil { - // We pre-allocate protected to be of size - // 2*altsRecordDefaultLength-1 during initialization. We only - // read from the network into protected when protected does not - // contain a complete frame, which is at most - // altsRecordDefaultLength-1 (bytes). And we read at most - // altsRecordDefaultLength (bytes) data into protected at one - // time. Therefore, 2*altsRecordDefaultLength-1 is large enough - // to buffer data read from the network. - protected = make([]byte, 0, 2*altsRecordDefaultLength-1) - } - - altsConn := &conn{ - Conn: c, - crypto: crypto, - payloadLengthLimit: payloadLengthLimit, - protected: protected, - writeBuf: make([]byte, altsWriteBufferInitialSize), - nextFrame: protected, - overhead: overhead, - } - return altsConn, nil -} - -// Read reads and decrypts a frame from the underlying connection, and copies the -// decrypted payload into b. If the size of the payload is greater than len(b), -// Read retains the remaining bytes in an internal buffer, and subsequent calls -// to Read will read from this buffer until it is exhausted. -func (p *conn) Read(b []byte) (n int, err error) { - if len(p.buf) == 0 { - var framedMsg []byte - framedMsg, p.nextFrame, err = ParseFramedMsg(p.nextFrame, altsRecordLengthLimit) - if err != nil { - return n, err - } - // Check whether the next frame to be decrypted has been - // completely received yet. - if len(framedMsg) == 0 { - copy(p.protected, p.nextFrame) - p.protected = p.protected[:len(p.nextFrame)] - // Always copy next incomplete frame to the beginning of - // the protected buffer and reset nextFrame to it. - p.nextFrame = p.protected - } - // Check whether a complete frame has been received yet. - for len(framedMsg) == 0 { - if len(p.protected) == cap(p.protected) { - tmp := make([]byte, len(p.protected), cap(p.protected)+altsRecordDefaultLength) - copy(tmp, p.protected) - p.protected = tmp - } - n, err = p.Conn.Read(p.protected[len(p.protected):min(cap(p.protected), len(p.protected)+altsRecordDefaultLength)]) - if err != nil { - return 0, err - } - p.protected = p.protected[:len(p.protected)+n] - framedMsg, p.nextFrame, err = ParseFramedMsg(p.protected, altsRecordLengthLimit) - if err != nil { - return 0, err - } - } - // Now we have a complete frame, decrypted it. - msg := framedMsg[MsgLenFieldSize:] - msgType := binary.LittleEndian.Uint32(msg[:msgTypeFieldSize]) - if msgType&0xff != altsRecordMsgType { - return 0, fmt.Errorf("received frame with incorrect message type %v, expected lower byte %v", - msgType, altsRecordMsgType) - } - ciphertext := msg[msgTypeFieldSize:] - - // Decrypt requires that if the dst and ciphertext alias, they - // must alias exactly. Code here used to use msg[:0], but msg - // starts MsgLenFieldSize+msgTypeFieldSize bytes earlier than - // ciphertext, so they alias inexactly. Using ciphertext[:0] - // arranges the appropriate aliasing without needing to copy - // ciphertext or use a separate destination buffer. For more info - // check: https://golang.org/pkg/crypto/cipher/#AEAD. - p.buf, err = p.crypto.Decrypt(ciphertext[:0], ciphertext) - if err != nil { - return 0, err - } - } - - n = copy(b, p.buf) - p.buf = p.buf[n:] - return n, nil -} - -// Write encrypts, frames, and writes bytes from b to the underlying connection. -func (p *conn) Write(b []byte) (n int, err error) { - n = len(b) - // Calculate the output buffer size with framing and encryption overhead. - numOfFrames := int(math.Ceil(float64(len(b)) / float64(p.payloadLengthLimit))) - size := len(b) + numOfFrames*p.overhead - // If writeBuf is too small, increase its size up to the maximum size. - partialBSize := len(b) - if size > altsWriteBufferMaxSize { - size = altsWriteBufferMaxSize - const numOfFramesInMaxWriteBuf = altsWriteBufferMaxSize / altsRecordDefaultLength - partialBSize = numOfFramesInMaxWriteBuf * p.payloadLengthLimit - } - if len(p.writeBuf) < size { - p.writeBuf = make([]byte, size) - } - - for partialBStart := 0; partialBStart < len(b); partialBStart += partialBSize { - partialBEnd := partialBStart + partialBSize - if partialBEnd > len(b) { - partialBEnd = len(b) - } - partialB := b[partialBStart:partialBEnd] - writeBufIndex := 0 - for len(partialB) > 0 { - payloadLen := len(partialB) - if payloadLen > p.payloadLengthLimit { - payloadLen = p.payloadLengthLimit - } - buf := partialB[:payloadLen] - partialB = partialB[payloadLen:] - - // Write buffer contains: length, type, payload, and tag - // if any. - - // 1. Fill in type field. - msg := p.writeBuf[writeBufIndex+MsgLenFieldSize:] - binary.LittleEndian.PutUint32(msg, altsRecordMsgType) - - // 2. Encrypt the payload and create a tag if any. - msg, err = p.crypto.Encrypt(msg[:msgTypeFieldSize], buf) - if err != nil { - return n, err - } - - // 3. Fill in the size field. - binary.LittleEndian.PutUint32(p.writeBuf[writeBufIndex:], uint32(len(msg))) - - // 4. Increase writeBufIndex. - writeBufIndex += len(buf) + p.overhead - } - nn, err := p.Conn.Write(p.writeBuf[:writeBufIndex]) - if err != nil { - // We need to calculate the actual data size that was - // written. This means we need to remove header, - // encryption overheads, and any partially-written - // frame data. - numOfWrittenFrames := int(math.Floor(float64(nn) / float64(altsRecordDefaultLength))) - return partialBStart + numOfWrittenFrames*p.payloadLengthLimit, err - } - } - return n, nil -} - -func min(a, b int) int { - if a < b { - return a - } - return b -} diff --git a/vendor/google.golang.org/grpc/credentials/alts/internal/conn/utils.go b/vendor/google.golang.org/grpc/credentials/alts/internal/conn/utils.go deleted file mode 100644 index 84821fa254..0000000000 --- a/vendor/google.golang.org/grpc/credentials/alts/internal/conn/utils.go +++ /dev/null @@ -1,63 +0,0 @@ -/* - * - * Copyright 2018 gRPC 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 conn - -import core "google.golang.org/grpc/credentials/alts/internal" - -// NewOutCounter returns an outgoing counter initialized to the starting sequence -// number for the client/server side of a connection. -func NewOutCounter(s core.Side, overflowLen int) (c Counter) { - c.overflowLen = overflowLen - if s == core.ServerSide { - // Server counters in ALTS record have the little-endian high bit - // set. - c.value[counterLen-1] = 0x80 - } - return -} - -// NewInCounter returns an incoming counter initialized to the starting sequence -// number for the client/server side of a connection. This is used in ALTS record -// to check that incoming counters are as expected, since ALTS record guarantees -// that messages are unwrapped in the same order that the peer wrapped them. -func NewInCounter(s core.Side, overflowLen int) (c Counter) { - c.overflowLen = overflowLen - if s == core.ClientSide { - // Server counters in ALTS record have the little-endian high bit - // set. - c.value[counterLen-1] = 0x80 - } - return -} - -// CounterFromValue creates a new counter given an initial value. -func CounterFromValue(value []byte, overflowLen int) (c Counter) { - c.overflowLen = overflowLen - copy(c.value[:], value) - return -} - -// CounterSide returns the connection side (client/server) a sequence counter is -// associated with. -func CounterSide(c []byte) core.Side { - if c[counterLen-1]&0x80 == 0x80 { - return core.ServerSide - } - return core.ClientSide -} diff --git a/vendor/google.golang.org/grpc/credentials/alts/internal/handshaker/handshaker.go b/vendor/google.golang.org/grpc/credentials/alts/internal/handshaker/handshaker.go deleted file mode 100644 index 8bc7ceee0a..0000000000 --- a/vendor/google.golang.org/grpc/credentials/alts/internal/handshaker/handshaker.go +++ /dev/null @@ -1,375 +0,0 @@ -/* - * - * Copyright 2018 gRPC 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 handshaker provides ALTS handshaking functionality for GCP. -package handshaker - -import ( - "context" - "errors" - "fmt" - "io" - "net" - "sync" - - grpc "google.golang.org/grpc" - "google.golang.org/grpc/codes" - "google.golang.org/grpc/credentials" - core "google.golang.org/grpc/credentials/alts/internal" - "google.golang.org/grpc/credentials/alts/internal/authinfo" - "google.golang.org/grpc/credentials/alts/internal/conn" - altsgrpc "google.golang.org/grpc/credentials/alts/internal/proto/grpc_gcp" - altspb "google.golang.org/grpc/credentials/alts/internal/proto/grpc_gcp" -) - -const ( - // The maximum byte size of receive frames. - frameLimit = 64 * 1024 // 64 KB - rekeyRecordProtocolName = "ALTSRP_GCM_AES128_REKEY" - // maxPendingHandshakes represents the maximum number of concurrent - // handshakes. - maxPendingHandshakes = 100 -) - -var ( - hsProtocol = altspb.HandshakeProtocol_ALTS - appProtocols = []string{"grpc"} - recordProtocols = []string{rekeyRecordProtocolName} - keyLength = map[string]int{ - rekeyRecordProtocolName: 44, - } - altsRecordFuncs = map[string]conn.ALTSRecordFunc{ - // ALTS handshaker protocols. - rekeyRecordProtocolName: func(s core.Side, keyData []byte) (conn.ALTSRecordCrypto, error) { - return conn.NewAES128GCMRekey(s, keyData) - }, - } - // control number of concurrent created (but not closed) handshakers. - mu sync.Mutex - concurrentHandshakes = int64(0) - // errDropped occurs when maxPendingHandshakes is reached. - errDropped = errors.New("maximum number of concurrent ALTS handshakes is reached") - // errOutOfBound occurs when the handshake service returns a consumed - // bytes value larger than the buffer that was passed to it originally. - errOutOfBound = errors.New("handshaker service consumed bytes value is out-of-bound") -) - -func init() { - for protocol, f := range altsRecordFuncs { - if err := conn.RegisterProtocol(protocol, f); err != nil { - panic(err) - } - } -} - -func acquire() bool { - mu.Lock() - // If we need n to be configurable, we can pass it as an argument. - n := int64(1) - success := maxPendingHandshakes-concurrentHandshakes >= n - if success { - concurrentHandshakes += n - } - mu.Unlock() - return success -} - -func release() { - mu.Lock() - // If we need n to be configurable, we can pass it as an argument. - n := int64(1) - concurrentHandshakes -= n - if concurrentHandshakes < 0 { - mu.Unlock() - panic("bad release") - } - mu.Unlock() -} - -// ClientHandshakerOptions contains the client handshaker options that can -// provided by the caller. -type ClientHandshakerOptions struct { - // ClientIdentity is the handshaker client local identity. - ClientIdentity *altspb.Identity - // TargetName is the server service account name for secure name - // checking. - TargetName string - // TargetServiceAccounts contains a list of expected target service - // accounts. One of these accounts should match one of the accounts in - // the handshaker results. Otherwise, the handshake fails. - TargetServiceAccounts []string - // RPCVersions specifies the gRPC versions accepted by the client. - RPCVersions *altspb.RpcProtocolVersions -} - -// ServerHandshakerOptions contains the server handshaker options that can -// provided by the caller. -type ServerHandshakerOptions struct { - // RPCVersions specifies the gRPC versions accepted by the server. - RPCVersions *altspb.RpcProtocolVersions -} - -// DefaultClientHandshakerOptions returns the default client handshaker options. -func DefaultClientHandshakerOptions() *ClientHandshakerOptions { - return &ClientHandshakerOptions{} -} - -// DefaultServerHandshakerOptions returns the default client handshaker options. -func DefaultServerHandshakerOptions() *ServerHandshakerOptions { - return &ServerHandshakerOptions{} -} - -// TODO: add support for future local and remote endpoint in both client options -// and server options (server options struct does not exist now. When -// caller can provide endpoints, it should be created. - -// altsHandshaker is used to complete a ALTS handshaking between client and -// server. This handshaker talks to the ALTS handshaker service in the metadata -// server. -type altsHandshaker struct { - // RPC stream used to access the ALTS Handshaker service. - stream altsgrpc.HandshakerService_DoHandshakeClient - // the connection to the peer. - conn net.Conn - // client handshake options. - clientOpts *ClientHandshakerOptions - // server handshake options. - serverOpts *ServerHandshakerOptions - // defines the side doing the handshake, client or server. - side core.Side -} - -// NewClientHandshaker creates a ALTS handshaker for GCP which contains an RPC -// stub created using the passed conn and used to talk to the ALTS Handshaker -// service in the metadata server. -func NewClientHandshaker(ctx context.Context, conn *grpc.ClientConn, c net.Conn, opts *ClientHandshakerOptions) (core.Handshaker, error) { - stream, err := altsgrpc.NewHandshakerServiceClient(conn).DoHandshake(ctx, grpc.WaitForReady(true)) - if err != nil { - return nil, err - } - return &altsHandshaker{ - stream: stream, - conn: c, - clientOpts: opts, - side: core.ClientSide, - }, nil -} - -// NewServerHandshaker creates a ALTS handshaker for GCP which contains an RPC -// stub created using the passed conn and used to talk to the ALTS Handshaker -// service in the metadata server. -func NewServerHandshaker(ctx context.Context, conn *grpc.ClientConn, c net.Conn, opts *ServerHandshakerOptions) (core.Handshaker, error) { - stream, err := altsgrpc.NewHandshakerServiceClient(conn).DoHandshake(ctx, grpc.WaitForReady(true)) - if err != nil { - return nil, err - } - return &altsHandshaker{ - stream: stream, - conn: c, - serverOpts: opts, - side: core.ServerSide, - }, nil -} - -// ClientHandshake starts and completes a client ALTS handshaking for GCP. Once -// done, ClientHandshake returns a secure connection. -func (h *altsHandshaker) ClientHandshake(ctx context.Context) (net.Conn, credentials.AuthInfo, error) { - if !acquire() { - return nil, nil, errDropped - } - defer release() - - if h.side != core.ClientSide { - return nil, nil, errors.New("only handshakers created using NewClientHandshaker can perform a client handshaker") - } - - // Create target identities from service account list. - targetIdentities := make([]*altspb.Identity, 0, len(h.clientOpts.TargetServiceAccounts)) - for _, account := range h.clientOpts.TargetServiceAccounts { - targetIdentities = append(targetIdentities, &altspb.Identity{ - IdentityOneof: &altspb.Identity_ServiceAccount{ - ServiceAccount: account, - }, - }) - } - req := &altspb.HandshakerReq{ - ReqOneof: &altspb.HandshakerReq_ClientStart{ - ClientStart: &altspb.StartClientHandshakeReq{ - HandshakeSecurityProtocol: hsProtocol, - ApplicationProtocols: appProtocols, - RecordProtocols: recordProtocols, - TargetIdentities: targetIdentities, - LocalIdentity: h.clientOpts.ClientIdentity, - TargetName: h.clientOpts.TargetName, - RpcVersions: h.clientOpts.RPCVersions, - }, - }, - } - - conn, result, err := h.doHandshake(req) - if err != nil { - return nil, nil, err - } - authInfo := authinfo.New(result) - return conn, authInfo, nil -} - -// ServerHandshake starts and completes a server ALTS handshaking for GCP. Once -// done, ServerHandshake returns a secure connection. -func (h *altsHandshaker) ServerHandshake(ctx context.Context) (net.Conn, credentials.AuthInfo, error) { - if !acquire() { - return nil, nil, errDropped - } - defer release() - - if h.side != core.ServerSide { - return nil, nil, errors.New("only handshakers created using NewServerHandshaker can perform a server handshaker") - } - - p := make([]byte, frameLimit) - n, err := h.conn.Read(p) - if err != nil { - return nil, nil, err - } - - // Prepare server parameters. - // TODO: currently only ALTS parameters are provided. Might need to use - // more options in the future. - params := make(map[int32]*altspb.ServerHandshakeParameters) - params[int32(altspb.HandshakeProtocol_ALTS)] = &altspb.ServerHandshakeParameters{ - RecordProtocols: recordProtocols, - } - req := &altspb.HandshakerReq{ - ReqOneof: &altspb.HandshakerReq_ServerStart{ - ServerStart: &altspb.StartServerHandshakeReq{ - ApplicationProtocols: appProtocols, - HandshakeParameters: params, - InBytes: p[:n], - RpcVersions: h.serverOpts.RPCVersions, - }, - }, - } - - conn, result, err := h.doHandshake(req) - if err != nil { - return nil, nil, err - } - authInfo := authinfo.New(result) - return conn, authInfo, nil -} - -func (h *altsHandshaker) doHandshake(req *altspb.HandshakerReq) (net.Conn, *altspb.HandshakerResult, error) { - resp, err := h.accessHandshakerService(req) - if err != nil { - return nil, nil, err - } - // Check of the returned status is an error. - if resp.GetStatus() != nil { - if got, want := resp.GetStatus().Code, uint32(codes.OK); got != want { - return nil, nil, fmt.Errorf("%v", resp.GetStatus().Details) - } - } - - var extra []byte - if req.GetServerStart() != nil { - if resp.GetBytesConsumed() > uint32(len(req.GetServerStart().GetInBytes())) { - return nil, nil, errOutOfBound - } - extra = req.GetServerStart().GetInBytes()[resp.GetBytesConsumed():] - } - result, extra, err := h.processUntilDone(resp, extra) - if err != nil { - return nil, nil, err - } - // The handshaker returns a 128 bytes key. It should be truncated based - // on the returned record protocol. - keyLen, ok := keyLength[result.RecordProtocol] - if !ok { - return nil, nil, fmt.Errorf("unknown resulted record protocol %v", result.RecordProtocol) - } - sc, err := conn.NewConn(h.conn, h.side, result.GetRecordProtocol(), result.KeyData[:keyLen], extra) - if err != nil { - return nil, nil, err - } - return sc, result, nil -} - -func (h *altsHandshaker) accessHandshakerService(req *altspb.HandshakerReq) (*altspb.HandshakerResp, error) { - if err := h.stream.Send(req); err != nil { - return nil, err - } - resp, err := h.stream.Recv() - if err != nil { - return nil, err - } - return resp, nil -} - -// processUntilDone processes the handshake until the handshaker service returns -// the results. Handshaker service takes care of frame parsing, so we read -// whatever received from the network and send it to the handshaker service. -func (h *altsHandshaker) processUntilDone(resp *altspb.HandshakerResp, extra []byte) (*altspb.HandshakerResult, []byte, error) { - for { - if len(resp.OutFrames) > 0 { - if _, err := h.conn.Write(resp.OutFrames); err != nil { - return nil, nil, err - } - } - if resp.Result != nil { - return resp.Result, extra, nil - } - buf := make([]byte, frameLimit) - n, err := h.conn.Read(buf) - if err != nil && err != io.EOF { - return nil, nil, err - } - // If there is nothing to send to the handshaker service, and - // nothing is received from the peer, then we are stuck. - // This covers the case when the peer is not responding. Note - // that handshaker service connection issues are caught in - // accessHandshakerService before we even get here. - if len(resp.OutFrames) == 0 && n == 0 { - return nil, nil, core.PeerNotRespondingError - } - // Append extra bytes from the previous interaction with the - // handshaker service with the current buffer read from conn. - p := append(extra, buf[:n]...) - // From here on, p and extra point to the same slice. - resp, err = h.accessHandshakerService(&altspb.HandshakerReq{ - ReqOneof: &altspb.HandshakerReq_Next{ - Next: &altspb.NextHandshakeMessageReq{ - InBytes: p, - }, - }, - }) - if err != nil { - return nil, nil, err - } - // Set extra based on handshaker service response. - if resp.GetBytesConsumed() > uint32(len(p)) { - return nil, nil, errOutOfBound - } - extra = p[resp.GetBytesConsumed():] - } -} - -// Close terminates the Handshaker. It should be called when the caller obtains -// the secure connection. -func (h *altsHandshaker) Close() { - h.stream.CloseSend() -} diff --git a/vendor/google.golang.org/grpc/credentials/alts/internal/handshaker/service/service.go b/vendor/google.golang.org/grpc/credentials/alts/internal/handshaker/service/service.go deleted file mode 100644 index 0c7b568354..0000000000 --- a/vendor/google.golang.org/grpc/credentials/alts/internal/handshaker/service/service.go +++ /dev/null @@ -1,54 +0,0 @@ -/* - * - * Copyright 2018 gRPC 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 service manages connections between the VM application and the ALTS -// handshaker service. -package service - -import ( - "sync" - - grpc "google.golang.org/grpc" -) - -var ( - // hsConn represents a connection to hypervisor handshaker service. - hsConn *grpc.ClientConn - mu sync.Mutex - // hsDialer will be reassigned in tests. - hsDialer = grpc.Dial -) - -// Dial dials the handshake service in the hypervisor. If a connection has -// already been established, this function returns it. Otherwise, a new -// connection is created. -func Dial(hsAddress string) (*grpc.ClientConn, error) { - mu.Lock() - defer mu.Unlock() - - if hsConn == nil { - // Create a new connection to the handshaker service. Note that - // this connection stays open until the application is closed. - var err error - hsConn, err = hsDialer(hsAddress, grpc.WithInsecure()) - if err != nil { - return nil, err - } - } - return hsConn, nil -} diff --git a/vendor/google.golang.org/grpc/credentials/alts/internal/proto/grpc_gcp/altscontext.pb.go b/vendor/google.golang.org/grpc/credentials/alts/internal/proto/grpc_gcp/altscontext.pb.go deleted file mode 100644 index 38c4832dfd..0000000000 --- a/vendor/google.golang.org/grpc/credentials/alts/internal/proto/grpc_gcp/altscontext.pb.go +++ /dev/null @@ -1,152 +0,0 @@ -// Code generated by protoc-gen-go. DO NOT EDIT. -// source: grpc/gcp/altscontext.proto - -package grpc_gcp - -import ( - fmt "fmt" - proto "github.com/golang/protobuf/proto" - 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.ProtoPackageIsVersion3 // please upgrade the proto package - -type AltsContext struct { - // The application protocol negotiated for this connection. - ApplicationProtocol string `protobuf:"bytes,1,opt,name=application_protocol,json=applicationProtocol,proto3" json:"application_protocol,omitempty"` - // The record protocol negotiated for this connection. - RecordProtocol string `protobuf:"bytes,2,opt,name=record_protocol,json=recordProtocol,proto3" json:"record_protocol,omitempty"` - // The security level of the created secure channel. - SecurityLevel SecurityLevel `protobuf:"varint,3,opt,name=security_level,json=securityLevel,proto3,enum=grpc.gcp.SecurityLevel" json:"security_level,omitempty"` - // The peer service account. - PeerServiceAccount string `protobuf:"bytes,4,opt,name=peer_service_account,json=peerServiceAccount,proto3" json:"peer_service_account,omitempty"` - // The local service account. - LocalServiceAccount string `protobuf:"bytes,5,opt,name=local_service_account,json=localServiceAccount,proto3" json:"local_service_account,omitempty"` - // The RPC protocol versions supported by the peer. - PeerRpcVersions *RpcProtocolVersions `protobuf:"bytes,6,opt,name=peer_rpc_versions,json=peerRpcVersions,proto3" json:"peer_rpc_versions,omitempty"` - // Additional attributes of the peer. - PeerAttributes map[string]string `protobuf:"bytes,7,rep,name=peer_attributes,json=peerAttributes,proto3" json:"peer_attributes,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *AltsContext) Reset() { *m = AltsContext{} } -func (m *AltsContext) String() string { return proto.CompactTextString(m) } -func (*AltsContext) ProtoMessage() {} -func (*AltsContext) Descriptor() ([]byte, []int) { - return fileDescriptor_6647a41e53a575a3, []int{0} -} - -func (m *AltsContext) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_AltsContext.Unmarshal(m, b) -} -func (m *AltsContext) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_AltsContext.Marshal(b, m, deterministic) -} -func (m *AltsContext) XXX_Merge(src proto.Message) { - xxx_messageInfo_AltsContext.Merge(m, src) -} -func (m *AltsContext) XXX_Size() int { - return xxx_messageInfo_AltsContext.Size(m) -} -func (m *AltsContext) XXX_DiscardUnknown() { - xxx_messageInfo_AltsContext.DiscardUnknown(m) -} - -var xxx_messageInfo_AltsContext proto.InternalMessageInfo - -func (m *AltsContext) GetApplicationProtocol() string { - if m != nil { - return m.ApplicationProtocol - } - return "" -} - -func (m *AltsContext) GetRecordProtocol() string { - if m != nil { - return m.RecordProtocol - } - return "" -} - -func (m *AltsContext) GetSecurityLevel() SecurityLevel { - if m != nil { - return m.SecurityLevel - } - return SecurityLevel_SECURITY_NONE -} - -func (m *AltsContext) GetPeerServiceAccount() string { - if m != nil { - return m.PeerServiceAccount - } - return "" -} - -func (m *AltsContext) GetLocalServiceAccount() string { - if m != nil { - return m.LocalServiceAccount - } - return "" -} - -func (m *AltsContext) GetPeerRpcVersions() *RpcProtocolVersions { - if m != nil { - return m.PeerRpcVersions - } - return nil -} - -func (m *AltsContext) GetPeerAttributes() map[string]string { - if m != nil { - return m.PeerAttributes - } - return nil -} - -func init() { - proto.RegisterType((*AltsContext)(nil), "grpc.gcp.AltsContext") - proto.RegisterMapType((map[string]string)(nil), "grpc.gcp.AltsContext.PeerAttributesEntry") -} - -func init() { proto.RegisterFile("grpc/gcp/altscontext.proto", fileDescriptor_6647a41e53a575a3) } - -var fileDescriptor_6647a41e53a575a3 = []byte{ - // 411 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x6c, 0x92, 0x4d, 0x6f, 0x13, 0x31, - 0x10, 0x86, 0xb5, 0x0d, 0x2d, 0xe0, 0x88, 0xb4, 0xb8, 0xa9, 0x58, 0x45, 0x42, 0x8a, 0xb8, 0xb0, - 0x5c, 0x76, 0x21, 0x5c, 0x10, 0x07, 0x50, 0x8a, 0x38, 0x20, 0x71, 0x88, 0xb6, 0x12, 0x07, 0x2e, - 0x2b, 0x77, 0x3a, 0xb2, 0x2c, 0x5c, 0x8f, 0x35, 0x76, 0x22, 0xf2, 0xb3, 0xf9, 0x07, 0x68, 0xed, - 0xcd, 0x07, 0x1f, 0xb7, 0x9d, 0x79, 0x9f, 0x19, 0xbf, 0xb3, 0x33, 0x62, 0xa6, 0xd9, 0x43, 0xa3, - 0xc1, 0x37, 0xca, 0xc6, 0x00, 0xe4, 0x22, 0xfe, 0x8c, 0xb5, 0x67, 0x8a, 0x24, 0x1f, 0xf5, 0x5a, - 0xad, 0xc1, 0xcf, 0xaa, 0x3d, 0x15, 0x59, 0xb9, 0xe0, 0x89, 0x63, 0x17, 0x10, 0xd6, 0x6c, 0xe2, - 0xb6, 0x03, 0xba, 0xbf, 0x27, 0x97, 0x6b, 0x5e, 0xfc, 0x1a, 0x89, 0xf1, 0xd2, 0xc6, 0xf0, 0x29, - 0x77, 0x92, 0x6f, 0xc4, 0x54, 0x79, 0x6f, 0x0d, 0xa8, 0x68, 0xc8, 0x75, 0x09, 0x02, 0xb2, 0x65, - 0x31, 0x2f, 0xaa, 0xc7, 0xed, 0xe5, 0x91, 0xb6, 0x1a, 0x24, 0xf9, 0x52, 0x9c, 0x33, 0x02, 0xf1, - 0xdd, 0x81, 0x3e, 0x49, 0xf4, 0x24, 0xa7, 0xf7, 0xe0, 0x07, 0x31, 0xd9, 0x9b, 0xb0, 0xb8, 0x41, - 0x5b, 0x8e, 0xe6, 0x45, 0x35, 0x59, 0x3c, 0xab, 0x77, 0xc6, 0xeb, 0x9b, 0x41, 0xff, 0xda, 0xcb, - 0xed, 0x93, 0x70, 0x1c, 0xca, 0xd7, 0x62, 0xea, 0x11, 0xb9, 0x0b, 0xc8, 0x1b, 0x03, 0xd8, 0x29, - 0x00, 0x5a, 0xbb, 0x58, 0x3e, 0x48, 0xaf, 0xc9, 0x5e, 0xbb, 0xc9, 0xd2, 0x32, 0x2b, 0x72, 0x21, - 0xae, 0x2c, 0x81, 0xb2, 0xff, 0x94, 0x9c, 0xe6, 0x71, 0x92, 0xf8, 0x57, 0xcd, 0x17, 0xf1, 0x34, - 0xbd, 0xc2, 0x1e, 0xba, 0x0d, 0x72, 0x30, 0xe4, 0x42, 0x79, 0x36, 0x2f, 0xaa, 0xf1, 0xe2, 0xf9, - 0xc1, 0x68, 0xeb, 0x61, 0x37, 0xd7, 0xb7, 0x01, 0x6a, 0xcf, 0xfb, 0xba, 0xd6, 0xc3, 0x2e, 0x21, - 0x5b, 0x91, 0x52, 0x9d, 0x8a, 0x91, 0xcd, 0xed, 0x3a, 0x62, 0x28, 0x1f, 0xce, 0x47, 0xd5, 0x78, - 0xf1, 0xea, 0xd0, 0xe8, 0xe8, 0xe7, 0xd7, 0x2b, 0x44, 0x5e, 0xee, 0xd9, 0xcf, 0x2e, 0xf2, 0xb6, - 0x9d, 0xf8, 0x3f, 0x92, 0xb3, 0xa5, 0xb8, 0xfc, 0x0f, 0x26, 0x2f, 0xc4, 0xe8, 0x07, 0x6e, 0x87, - 0x35, 0xf5, 0x9f, 0x72, 0x2a, 0x4e, 0x37, 0xca, 0xae, 0x71, 0x58, 0x46, 0x0e, 0xde, 0x9f, 0xbc, - 0x2b, 0xae, 0xad, 0xb8, 0x32, 0x94, 0x1d, 0xf4, 0x47, 0x54, 0x1b, 0x17, 0x91, 0x9d, 0xb2, 0xd7, - 0x17, 0x47, 0x66, 0xd2, 0x74, 0xab, 0xe2, 0xfb, 0x47, 0x4d, 0xa4, 0x2d, 0xd6, 0x9a, 0xac, 0x72, - 0xba, 0x26, 0xd6, 0x4d, 0x3a, 0x2e, 0x60, 0xbc, 0x43, 0x17, 0x8d, 0xb2, 0x21, 0x9d, 0x62, 0xb3, - 0xeb, 0xd2, 0xa4, 0x2b, 0x48, 0x50, 0xa7, 0xc1, 0xdf, 0x9e, 0xa5, 0xf8, 0xed, 0xef, 0x00, 0x00, - 0x00, 0xff, 0xff, 0x9b, 0x8c, 0xe4, 0x6a, 0xba, 0x02, 0x00, 0x00, -} diff --git a/vendor/google.golang.org/grpc/credentials/alts/internal/proto/grpc_gcp/handshaker.pb.go b/vendor/google.golang.org/grpc/credentials/alts/internal/proto/grpc_gcp/handshaker.pb.go deleted file mode 100644 index 4d1fc4c4d8..0000000000 --- a/vendor/google.golang.org/grpc/credentials/alts/internal/proto/grpc_gcp/handshaker.pb.go +++ /dev/null @@ -1,1105 +0,0 @@ -// Code generated by protoc-gen-go. DO NOT EDIT. -// source: grpc/gcp/handshaker.proto - -package grpc_gcp - -import ( - context "context" - fmt "fmt" - proto "github.com/golang/protobuf/proto" - grpc "google.golang.org/grpc" - codes "google.golang.org/grpc/codes" - status "google.golang.org/grpc/status" - 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.ProtoPackageIsVersion3 // please upgrade the proto package - -type HandshakeProtocol int32 - -const ( - // Default value. - HandshakeProtocol_HANDSHAKE_PROTOCOL_UNSPECIFIED HandshakeProtocol = 0 - // TLS handshake protocol. - HandshakeProtocol_TLS HandshakeProtocol = 1 - // Application Layer Transport Security handshake protocol. - HandshakeProtocol_ALTS HandshakeProtocol = 2 -) - -var HandshakeProtocol_name = map[int32]string{ - 0: "HANDSHAKE_PROTOCOL_UNSPECIFIED", - 1: "TLS", - 2: "ALTS", -} - -var HandshakeProtocol_value = map[string]int32{ - "HANDSHAKE_PROTOCOL_UNSPECIFIED": 0, - "TLS": 1, - "ALTS": 2, -} - -func (x HandshakeProtocol) String() string { - return proto.EnumName(HandshakeProtocol_name, int32(x)) -} - -func (HandshakeProtocol) EnumDescriptor() ([]byte, []int) { - return fileDescriptor_54c074f40c7c7e99, []int{0} -} - -type NetworkProtocol int32 - -const ( - NetworkProtocol_NETWORK_PROTOCOL_UNSPECIFIED NetworkProtocol = 0 - NetworkProtocol_TCP NetworkProtocol = 1 - NetworkProtocol_UDP NetworkProtocol = 2 -) - -var NetworkProtocol_name = map[int32]string{ - 0: "NETWORK_PROTOCOL_UNSPECIFIED", - 1: "TCP", - 2: "UDP", -} - -var NetworkProtocol_value = map[string]int32{ - "NETWORK_PROTOCOL_UNSPECIFIED": 0, - "TCP": 1, - "UDP": 2, -} - -func (x NetworkProtocol) String() string { - return proto.EnumName(NetworkProtocol_name, int32(x)) -} - -func (NetworkProtocol) EnumDescriptor() ([]byte, []int) { - return fileDescriptor_54c074f40c7c7e99, []int{1} -} - -type Endpoint struct { - // IP address. It should contain an IPv4 or IPv6 string literal, e.g. - // "192.168.0.1" or "2001:db8::1". - IpAddress string `protobuf:"bytes,1,opt,name=ip_address,json=ipAddress,proto3" json:"ip_address,omitempty"` - // Port number. - Port int32 `protobuf:"varint,2,opt,name=port,proto3" json:"port,omitempty"` - // Network protocol (e.g., TCP, UDP) associated with this endpoint. - Protocol NetworkProtocol `protobuf:"varint,3,opt,name=protocol,proto3,enum=grpc.gcp.NetworkProtocol" json:"protocol,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *Endpoint) Reset() { *m = Endpoint{} } -func (m *Endpoint) String() string { return proto.CompactTextString(m) } -func (*Endpoint) ProtoMessage() {} -func (*Endpoint) Descriptor() ([]byte, []int) { - return fileDescriptor_54c074f40c7c7e99, []int{0} -} - -func (m *Endpoint) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_Endpoint.Unmarshal(m, b) -} -func (m *Endpoint) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_Endpoint.Marshal(b, m, deterministic) -} -func (m *Endpoint) XXX_Merge(src proto.Message) { - xxx_messageInfo_Endpoint.Merge(m, src) -} -func (m *Endpoint) XXX_Size() int { - return xxx_messageInfo_Endpoint.Size(m) -} -func (m *Endpoint) XXX_DiscardUnknown() { - xxx_messageInfo_Endpoint.DiscardUnknown(m) -} - -var xxx_messageInfo_Endpoint proto.InternalMessageInfo - -func (m *Endpoint) GetIpAddress() string { - if m != nil { - return m.IpAddress - } - return "" -} - -func (m *Endpoint) GetPort() int32 { - if m != nil { - return m.Port - } - return 0 -} - -func (m *Endpoint) GetProtocol() NetworkProtocol { - if m != nil { - return m.Protocol - } - return NetworkProtocol_NETWORK_PROTOCOL_UNSPECIFIED -} - -type Identity struct { - // Types that are valid to be assigned to IdentityOneof: - // *Identity_ServiceAccount - // *Identity_Hostname - IdentityOneof isIdentity_IdentityOneof `protobuf_oneof:"identity_oneof"` - // Additional attributes of the identity. - Attributes map[string]string `protobuf:"bytes,3,rep,name=attributes,proto3" json:"attributes,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *Identity) Reset() { *m = Identity{} } -func (m *Identity) String() string { return proto.CompactTextString(m) } -func (*Identity) ProtoMessage() {} -func (*Identity) Descriptor() ([]byte, []int) { - return fileDescriptor_54c074f40c7c7e99, []int{1} -} - -func (m *Identity) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_Identity.Unmarshal(m, b) -} -func (m *Identity) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_Identity.Marshal(b, m, deterministic) -} -func (m *Identity) XXX_Merge(src proto.Message) { - xxx_messageInfo_Identity.Merge(m, src) -} -func (m *Identity) XXX_Size() int { - return xxx_messageInfo_Identity.Size(m) -} -func (m *Identity) XXX_DiscardUnknown() { - xxx_messageInfo_Identity.DiscardUnknown(m) -} - -var xxx_messageInfo_Identity proto.InternalMessageInfo - -type isIdentity_IdentityOneof interface { - isIdentity_IdentityOneof() -} - -type Identity_ServiceAccount struct { - ServiceAccount string `protobuf:"bytes,1,opt,name=service_account,json=serviceAccount,proto3,oneof"` -} - -type Identity_Hostname struct { - Hostname string `protobuf:"bytes,2,opt,name=hostname,proto3,oneof"` -} - -func (*Identity_ServiceAccount) isIdentity_IdentityOneof() {} - -func (*Identity_Hostname) isIdentity_IdentityOneof() {} - -func (m *Identity) GetIdentityOneof() isIdentity_IdentityOneof { - if m != nil { - return m.IdentityOneof - } - return nil -} - -func (m *Identity) GetServiceAccount() string { - if x, ok := m.GetIdentityOneof().(*Identity_ServiceAccount); ok { - return x.ServiceAccount - } - return "" -} - -func (m *Identity) GetHostname() string { - if x, ok := m.GetIdentityOneof().(*Identity_Hostname); ok { - return x.Hostname - } - return "" -} - -func (m *Identity) GetAttributes() map[string]string { - if m != nil { - return m.Attributes - } - return nil -} - -// XXX_OneofWrappers is for the internal use of the proto package. -func (*Identity) XXX_OneofWrappers() []interface{} { - return []interface{}{ - (*Identity_ServiceAccount)(nil), - (*Identity_Hostname)(nil), - } -} - -type StartClientHandshakeReq struct { - // Handshake security protocol requested by the client. - HandshakeSecurityProtocol HandshakeProtocol `protobuf:"varint,1,opt,name=handshake_security_protocol,json=handshakeSecurityProtocol,proto3,enum=grpc.gcp.HandshakeProtocol" json:"handshake_security_protocol,omitempty"` - // The application protocols supported by the client, e.g., "h2" (for http2), - // "grpc". - ApplicationProtocols []string `protobuf:"bytes,2,rep,name=application_protocols,json=applicationProtocols,proto3" json:"application_protocols,omitempty"` - // The record protocols supported by the client, e.g., - // "ALTSRP_GCM_AES128". - RecordProtocols []string `protobuf:"bytes,3,rep,name=record_protocols,json=recordProtocols,proto3" json:"record_protocols,omitempty"` - // (Optional) Describes which server identities are acceptable by the client. - // If target identities are provided and none of them matches the peer - // identity of the server, handshake will fail. - TargetIdentities []*Identity `protobuf:"bytes,4,rep,name=target_identities,json=targetIdentities,proto3" json:"target_identities,omitempty"` - // (Optional) Application may specify a local identity. Otherwise, the - // handshaker chooses a default local identity. - LocalIdentity *Identity `protobuf:"bytes,5,opt,name=local_identity,json=localIdentity,proto3" json:"local_identity,omitempty"` - // (Optional) Local endpoint information of the connection to the server, - // such as local IP address, port number, and network protocol. - LocalEndpoint *Endpoint `protobuf:"bytes,6,opt,name=local_endpoint,json=localEndpoint,proto3" json:"local_endpoint,omitempty"` - // (Optional) Endpoint information of the remote server, such as IP address, - // port number, and network protocol. - RemoteEndpoint *Endpoint `protobuf:"bytes,7,opt,name=remote_endpoint,json=remoteEndpoint,proto3" json:"remote_endpoint,omitempty"` - // (Optional) If target name is provided, a secure naming check is performed - // to verify that the peer authenticated identity is indeed authorized to run - // the target name. - TargetName string `protobuf:"bytes,8,opt,name=target_name,json=targetName,proto3" json:"target_name,omitempty"` - // (Optional) RPC protocol versions supported by the client. - RpcVersions *RpcProtocolVersions `protobuf:"bytes,9,opt,name=rpc_versions,json=rpcVersions,proto3" json:"rpc_versions,omitempty"` - // (Optional) Maximum frame size supported by the client. - MaxFrameSize uint32 `protobuf:"varint,10,opt,name=max_frame_size,json=maxFrameSize,proto3" json:"max_frame_size,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *StartClientHandshakeReq) Reset() { *m = StartClientHandshakeReq{} } -func (m *StartClientHandshakeReq) String() string { return proto.CompactTextString(m) } -func (*StartClientHandshakeReq) ProtoMessage() {} -func (*StartClientHandshakeReq) Descriptor() ([]byte, []int) { - return fileDescriptor_54c074f40c7c7e99, []int{2} -} - -func (m *StartClientHandshakeReq) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_StartClientHandshakeReq.Unmarshal(m, b) -} -func (m *StartClientHandshakeReq) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_StartClientHandshakeReq.Marshal(b, m, deterministic) -} -func (m *StartClientHandshakeReq) XXX_Merge(src proto.Message) { - xxx_messageInfo_StartClientHandshakeReq.Merge(m, src) -} -func (m *StartClientHandshakeReq) XXX_Size() int { - return xxx_messageInfo_StartClientHandshakeReq.Size(m) -} -func (m *StartClientHandshakeReq) XXX_DiscardUnknown() { - xxx_messageInfo_StartClientHandshakeReq.DiscardUnknown(m) -} - -var xxx_messageInfo_StartClientHandshakeReq proto.InternalMessageInfo - -func (m *StartClientHandshakeReq) GetHandshakeSecurityProtocol() HandshakeProtocol { - if m != nil { - return m.HandshakeSecurityProtocol - } - return HandshakeProtocol_HANDSHAKE_PROTOCOL_UNSPECIFIED -} - -func (m *StartClientHandshakeReq) GetApplicationProtocols() []string { - if m != nil { - return m.ApplicationProtocols - } - return nil -} - -func (m *StartClientHandshakeReq) GetRecordProtocols() []string { - if m != nil { - return m.RecordProtocols - } - return nil -} - -func (m *StartClientHandshakeReq) GetTargetIdentities() []*Identity { - if m != nil { - return m.TargetIdentities - } - return nil -} - -func (m *StartClientHandshakeReq) GetLocalIdentity() *Identity { - if m != nil { - return m.LocalIdentity - } - return nil -} - -func (m *StartClientHandshakeReq) GetLocalEndpoint() *Endpoint { - if m != nil { - return m.LocalEndpoint - } - return nil -} - -func (m *StartClientHandshakeReq) GetRemoteEndpoint() *Endpoint { - if m != nil { - return m.RemoteEndpoint - } - return nil -} - -func (m *StartClientHandshakeReq) GetTargetName() string { - if m != nil { - return m.TargetName - } - return "" -} - -func (m *StartClientHandshakeReq) GetRpcVersions() *RpcProtocolVersions { - if m != nil { - return m.RpcVersions - } - return nil -} - -func (m *StartClientHandshakeReq) GetMaxFrameSize() uint32 { - if m != nil { - return m.MaxFrameSize - } - return 0 -} - -type ServerHandshakeParameters struct { - // The record protocols supported by the server, e.g., - // "ALTSRP_GCM_AES128". - RecordProtocols []string `protobuf:"bytes,1,rep,name=record_protocols,json=recordProtocols,proto3" json:"record_protocols,omitempty"` - // (Optional) A list of local identities supported by the server, if - // specified. Otherwise, the handshaker chooses a default local identity. - LocalIdentities []*Identity `protobuf:"bytes,2,rep,name=local_identities,json=localIdentities,proto3" json:"local_identities,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *ServerHandshakeParameters) Reset() { *m = ServerHandshakeParameters{} } -func (m *ServerHandshakeParameters) String() string { return proto.CompactTextString(m) } -func (*ServerHandshakeParameters) ProtoMessage() {} -func (*ServerHandshakeParameters) Descriptor() ([]byte, []int) { - return fileDescriptor_54c074f40c7c7e99, []int{3} -} - -func (m *ServerHandshakeParameters) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_ServerHandshakeParameters.Unmarshal(m, b) -} -func (m *ServerHandshakeParameters) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_ServerHandshakeParameters.Marshal(b, m, deterministic) -} -func (m *ServerHandshakeParameters) XXX_Merge(src proto.Message) { - xxx_messageInfo_ServerHandshakeParameters.Merge(m, src) -} -func (m *ServerHandshakeParameters) XXX_Size() int { - return xxx_messageInfo_ServerHandshakeParameters.Size(m) -} -func (m *ServerHandshakeParameters) XXX_DiscardUnknown() { - xxx_messageInfo_ServerHandshakeParameters.DiscardUnknown(m) -} - -var xxx_messageInfo_ServerHandshakeParameters proto.InternalMessageInfo - -func (m *ServerHandshakeParameters) GetRecordProtocols() []string { - if m != nil { - return m.RecordProtocols - } - return nil -} - -func (m *ServerHandshakeParameters) GetLocalIdentities() []*Identity { - if m != nil { - return m.LocalIdentities - } - return nil -} - -type StartServerHandshakeReq struct { - // The application protocols supported by the server, e.g., "h2" (for http2), - // "grpc". - ApplicationProtocols []string `protobuf:"bytes,1,rep,name=application_protocols,json=applicationProtocols,proto3" json:"application_protocols,omitempty"` - // Handshake parameters (record protocols and local identities supported by - // the server) mapped by the handshake protocol. Each handshake security - // protocol (e.g., TLS or ALTS) has its own set of record protocols and local - // identities. Since protobuf does not support enum as key to the map, the key - // to handshake_parameters is the integer value of HandshakeProtocol enum. - HandshakeParameters map[int32]*ServerHandshakeParameters `protobuf:"bytes,2,rep,name=handshake_parameters,json=handshakeParameters,proto3" json:"handshake_parameters,omitempty" protobuf_key:"varint,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` - // Bytes in out_frames returned from the peer's HandshakerResp. It is possible - // that the peer's out_frames are split into multiple HandshakReq messages. - InBytes []byte `protobuf:"bytes,3,opt,name=in_bytes,json=inBytes,proto3" json:"in_bytes,omitempty"` - // (Optional) Local endpoint information of the connection to the client, - // such as local IP address, port number, and network protocol. - LocalEndpoint *Endpoint `protobuf:"bytes,4,opt,name=local_endpoint,json=localEndpoint,proto3" json:"local_endpoint,omitempty"` - // (Optional) Endpoint information of the remote client, such as IP address, - // port number, and network protocol. - RemoteEndpoint *Endpoint `protobuf:"bytes,5,opt,name=remote_endpoint,json=remoteEndpoint,proto3" json:"remote_endpoint,omitempty"` - // (Optional) RPC protocol versions supported by the server. - RpcVersions *RpcProtocolVersions `protobuf:"bytes,6,opt,name=rpc_versions,json=rpcVersions,proto3" json:"rpc_versions,omitempty"` - // (Optional) Maximum frame size supported by the server. - MaxFrameSize uint32 `protobuf:"varint,7,opt,name=max_frame_size,json=maxFrameSize,proto3" json:"max_frame_size,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *StartServerHandshakeReq) Reset() { *m = StartServerHandshakeReq{} } -func (m *StartServerHandshakeReq) String() string { return proto.CompactTextString(m) } -func (*StartServerHandshakeReq) ProtoMessage() {} -func (*StartServerHandshakeReq) Descriptor() ([]byte, []int) { - return fileDescriptor_54c074f40c7c7e99, []int{4} -} - -func (m *StartServerHandshakeReq) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_StartServerHandshakeReq.Unmarshal(m, b) -} -func (m *StartServerHandshakeReq) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_StartServerHandshakeReq.Marshal(b, m, deterministic) -} -func (m *StartServerHandshakeReq) XXX_Merge(src proto.Message) { - xxx_messageInfo_StartServerHandshakeReq.Merge(m, src) -} -func (m *StartServerHandshakeReq) XXX_Size() int { - return xxx_messageInfo_StartServerHandshakeReq.Size(m) -} -func (m *StartServerHandshakeReq) XXX_DiscardUnknown() { - xxx_messageInfo_StartServerHandshakeReq.DiscardUnknown(m) -} - -var xxx_messageInfo_StartServerHandshakeReq proto.InternalMessageInfo - -func (m *StartServerHandshakeReq) GetApplicationProtocols() []string { - if m != nil { - return m.ApplicationProtocols - } - return nil -} - -func (m *StartServerHandshakeReq) GetHandshakeParameters() map[int32]*ServerHandshakeParameters { - if m != nil { - return m.HandshakeParameters - } - return nil -} - -func (m *StartServerHandshakeReq) GetInBytes() []byte { - if m != nil { - return m.InBytes - } - return nil -} - -func (m *StartServerHandshakeReq) GetLocalEndpoint() *Endpoint { - if m != nil { - return m.LocalEndpoint - } - return nil -} - -func (m *StartServerHandshakeReq) GetRemoteEndpoint() *Endpoint { - if m != nil { - return m.RemoteEndpoint - } - return nil -} - -func (m *StartServerHandshakeReq) GetRpcVersions() *RpcProtocolVersions { - if m != nil { - return m.RpcVersions - } - return nil -} - -func (m *StartServerHandshakeReq) GetMaxFrameSize() uint32 { - if m != nil { - return m.MaxFrameSize - } - return 0 -} - -type NextHandshakeMessageReq struct { - // Bytes in out_frames returned from the peer's HandshakerResp. It is possible - // that the peer's out_frames are split into multiple NextHandshakerMessageReq - // messages. - InBytes []byte `protobuf:"bytes,1,opt,name=in_bytes,json=inBytes,proto3" json:"in_bytes,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *NextHandshakeMessageReq) Reset() { *m = NextHandshakeMessageReq{} } -func (m *NextHandshakeMessageReq) String() string { return proto.CompactTextString(m) } -func (*NextHandshakeMessageReq) ProtoMessage() {} -func (*NextHandshakeMessageReq) Descriptor() ([]byte, []int) { - return fileDescriptor_54c074f40c7c7e99, []int{5} -} - -func (m *NextHandshakeMessageReq) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_NextHandshakeMessageReq.Unmarshal(m, b) -} -func (m *NextHandshakeMessageReq) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_NextHandshakeMessageReq.Marshal(b, m, deterministic) -} -func (m *NextHandshakeMessageReq) XXX_Merge(src proto.Message) { - xxx_messageInfo_NextHandshakeMessageReq.Merge(m, src) -} -func (m *NextHandshakeMessageReq) XXX_Size() int { - return xxx_messageInfo_NextHandshakeMessageReq.Size(m) -} -func (m *NextHandshakeMessageReq) XXX_DiscardUnknown() { - xxx_messageInfo_NextHandshakeMessageReq.DiscardUnknown(m) -} - -var xxx_messageInfo_NextHandshakeMessageReq proto.InternalMessageInfo - -func (m *NextHandshakeMessageReq) GetInBytes() []byte { - if m != nil { - return m.InBytes - } - return nil -} - -type HandshakerReq struct { - // Types that are valid to be assigned to ReqOneof: - // *HandshakerReq_ClientStart - // *HandshakerReq_ServerStart - // *HandshakerReq_Next - ReqOneof isHandshakerReq_ReqOneof `protobuf_oneof:"req_oneof"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *HandshakerReq) Reset() { *m = HandshakerReq{} } -func (m *HandshakerReq) String() string { return proto.CompactTextString(m) } -func (*HandshakerReq) ProtoMessage() {} -func (*HandshakerReq) Descriptor() ([]byte, []int) { - return fileDescriptor_54c074f40c7c7e99, []int{6} -} - -func (m *HandshakerReq) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_HandshakerReq.Unmarshal(m, b) -} -func (m *HandshakerReq) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_HandshakerReq.Marshal(b, m, deterministic) -} -func (m *HandshakerReq) XXX_Merge(src proto.Message) { - xxx_messageInfo_HandshakerReq.Merge(m, src) -} -func (m *HandshakerReq) XXX_Size() int { - return xxx_messageInfo_HandshakerReq.Size(m) -} -func (m *HandshakerReq) XXX_DiscardUnknown() { - xxx_messageInfo_HandshakerReq.DiscardUnknown(m) -} - -var xxx_messageInfo_HandshakerReq proto.InternalMessageInfo - -type isHandshakerReq_ReqOneof interface { - isHandshakerReq_ReqOneof() -} - -type HandshakerReq_ClientStart struct { - ClientStart *StartClientHandshakeReq `protobuf:"bytes,1,opt,name=client_start,json=clientStart,proto3,oneof"` -} - -type HandshakerReq_ServerStart struct { - ServerStart *StartServerHandshakeReq `protobuf:"bytes,2,opt,name=server_start,json=serverStart,proto3,oneof"` -} - -type HandshakerReq_Next struct { - Next *NextHandshakeMessageReq `protobuf:"bytes,3,opt,name=next,proto3,oneof"` -} - -func (*HandshakerReq_ClientStart) isHandshakerReq_ReqOneof() {} - -func (*HandshakerReq_ServerStart) isHandshakerReq_ReqOneof() {} - -func (*HandshakerReq_Next) isHandshakerReq_ReqOneof() {} - -func (m *HandshakerReq) GetReqOneof() isHandshakerReq_ReqOneof { - if m != nil { - return m.ReqOneof - } - return nil -} - -func (m *HandshakerReq) GetClientStart() *StartClientHandshakeReq { - if x, ok := m.GetReqOneof().(*HandshakerReq_ClientStart); ok { - return x.ClientStart - } - return nil -} - -func (m *HandshakerReq) GetServerStart() *StartServerHandshakeReq { - if x, ok := m.GetReqOneof().(*HandshakerReq_ServerStart); ok { - return x.ServerStart - } - return nil -} - -func (m *HandshakerReq) GetNext() *NextHandshakeMessageReq { - if x, ok := m.GetReqOneof().(*HandshakerReq_Next); ok { - return x.Next - } - return nil -} - -// XXX_OneofWrappers is for the internal use of the proto package. -func (*HandshakerReq) XXX_OneofWrappers() []interface{} { - return []interface{}{ - (*HandshakerReq_ClientStart)(nil), - (*HandshakerReq_ServerStart)(nil), - (*HandshakerReq_Next)(nil), - } -} - -type HandshakerResult struct { - // The application protocol negotiated for this connection. - ApplicationProtocol string `protobuf:"bytes,1,opt,name=application_protocol,json=applicationProtocol,proto3" json:"application_protocol,omitempty"` - // The record protocol negotiated for this connection. - RecordProtocol string `protobuf:"bytes,2,opt,name=record_protocol,json=recordProtocol,proto3" json:"record_protocol,omitempty"` - // Cryptographic key data. The key data may be more than the key length - // required for the record protocol, thus the client of the handshaker - // service needs to truncate the key data into the right key length. - KeyData []byte `protobuf:"bytes,3,opt,name=key_data,json=keyData,proto3" json:"key_data,omitempty"` - // The authenticated identity of the peer. - PeerIdentity *Identity `protobuf:"bytes,4,opt,name=peer_identity,json=peerIdentity,proto3" json:"peer_identity,omitempty"` - // The local identity used in the handshake. - LocalIdentity *Identity `protobuf:"bytes,5,opt,name=local_identity,json=localIdentity,proto3" json:"local_identity,omitempty"` - // Indicate whether the handshaker service client should keep the channel - // between the handshaker service open, e.g., in order to handle - // post-handshake messages in the future. - KeepChannelOpen bool `protobuf:"varint,6,opt,name=keep_channel_open,json=keepChannelOpen,proto3" json:"keep_channel_open,omitempty"` - // The RPC protocol versions supported by the peer. - PeerRpcVersions *RpcProtocolVersions `protobuf:"bytes,7,opt,name=peer_rpc_versions,json=peerRpcVersions,proto3" json:"peer_rpc_versions,omitempty"` - // The maximum frame size of the peer. - MaxFrameSize uint32 `protobuf:"varint,8,opt,name=max_frame_size,json=maxFrameSize,proto3" json:"max_frame_size,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *HandshakerResult) Reset() { *m = HandshakerResult{} } -func (m *HandshakerResult) String() string { return proto.CompactTextString(m) } -func (*HandshakerResult) ProtoMessage() {} -func (*HandshakerResult) Descriptor() ([]byte, []int) { - return fileDescriptor_54c074f40c7c7e99, []int{7} -} - -func (m *HandshakerResult) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_HandshakerResult.Unmarshal(m, b) -} -func (m *HandshakerResult) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_HandshakerResult.Marshal(b, m, deterministic) -} -func (m *HandshakerResult) XXX_Merge(src proto.Message) { - xxx_messageInfo_HandshakerResult.Merge(m, src) -} -func (m *HandshakerResult) XXX_Size() int { - return xxx_messageInfo_HandshakerResult.Size(m) -} -func (m *HandshakerResult) XXX_DiscardUnknown() { - xxx_messageInfo_HandshakerResult.DiscardUnknown(m) -} - -var xxx_messageInfo_HandshakerResult proto.InternalMessageInfo - -func (m *HandshakerResult) GetApplicationProtocol() string { - if m != nil { - return m.ApplicationProtocol - } - return "" -} - -func (m *HandshakerResult) GetRecordProtocol() string { - if m != nil { - return m.RecordProtocol - } - return "" -} - -func (m *HandshakerResult) GetKeyData() []byte { - if m != nil { - return m.KeyData - } - return nil -} - -func (m *HandshakerResult) GetPeerIdentity() *Identity { - if m != nil { - return m.PeerIdentity - } - return nil -} - -func (m *HandshakerResult) GetLocalIdentity() *Identity { - if m != nil { - return m.LocalIdentity - } - return nil -} - -func (m *HandshakerResult) GetKeepChannelOpen() bool { - if m != nil { - return m.KeepChannelOpen - } - return false -} - -func (m *HandshakerResult) GetPeerRpcVersions() *RpcProtocolVersions { - if m != nil { - return m.PeerRpcVersions - } - return nil -} - -func (m *HandshakerResult) GetMaxFrameSize() uint32 { - if m != nil { - return m.MaxFrameSize - } - return 0 -} - -type HandshakerStatus struct { - // The status code. This could be the gRPC status code. - Code uint32 `protobuf:"varint,1,opt,name=code,proto3" json:"code,omitempty"` - // The status details. - Details string `protobuf:"bytes,2,opt,name=details,proto3" json:"details,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *HandshakerStatus) Reset() { *m = HandshakerStatus{} } -func (m *HandshakerStatus) String() string { return proto.CompactTextString(m) } -func (*HandshakerStatus) ProtoMessage() {} -func (*HandshakerStatus) Descriptor() ([]byte, []int) { - return fileDescriptor_54c074f40c7c7e99, []int{8} -} - -func (m *HandshakerStatus) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_HandshakerStatus.Unmarshal(m, b) -} -func (m *HandshakerStatus) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_HandshakerStatus.Marshal(b, m, deterministic) -} -func (m *HandshakerStatus) XXX_Merge(src proto.Message) { - xxx_messageInfo_HandshakerStatus.Merge(m, src) -} -func (m *HandshakerStatus) XXX_Size() int { - return xxx_messageInfo_HandshakerStatus.Size(m) -} -func (m *HandshakerStatus) XXX_DiscardUnknown() { - xxx_messageInfo_HandshakerStatus.DiscardUnknown(m) -} - -var xxx_messageInfo_HandshakerStatus proto.InternalMessageInfo - -func (m *HandshakerStatus) GetCode() uint32 { - if m != nil { - return m.Code - } - return 0 -} - -func (m *HandshakerStatus) GetDetails() string { - if m != nil { - return m.Details - } - return "" -} - -type HandshakerResp struct { - // Frames to be given to the peer for the NextHandshakeMessageReq. May be - // empty if no out_frames have to be sent to the peer or if in_bytes in the - // HandshakerReq are incomplete. All the non-empty out frames must be sent to - // the peer even if the handshaker status is not OK as these frames may - // contain the alert frames. - OutFrames []byte `protobuf:"bytes,1,opt,name=out_frames,json=outFrames,proto3" json:"out_frames,omitempty"` - // Number of bytes in the in_bytes consumed by the handshaker. It is possible - // that part of in_bytes in HandshakerReq was unrelated to the handshake - // process. - BytesConsumed uint32 `protobuf:"varint,2,opt,name=bytes_consumed,json=bytesConsumed,proto3" json:"bytes_consumed,omitempty"` - // This is set iff the handshake was successful. out_frames may still be set - // to frames that needs to be forwarded to the peer. - Result *HandshakerResult `protobuf:"bytes,3,opt,name=result,proto3" json:"result,omitempty"` - // Status of the handshaker. - Status *HandshakerStatus `protobuf:"bytes,4,opt,name=status,proto3" json:"status,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *HandshakerResp) Reset() { *m = HandshakerResp{} } -func (m *HandshakerResp) String() string { return proto.CompactTextString(m) } -func (*HandshakerResp) ProtoMessage() {} -func (*HandshakerResp) Descriptor() ([]byte, []int) { - return fileDescriptor_54c074f40c7c7e99, []int{9} -} - -func (m *HandshakerResp) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_HandshakerResp.Unmarshal(m, b) -} -func (m *HandshakerResp) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_HandshakerResp.Marshal(b, m, deterministic) -} -func (m *HandshakerResp) XXX_Merge(src proto.Message) { - xxx_messageInfo_HandshakerResp.Merge(m, src) -} -func (m *HandshakerResp) XXX_Size() int { - return xxx_messageInfo_HandshakerResp.Size(m) -} -func (m *HandshakerResp) XXX_DiscardUnknown() { - xxx_messageInfo_HandshakerResp.DiscardUnknown(m) -} - -var xxx_messageInfo_HandshakerResp proto.InternalMessageInfo - -func (m *HandshakerResp) GetOutFrames() []byte { - if m != nil { - return m.OutFrames - } - return nil -} - -func (m *HandshakerResp) GetBytesConsumed() uint32 { - if m != nil { - return m.BytesConsumed - } - return 0 -} - -func (m *HandshakerResp) GetResult() *HandshakerResult { - if m != nil { - return m.Result - } - return nil -} - -func (m *HandshakerResp) GetStatus() *HandshakerStatus { - if m != nil { - return m.Status - } - return nil -} - -func init() { - proto.RegisterEnum("grpc.gcp.HandshakeProtocol", HandshakeProtocol_name, HandshakeProtocol_value) - proto.RegisterEnum("grpc.gcp.NetworkProtocol", NetworkProtocol_name, NetworkProtocol_value) - proto.RegisterType((*Endpoint)(nil), "grpc.gcp.Endpoint") - proto.RegisterType((*Identity)(nil), "grpc.gcp.Identity") - proto.RegisterMapType((map[string]string)(nil), "grpc.gcp.Identity.AttributesEntry") - proto.RegisterType((*StartClientHandshakeReq)(nil), "grpc.gcp.StartClientHandshakeReq") - proto.RegisterType((*ServerHandshakeParameters)(nil), "grpc.gcp.ServerHandshakeParameters") - proto.RegisterType((*StartServerHandshakeReq)(nil), "grpc.gcp.StartServerHandshakeReq") - proto.RegisterMapType((map[int32]*ServerHandshakeParameters)(nil), "grpc.gcp.StartServerHandshakeReq.HandshakeParametersEntry") - proto.RegisterType((*NextHandshakeMessageReq)(nil), "grpc.gcp.NextHandshakeMessageReq") - proto.RegisterType((*HandshakerReq)(nil), "grpc.gcp.HandshakerReq") - proto.RegisterType((*HandshakerResult)(nil), "grpc.gcp.HandshakerResult") - proto.RegisterType((*HandshakerStatus)(nil), "grpc.gcp.HandshakerStatus") - proto.RegisterType((*HandshakerResp)(nil), "grpc.gcp.HandshakerResp") -} - -func init() { proto.RegisterFile("grpc/gcp/handshaker.proto", fileDescriptor_54c074f40c7c7e99) } - -var fileDescriptor_54c074f40c7c7e99 = []byte{ - // 1203 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x56, 0xdd, 0x6e, 0x1b, 0x45, - 0x14, 0xce, 0xda, 0x4e, 0xe2, 0x1c, 0xc7, 0x3f, 0x99, 0xa6, 0xea, 0x26, 0x6d, 0xc1, 0x18, 0x10, - 0x6e, 0x2f, 0x6c, 0x70, 0x41, 0xa5, 0x45, 0x55, 0x6b, 0x3b, 0x8e, 0x1c, 0x5a, 0x1c, 0x6b, 0x9d, - 0x82, 0x44, 0x2f, 0x56, 0xd3, 0xf5, 0xd4, 0x59, 0x79, 0x3d, 0xb3, 0x9d, 0x19, 0x87, 0xb8, 0xf7, - 0xbc, 0x04, 0xf7, 0xbc, 0x06, 0x2f, 0xc1, 0x33, 0x20, 0xf1, 0x18, 0x68, 0x67, 0x7f, 0x6d, 0xaf, - 0xab, 0x22, 0xb8, 0xdb, 0x39, 0xf3, 0x7d, 0x67, 0xce, 0x9c, 0xf3, 0x9d, 0xb3, 0x03, 0x47, 0x13, - 0xee, 0x5a, 0xcd, 0x89, 0xe5, 0x36, 0x2f, 0x31, 0x1d, 0x8b, 0x4b, 0x3c, 0x25, 0xbc, 0xe1, 0x72, - 0x26, 0x19, 0xca, 0x7b, 0x5b, 0x8d, 0x89, 0xe5, 0x1e, 0xd7, 0x23, 0x90, 0xe4, 0x98, 0x0a, 0x97, - 0x71, 0x69, 0x0a, 0x62, 0xcd, 0xb9, 0x2d, 0x17, 0xa6, 0xc5, 0x66, 0x33, 0x46, 0x7d, 0x4e, 0x4d, - 0x42, 0xbe, 0x47, 0xc7, 0x2e, 0xb3, 0xa9, 0x44, 0x77, 0x01, 0x6c, 0xd7, 0xc4, 0xe3, 0x31, 0x27, - 0x42, 0xe8, 0x5a, 0x55, 0xab, 0xef, 0x19, 0x7b, 0xb6, 0xdb, 0xf6, 0x0d, 0x08, 0x41, 0xce, 0x73, - 0xa4, 0x67, 0xaa, 0x5a, 0x7d, 0xdb, 0x50, 0xdf, 0xe8, 0x1b, 0xc8, 0x2b, 0x3f, 0x16, 0x73, 0xf4, - 0x6c, 0x55, 0xab, 0x97, 0x5a, 0x47, 0x8d, 0x30, 0x8a, 0xc6, 0x80, 0xc8, 0x5f, 0x18, 0x9f, 0x0e, - 0x03, 0x80, 0x11, 0x41, 0x6b, 0x7f, 0x6b, 0x90, 0x3f, 0x1b, 0x13, 0x2a, 0x6d, 0xb9, 0x40, 0xf7, - 0xa0, 0x2c, 0x08, 0xbf, 0xb2, 0x2d, 0x62, 0x62, 0xcb, 0x62, 0x73, 0x2a, 0xfd, 0xb3, 0xfb, 0x5b, - 0x46, 0x29, 0xd8, 0x68, 0xfb, 0x76, 0x74, 0x07, 0xf2, 0x97, 0x4c, 0x48, 0x8a, 0x67, 0x44, 0x85, - 0xe1, 0x61, 0x22, 0x0b, 0xea, 0x00, 0x60, 0x29, 0xb9, 0xfd, 0x7a, 0x2e, 0x89, 0xd0, 0xb3, 0xd5, - 0x6c, 0xbd, 0xd0, 0xaa, 0xc5, 0xe1, 0x84, 0x07, 0x36, 0xda, 0x11, 0xa8, 0x47, 0x25, 0x5f, 0x18, - 0x09, 0xd6, 0xf1, 0x13, 0x28, 0xaf, 0x6c, 0xa3, 0x0a, 0x64, 0xa7, 0x64, 0x11, 0xe4, 0xc3, 0xfb, - 0x44, 0x87, 0xb0, 0x7d, 0x85, 0x9d, 0x79, 0x10, 0x83, 0xe1, 0x2f, 0x1e, 0x67, 0xbe, 0xd5, 0x3a, - 0x15, 0x28, 0xd9, 0xc1, 0x31, 0x26, 0xa3, 0x84, 0xbd, 0xa9, 0xfd, 0x99, 0x83, 0x5b, 0x23, 0x89, - 0xb9, 0xec, 0x3a, 0x36, 0xa1, 0xb2, 0x1f, 0x16, 0xcd, 0x20, 0x6f, 0xd1, 0x2b, 0xb8, 0x1d, 0x15, - 0x31, 0xae, 0x4f, 0x94, 0x50, 0x4d, 0x25, 0xf4, 0x76, 0x7c, 0x83, 0x88, 0x1c, 0xa5, 0xf4, 0x28, - 0xe2, 0x8f, 0x02, 0x7a, 0xb8, 0x85, 0x1e, 0xc0, 0x4d, 0xec, 0xba, 0x8e, 0x6d, 0x61, 0x69, 0x33, - 0x1a, 0x79, 0x15, 0x7a, 0xa6, 0x9a, 0xad, 0xef, 0x19, 0x87, 0x89, 0xcd, 0x90, 0x23, 0xd0, 0x3d, - 0xa8, 0x70, 0x62, 0x31, 0x3e, 0x4e, 0xe0, 0xb3, 0x0a, 0x5f, 0xf6, 0xed, 0x31, 0xf4, 0x29, 0x1c, - 0x48, 0xcc, 0x27, 0x44, 0x9a, 0xc1, 0x8d, 0x6d, 0x22, 0xf4, 0x9c, 0x4a, 0x3a, 0x5a, 0x4f, 0xba, - 0x51, 0xf1, 0xc1, 0x67, 0x11, 0x16, 0x3d, 0x82, 0x92, 0xc3, 0x2c, 0xec, 0x84, 0xfc, 0x85, 0xbe, - 0x5d, 0xd5, 0x36, 0xb0, 0x8b, 0x0a, 0x19, 0x49, 0x26, 0xa2, 0x92, 0x40, 0xbb, 0xfa, 0xce, 0x2a, - 0x35, 0x54, 0x75, 0x40, 0x8d, 0x44, 0xfe, 0x1d, 0x94, 0x39, 0x99, 0x31, 0x49, 0x62, 0xee, 0xee, - 0x46, 0x6e, 0xc9, 0x87, 0x46, 0xe4, 0x8f, 0xa1, 0x10, 0xdc, 0x59, 0x49, 0x30, 0xaf, 0xca, 0x0f, - 0xbe, 0x69, 0xe0, 0x49, 0xf0, 0x19, 0xec, 0x73, 0xd7, 0x32, 0xaf, 0x08, 0x17, 0x36, 0xa3, 0x42, - 0xdf, 0x53, 0xae, 0xef, 0xc6, 0xae, 0x0d, 0xd7, 0x0a, 0x53, 0xf8, 0x63, 0x00, 0x32, 0x0a, 0xdc, - 0xb5, 0xc2, 0x05, 0xfa, 0x0c, 0x4a, 0x33, 0x7c, 0x6d, 0xbe, 0xe1, 0x78, 0x46, 0x4c, 0x61, 0xbf, - 0x23, 0x3a, 0x54, 0xb5, 0x7a, 0xd1, 0xd8, 0x9f, 0xe1, 0xeb, 0x53, 0xcf, 0x38, 0xb2, 0xdf, 0x91, - 0xda, 0xaf, 0x1a, 0x1c, 0x8d, 0x08, 0xbf, 0x22, 0x3c, 0xd6, 0x04, 0xf6, 0x76, 0x25, 0xe1, 0xe9, - 0x55, 0xd4, 0xd2, 0xab, 0xf8, 0x04, 0x2a, 0x4b, 0x45, 0xf0, 0x8a, 0x98, 0xd9, 0x58, 0xc4, 0x72, - 0xb2, 0x0c, 0x36, 0x11, 0xb5, 0xdf, 0x43, 0x75, 0xaf, 0x04, 0xe3, 0xa9, 0x7b, 0xa3, 0x00, 0xb5, - 0xf7, 0x08, 0x70, 0x06, 0x87, 0x71, 0x4b, 0xb8, 0xd1, 0x95, 0x82, 0x98, 0x1e, 0xc7, 0x31, 0x6d, - 0x38, 0xb5, 0x91, 0x92, 0x0f, 0xbf, 0xcb, 0x6f, 0x5c, 0xa6, 0x64, 0xea, 0x08, 0xf2, 0x36, 0x35, - 0x5f, 0x2f, 0xfc, 0x81, 0xa1, 0xd5, 0xf7, 0x8d, 0x5d, 0x9b, 0x76, 0xbc, 0x65, 0x8a, 0xc6, 0x72, - 0xff, 0x41, 0x63, 0xdb, 0x1f, 0xac, 0xb1, 0x55, 0x09, 0xed, 0xfc, 0x0f, 0x12, 0xda, 0x5d, 0x97, - 0xd0, 0xf1, 0x14, 0xf4, 0x4d, 0xb9, 0x4a, 0x8e, 0xbc, 0x6d, 0x7f, 0xe4, 0x3d, 0x4a, 0x8e, 0xbc, - 0x42, 0xeb, 0xd3, 0x44, 0x21, 0x36, 0xc9, 0x30, 0x31, 0x17, 0x6b, 0x5f, 0xc3, 0xad, 0x01, 0xb9, - 0x8e, 0xa7, 0xdf, 0x0f, 0x44, 0x08, 0x3c, 0x51, 0x32, 0x49, 0x96, 0x40, 0x5b, 0x2a, 0x41, 0xed, - 0x2f, 0x0d, 0x8a, 0x11, 0x85, 0x7b, 0xe0, 0x53, 0xd8, 0xb7, 0xd4, 0x1c, 0x35, 0x85, 0x57, 0x7f, - 0x45, 0x28, 0xb4, 0x3e, 0x59, 0x91, 0xc5, 0xfa, 0xa8, 0xed, 0x6f, 0x19, 0x05, 0x9f, 0xa8, 0x00, - 0x9e, 0x1f, 0xa1, 0xe2, 0x0e, 0xfc, 0x64, 0x52, 0xfd, 0xac, 0xcb, 0xcb, 0xf3, 0xe3, 0x13, 0x7d, - 0x3f, 0x0f, 0x21, 0x47, 0xc9, 0xb5, 0x54, 0xda, 0x59, 0xe2, 0x6f, 0xb8, 0x6d, 0x7f, 0xcb, 0x50, - 0x84, 0x4e, 0x01, 0xf6, 0x38, 0x79, 0x1b, 0xfc, 0x23, 0x7e, 0xcb, 0x42, 0x25, 0x79, 0x4f, 0x31, - 0x77, 0x24, 0xfa, 0x0a, 0x0e, 0xd3, 0xda, 0x27, 0xf8, 0x0f, 0xdd, 0x48, 0xe9, 0x1e, 0xf4, 0x05, - 0x94, 0x57, 0xfa, 0x3e, 0xf8, 0x43, 0x95, 0x96, 0xdb, 0xde, 0xcb, 0xf9, 0x94, 0x2c, 0xcc, 0x31, - 0x96, 0x38, 0x94, 0xfd, 0x94, 0x2c, 0x4e, 0xb0, 0xc4, 0xe8, 0x21, 0x14, 0x5d, 0x42, 0x78, 0x3c, - 0x94, 0x73, 0x1b, 0x87, 0xf2, 0xbe, 0x07, 0x5c, 0x9f, 0xc9, 0xff, 0x7e, 0x9c, 0xdf, 0x87, 0x83, - 0x29, 0x21, 0xae, 0x69, 0x5d, 0x62, 0x4a, 0x89, 0x63, 0x32, 0x97, 0x50, 0xa5, 0xfb, 0xbc, 0x51, - 0xf6, 0x36, 0xba, 0xbe, 0xfd, 0xdc, 0x25, 0x14, 0x9d, 0xc1, 0x81, 0x8a, 0x6f, 0xa9, 0x47, 0x76, - 0x3f, 0xa4, 0x47, 0xca, 0x1e, 0xcf, 0x78, 0x6f, 0x9f, 0xe4, 0x53, 0x46, 0xed, 0xb3, 0x64, 0x6d, - 0x46, 0x12, 0xcb, 0xb9, 0x7a, 0x0a, 0x59, 0x6c, 0x4c, 0x54, 0x2d, 0x8a, 0x86, 0xfa, 0x46, 0x3a, - 0xec, 0x8e, 0x89, 0xc4, 0xb6, 0xfa, 0xc3, 0x7a, 0x49, 0x0f, 0x97, 0xb5, 0x3f, 0x34, 0x28, 0x2d, - 0x95, 0xd7, 0xf5, 0x9e, 0x5a, 0x6c, 0x2e, 0xfd, 0xa3, 0x43, 0xd9, 0xef, 0xb1, 0xb9, 0x54, 0xc7, - 0x0a, 0xf4, 0x39, 0x94, 0x54, 0x43, 0x98, 0x16, 0xa3, 0x62, 0x3e, 0x23, 0x63, 0xe5, 0xb2, 0x68, - 0x14, 0x95, 0xb5, 0x1b, 0x18, 0x51, 0x0b, 0x76, 0xb8, 0x12, 0x4b, 0xa0, 0xbf, 0xe3, 0x94, 0xa7, - 0x42, 0x20, 0x27, 0x23, 0x40, 0x7a, 0x1c, 0xa1, 0x2e, 0x11, 0x14, 0x36, 0x95, 0xe3, 0x5f, 0xd3, - 0x08, 0x90, 0xf7, 0xbf, 0x87, 0x83, 0xb5, 0xa7, 0x07, 0xaa, 0xc1, 0x47, 0xfd, 0xf6, 0xe0, 0x64, - 0xd4, 0x6f, 0x3f, 0xef, 0x99, 0x43, 0xe3, 0xfc, 0xe2, 0xbc, 0x7b, 0xfe, 0xc2, 0x7c, 0x39, 0x18, - 0x0d, 0x7b, 0xdd, 0xb3, 0xd3, 0xb3, 0xde, 0x49, 0x65, 0x0b, 0xed, 0x42, 0xf6, 0xe2, 0xc5, 0xa8, - 0xa2, 0xa1, 0x3c, 0xe4, 0xda, 0x2f, 0x2e, 0x46, 0x95, 0xcc, 0xfd, 0x1e, 0x94, 0x57, 0xde, 0x85, - 0xa8, 0x0a, 0x77, 0x06, 0xbd, 0x8b, 0x9f, 0xce, 0x8d, 0xe7, 0xef, 0xf3, 0xd3, 0x1d, 0x56, 0x34, - 0xef, 0xe3, 0xe5, 0xc9, 0xb0, 0x92, 0x69, 0xbd, 0x4a, 0x84, 0xc4, 0x47, 0xfe, 0x2b, 0x11, 0x9d, - 0x42, 0xe1, 0x84, 0x45, 0x66, 0x74, 0x2b, 0x3d, 0x1d, 0x6f, 0x8f, 0xf5, 0x0d, 0x79, 0x72, 0x6b, - 0x5b, 0x75, 0xed, 0x4b, 0xad, 0x33, 0x85, 0x9b, 0x36, 0xf3, 0x31, 0xd8, 0x91, 0xa2, 0x61, 0x53, - 0x49, 0x38, 0xc5, 0x4e, 0xa7, 0x1c, 0xc3, 0x55, 0xf4, 0x43, 0xed, 0xe7, 0xa7, 0x13, 0xc6, 0x26, - 0x0e, 0x69, 0x4c, 0x98, 0x83, 0xe9, 0xa4, 0xc1, 0xf8, 0xa4, 0xa9, 0x1e, 0xdf, 0x16, 0x27, 0x4a, - 0xde, 0xd8, 0x11, 0x4d, 0xcf, 0x49, 0x33, 0x74, 0xd2, 0x54, 0xbd, 0xa9, 0x40, 0xe6, 0xc4, 0x72, - 0x5f, 0xef, 0xa8, 0xf5, 0x83, 0x7f, 0x02, 0x00, 0x00, 0xff, 0xff, 0xc1, 0xf9, 0x9d, 0xf2, 0xd9, - 0x0b, 0x00, 0x00, -} - -// Reference imports to suppress errors if they are not otherwise used. -var _ context.Context -var _ grpc.ClientConn - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the grpc package it is being compiled against. -const _ = grpc.SupportPackageIsVersion4 - -// HandshakerServiceClient is the client API for HandshakerService service. -// -// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. -type HandshakerServiceClient interface { - // Handshaker service accepts a stream of handshaker request, returning a - // stream of handshaker response. Client is expected to send exactly one - // message with either client_start or server_start followed by one or more - // messages with next. Each time client sends a request, the handshaker - // service expects to respond. Client does not have to wait for service's - // response before sending next request. - DoHandshake(ctx context.Context, opts ...grpc.CallOption) (HandshakerService_DoHandshakeClient, error) -} - -type handshakerServiceClient struct { - cc *grpc.ClientConn -} - -func NewHandshakerServiceClient(cc *grpc.ClientConn) HandshakerServiceClient { - return &handshakerServiceClient{cc} -} - -func (c *handshakerServiceClient) DoHandshake(ctx context.Context, opts ...grpc.CallOption) (HandshakerService_DoHandshakeClient, error) { - stream, err := c.cc.NewStream(ctx, &_HandshakerService_serviceDesc.Streams[0], "/grpc.gcp.HandshakerService/DoHandshake", opts...) - if err != nil { - return nil, err - } - x := &handshakerServiceDoHandshakeClient{stream} - return x, nil -} - -type HandshakerService_DoHandshakeClient interface { - Send(*HandshakerReq) error - Recv() (*HandshakerResp, error) - grpc.ClientStream -} - -type handshakerServiceDoHandshakeClient struct { - grpc.ClientStream -} - -func (x *handshakerServiceDoHandshakeClient) Send(m *HandshakerReq) error { - return x.ClientStream.SendMsg(m) -} - -func (x *handshakerServiceDoHandshakeClient) Recv() (*HandshakerResp, error) { - m := new(HandshakerResp) - if err := x.ClientStream.RecvMsg(m); err != nil { - return nil, err - } - return m, nil -} - -// HandshakerServiceServer is the server API for HandshakerService service. -type HandshakerServiceServer interface { - // Handshaker service accepts a stream of handshaker request, returning a - // stream of handshaker response. Client is expected to send exactly one - // message with either client_start or server_start followed by one or more - // messages with next. Each time client sends a request, the handshaker - // service expects to respond. Client does not have to wait for service's - // response before sending next request. - DoHandshake(HandshakerService_DoHandshakeServer) error -} - -// UnimplementedHandshakerServiceServer can be embedded to have forward compatible implementations. -type UnimplementedHandshakerServiceServer struct { -} - -func (*UnimplementedHandshakerServiceServer) DoHandshake(srv HandshakerService_DoHandshakeServer) error { - return status.Errorf(codes.Unimplemented, "method DoHandshake not implemented") -} - -func RegisterHandshakerServiceServer(s *grpc.Server, srv HandshakerServiceServer) { - s.RegisterService(&_HandshakerService_serviceDesc, srv) -} - -func _HandshakerService_DoHandshake_Handler(srv interface{}, stream grpc.ServerStream) error { - return srv.(HandshakerServiceServer).DoHandshake(&handshakerServiceDoHandshakeServer{stream}) -} - -type HandshakerService_DoHandshakeServer interface { - Send(*HandshakerResp) error - Recv() (*HandshakerReq, error) - grpc.ServerStream -} - -type handshakerServiceDoHandshakeServer struct { - grpc.ServerStream -} - -func (x *handshakerServiceDoHandshakeServer) Send(m *HandshakerResp) error { - return x.ServerStream.SendMsg(m) -} - -func (x *handshakerServiceDoHandshakeServer) Recv() (*HandshakerReq, error) { - m := new(HandshakerReq) - if err := x.ServerStream.RecvMsg(m); err != nil { - return nil, err - } - return m, nil -} - -var _HandshakerService_serviceDesc = grpc.ServiceDesc{ - ServiceName: "grpc.gcp.HandshakerService", - HandlerType: (*HandshakerServiceServer)(nil), - Methods: []grpc.MethodDesc{}, - Streams: []grpc.StreamDesc{ - { - StreamName: "DoHandshake", - Handler: _HandshakerService_DoHandshake_Handler, - ServerStreams: true, - ClientStreams: true, - }, - }, - Metadata: "grpc/gcp/handshaker.proto", -} diff --git a/vendor/google.golang.org/grpc/credentials/alts/internal/proto/grpc_gcp/transport_security_common.pb.go b/vendor/google.golang.org/grpc/credentials/alts/internal/proto/grpc_gcp/transport_security_common.pb.go deleted file mode 100644 index 992805165d..0000000000 --- a/vendor/google.golang.org/grpc/credentials/alts/internal/proto/grpc_gcp/transport_security_common.pb.go +++ /dev/null @@ -1,184 +0,0 @@ -// Code generated by protoc-gen-go. DO NOT EDIT. -// source: grpc/gcp/transport_security_common.proto - -package grpc_gcp - -import ( - fmt "fmt" - proto "github.com/golang/protobuf/proto" - 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.ProtoPackageIsVersion3 // please upgrade the proto package - -// The security level of the created channel. The list is sorted in increasing -// level of security. This order must always be maintained. -type SecurityLevel int32 - -const ( - SecurityLevel_SECURITY_NONE SecurityLevel = 0 - SecurityLevel_INTEGRITY_ONLY SecurityLevel = 1 - SecurityLevel_INTEGRITY_AND_PRIVACY SecurityLevel = 2 -) - -var SecurityLevel_name = map[int32]string{ - 0: "SECURITY_NONE", - 1: "INTEGRITY_ONLY", - 2: "INTEGRITY_AND_PRIVACY", -} - -var SecurityLevel_value = map[string]int32{ - "SECURITY_NONE": 0, - "INTEGRITY_ONLY": 1, - "INTEGRITY_AND_PRIVACY": 2, -} - -func (x SecurityLevel) String() string { - return proto.EnumName(SecurityLevel_name, int32(x)) -} - -func (SecurityLevel) EnumDescriptor() ([]byte, []int) { - return fileDescriptor_b97e31e3cc23582a, []int{0} -} - -// Max and min supported RPC protocol versions. -type RpcProtocolVersions struct { - // Maximum supported RPC version. - MaxRpcVersion *RpcProtocolVersions_Version `protobuf:"bytes,1,opt,name=max_rpc_version,json=maxRpcVersion,proto3" json:"max_rpc_version,omitempty"` - // Minimum supported RPC version. - MinRpcVersion *RpcProtocolVersions_Version `protobuf:"bytes,2,opt,name=min_rpc_version,json=minRpcVersion,proto3" json:"min_rpc_version,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *RpcProtocolVersions) Reset() { *m = RpcProtocolVersions{} } -func (m *RpcProtocolVersions) String() string { return proto.CompactTextString(m) } -func (*RpcProtocolVersions) ProtoMessage() {} -func (*RpcProtocolVersions) Descriptor() ([]byte, []int) { - return fileDescriptor_b97e31e3cc23582a, []int{0} -} - -func (m *RpcProtocolVersions) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_RpcProtocolVersions.Unmarshal(m, b) -} -func (m *RpcProtocolVersions) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_RpcProtocolVersions.Marshal(b, m, deterministic) -} -func (m *RpcProtocolVersions) XXX_Merge(src proto.Message) { - xxx_messageInfo_RpcProtocolVersions.Merge(m, src) -} -func (m *RpcProtocolVersions) XXX_Size() int { - return xxx_messageInfo_RpcProtocolVersions.Size(m) -} -func (m *RpcProtocolVersions) XXX_DiscardUnknown() { - xxx_messageInfo_RpcProtocolVersions.DiscardUnknown(m) -} - -var xxx_messageInfo_RpcProtocolVersions proto.InternalMessageInfo - -func (m *RpcProtocolVersions) GetMaxRpcVersion() *RpcProtocolVersions_Version { - if m != nil { - return m.MaxRpcVersion - } - return nil -} - -func (m *RpcProtocolVersions) GetMinRpcVersion() *RpcProtocolVersions_Version { - if m != nil { - return m.MinRpcVersion - } - return nil -} - -// RPC version contains a major version and a minor version. -type RpcProtocolVersions_Version struct { - Major uint32 `protobuf:"varint,1,opt,name=major,proto3" json:"major,omitempty"` - Minor uint32 `protobuf:"varint,2,opt,name=minor,proto3" json:"minor,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *RpcProtocolVersions_Version) Reset() { *m = RpcProtocolVersions_Version{} } -func (m *RpcProtocolVersions_Version) String() string { return proto.CompactTextString(m) } -func (*RpcProtocolVersions_Version) ProtoMessage() {} -func (*RpcProtocolVersions_Version) Descriptor() ([]byte, []int) { - return fileDescriptor_b97e31e3cc23582a, []int{0, 0} -} - -func (m *RpcProtocolVersions_Version) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_RpcProtocolVersions_Version.Unmarshal(m, b) -} -func (m *RpcProtocolVersions_Version) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_RpcProtocolVersions_Version.Marshal(b, m, deterministic) -} -func (m *RpcProtocolVersions_Version) XXX_Merge(src proto.Message) { - xxx_messageInfo_RpcProtocolVersions_Version.Merge(m, src) -} -func (m *RpcProtocolVersions_Version) XXX_Size() int { - return xxx_messageInfo_RpcProtocolVersions_Version.Size(m) -} -func (m *RpcProtocolVersions_Version) XXX_DiscardUnknown() { - xxx_messageInfo_RpcProtocolVersions_Version.DiscardUnknown(m) -} - -var xxx_messageInfo_RpcProtocolVersions_Version proto.InternalMessageInfo - -func (m *RpcProtocolVersions_Version) GetMajor() uint32 { - if m != nil { - return m.Major - } - return 0 -} - -func (m *RpcProtocolVersions_Version) GetMinor() uint32 { - if m != nil { - return m.Minor - } - return 0 -} - -func init() { - proto.RegisterEnum("grpc.gcp.SecurityLevel", SecurityLevel_name, SecurityLevel_value) - proto.RegisterType((*RpcProtocolVersions)(nil), "grpc.gcp.RpcProtocolVersions") - proto.RegisterType((*RpcProtocolVersions_Version)(nil), "grpc.gcp.RpcProtocolVersions.Version") -} - -func init() { - proto.RegisterFile("grpc/gcp/transport_security_common.proto", fileDescriptor_b97e31e3cc23582a) -} - -var fileDescriptor_b97e31e3cc23582a = []byte{ - // 323 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x91, 0x41, 0x4b, 0x3b, 0x31, - 0x10, 0xc5, 0xff, 0x5b, 0xf8, 0xab, 0x44, 0x56, 0xeb, 0x6a, 0x41, 0xc5, 0x83, 0x08, 0x42, 0xf1, - 0x90, 0x05, 0xc5, 0xb3, 0xb4, 0xb5, 0x48, 0xa1, 0x6e, 0xeb, 0xb6, 0x16, 0xea, 0x25, 0xc4, 0x18, - 0x42, 0x24, 0x9b, 0x09, 0xb3, 0xb1, 0xd4, 0xaf, 0xec, 0xa7, 0x90, 0x4d, 0xbb, 0x14, 0xc1, 0x8b, - 0xb7, 0xbc, 0xc7, 0xcc, 0x6f, 0x32, 0xf3, 0x48, 0x5b, 0xa1, 0x13, 0xa9, 0x12, 0x2e, 0xf5, 0xc8, - 0x6d, 0xe9, 0x00, 0x3d, 0x2b, 0xa5, 0xf8, 0x40, 0xed, 0x3f, 0x99, 0x80, 0xa2, 0x00, 0x4b, 0x1d, - 0x82, 0x87, 0x64, 0xa7, 0xaa, 0xa4, 0x4a, 0xb8, 0x8b, 0xaf, 0x88, 0x1c, 0xe6, 0x4e, 0x8c, 0x2b, - 0x5b, 0x80, 0x99, 0x49, 0x2c, 0x35, 0xd8, 0x32, 0x79, 0x24, 0xfb, 0x05, 0x5f, 0x32, 0x74, 0x82, - 0x2d, 0x56, 0xde, 0x71, 0x74, 0x1e, 0xb5, 0x77, 0xaf, 0x2f, 0x69, 0xdd, 0x4b, 0x7f, 0xe9, 0xa3, - 0xeb, 0x47, 0x1e, 0x17, 0x7c, 0x99, 0x3b, 0xb1, 0x96, 0x01, 0xa7, 0xed, 0x0f, 0x5c, 0xe3, 0x6f, - 0x38, 0x6d, 0x37, 0xb8, 0xd3, 0x5b, 0xb2, 0x5d, 0x93, 0x8f, 0xc8, 0xff, 0x82, 0xbf, 0x03, 0x86, - 0xef, 0xc5, 0xf9, 0x4a, 0x04, 0x57, 0x5b, 0xc0, 0x30, 0xa5, 0x72, 0x2b, 0x71, 0xf5, 0x44, 0xe2, - 0xc9, 0xfa, 0x1e, 0x43, 0xb9, 0x90, 0x26, 0x39, 0x20, 0xf1, 0xa4, 0xdf, 0x7b, 0xce, 0x07, 0xd3, - 0x39, 0xcb, 0x46, 0x59, 0xbf, 0xf9, 0x2f, 0x49, 0xc8, 0xde, 0x20, 0x9b, 0xf6, 0x1f, 0x82, 0x37, - 0xca, 0x86, 0xf3, 0x66, 0x94, 0x9c, 0x90, 0xd6, 0xc6, 0xeb, 0x64, 0xf7, 0x6c, 0x9c, 0x0f, 0x66, - 0x9d, 0xde, 0xbc, 0xd9, 0xe8, 0x2e, 0x49, 0x4b, 0xc3, 0x6a, 0x07, 0x6e, 0x7c, 0x49, 0xb5, 0xf5, - 0x12, 0x2d, 0x37, 0xdd, 0xb3, 0x69, 0x9d, 0x41, 0x3d, 0xb2, 0x17, 0x12, 0x08, 0x2b, 0x8e, 0xa3, - 0x97, 0x3b, 0x05, 0xa0, 0x8c, 0xa4, 0x0a, 0x0c, 0xb7, 0x8a, 0x02, 0xaa, 0x34, 0xc4, 0x27, 0x50, - 0xbe, 0x49, 0xeb, 0x35, 0x37, 0x65, 0x5a, 0x11, 0xd3, 0x9a, 0x98, 0x86, 0xe8, 0x42, 0x11, 0x53, - 0xc2, 0xbd, 0x6e, 0x05, 0x7d, 0xf3, 0x1d, 0x00, 0x00, 0xff, 0xff, 0x31, 0x14, 0xb4, 0x11, 0xf6, - 0x01, 0x00, 0x00, -} diff --git a/vendor/google.golang.org/grpc/credentials/alts/internal/regenerate.sh b/vendor/google.golang.org/grpc/credentials/alts/internal/regenerate.sh deleted file mode 100644 index a79c4201b3..0000000000 --- a/vendor/google.golang.org/grpc/credentials/alts/internal/regenerate.sh +++ /dev/null @@ -1,35 +0,0 @@ -#!/bin/bash -# Copyright 2018 gRPC 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. - -set -eux -o pipefail - -TMP=$(mktemp -d) - -function finish { - rm -rf "$TMP" -} -trap finish EXIT - -pushd "$TMP" -mkdir -p grpc/gcp -curl https://raw.githubusercontent.com/grpc/grpc-proto/master/grpc/gcp/altscontext.proto > grpc/gcp/altscontext.proto -curl https://raw.githubusercontent.com/grpc/grpc-proto/master/grpc/gcp/handshaker.proto > grpc/gcp/handshaker.proto -curl https://raw.githubusercontent.com/grpc/grpc-proto/master/grpc/gcp/transport_security_common.proto > grpc/gcp/transport_security_common.proto - -protoc --go_out=plugins=grpc,paths=source_relative:. -I. grpc/gcp/*.proto -popd -rm -f proto/grpc_gcp/*.pb.go -cp "$TMP"/grpc/gcp/*.pb.go proto/grpc_gcp/ - diff --git a/vendor/google.golang.org/grpc/credentials/alts/utils.go b/vendor/google.golang.org/grpc/credentials/alts/utils.go deleted file mode 100644 index f13aeef1c4..0000000000 --- a/vendor/google.golang.org/grpc/credentials/alts/utils.go +++ /dev/null @@ -1,144 +0,0 @@ -/* - * - * Copyright 2018 gRPC 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 alts - -import ( - "context" - "errors" - "fmt" - "io" - "io/ioutil" - "log" - "os" - "os/exec" - "regexp" - "runtime" - "strings" - - "google.golang.org/grpc/peer" -) - -const ( - linuxProductNameFile = "/sys/class/dmi/id/product_name" - windowsCheckCommand = "powershell.exe" - windowsCheckCommandArgs = "Get-WmiObject -Class Win32_BIOS" - powershellOutputFilter = "Manufacturer" - windowsManufacturerRegex = ":(.*)" -) - -type platformError string - -func (k platformError) Error() string { - return fmt.Sprintf("%s is not supported", string(k)) -} - -var ( - // The following two variables will be reassigned in tests. - runningOS = runtime.GOOS - manufacturerReader = func() (io.Reader, error) { - switch runningOS { - case "linux": - return os.Open(linuxProductNameFile) - case "windows": - cmd := exec.Command(windowsCheckCommand, windowsCheckCommandArgs) - out, err := cmd.Output() - if err != nil { - return nil, err - } - - for _, line := range strings.Split(strings.TrimSuffix(string(out), "\n"), "\n") { - if strings.HasPrefix(line, powershellOutputFilter) { - re := regexp.MustCompile(windowsManufacturerRegex) - name := re.FindString(line) - name = strings.TrimLeft(name, ":") - return strings.NewReader(name), nil - } - } - - return nil, errors.New("cannot determine the machine's manufacturer") - default: - return nil, platformError(runningOS) - } - } - vmOnGCP bool -) - -// isRunningOnGCP checks whether the local system, without doing a network request is -// running on GCP. -func isRunningOnGCP() bool { - manufacturer, err := readManufacturer() - if os.IsNotExist(err) { - return false - } - if err != nil { - log.Fatalf("failure to read manufacturer information: %v", err) - } - name := string(manufacturer) - switch runningOS { - case "linux": - name = strings.TrimSpace(name) - return name == "Google" || name == "Google Compute Engine" - case "windows": - name = strings.Replace(name, " ", "", -1) - name = strings.Replace(name, "\n", "", -1) - name = strings.Replace(name, "\r", "", -1) - return name == "Google" - default: - log.Fatal(platformError(runningOS)) - } - return false -} - -func readManufacturer() ([]byte, error) { - reader, err := manufacturerReader() - if err != nil { - return nil, err - } - if reader == nil { - return nil, errors.New("got nil reader") - } - manufacturer, err := ioutil.ReadAll(reader) - if err != nil { - return nil, fmt.Errorf("failed reading %v: %v", linuxProductNameFile, err) - } - return manufacturer, nil -} - -// AuthInfoFromContext extracts the alts.AuthInfo object from the given context, -// if it exists. This API should be used by gRPC server RPC handlers to get -// information about the communicating peer. For client-side, use grpc.Peer() -// CallOption. -func AuthInfoFromContext(ctx context.Context) (AuthInfo, error) { - p, ok := peer.FromContext(ctx) - if !ok { - return nil, errors.New("no Peer found in Context") - } - return AuthInfoFromPeer(p) -} - -// AuthInfoFromPeer extracts the alts.AuthInfo object from the given peer, if it -// exists. This API should be used by gRPC clients after obtaining a peer object -// using the grpc.Peer() CallOption. -func AuthInfoFromPeer(p *peer.Peer) (AuthInfo, error) { - altsAuthInfo, ok := p.AuthInfo.(AuthInfo) - if !ok { - return nil, errors.New("no alts.AuthInfo found in Peer") - } - return altsAuthInfo, nil -} diff --git a/vendor/google.golang.org/grpc/credentials/google/google.go b/vendor/google.golang.org/grpc/credentials/google/google.go deleted file mode 100644 index 04b349abcf..0000000000 --- a/vendor/google.golang.org/grpc/credentials/google/google.go +++ /dev/null @@ -1,125 +0,0 @@ -/* - * - * Copyright 2018 gRPC 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 google defines credentials for google cloud services. -package google - -import ( - "context" - "fmt" - "time" - - "google.golang.org/grpc/credentials" - "google.golang.org/grpc/credentials/alts" - "google.golang.org/grpc/credentials/oauth" - "google.golang.org/grpc/grpclog" - "google.golang.org/grpc/internal" -) - -const tokenRequestTimeout = 30 * time.Second - -// NewDefaultCredentials returns a credentials bundle that is configured to work -// with google services. -// -// This API is experimental. -func NewDefaultCredentials() credentials.Bundle { - c := &creds{ - newPerRPCCreds: func() credentials.PerRPCCredentials { - ctx, cancel := context.WithTimeout(context.Background(), tokenRequestTimeout) - defer cancel() - perRPCCreds, err := oauth.NewApplicationDefault(ctx) - if err != nil { - grpclog.Warningf("google default creds: failed to create application oauth: %v", err) - } - return perRPCCreds - }, - } - bundle, err := c.NewWithMode(internal.CredsBundleModeFallback) - if err != nil { - grpclog.Warningf("google default creds: failed to create new creds: %v", err) - } - return bundle -} - -// NewComputeEngineCredentials returns a credentials bundle that is configured to work -// with google services. This API must only be used when running on GCE. Authentication configured -// by this API represents the GCE VM's default service account. -// -// This API is experimental. -func NewComputeEngineCredentials() credentials.Bundle { - c := &creds{ - newPerRPCCreds: func() credentials.PerRPCCredentials { - return oauth.NewComputeEngine() - }, - } - bundle, err := c.NewWithMode(internal.CredsBundleModeFallback) - if err != nil { - grpclog.Warningf("compute engine creds: failed to create new creds: %v", err) - } - return bundle -} - -// creds implements credentials.Bundle. -type creds struct { - // Supported modes are defined in internal/internal.go. - mode string - // The transport credentials associated with this bundle. - transportCreds credentials.TransportCredentials - // The per RPC credentials associated with this bundle. - perRPCCreds credentials.PerRPCCredentials - // Creates new per RPC credentials - newPerRPCCreds func() credentials.PerRPCCredentials -} - -func (c *creds) TransportCredentials() credentials.TransportCredentials { - return c.transportCreds -} - -func (c *creds) PerRPCCredentials() credentials.PerRPCCredentials { - if c == nil { - return nil - } - return c.perRPCCreds -} - -// NewWithMode should make a copy of Bundle, and switch mode. Modifying the -// existing Bundle may cause races. -func (c *creds) NewWithMode(mode string) (credentials.Bundle, error) { - newCreds := &creds{ - mode: mode, - newPerRPCCreds: c.newPerRPCCreds, - } - - // Create transport credentials. - switch mode { - case internal.CredsBundleModeFallback: - newCreds.transportCreds = credentials.NewTLS(nil) - case internal.CredsBundleModeBackendFromBalancer, internal.CredsBundleModeBalancer: - // Only the clients can use google default credentials, so we only need - // to create new ALTS client creds here. - newCreds.transportCreds = alts.NewClientCreds(alts.DefaultClientOptions()) - default: - return nil, fmt.Errorf("unsupported mode: %v", mode) - } - - if mode == internal.CredsBundleModeFallback || mode == internal.CredsBundleModeBackendFromBalancer { - newCreds.perRPCCreds = newCreds.newPerRPCCreds() - } - - return newCreds, nil -} diff --git a/vendor/google.golang.org/grpc/credentials/oauth/oauth.go b/vendor/google.golang.org/grpc/credentials/oauth/oauth.go deleted file mode 100644 index e0e74d8153..0000000000 --- a/vendor/google.golang.org/grpc/credentials/oauth/oauth.go +++ /dev/null @@ -1,173 +0,0 @@ -/* - * - * Copyright 2015 gRPC 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 oauth implements gRPC credentials using OAuth. -package oauth - -import ( - "context" - "fmt" - "io/ioutil" - "sync" - - "golang.org/x/oauth2" - "golang.org/x/oauth2/google" - "golang.org/x/oauth2/jwt" - "google.golang.org/grpc/credentials" -) - -// TokenSource supplies PerRPCCredentials from an oauth2.TokenSource. -type TokenSource struct { - oauth2.TokenSource -} - -// GetRequestMetadata gets the request metadata as a map from a TokenSource. -func (ts TokenSource) GetRequestMetadata(ctx context.Context, uri ...string) (map[string]string, error) { - token, err := ts.Token() - if err != nil { - return nil, err - } - return map[string]string{ - "authorization": token.Type() + " " + token.AccessToken, - }, nil -} - -// RequireTransportSecurity indicates whether the credentials requires transport security. -func (ts TokenSource) RequireTransportSecurity() bool { - return true -} - -type jwtAccess struct { - jsonKey []byte -} - -// NewJWTAccessFromFile creates PerRPCCredentials from the given keyFile. -func NewJWTAccessFromFile(keyFile string) (credentials.PerRPCCredentials, error) { - jsonKey, err := ioutil.ReadFile(keyFile) - if err != nil { - return nil, fmt.Errorf("credentials: failed to read the service account key file: %v", err) - } - return NewJWTAccessFromKey(jsonKey) -} - -// NewJWTAccessFromKey creates PerRPCCredentials from the given jsonKey. -func NewJWTAccessFromKey(jsonKey []byte) (credentials.PerRPCCredentials, error) { - return jwtAccess{jsonKey}, nil -} - -func (j jwtAccess) GetRequestMetadata(ctx context.Context, uri ...string) (map[string]string, error) { - ts, err := google.JWTAccessTokenSourceFromJSON(j.jsonKey, uri[0]) - if err != nil { - return nil, err - } - token, err := ts.Token() - if err != nil { - return nil, err - } - return map[string]string{ - "authorization": token.Type() + " " + token.AccessToken, - }, nil -} - -func (j jwtAccess) RequireTransportSecurity() bool { - return true -} - -// oauthAccess supplies PerRPCCredentials from a given token. -type oauthAccess struct { - token oauth2.Token -} - -// NewOauthAccess constructs the PerRPCCredentials using a given token. -func NewOauthAccess(token *oauth2.Token) credentials.PerRPCCredentials { - return oauthAccess{token: *token} -} - -func (oa oauthAccess) GetRequestMetadata(ctx context.Context, uri ...string) (map[string]string, error) { - return map[string]string{ - "authorization": oa.token.Type() + " " + oa.token.AccessToken, - }, nil -} - -func (oa oauthAccess) RequireTransportSecurity() bool { - return true -} - -// NewComputeEngine constructs the PerRPCCredentials that fetches access tokens from -// Google Compute Engine (GCE)'s metadata server. It is only valid to use this -// if your program is running on a GCE instance. -// TODO(dsymonds): Deprecate and remove this. -func NewComputeEngine() credentials.PerRPCCredentials { - return TokenSource{google.ComputeTokenSource("")} -} - -// serviceAccount represents PerRPCCredentials via JWT signing key. -type serviceAccount struct { - mu sync.Mutex - config *jwt.Config - t *oauth2.Token -} - -func (s *serviceAccount) GetRequestMetadata(ctx context.Context, uri ...string) (map[string]string, error) { - s.mu.Lock() - defer s.mu.Unlock() - if !s.t.Valid() { - var err error - s.t, err = s.config.TokenSource(ctx).Token() - if err != nil { - return nil, err - } - } - return map[string]string{ - "authorization": s.t.Type() + " " + s.t.AccessToken, - }, nil -} - -func (s *serviceAccount) RequireTransportSecurity() bool { - return true -} - -// NewServiceAccountFromKey constructs the PerRPCCredentials using the JSON key slice -// from a Google Developers service account. -func NewServiceAccountFromKey(jsonKey []byte, scope ...string) (credentials.PerRPCCredentials, error) { - config, err := google.JWTConfigFromJSON(jsonKey, scope...) - if err != nil { - return nil, err - } - return &serviceAccount{config: config}, nil -} - -// NewServiceAccountFromFile constructs the PerRPCCredentials using the JSON key file -// of a Google Developers service account. -func NewServiceAccountFromFile(keyFile string, scope ...string) (credentials.PerRPCCredentials, error) { - jsonKey, err := ioutil.ReadFile(keyFile) - if err != nil { - return nil, fmt.Errorf("credentials: failed to read the service account key file: %v", err) - } - return NewServiceAccountFromKey(jsonKey, scope...) -} - -// NewApplicationDefault returns "Application Default Credentials". For more -// detail, see https://developers.google.com/accounts/docs/application-default-credentials. -func NewApplicationDefault(ctx context.Context, scope ...string) (credentials.PerRPCCredentials, error) { - t, err := google.DefaultTokenSource(ctx, scope...) - if err != nil { - return nil, err - } - return TokenSource{t}, nil -} diff --git a/vendor/modules.txt b/vendor/modules.txt index 9799e1364a..1f63f06d0c 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -6,7 +6,6 @@ cloud.google.com/go/internal cloud.google.com/go/internal/optional cloud.google.com/go/internal/trace cloud.google.com/go/internal/version -cloud.google.com/go/monitoring/apiv3 # cloud.google.com/go/storage v1.5.0 cloud.google.com/go/storage # github.com/360EntSecGroup-Skylar/excelize v1.4.0 @@ -325,12 +324,6 @@ github.com/golang/protobuf/ptypes/wrappers github.com/golang/snappy # github.com/google/btree v1.0.0 github.com/google/btree -# github.com/google/go-cmp v0.3.1 -github.com/google/go-cmp/cmp -github.com/google/go-cmp/cmp/internal/diff -github.com/google/go-cmp/cmp/internal/flags -github.com/google/go-cmp/cmp/internal/function -github.com/google/go-cmp/cmp/internal/value # github.com/google/go-querystring v1.0.0 github.com/google/go-querystring/query # github.com/google/gofuzz v1.0.0 @@ -610,7 +603,6 @@ go.opencensus.io/internal go.opencensus.io/internal/tagencoding go.opencensus.io/metric/metricdata go.opencensus.io/metric/metricproducer -go.opencensus.io/plugin/ocgrpc go.opencensus.io/plugin/ochttp go.opencensus.io/plugin/ochttp/propagation/b3 go.opencensus.io/resource @@ -723,8 +715,6 @@ google.golang.org/api/internal/third_party/uritemplates google.golang.org/api/iterator google.golang.org/api/option google.golang.org/api/storage/v1 -google.golang.org/api/transport -google.golang.org/api/transport/grpc google.golang.org/api/transport/http google.golang.org/api/transport/http/internal/propagation # google.golang.org/appengine v1.6.5 @@ -740,9 +730,7 @@ google.golang.org/appengine/internal/datastore google.golang.org/appengine/internal/log google.golang.org/appengine/internal/modules google.golang.org/appengine/internal/remote_api -google.golang.org/appengine/internal/socket google.golang.org/appengine/internal/urlfetch -google.golang.org/appengine/socket google.golang.org/appengine/urlfetch # google.golang.org/genproto v0.0.0-20191230161307-f3c370f40bfb google.golang.org/genproto/googleapis/api @@ -764,23 +752,12 @@ google.golang.org/grpc/attributes google.golang.org/grpc/backoff google.golang.org/grpc/balancer google.golang.org/grpc/balancer/base -google.golang.org/grpc/balancer/grpclb -google.golang.org/grpc/balancer/grpclb/grpc_lb_v1 google.golang.org/grpc/balancer/roundrobin google.golang.org/grpc/binarylog/grpc_binarylog_v1 google.golang.org/grpc/codes google.golang.org/grpc/connectivity google.golang.org/grpc/credentials -google.golang.org/grpc/credentials/alts -google.golang.org/grpc/credentials/alts/internal -google.golang.org/grpc/credentials/alts/internal/authinfo -google.golang.org/grpc/credentials/alts/internal/conn -google.golang.org/grpc/credentials/alts/internal/handshaker -google.golang.org/grpc/credentials/alts/internal/handshaker/service -google.golang.org/grpc/credentials/alts/internal/proto/grpc_gcp -google.golang.org/grpc/credentials/google google.golang.org/grpc/credentials/internal -google.golang.org/grpc/credentials/oauth google.golang.org/grpc/encoding google.golang.org/grpc/encoding/proto google.golang.org/grpc/grpclog From 7c3d9d7f8993845d217f2f38a7f7c87694ce2552 Mon Sep 17 00:00:00 2001 From: Yousong Zhou Date: Fri, 8 May 2020 22:25:09 +0800 Subject: [PATCH 02/13] vendor: import yunion.io/x/ovsdb --- go.mod | 3 +- go.sum | 6 + vendor/github.com/pkg/errors/.travis.yml | 11 +- vendor/github.com/pkg/errors/Makefile | 44 + vendor/github.com/pkg/errors/README.md | 11 +- vendor/github.com/pkg/errors/errors.go | 8 +- vendor/github.com/pkg/errors/go113.go | 38 + vendor/github.com/pkg/errors/stack.go | 58 +- vendor/modules.txt | 6 +- .../yunion.io/x/ovsdb/cli_util/unmarshal.go | 45 + .../yunion.io/x/ovsdb/schema/ovn_nb/schema.go | 2773 +++++++++++++++++ vendor/yunion.io/x/ovsdb/types/atomic.go | 62 + vendor/yunion.io/x/ovsdb/types/atomic_gen.go | 423 +++ .../types/atomic_gen_cmdargs_zz_generated.go | 418 +++ .../types/atomic_gen_ensures_zz_generated.go | 756 +++++ .../types/atomic_gen_matches_zz_generated.go | 978 ++++++ vendor/yunion.io/x/ovsdb/types/errors.go | 12 + vendor/yunion.io/x/ovsdb/types/generator.go | 52 + vendor/yunion.io/x/ovsdb/types/interface.go | 25 + vendor/yunion.io/x/ovsdb/types/names.go | 30 + .../yunion.io/x/ovsdb/types/ovn-nb.ovsschema | 344 ++ .../yunion.io/x/ovsdb/types/ovn-sb.ovsschema | 272 ++ vendor/yunion.io/x/ovsdb/types/schema.go | 199 ++ vendor/yunion.io/x/ovsdb/types/schema_gen.go | 362 +++ .../yunion.io/x/ovsdb/types/vswitch.ovsschema | 651 ++++ vendor/yunion.io/x/ovsdb/types/vtep.ovsschema | 307 ++ vendor/yunion.io/x/ovsdb/types/writer.go | 21 + 27 files changed, 7888 insertions(+), 27 deletions(-) create mode 100644 vendor/github.com/pkg/errors/Makefile create mode 100644 vendor/github.com/pkg/errors/go113.go create mode 100644 vendor/yunion.io/x/ovsdb/cli_util/unmarshal.go create mode 100644 vendor/yunion.io/x/ovsdb/schema/ovn_nb/schema.go create mode 100644 vendor/yunion.io/x/ovsdb/types/atomic.go create mode 100644 vendor/yunion.io/x/ovsdb/types/atomic_gen.go create mode 100644 vendor/yunion.io/x/ovsdb/types/atomic_gen_cmdargs_zz_generated.go create mode 100644 vendor/yunion.io/x/ovsdb/types/atomic_gen_ensures_zz_generated.go create mode 100644 vendor/yunion.io/x/ovsdb/types/atomic_gen_matches_zz_generated.go create mode 100644 vendor/yunion.io/x/ovsdb/types/errors.go create mode 100644 vendor/yunion.io/x/ovsdb/types/generator.go create mode 100644 vendor/yunion.io/x/ovsdb/types/interface.go create mode 100644 vendor/yunion.io/x/ovsdb/types/names.go create mode 100644 vendor/yunion.io/x/ovsdb/types/ovn-nb.ovsschema create mode 100644 vendor/yunion.io/x/ovsdb/types/ovn-sb.ovsschema create mode 100644 vendor/yunion.io/x/ovsdb/types/schema.go create mode 100644 vendor/yunion.io/x/ovsdb/types/schema_gen.go create mode 100644 vendor/yunion.io/x/ovsdb/types/vswitch.ovsschema create mode 100644 vendor/yunion.io/x/ovsdb/types/vtep.ovsschema create mode 100644 vendor/yunion.io/x/ovsdb/types/writer.go diff --git a/go.mod b/go.mod index db1a200eb4..39fdfa2d00 100644 --- a/go.mod +++ b/go.mod @@ -86,7 +86,7 @@ require ( github.com/opentracing/opentracing-go v1.0.2 // indirect github.com/openzipkin/zipkin-go-opentracing v0.3.4 // indirect github.com/pierrec/lz4 v2.0.5+incompatible - github.com/pkg/errors v0.8.1 + github.com/pkg/errors v0.9.1 github.com/pkg/term v0.0.0-20181116001808-27bbf2edb814 // indirect github.com/pquerna/otp v1.2.0 github.com/serialx/hashring v0.0.0-20180504054112-49a4782e9908 @@ -129,6 +129,7 @@ require ( yunion.io/x/executor v0.0.0-20200227030256-a18417815e74 yunion.io/x/jsonutils v0.0.0-20200415132054-2bf8a5e94501 yunion.io/x/log v0.0.0-20200313080802-57a4ce5966b3 + yunion.io/x/ovsdb v0.0.0-20200508142751-3e60f3fc7d18 yunion.io/x/pkg v0.0.0-20200416145704-22c189971435 yunion.io/x/s3cli v0.0.0-20190917004522-13ac36d8687e yunion.io/x/sqlchemy v0.0.0-20200312002602-1177cd8fbc57 diff --git a/go.sum b/go.sum index 6c5f5650cb..1dfcf0c968 100644 --- a/go.sum +++ b/go.sum @@ -630,6 +630,8 @@ github.com/pierrec/lz4 v2.0.5+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= +github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/term v0.0.0-20181116001808-27bbf2edb814 h1:qWlKm6sU/AyVAgBC1Pg1uuY/X/p4lNYG7t4v8/f4FJE= github.com/pkg/term v0.0.0-20181116001808-27bbf2edb814/go.mod h1:eCbImbZ95eXtAUIbLAuAVnBnwf83mjf6QIVH8SHYwqQ= github.com/pmezard/go-difflib v0.0.0-20151028094244-d8ed2627bdf0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= @@ -1113,6 +1115,10 @@ yunion.io/x/log v0.0.0-20190629062853-9f6483a7103d h1:59zrDL7Ft+hDukguJRmLr/Gdu/ yunion.io/x/log v0.0.0-20190629062853-9f6483a7103d/go.mod h1:LC6f/4FozL0iaAbnFt2eDX9jlsyo3WiOUPm03d7+U4U= yunion.io/x/log v0.0.0-20200313080802-57a4ce5966b3 h1:5Wc5hkB8PtMudmHuzCyok960RuOa9I55imIGrigSdjs= yunion.io/x/log v0.0.0-20200313080802-57a4ce5966b3/go.mod h1:LC6f/4FozL0iaAbnFt2eDX9jlsyo3WiOUPm03d7+U4U= +yunion.io/x/ovsdb v0.0.0-20200508121407-498ee891147e h1:M6sOv52s2wqXECm9w9eMHfEnxvSAfPsVwVmyD4yKbiI= +yunion.io/x/ovsdb v0.0.0-20200508121407-498ee891147e/go.mod h1:0vLkNEhlmA64HViPBAnSTUMrx5QP1CLsxXmxDKQ80tc= +yunion.io/x/ovsdb v0.0.0-20200508142751-3e60f3fc7d18 h1:MTR7IYAR5oxAjmBIcnk8A6PIjHz7gLN69jUgnkgYgQ8= +yunion.io/x/ovsdb v0.0.0-20200508142751-3e60f3fc7d18/go.mod h1:0vLkNEhlmA64HViPBAnSTUMrx5QP1CLsxXmxDKQ80tc= yunion.io/x/pkg v0.0.0-20190620104149-945c25821dbf/go.mod h1:t6rEGG2sQ4J7DhFxSZVOTjNd0YO/KlfWQyK1W4tog+E= yunion.io/x/pkg v0.0.0-20190628082551-f4033ba2ea30/go.mod h1:t6rEGG2sQ4J7DhFxSZVOTjNd0YO/KlfWQyK1W4tog+E= yunion.io/x/pkg v0.0.0-20200302034534-fdf44d54b070/go.mod h1:t6rEGG2sQ4J7DhFxSZVOTjNd0YO/KlfWQyK1W4tog+E= diff --git a/vendor/github.com/pkg/errors/.travis.yml b/vendor/github.com/pkg/errors/.travis.yml index d4b92663ba..9159de03e0 100644 --- a/vendor/github.com/pkg/errors/.travis.yml +++ b/vendor/github.com/pkg/errors/.travis.yml @@ -1,15 +1,10 @@ language: go go_import_path: github.com/pkg/errors go: - - 1.4.x - - 1.5.x - - 1.6.x - - 1.7.x - - 1.8.x - - 1.9.x - - 1.10.x - 1.11.x + - 1.12.x + - 1.13.x - tip script: - - go test -v ./... + - make check diff --git a/vendor/github.com/pkg/errors/Makefile b/vendor/github.com/pkg/errors/Makefile new file mode 100644 index 0000000000..ce9d7cded6 --- /dev/null +++ b/vendor/github.com/pkg/errors/Makefile @@ -0,0 +1,44 @@ +PKGS := github.com/pkg/errors +SRCDIRS := $(shell go list -f '{{.Dir}}' $(PKGS)) +GO := go + +check: test vet gofmt misspell unconvert staticcheck ineffassign unparam + +test: + $(GO) test $(PKGS) + +vet: | test + $(GO) vet $(PKGS) + +staticcheck: + $(GO) get honnef.co/go/tools/cmd/staticcheck + staticcheck -checks all $(PKGS) + +misspell: + $(GO) get github.com/client9/misspell/cmd/misspell + misspell \ + -locale GB \ + -error \ + *.md *.go + +unconvert: + $(GO) get github.com/mdempsky/unconvert + unconvert -v $(PKGS) + +ineffassign: + $(GO) get github.com/gordonklaus/ineffassign + find $(SRCDIRS) -name '*.go' | xargs ineffassign + +pedantic: check errcheck + +unparam: + $(GO) get mvdan.cc/unparam + unparam ./... + +errcheck: + $(GO) get github.com/kisielk/errcheck + errcheck $(PKGS) + +gofmt: + @echo Checking code is gofmted + @test -z "$(shell gofmt -s -l -d -e $(SRCDIRS) | tee /dev/stderr)" diff --git a/vendor/github.com/pkg/errors/README.md b/vendor/github.com/pkg/errors/README.md index 6483ba2afb..54dfdcb12e 100644 --- a/vendor/github.com/pkg/errors/README.md +++ b/vendor/github.com/pkg/errors/README.md @@ -41,11 +41,18 @@ default: [Read the package documentation for more information](https://godoc.org/github.com/pkg/errors). +## Roadmap + +With the upcoming [Go2 error proposals](https://go.googlesource.com/proposal/+/master/design/go2draft.md) this package is moving into maintenance mode. The roadmap for a 1.0 release is as follows: + +- 0.9. Remove pre Go 1.9 and Go 1.10 support, address outstanding pull requests (if possible) +- 1.0. Final release. + ## Contributing -We welcome pull requests, bug fixes and issue reports. With that said, the bar for adding new symbols to this package is intentionally set high. +Because of the Go2 errors changes, this package is not accepting proposals for new functionality. With that said, we welcome pull requests, bug fixes and issue reports. -Before proposing a change, please discuss your change by raising an issue. +Before sending a PR, please discuss your change by raising an issue. ## License diff --git a/vendor/github.com/pkg/errors/errors.go b/vendor/github.com/pkg/errors/errors.go index 7421f326ff..161aea2582 100644 --- a/vendor/github.com/pkg/errors/errors.go +++ b/vendor/github.com/pkg/errors/errors.go @@ -82,7 +82,7 @@ // // if err, ok := err.(stackTracer); ok { // for _, f := range err.StackTrace() { -// fmt.Printf("%+s:%d", f) +// fmt.Printf("%+s:%d\n", f, f) // } // } // @@ -159,6 +159,9 @@ type withStack struct { func (w *withStack) Cause() error { return w.error } +// Unwrap provides compatibility for Go 1.13 error chains. +func (w *withStack) Unwrap() error { return w.error } + func (w *withStack) Format(s fmt.State, verb rune) { switch verb { case 'v': @@ -241,6 +244,9 @@ type withMessage struct { func (w *withMessage) Error() string { return w.msg + ": " + w.cause.Error() } func (w *withMessage) Cause() error { return w.cause } +// Unwrap provides compatibility for Go 1.13 error chains. +func (w *withMessage) Unwrap() error { return w.cause } + func (w *withMessage) Format(s fmt.State, verb rune) { switch verb { case 'v': diff --git a/vendor/github.com/pkg/errors/go113.go b/vendor/github.com/pkg/errors/go113.go new file mode 100644 index 0000000000..be0d10d0c7 --- /dev/null +++ b/vendor/github.com/pkg/errors/go113.go @@ -0,0 +1,38 @@ +// +build go1.13 + +package errors + +import ( + stderrors "errors" +) + +// Is reports whether any error in err's chain matches target. +// +// The chain consists of err itself followed by the sequence of errors obtained by +// repeatedly calling Unwrap. +// +// An error is considered to match a target if it is equal to that target or if +// it implements a method Is(error) bool such that Is(target) returns true. +func Is(err, target error) bool { return stderrors.Is(err, target) } + +// As finds the first error in err's chain that matches target, and if so, sets +// target to that error value and returns true. +// +// The chain consists of err itself followed by the sequence of errors obtained by +// repeatedly calling Unwrap. +// +// An error matches target if the error's concrete value is assignable to the value +// pointed to by target, or if the error has a method As(interface{}) bool such that +// As(target) returns true. In the latter case, the As method is responsible for +// setting target. +// +// As will panic if target is not a non-nil pointer to either a type that implements +// error, or to any interface type. As returns false if err is nil. +func As(err error, target interface{}) bool { return stderrors.As(err, target) } + +// Unwrap returns the result of calling the Unwrap method on err, if err's +// type contains an Unwrap method returning error. +// Otherwise, Unwrap returns nil. +func Unwrap(err error) error { + return stderrors.Unwrap(err) +} diff --git a/vendor/github.com/pkg/errors/stack.go b/vendor/github.com/pkg/errors/stack.go index 2874a048cf..779a8348fb 100644 --- a/vendor/github.com/pkg/errors/stack.go +++ b/vendor/github.com/pkg/errors/stack.go @@ -5,10 +5,13 @@ import ( "io" "path" "runtime" + "strconv" "strings" ) // Frame represents a program counter inside a stack frame. +// For historical reasons if Frame is interpreted as a uintptr +// its value represents the program counter + 1. type Frame uintptr // pc returns the program counter for this frame; @@ -37,6 +40,15 @@ func (f Frame) line() int { return line } +// name returns the name of this function, if known. +func (f Frame) name() string { + fn := runtime.FuncForPC(f.pc()) + if fn == nil { + return "unknown" + } + return fn.Name() +} + // Format formats the frame according to the fmt.Formatter interface. // // %s source file @@ -54,22 +66,16 @@ func (f Frame) Format(s fmt.State, verb rune) { case 's': switch { case s.Flag('+'): - pc := f.pc() - fn := runtime.FuncForPC(pc) - if fn == nil { - io.WriteString(s, "unknown") - } else { - file, _ := fn.FileLine(pc) - fmt.Fprintf(s, "%s\n\t%s", fn.Name(), file) - } + io.WriteString(s, f.name()) + io.WriteString(s, "\n\t") + io.WriteString(s, f.file()) default: io.WriteString(s, path.Base(f.file())) } case 'd': - fmt.Fprintf(s, "%d", f.line()) + io.WriteString(s, strconv.Itoa(f.line())) case 'n': - name := runtime.FuncForPC(f.pc()).Name() - io.WriteString(s, funcname(name)) + io.WriteString(s, funcname(f.name())) case 'v': f.Format(s, 's') io.WriteString(s, ":") @@ -77,6 +83,16 @@ func (f Frame) Format(s fmt.State, verb rune) { } } +// MarshalText formats a stacktrace Frame as a text string. The output is the +// same as that of fmt.Sprintf("%+v", f), but without newlines or tabs. +func (f Frame) MarshalText() ([]byte, error) { + name := f.name() + if name == "unknown" { + return []byte(name), nil + } + return []byte(fmt.Sprintf("%s %s:%d", name, f.file(), f.line())), nil +} + // StackTrace is stack of Frames from innermost (newest) to outermost (oldest). type StackTrace []Frame @@ -94,18 +110,32 @@ func (st StackTrace) Format(s fmt.State, verb rune) { switch { case s.Flag('+'): for _, f := range st { - fmt.Fprintf(s, "\n%+v", f) + io.WriteString(s, "\n") + f.Format(s, verb) } case s.Flag('#'): fmt.Fprintf(s, "%#v", []Frame(st)) default: - fmt.Fprintf(s, "%v", []Frame(st)) + st.formatSlice(s, verb) } case 's': - fmt.Fprintf(s, "%s", []Frame(st)) + st.formatSlice(s, verb) } } +// formatSlice will format this StackTrace into the given buffer as a slice of +// Frame, only valid when called with '%s' or '%v'. +func (st StackTrace) formatSlice(s fmt.State, verb rune) { + io.WriteString(s, "[") + for i, f := range st { + if i > 0 { + io.WriteString(s, " ") + } + f.Format(s, verb) + } + io.WriteString(s, "]") +} + // stack represents a stack of program counters. type stack []uintptr diff --git a/vendor/modules.txt b/vendor/modules.txt index 1f63f06d0c..166fc98a94 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -464,7 +464,7 @@ github.com/philhofer/fwd # github.com/pierrec/lz4 v2.0.5+incompatible github.com/pierrec/lz4 github.com/pierrec/lz4/internal/xxh32 -# github.com/pkg/errors v0.8.1 +# github.com/pkg/errors v0.9.1 github.com/pkg/errors # github.com/pkg/term v0.0.0-20181116001808-27bbf2edb814 github.com/pkg/term/termios @@ -996,6 +996,10 @@ yunion.io/x/jsonutils # yunion.io/x/log v0.0.0-20200313080802-57a4ce5966b3 yunion.io/x/log yunion.io/x/log/hooks +# yunion.io/x/ovsdb v0.0.0-20200508142751-3e60f3fc7d18 +yunion.io/x/ovsdb/cli_util +yunion.io/x/ovsdb/schema/ovn_nb +yunion.io/x/ovsdb/types # yunion.io/x/pkg v0.0.0-20200416145704-22c189971435 yunion.io/x/pkg/errors yunion.io/x/pkg/gotypes diff --git a/vendor/yunion.io/x/ovsdb/cli_util/unmarshal.go b/vendor/yunion.io/x/ovsdb/cli_util/unmarshal.go new file mode 100644 index 0000000000..72b5599e7d --- /dev/null +++ b/vendor/yunion.io/x/ovsdb/cli_util/unmarshal.go @@ -0,0 +1,45 @@ +package cli_util + +import ( + "encoding/json" + "fmt" + + "yunion.io/x/ovsdb/types" +) + +type List struct { + Headings ListHeadings + Data []ListDataRow +} +type ListHeadings []string +type ListDataRow []ListDataColumn +type ListDataColumn = interface{} + +func (h ListHeadings) getNth(i int) (string, error) { + if i < len(h) { + return h[i], nil + } + return "", fmt.Errorf("bad index into list headings (%d>=%d)", i, len(h)) +} + +func UnmarshalJSON(data []byte, irows types.ITable) error { + list := &List{} + if err := json.Unmarshal(data, list); err != nil { + return err + } + for _, row := range list.Data { + irow := irows.NewRow() + for colI := range row { + col := row[colI] + colName, err := list.Headings.getNth(colI) + if err != nil { + return err + } + if err := irow.SetColumn(colName, col); err != nil { + return err + } + } + irows.AppendRow(irow) + } + return nil +} diff --git a/vendor/yunion.io/x/ovsdb/schema/ovn_nb/schema.go b/vendor/yunion.io/x/ovsdb/schema/ovn_nb/schema.go new file mode 100644 index 0000000000..08345e2793 --- /dev/null +++ b/vendor/yunion.io/x/ovsdb/schema/ovn_nb/schema.go @@ -0,0 +1,2773 @@ +// DO NOT EDIT: automatically generated code + +package ovn_nb + +import ( + "fmt" + + "github.com/pkg/errors" + + "yunion.io/x/ovsdb/types" +) + +type OVNNorthbound struct { + ACL ACLTable + AddressSet AddressSetTable + Connection ConnectionTable + DHCPOptions DHCPOptionsTable + DNS DNSTable + GatewayChassis GatewayChassisTable + LoadBalancer LoadBalancerTable + LogicalRouter LogicalRouterTable + LogicalRouterPort LogicalRouterPortTable + LogicalRouterStaticRoute LogicalRouterStaticRouteTable + LogicalSwitch LogicalSwitchTable + LogicalSwitchPort LogicalSwitchPortTable + NAT NATTable + NBGlobal NBGlobalTable + QoS QoSTable + SSL SSLTable +} + +func (db OVNNorthbound) FindOneMatchNonZeros(irow types.IRow) types.IRow { + switch row := irow.(type) { + case *ACL: + if r := db.ACL.FindOneMatchNonZeros(row); r != nil { + return r + } + return nil + } + switch row := irow.(type) { + case *AddressSet: + if r := db.AddressSet.FindOneMatchNonZeros(row); r != nil { + return r + } + return nil + } + switch row := irow.(type) { + case *Connection: + if r := db.Connection.FindOneMatchNonZeros(row); r != nil { + return r + } + return nil + } + switch row := irow.(type) { + case *DHCPOptions: + if r := db.DHCPOptions.FindOneMatchNonZeros(row); r != nil { + return r + } + return nil + } + switch row := irow.(type) { + case *DNS: + if r := db.DNS.FindOneMatchNonZeros(row); r != nil { + return r + } + return nil + } + switch row := irow.(type) { + case *GatewayChassis: + if r := db.GatewayChassis.FindOneMatchNonZeros(row); r != nil { + return r + } + return nil + } + switch row := irow.(type) { + case *LoadBalancer: + if r := db.LoadBalancer.FindOneMatchNonZeros(row); r != nil { + return r + } + return nil + } + switch row := irow.(type) { + case *LogicalRouter: + if r := db.LogicalRouter.FindOneMatchNonZeros(row); r != nil { + return r + } + return nil + } + switch row := irow.(type) { + case *LogicalRouterPort: + if r := db.LogicalRouterPort.FindOneMatchNonZeros(row); r != nil { + return r + } + return nil + } + switch row := irow.(type) { + case *LogicalRouterStaticRoute: + if r := db.LogicalRouterStaticRoute.FindOneMatchNonZeros(row); r != nil { + return r + } + return nil + } + switch row := irow.(type) { + case *LogicalSwitch: + if r := db.LogicalSwitch.FindOneMatchNonZeros(row); r != nil { + return r + } + return nil + } + switch row := irow.(type) { + case *LogicalSwitchPort: + if r := db.LogicalSwitchPort.FindOneMatchNonZeros(row); r != nil { + return r + } + return nil + } + switch row := irow.(type) { + case *NAT: + if r := db.NAT.FindOneMatchNonZeros(row); r != nil { + return r + } + return nil + } + switch row := irow.(type) { + case *NBGlobal: + if r := db.NBGlobal.FindOneMatchNonZeros(row); r != nil { + return r + } + return nil + } + switch row := irow.(type) { + case *QoS: + if r := db.QoS.FindOneMatchNonZeros(row); r != nil { + return r + } + return nil + } + switch row := irow.(type) { + case *SSL: + if r := db.SSL.FindOneMatchNonZeros(row); r != nil { + return r + } + return nil + } + panic(types.ErrBadType) +} + +type ACLTable []ACL + +var _ types.ITable = &ACLTable{} + +func (tbl ACLTable) OvsdbTableName() string { + return "ACL" +} + +func (tbl ACLTable) OvsdbIsRoot() bool { + return false +} + +func (tbl ACLTable) Rows() []types.IRow { + r := make([]types.IRow, len(tbl)) + for i := range tbl { + r[i] = &tbl[i] + } + return r +} + +func (tbl ACLTable) NewRow() types.IRow { + return &ACL{} +} + +func (tbl *ACLTable) AppendRow(irow types.IRow) { + row := irow.(*ACL) + *tbl = append(*tbl, *row) +} + +func (tbl ACLTable) FindOneMatchNonZeros(row1 *ACL) *ACL { + for i := range tbl { + row := &tbl[i] + if row.MatchNonZeros(row1) { + return row + } + } + return nil +} + +type ACL struct { + Uuid string `json:"_uuid"` + Version string `json:"_version"` + Action string `json:"action"` + Direction string `json:"direction"` + ExternalIds map[string]string `json:"external_ids"` + Log bool `json:"log"` + Match string `json:"match"` + Name *string `json:"name"` + Priority int64 `json:"priority"` + Severity *string `json:"severity"` +} + +var _ types.IRow = &ACL{} + +func (row *ACL) OvsdbTableName() string { + return "ACL" +} + +func (row *ACL) OvsdbIsRoot() bool { + return false +} + +func (row *ACL) OvsdbUuid() string { + return row.Uuid +} + +func (row *ACL) OvsdbCmdArgs() []string { + r := []string{} + r = append(r, types.OvsdbCmdArgsString("action", row.Action)...) + r = append(r, types.OvsdbCmdArgsString("direction", row.Direction)...) + r = append(r, types.OvsdbCmdArgsMapStringString("external_ids", row.ExternalIds)...) + r = append(r, types.OvsdbCmdArgsBoolean("log", row.Log)...) + r = append(r, types.OvsdbCmdArgsString("match", row.Match)...) + r = append(r, types.OvsdbCmdArgsStringOptional("name", row.Name)...) + r = append(r, types.OvsdbCmdArgsInteger("priority", row.Priority)...) + r = append(r, types.OvsdbCmdArgsStringOptional("severity", row.Severity)...) + return r +} + +func (row *ACL) SetColumn(name string, val interface{}) (err error) { + defer func() { + if panicErr := recover(); panicErr != nil { + err = errors.Wrapf(panicErr.(error), "%s: %#v", name, fmt.Sprintf("%#v", val)) + } + }() + switch name { + case "_uuid": + row.Uuid = types.EnsureUuid(val) + case "_version": + row.Version = types.EnsureUuid(val) + case "action": + row.Action = types.EnsureString(val) + case "direction": + row.Direction = types.EnsureString(val) + case "external_ids": + row.ExternalIds = types.EnsureMapStringString(val) + case "log": + row.Log = types.EnsureBoolean(val) + case "match": + row.Match = types.EnsureString(val) + case "name": + row.Name = types.EnsureStringOptional(val) + case "priority": + row.Priority = types.EnsureInteger(val) + case "severity": + row.Severity = types.EnsureStringOptional(val) + default: + panic(types.ErrUnknownColumn) + } + return +} + +func (row *ACL) MatchNonZeros(row1 *ACL) bool { + if !types.MatchUuidIfNonZero(row.Uuid, row1.Uuid) { + return false + } + if !types.MatchUuidIfNonZero(row.Version, row1.Version) { + return false + } + if !types.MatchStringIfNonZero(row.Action, row1.Action) { + return false + } + if !types.MatchStringIfNonZero(row.Direction, row1.Direction) { + return false + } + if !types.MatchMapStringStringIfNonZero(row.ExternalIds, row1.ExternalIds) { + return false + } + if !types.MatchBooleanIfNonZero(row.Log, row1.Log) { + return false + } + if !types.MatchStringIfNonZero(row.Match, row1.Match) { + return false + } + if !types.MatchStringOptionalIfNonZero(row.Name, row1.Name) { + return false + } + if !types.MatchIntegerIfNonZero(row.Priority, row1.Priority) { + return false + } + if !types.MatchStringOptionalIfNonZero(row.Severity, row1.Severity) { + return false + } + return true +} + +func (row *ACL) HasExternalIds() bool { + return true +} + +func (row *ACL) SetExternalId(k, v string) { + if row.ExternalIds == nil { + row.ExternalIds = map[string]string{} + } + row.ExternalIds[k] = v +} + +func (row *ACL) GetExternalId(k string) (string, bool) { + if row.ExternalIds == nil { + return "", false + } + r, ok := row.ExternalIds[k] + return r, ok +} + +func (row *ACL) RemoveExternalId(k string) (string, bool) { + if row.ExternalIds == nil { + return "", false + } + r, ok := row.ExternalIds[k] + if ok { + delete(row.ExternalIds, k) + } + return r, ok +} + +type AddressSetTable []AddressSet + +var _ types.ITable = &AddressSetTable{} + +func (tbl AddressSetTable) OvsdbTableName() string { + return "Address_Set" +} + +func (tbl AddressSetTable) OvsdbIsRoot() bool { + return true +} + +func (tbl AddressSetTable) Rows() []types.IRow { + r := make([]types.IRow, len(tbl)) + for i := range tbl { + r[i] = &tbl[i] + } + return r +} + +func (tbl AddressSetTable) NewRow() types.IRow { + return &AddressSet{} +} + +func (tbl *AddressSetTable) AppendRow(irow types.IRow) { + row := irow.(*AddressSet) + *tbl = append(*tbl, *row) +} + +func (tbl AddressSetTable) FindOneMatchNonZeros(row1 *AddressSet) *AddressSet { + for i := range tbl { + row := &tbl[i] + if row.MatchNonZeros(row1) { + return row + } + } + return nil +} + +type AddressSet struct { + Uuid string `json:"_uuid"` + Version string `json:"_version"` + Addresses []string `json:"addresses"` + ExternalIds map[string]string `json:"external_ids"` + Name string `json:"name"` +} + +var _ types.IRow = &AddressSet{} + +func (row *AddressSet) OvsdbTableName() string { + return "Address_Set" +} + +func (row *AddressSet) OvsdbIsRoot() bool { + return true +} + +func (row *AddressSet) OvsdbUuid() string { + return row.Uuid +} + +func (row *AddressSet) OvsdbCmdArgs() []string { + r := []string{} + r = append(r, types.OvsdbCmdArgsStringMultiples("addresses", row.Addresses)...) + r = append(r, types.OvsdbCmdArgsMapStringString("external_ids", row.ExternalIds)...) + r = append(r, types.OvsdbCmdArgsString("name", row.Name)...) + return r +} + +func (row *AddressSet) SetColumn(name string, val interface{}) (err error) { + defer func() { + if panicErr := recover(); panicErr != nil { + err = errors.Wrapf(panicErr.(error), "%s: %#v", name, fmt.Sprintf("%#v", val)) + } + }() + switch name { + case "_uuid": + row.Uuid = types.EnsureUuid(val) + case "_version": + row.Version = types.EnsureUuid(val) + case "addresses": + row.Addresses = types.EnsureStringMultiples(val) + case "external_ids": + row.ExternalIds = types.EnsureMapStringString(val) + case "name": + row.Name = types.EnsureString(val) + default: + panic(types.ErrUnknownColumn) + } + return +} + +func (row *AddressSet) MatchNonZeros(row1 *AddressSet) bool { + if !types.MatchUuidIfNonZero(row.Uuid, row1.Uuid) { + return false + } + if !types.MatchUuidIfNonZero(row.Version, row1.Version) { + return false + } + if !types.MatchStringMultiplesIfNonZero(row.Addresses, row1.Addresses) { + return false + } + if !types.MatchMapStringStringIfNonZero(row.ExternalIds, row1.ExternalIds) { + return false + } + if !types.MatchStringIfNonZero(row.Name, row1.Name) { + return false + } + return true +} + +func (row *AddressSet) HasExternalIds() bool { + return true +} + +func (row *AddressSet) SetExternalId(k, v string) { + if row.ExternalIds == nil { + row.ExternalIds = map[string]string{} + } + row.ExternalIds[k] = v +} + +func (row *AddressSet) GetExternalId(k string) (string, bool) { + if row.ExternalIds == nil { + return "", false + } + r, ok := row.ExternalIds[k] + return r, ok +} + +func (row *AddressSet) RemoveExternalId(k string) (string, bool) { + if row.ExternalIds == nil { + return "", false + } + r, ok := row.ExternalIds[k] + if ok { + delete(row.ExternalIds, k) + } + return r, ok +} + +type ConnectionTable []Connection + +var _ types.ITable = &ConnectionTable{} + +func (tbl ConnectionTable) OvsdbTableName() string { + return "Connection" +} + +func (tbl ConnectionTable) OvsdbIsRoot() bool { + return false +} + +func (tbl ConnectionTable) Rows() []types.IRow { + r := make([]types.IRow, len(tbl)) + for i := range tbl { + r[i] = &tbl[i] + } + return r +} + +func (tbl ConnectionTable) NewRow() types.IRow { + return &Connection{} +} + +func (tbl *ConnectionTable) AppendRow(irow types.IRow) { + row := irow.(*Connection) + *tbl = append(*tbl, *row) +} + +func (tbl ConnectionTable) FindOneMatchNonZeros(row1 *Connection) *Connection { + for i := range tbl { + row := &tbl[i] + if row.MatchNonZeros(row1) { + return row + } + } + return nil +} + +type Connection struct { + Uuid string `json:"_uuid"` + Version string `json:"_version"` + ExternalIds map[string]string `json:"external_ids"` + InactivityProbe *int64 `json:"inactivity_probe"` + IsConnected bool `json:"is_connected"` + MaxBackoff *int64 `json:"max_backoff"` + OtherConfig map[string]string `json:"other_config"` + Status map[string]string `json:"status"` + Target string `json:"target"` +} + +var _ types.IRow = &Connection{} + +func (row *Connection) OvsdbTableName() string { + return "Connection" +} + +func (row *Connection) OvsdbIsRoot() bool { + return false +} + +func (row *Connection) OvsdbUuid() string { + return row.Uuid +} + +func (row *Connection) OvsdbCmdArgs() []string { + r := []string{} + r = append(r, types.OvsdbCmdArgsMapStringString("external_ids", row.ExternalIds)...) + r = append(r, types.OvsdbCmdArgsIntegerOptional("inactivity_probe", row.InactivityProbe)...) + r = append(r, types.OvsdbCmdArgsBoolean("is_connected", row.IsConnected)...) + r = append(r, types.OvsdbCmdArgsIntegerOptional("max_backoff", row.MaxBackoff)...) + r = append(r, types.OvsdbCmdArgsMapStringString("other_config", row.OtherConfig)...) + r = append(r, types.OvsdbCmdArgsMapStringString("status", row.Status)...) + r = append(r, types.OvsdbCmdArgsString("target", row.Target)...) + return r +} + +func (row *Connection) SetColumn(name string, val interface{}) (err error) { + defer func() { + if panicErr := recover(); panicErr != nil { + err = errors.Wrapf(panicErr.(error), "%s: %#v", name, fmt.Sprintf("%#v", val)) + } + }() + switch name { + case "_uuid": + row.Uuid = types.EnsureUuid(val) + case "_version": + row.Version = types.EnsureUuid(val) + case "external_ids": + row.ExternalIds = types.EnsureMapStringString(val) + case "inactivity_probe": + row.InactivityProbe = types.EnsureIntegerOptional(val) + case "is_connected": + row.IsConnected = types.EnsureBoolean(val) + case "max_backoff": + row.MaxBackoff = types.EnsureIntegerOptional(val) + case "other_config": + row.OtherConfig = types.EnsureMapStringString(val) + case "status": + row.Status = types.EnsureMapStringString(val) + case "target": + row.Target = types.EnsureString(val) + default: + panic(types.ErrUnknownColumn) + } + return +} + +func (row *Connection) MatchNonZeros(row1 *Connection) bool { + if !types.MatchUuidIfNonZero(row.Uuid, row1.Uuid) { + return false + } + if !types.MatchUuidIfNonZero(row.Version, row1.Version) { + return false + } + if !types.MatchMapStringStringIfNonZero(row.ExternalIds, row1.ExternalIds) { + return false + } + if !types.MatchIntegerOptionalIfNonZero(row.InactivityProbe, row1.InactivityProbe) { + return false + } + if !types.MatchBooleanIfNonZero(row.IsConnected, row1.IsConnected) { + return false + } + if !types.MatchIntegerOptionalIfNonZero(row.MaxBackoff, row1.MaxBackoff) { + return false + } + if !types.MatchMapStringStringIfNonZero(row.OtherConfig, row1.OtherConfig) { + return false + } + if !types.MatchMapStringStringIfNonZero(row.Status, row1.Status) { + return false + } + if !types.MatchStringIfNonZero(row.Target, row1.Target) { + return false + } + return true +} + +func (row *Connection) HasExternalIds() bool { + return true +} + +func (row *Connection) SetExternalId(k, v string) { + if row.ExternalIds == nil { + row.ExternalIds = map[string]string{} + } + row.ExternalIds[k] = v +} + +func (row *Connection) GetExternalId(k string) (string, bool) { + if row.ExternalIds == nil { + return "", false + } + r, ok := row.ExternalIds[k] + return r, ok +} + +func (row *Connection) RemoveExternalId(k string) (string, bool) { + if row.ExternalIds == nil { + return "", false + } + r, ok := row.ExternalIds[k] + if ok { + delete(row.ExternalIds, k) + } + return r, ok +} + +type DHCPOptionsTable []DHCPOptions + +var _ types.ITable = &DHCPOptionsTable{} + +func (tbl DHCPOptionsTable) OvsdbTableName() string { + return "DHCP_Options" +} + +func (tbl DHCPOptionsTable) OvsdbIsRoot() bool { + return true +} + +func (tbl DHCPOptionsTable) Rows() []types.IRow { + r := make([]types.IRow, len(tbl)) + for i := range tbl { + r[i] = &tbl[i] + } + return r +} + +func (tbl DHCPOptionsTable) NewRow() types.IRow { + return &DHCPOptions{} +} + +func (tbl *DHCPOptionsTable) AppendRow(irow types.IRow) { + row := irow.(*DHCPOptions) + *tbl = append(*tbl, *row) +} + +func (tbl DHCPOptionsTable) FindOneMatchNonZeros(row1 *DHCPOptions) *DHCPOptions { + for i := range tbl { + row := &tbl[i] + if row.MatchNonZeros(row1) { + return row + } + } + return nil +} + +type DHCPOptions struct { + Uuid string `json:"_uuid"` + Version string `json:"_version"` + Cidr string `json:"cidr"` + ExternalIds map[string]string `json:"external_ids"` + Options map[string]string `json:"options"` +} + +var _ types.IRow = &DHCPOptions{} + +func (row *DHCPOptions) OvsdbTableName() string { + return "DHCP_Options" +} + +func (row *DHCPOptions) OvsdbIsRoot() bool { + return true +} + +func (row *DHCPOptions) OvsdbUuid() string { + return row.Uuid +} + +func (row *DHCPOptions) OvsdbCmdArgs() []string { + r := []string{} + r = append(r, types.OvsdbCmdArgsString("cidr", row.Cidr)...) + r = append(r, types.OvsdbCmdArgsMapStringString("external_ids", row.ExternalIds)...) + r = append(r, types.OvsdbCmdArgsMapStringString("options", row.Options)...) + return r +} + +func (row *DHCPOptions) SetColumn(name string, val interface{}) (err error) { + defer func() { + if panicErr := recover(); panicErr != nil { + err = errors.Wrapf(panicErr.(error), "%s: %#v", name, fmt.Sprintf("%#v", val)) + } + }() + switch name { + case "_uuid": + row.Uuid = types.EnsureUuid(val) + case "_version": + row.Version = types.EnsureUuid(val) + case "cidr": + row.Cidr = types.EnsureString(val) + case "external_ids": + row.ExternalIds = types.EnsureMapStringString(val) + case "options": + row.Options = types.EnsureMapStringString(val) + default: + panic(types.ErrUnknownColumn) + } + return +} + +func (row *DHCPOptions) MatchNonZeros(row1 *DHCPOptions) bool { + if !types.MatchUuidIfNonZero(row.Uuid, row1.Uuid) { + return false + } + if !types.MatchUuidIfNonZero(row.Version, row1.Version) { + return false + } + if !types.MatchStringIfNonZero(row.Cidr, row1.Cidr) { + return false + } + if !types.MatchMapStringStringIfNonZero(row.ExternalIds, row1.ExternalIds) { + return false + } + if !types.MatchMapStringStringIfNonZero(row.Options, row1.Options) { + return false + } + return true +} + +func (row *DHCPOptions) HasExternalIds() bool { + return true +} + +func (row *DHCPOptions) SetExternalId(k, v string) { + if row.ExternalIds == nil { + row.ExternalIds = map[string]string{} + } + row.ExternalIds[k] = v +} + +func (row *DHCPOptions) GetExternalId(k string) (string, bool) { + if row.ExternalIds == nil { + return "", false + } + r, ok := row.ExternalIds[k] + return r, ok +} + +func (row *DHCPOptions) RemoveExternalId(k string) (string, bool) { + if row.ExternalIds == nil { + return "", false + } + r, ok := row.ExternalIds[k] + if ok { + delete(row.ExternalIds, k) + } + return r, ok +} + +type DNSTable []DNS + +var _ types.ITable = &DNSTable{} + +func (tbl DNSTable) OvsdbTableName() string { + return "DNS" +} + +func (tbl DNSTable) OvsdbIsRoot() bool { + return true +} + +func (tbl DNSTable) Rows() []types.IRow { + r := make([]types.IRow, len(tbl)) + for i := range tbl { + r[i] = &tbl[i] + } + return r +} + +func (tbl DNSTable) NewRow() types.IRow { + return &DNS{} +} + +func (tbl *DNSTable) AppendRow(irow types.IRow) { + row := irow.(*DNS) + *tbl = append(*tbl, *row) +} + +func (tbl DNSTable) FindOneMatchNonZeros(row1 *DNS) *DNS { + for i := range tbl { + row := &tbl[i] + if row.MatchNonZeros(row1) { + return row + } + } + return nil +} + +type DNS struct { + Uuid string `json:"_uuid"` + Version string `json:"_version"` + ExternalIds map[string]string `json:"external_ids"` + Records map[string]string `json:"records"` +} + +var _ types.IRow = &DNS{} + +func (row *DNS) OvsdbTableName() string { + return "DNS" +} + +func (row *DNS) OvsdbIsRoot() bool { + return true +} + +func (row *DNS) OvsdbUuid() string { + return row.Uuid +} + +func (row *DNS) OvsdbCmdArgs() []string { + r := []string{} + r = append(r, types.OvsdbCmdArgsMapStringString("external_ids", row.ExternalIds)...) + r = append(r, types.OvsdbCmdArgsMapStringString("records", row.Records)...) + return r +} + +func (row *DNS) SetColumn(name string, val interface{}) (err error) { + defer func() { + if panicErr := recover(); panicErr != nil { + err = errors.Wrapf(panicErr.(error), "%s: %#v", name, fmt.Sprintf("%#v", val)) + } + }() + switch name { + case "_uuid": + row.Uuid = types.EnsureUuid(val) + case "_version": + row.Version = types.EnsureUuid(val) + case "external_ids": + row.ExternalIds = types.EnsureMapStringString(val) + case "records": + row.Records = types.EnsureMapStringString(val) + default: + panic(types.ErrUnknownColumn) + } + return +} + +func (row *DNS) MatchNonZeros(row1 *DNS) bool { + if !types.MatchUuidIfNonZero(row.Uuid, row1.Uuid) { + return false + } + if !types.MatchUuidIfNonZero(row.Version, row1.Version) { + return false + } + if !types.MatchMapStringStringIfNonZero(row.ExternalIds, row1.ExternalIds) { + return false + } + if !types.MatchMapStringStringIfNonZero(row.Records, row1.Records) { + return false + } + return true +} + +func (row *DNS) HasExternalIds() bool { + return true +} + +func (row *DNS) SetExternalId(k, v string) { + if row.ExternalIds == nil { + row.ExternalIds = map[string]string{} + } + row.ExternalIds[k] = v +} + +func (row *DNS) GetExternalId(k string) (string, bool) { + if row.ExternalIds == nil { + return "", false + } + r, ok := row.ExternalIds[k] + return r, ok +} + +func (row *DNS) RemoveExternalId(k string) (string, bool) { + if row.ExternalIds == nil { + return "", false + } + r, ok := row.ExternalIds[k] + if ok { + delete(row.ExternalIds, k) + } + return r, ok +} + +type GatewayChassisTable []GatewayChassis + +var _ types.ITable = &GatewayChassisTable{} + +func (tbl GatewayChassisTable) OvsdbTableName() string { + return "Gateway_Chassis" +} + +func (tbl GatewayChassisTable) OvsdbIsRoot() bool { + return false +} + +func (tbl GatewayChassisTable) Rows() []types.IRow { + r := make([]types.IRow, len(tbl)) + for i := range tbl { + r[i] = &tbl[i] + } + return r +} + +func (tbl GatewayChassisTable) NewRow() types.IRow { + return &GatewayChassis{} +} + +func (tbl *GatewayChassisTable) AppendRow(irow types.IRow) { + row := irow.(*GatewayChassis) + *tbl = append(*tbl, *row) +} + +func (tbl GatewayChassisTable) FindOneMatchNonZeros(row1 *GatewayChassis) *GatewayChassis { + for i := range tbl { + row := &tbl[i] + if row.MatchNonZeros(row1) { + return row + } + } + return nil +} + +type GatewayChassis struct { + Uuid string `json:"_uuid"` + Version string `json:"_version"` + ChassisName string `json:"chassis_name"` + ExternalIds map[string]string `json:"external_ids"` + Name string `json:"name"` + Options map[string]string `json:"options"` + Priority int64 `json:"priority"` +} + +var _ types.IRow = &GatewayChassis{} + +func (row *GatewayChassis) OvsdbTableName() string { + return "Gateway_Chassis" +} + +func (row *GatewayChassis) OvsdbIsRoot() bool { + return false +} + +func (row *GatewayChassis) OvsdbUuid() string { + return row.Uuid +} + +func (row *GatewayChassis) OvsdbCmdArgs() []string { + r := []string{} + r = append(r, types.OvsdbCmdArgsString("chassis_name", row.ChassisName)...) + r = append(r, types.OvsdbCmdArgsMapStringString("external_ids", row.ExternalIds)...) + r = append(r, types.OvsdbCmdArgsString("name", row.Name)...) + r = append(r, types.OvsdbCmdArgsMapStringString("options", row.Options)...) + r = append(r, types.OvsdbCmdArgsInteger("priority", row.Priority)...) + return r +} + +func (row *GatewayChassis) SetColumn(name string, val interface{}) (err error) { + defer func() { + if panicErr := recover(); panicErr != nil { + err = errors.Wrapf(panicErr.(error), "%s: %#v", name, fmt.Sprintf("%#v", val)) + } + }() + switch name { + case "_uuid": + row.Uuid = types.EnsureUuid(val) + case "_version": + row.Version = types.EnsureUuid(val) + case "chassis_name": + row.ChassisName = types.EnsureString(val) + case "external_ids": + row.ExternalIds = types.EnsureMapStringString(val) + case "name": + row.Name = types.EnsureString(val) + case "options": + row.Options = types.EnsureMapStringString(val) + case "priority": + row.Priority = types.EnsureInteger(val) + default: + panic(types.ErrUnknownColumn) + } + return +} + +func (row *GatewayChassis) MatchNonZeros(row1 *GatewayChassis) bool { + if !types.MatchUuidIfNonZero(row.Uuid, row1.Uuid) { + return false + } + if !types.MatchUuidIfNonZero(row.Version, row1.Version) { + return false + } + if !types.MatchStringIfNonZero(row.ChassisName, row1.ChassisName) { + return false + } + if !types.MatchMapStringStringIfNonZero(row.ExternalIds, row1.ExternalIds) { + return false + } + if !types.MatchStringIfNonZero(row.Name, row1.Name) { + return false + } + if !types.MatchMapStringStringIfNonZero(row.Options, row1.Options) { + return false + } + if !types.MatchIntegerIfNonZero(row.Priority, row1.Priority) { + return false + } + return true +} + +func (row *GatewayChassis) HasExternalIds() bool { + return true +} + +func (row *GatewayChassis) SetExternalId(k, v string) { + if row.ExternalIds == nil { + row.ExternalIds = map[string]string{} + } + row.ExternalIds[k] = v +} + +func (row *GatewayChassis) GetExternalId(k string) (string, bool) { + if row.ExternalIds == nil { + return "", false + } + r, ok := row.ExternalIds[k] + return r, ok +} + +func (row *GatewayChassis) RemoveExternalId(k string) (string, bool) { + if row.ExternalIds == nil { + return "", false + } + r, ok := row.ExternalIds[k] + if ok { + delete(row.ExternalIds, k) + } + return r, ok +} + +type LoadBalancerTable []LoadBalancer + +var _ types.ITable = &LoadBalancerTable{} + +func (tbl LoadBalancerTable) OvsdbTableName() string { + return "Load_Balancer" +} + +func (tbl LoadBalancerTable) OvsdbIsRoot() bool { + return true +} + +func (tbl LoadBalancerTable) Rows() []types.IRow { + r := make([]types.IRow, len(tbl)) + for i := range tbl { + r[i] = &tbl[i] + } + return r +} + +func (tbl LoadBalancerTable) NewRow() types.IRow { + return &LoadBalancer{} +} + +func (tbl *LoadBalancerTable) AppendRow(irow types.IRow) { + row := irow.(*LoadBalancer) + *tbl = append(*tbl, *row) +} + +func (tbl LoadBalancerTable) FindOneMatchNonZeros(row1 *LoadBalancer) *LoadBalancer { + for i := range tbl { + row := &tbl[i] + if row.MatchNonZeros(row1) { + return row + } + } + return nil +} + +type LoadBalancer struct { + Uuid string `json:"_uuid"` + Version string `json:"_version"` + ExternalIds map[string]string `json:"external_ids"` + Name string `json:"name"` + Protocol *string `json:"protocol"` + Vips map[string]string `json:"vips"` +} + +var _ types.IRow = &LoadBalancer{} + +func (row *LoadBalancer) OvsdbTableName() string { + return "Load_Balancer" +} + +func (row *LoadBalancer) OvsdbIsRoot() bool { + return true +} + +func (row *LoadBalancer) OvsdbUuid() string { + return row.Uuid +} + +func (row *LoadBalancer) OvsdbCmdArgs() []string { + r := []string{} + r = append(r, types.OvsdbCmdArgsMapStringString("external_ids", row.ExternalIds)...) + r = append(r, types.OvsdbCmdArgsString("name", row.Name)...) + r = append(r, types.OvsdbCmdArgsStringOptional("protocol", row.Protocol)...) + r = append(r, types.OvsdbCmdArgsMapStringString("vips", row.Vips)...) + return r +} + +func (row *LoadBalancer) SetColumn(name string, val interface{}) (err error) { + defer func() { + if panicErr := recover(); panicErr != nil { + err = errors.Wrapf(panicErr.(error), "%s: %#v", name, fmt.Sprintf("%#v", val)) + } + }() + switch name { + case "_uuid": + row.Uuid = types.EnsureUuid(val) + case "_version": + row.Version = types.EnsureUuid(val) + case "external_ids": + row.ExternalIds = types.EnsureMapStringString(val) + case "name": + row.Name = types.EnsureString(val) + case "protocol": + row.Protocol = types.EnsureStringOptional(val) + case "vips": + row.Vips = types.EnsureMapStringString(val) + default: + panic(types.ErrUnknownColumn) + } + return +} + +func (row *LoadBalancer) MatchNonZeros(row1 *LoadBalancer) bool { + if !types.MatchUuidIfNonZero(row.Uuid, row1.Uuid) { + return false + } + if !types.MatchUuidIfNonZero(row.Version, row1.Version) { + return false + } + if !types.MatchMapStringStringIfNonZero(row.ExternalIds, row1.ExternalIds) { + return false + } + if !types.MatchStringIfNonZero(row.Name, row1.Name) { + return false + } + if !types.MatchStringOptionalIfNonZero(row.Protocol, row1.Protocol) { + return false + } + if !types.MatchMapStringStringIfNonZero(row.Vips, row1.Vips) { + return false + } + return true +} + +func (row *LoadBalancer) HasExternalIds() bool { + return true +} + +func (row *LoadBalancer) SetExternalId(k, v string) { + if row.ExternalIds == nil { + row.ExternalIds = map[string]string{} + } + row.ExternalIds[k] = v +} + +func (row *LoadBalancer) GetExternalId(k string) (string, bool) { + if row.ExternalIds == nil { + return "", false + } + r, ok := row.ExternalIds[k] + return r, ok +} + +func (row *LoadBalancer) RemoveExternalId(k string) (string, bool) { + if row.ExternalIds == nil { + return "", false + } + r, ok := row.ExternalIds[k] + if ok { + delete(row.ExternalIds, k) + } + return r, ok +} + +type LogicalRouterTable []LogicalRouter + +var _ types.ITable = &LogicalRouterTable{} + +func (tbl LogicalRouterTable) OvsdbTableName() string { + return "Logical_Router" +} + +func (tbl LogicalRouterTable) OvsdbIsRoot() bool { + return true +} + +func (tbl LogicalRouterTable) Rows() []types.IRow { + r := make([]types.IRow, len(tbl)) + for i := range tbl { + r[i] = &tbl[i] + } + return r +} + +func (tbl LogicalRouterTable) NewRow() types.IRow { + return &LogicalRouter{} +} + +func (tbl *LogicalRouterTable) AppendRow(irow types.IRow) { + row := irow.(*LogicalRouter) + *tbl = append(*tbl, *row) +} + +func (tbl LogicalRouterTable) FindOneMatchNonZeros(row1 *LogicalRouter) *LogicalRouter { + for i := range tbl { + row := &tbl[i] + if row.MatchNonZeros(row1) { + return row + } + } + return nil +} + +type LogicalRouter struct { + Uuid string `json:"_uuid"` + Version string `json:"_version"` + Enabled *bool `json:"enabled"` + ExternalIds map[string]string `json:"external_ids"` + LoadBalancer []string `json:"load_balancer"` + Name string `json:"name"` + Nat []string `json:"nat"` + Options map[string]string `json:"options"` + Ports []string `json:"ports"` + StaticRoutes []string `json:"static_routes"` +} + +var _ types.IRow = &LogicalRouter{} + +func (row *LogicalRouter) OvsdbTableName() string { + return "Logical_Router" +} + +func (row *LogicalRouter) OvsdbIsRoot() bool { + return true +} + +func (row *LogicalRouter) OvsdbUuid() string { + return row.Uuid +} + +func (row *LogicalRouter) OvsdbCmdArgs() []string { + r := []string{} + r = append(r, types.OvsdbCmdArgsBooleanOptional("enabled", row.Enabled)...) + r = append(r, types.OvsdbCmdArgsMapStringString("external_ids", row.ExternalIds)...) + r = append(r, types.OvsdbCmdArgsUuidMultiples("load_balancer", row.LoadBalancer)...) + r = append(r, types.OvsdbCmdArgsString("name", row.Name)...) + r = append(r, types.OvsdbCmdArgsUuidMultiples("nat", row.Nat)...) + r = append(r, types.OvsdbCmdArgsMapStringString("options", row.Options)...) + r = append(r, types.OvsdbCmdArgsUuidMultiples("ports", row.Ports)...) + r = append(r, types.OvsdbCmdArgsUuidMultiples("static_routes", row.StaticRoutes)...) + return r +} + +func (row *LogicalRouter) SetColumn(name string, val interface{}) (err error) { + defer func() { + if panicErr := recover(); panicErr != nil { + err = errors.Wrapf(panicErr.(error), "%s: %#v", name, fmt.Sprintf("%#v", val)) + } + }() + switch name { + case "_uuid": + row.Uuid = types.EnsureUuid(val) + case "_version": + row.Version = types.EnsureUuid(val) + case "enabled": + row.Enabled = types.EnsureBooleanOptional(val) + case "external_ids": + row.ExternalIds = types.EnsureMapStringString(val) + case "load_balancer": + row.LoadBalancer = types.EnsureUuidMultiples(val) + case "name": + row.Name = types.EnsureString(val) + case "nat": + row.Nat = types.EnsureUuidMultiples(val) + case "options": + row.Options = types.EnsureMapStringString(val) + case "ports": + row.Ports = types.EnsureUuidMultiples(val) + case "static_routes": + row.StaticRoutes = types.EnsureUuidMultiples(val) + default: + panic(types.ErrUnknownColumn) + } + return +} + +func (row *LogicalRouter) MatchNonZeros(row1 *LogicalRouter) bool { + if !types.MatchUuidIfNonZero(row.Uuid, row1.Uuid) { + return false + } + if !types.MatchUuidIfNonZero(row.Version, row1.Version) { + return false + } + if !types.MatchBooleanOptionalIfNonZero(row.Enabled, row1.Enabled) { + return false + } + if !types.MatchMapStringStringIfNonZero(row.ExternalIds, row1.ExternalIds) { + return false + } + if !types.MatchUuidMultiplesIfNonZero(row.LoadBalancer, row1.LoadBalancer) { + return false + } + if !types.MatchStringIfNonZero(row.Name, row1.Name) { + return false + } + if !types.MatchUuidMultiplesIfNonZero(row.Nat, row1.Nat) { + return false + } + if !types.MatchMapStringStringIfNonZero(row.Options, row1.Options) { + return false + } + if !types.MatchUuidMultiplesIfNonZero(row.Ports, row1.Ports) { + return false + } + if !types.MatchUuidMultiplesIfNonZero(row.StaticRoutes, row1.StaticRoutes) { + return false + } + return true +} + +func (row *LogicalRouter) HasExternalIds() bool { + return true +} + +func (row *LogicalRouter) SetExternalId(k, v string) { + if row.ExternalIds == nil { + row.ExternalIds = map[string]string{} + } + row.ExternalIds[k] = v +} + +func (row *LogicalRouter) GetExternalId(k string) (string, bool) { + if row.ExternalIds == nil { + return "", false + } + r, ok := row.ExternalIds[k] + return r, ok +} + +func (row *LogicalRouter) RemoveExternalId(k string) (string, bool) { + if row.ExternalIds == nil { + return "", false + } + r, ok := row.ExternalIds[k] + if ok { + delete(row.ExternalIds, k) + } + return r, ok +} + +type LogicalRouterPortTable []LogicalRouterPort + +var _ types.ITable = &LogicalRouterPortTable{} + +func (tbl LogicalRouterPortTable) OvsdbTableName() string { + return "Logical_Router_Port" +} + +func (tbl LogicalRouterPortTable) OvsdbIsRoot() bool { + return false +} + +func (tbl LogicalRouterPortTable) Rows() []types.IRow { + r := make([]types.IRow, len(tbl)) + for i := range tbl { + r[i] = &tbl[i] + } + return r +} + +func (tbl LogicalRouterPortTable) NewRow() types.IRow { + return &LogicalRouterPort{} +} + +func (tbl *LogicalRouterPortTable) AppendRow(irow types.IRow) { + row := irow.(*LogicalRouterPort) + *tbl = append(*tbl, *row) +} + +func (tbl LogicalRouterPortTable) FindOneMatchNonZeros(row1 *LogicalRouterPort) *LogicalRouterPort { + for i := range tbl { + row := &tbl[i] + if row.MatchNonZeros(row1) { + return row + } + } + return nil +} + +type LogicalRouterPort struct { + Uuid string `json:"_uuid"` + Version string `json:"_version"` + Enabled *bool `json:"enabled"` + ExternalIds map[string]string `json:"external_ids"` + GatewayChassis []string `json:"gateway_chassis"` + Ipv6RaConfigs map[string]string `json:"ipv6_ra_configs"` + Mac string `json:"mac"` + Name string `json:"name"` + Networks []string `json:"networks"` + Options map[string]string `json:"options"` + Peer *string `json:"peer"` +} + +var _ types.IRow = &LogicalRouterPort{} + +func (row *LogicalRouterPort) OvsdbTableName() string { + return "Logical_Router_Port" +} + +func (row *LogicalRouterPort) OvsdbIsRoot() bool { + return false +} + +func (row *LogicalRouterPort) OvsdbUuid() string { + return row.Uuid +} + +func (row *LogicalRouterPort) OvsdbCmdArgs() []string { + r := []string{} + r = append(r, types.OvsdbCmdArgsBooleanOptional("enabled", row.Enabled)...) + r = append(r, types.OvsdbCmdArgsMapStringString("external_ids", row.ExternalIds)...) + r = append(r, types.OvsdbCmdArgsUuidMultiples("gateway_chassis", row.GatewayChassis)...) + r = append(r, types.OvsdbCmdArgsMapStringString("ipv6_ra_configs", row.Ipv6RaConfigs)...) + r = append(r, types.OvsdbCmdArgsString("mac", row.Mac)...) + r = append(r, types.OvsdbCmdArgsString("name", row.Name)...) + r = append(r, types.OvsdbCmdArgsStringMultiples("networks", row.Networks)...) + r = append(r, types.OvsdbCmdArgsMapStringString("options", row.Options)...) + r = append(r, types.OvsdbCmdArgsStringOptional("peer", row.Peer)...) + return r +} + +func (row *LogicalRouterPort) SetColumn(name string, val interface{}) (err error) { + defer func() { + if panicErr := recover(); panicErr != nil { + err = errors.Wrapf(panicErr.(error), "%s: %#v", name, fmt.Sprintf("%#v", val)) + } + }() + switch name { + case "_uuid": + row.Uuid = types.EnsureUuid(val) + case "_version": + row.Version = types.EnsureUuid(val) + case "enabled": + row.Enabled = types.EnsureBooleanOptional(val) + case "external_ids": + row.ExternalIds = types.EnsureMapStringString(val) + case "gateway_chassis": + row.GatewayChassis = types.EnsureUuidMultiples(val) + case "ipv6_ra_configs": + row.Ipv6RaConfigs = types.EnsureMapStringString(val) + case "mac": + row.Mac = types.EnsureString(val) + case "name": + row.Name = types.EnsureString(val) + case "networks": + row.Networks = types.EnsureStringMultiples(val) + case "options": + row.Options = types.EnsureMapStringString(val) + case "peer": + row.Peer = types.EnsureStringOptional(val) + default: + panic(types.ErrUnknownColumn) + } + return +} + +func (row *LogicalRouterPort) MatchNonZeros(row1 *LogicalRouterPort) bool { + if !types.MatchUuidIfNonZero(row.Uuid, row1.Uuid) { + return false + } + if !types.MatchUuidIfNonZero(row.Version, row1.Version) { + return false + } + if !types.MatchBooleanOptionalIfNonZero(row.Enabled, row1.Enabled) { + return false + } + if !types.MatchMapStringStringIfNonZero(row.ExternalIds, row1.ExternalIds) { + return false + } + if !types.MatchUuidMultiplesIfNonZero(row.GatewayChassis, row1.GatewayChassis) { + return false + } + if !types.MatchMapStringStringIfNonZero(row.Ipv6RaConfigs, row1.Ipv6RaConfigs) { + return false + } + if !types.MatchStringIfNonZero(row.Mac, row1.Mac) { + return false + } + if !types.MatchStringIfNonZero(row.Name, row1.Name) { + return false + } + if !types.MatchStringMultiplesIfNonZero(row.Networks, row1.Networks) { + return false + } + if !types.MatchMapStringStringIfNonZero(row.Options, row1.Options) { + return false + } + if !types.MatchStringOptionalIfNonZero(row.Peer, row1.Peer) { + return false + } + return true +} + +func (row *LogicalRouterPort) HasExternalIds() bool { + return true +} + +func (row *LogicalRouterPort) SetExternalId(k, v string) { + if row.ExternalIds == nil { + row.ExternalIds = map[string]string{} + } + row.ExternalIds[k] = v +} + +func (row *LogicalRouterPort) GetExternalId(k string) (string, bool) { + if row.ExternalIds == nil { + return "", false + } + r, ok := row.ExternalIds[k] + return r, ok +} + +func (row *LogicalRouterPort) RemoveExternalId(k string) (string, bool) { + if row.ExternalIds == nil { + return "", false + } + r, ok := row.ExternalIds[k] + if ok { + delete(row.ExternalIds, k) + } + return r, ok +} + +type LogicalRouterStaticRouteTable []LogicalRouterStaticRoute + +var _ types.ITable = &LogicalRouterStaticRouteTable{} + +func (tbl LogicalRouterStaticRouteTable) OvsdbTableName() string { + return "Logical_Router_Static_Route" +} + +func (tbl LogicalRouterStaticRouteTable) OvsdbIsRoot() bool { + return false +} + +func (tbl LogicalRouterStaticRouteTable) Rows() []types.IRow { + r := make([]types.IRow, len(tbl)) + for i := range tbl { + r[i] = &tbl[i] + } + return r +} + +func (tbl LogicalRouterStaticRouteTable) NewRow() types.IRow { + return &LogicalRouterStaticRoute{} +} + +func (tbl *LogicalRouterStaticRouteTable) AppendRow(irow types.IRow) { + row := irow.(*LogicalRouterStaticRoute) + *tbl = append(*tbl, *row) +} + +func (tbl LogicalRouterStaticRouteTable) FindOneMatchNonZeros(row1 *LogicalRouterStaticRoute) *LogicalRouterStaticRoute { + for i := range tbl { + row := &tbl[i] + if row.MatchNonZeros(row1) { + return row + } + } + return nil +} + +type LogicalRouterStaticRoute struct { + Uuid string `json:"_uuid"` + Version string `json:"_version"` + ExternalIds map[string]string `json:"external_ids"` + IpPrefix string `json:"ip_prefix"` + Nexthop string `json:"nexthop"` + OutputPort *string `json:"output_port"` + Policy *string `json:"policy"` +} + +var _ types.IRow = &LogicalRouterStaticRoute{} + +func (row *LogicalRouterStaticRoute) OvsdbTableName() string { + return "Logical_Router_Static_Route" +} + +func (row *LogicalRouterStaticRoute) OvsdbIsRoot() bool { + return false +} + +func (row *LogicalRouterStaticRoute) OvsdbUuid() string { + return row.Uuid +} + +func (row *LogicalRouterStaticRoute) OvsdbCmdArgs() []string { + r := []string{} + r = append(r, types.OvsdbCmdArgsMapStringString("external_ids", row.ExternalIds)...) + r = append(r, types.OvsdbCmdArgsString("ip_prefix", row.IpPrefix)...) + r = append(r, types.OvsdbCmdArgsString("nexthop", row.Nexthop)...) + r = append(r, types.OvsdbCmdArgsStringOptional("output_port", row.OutputPort)...) + r = append(r, types.OvsdbCmdArgsStringOptional("policy", row.Policy)...) + return r +} + +func (row *LogicalRouterStaticRoute) SetColumn(name string, val interface{}) (err error) { + defer func() { + if panicErr := recover(); panicErr != nil { + err = errors.Wrapf(panicErr.(error), "%s: %#v", name, fmt.Sprintf("%#v", val)) + } + }() + switch name { + case "_uuid": + row.Uuid = types.EnsureUuid(val) + case "_version": + row.Version = types.EnsureUuid(val) + case "external_ids": + row.ExternalIds = types.EnsureMapStringString(val) + case "ip_prefix": + row.IpPrefix = types.EnsureString(val) + case "nexthop": + row.Nexthop = types.EnsureString(val) + case "output_port": + row.OutputPort = types.EnsureStringOptional(val) + case "policy": + row.Policy = types.EnsureStringOptional(val) + default: + panic(types.ErrUnknownColumn) + } + return +} + +func (row *LogicalRouterStaticRoute) MatchNonZeros(row1 *LogicalRouterStaticRoute) bool { + if !types.MatchUuidIfNonZero(row.Uuid, row1.Uuid) { + return false + } + if !types.MatchUuidIfNonZero(row.Version, row1.Version) { + return false + } + if !types.MatchMapStringStringIfNonZero(row.ExternalIds, row1.ExternalIds) { + return false + } + if !types.MatchStringIfNonZero(row.IpPrefix, row1.IpPrefix) { + return false + } + if !types.MatchStringIfNonZero(row.Nexthop, row1.Nexthop) { + return false + } + if !types.MatchStringOptionalIfNonZero(row.OutputPort, row1.OutputPort) { + return false + } + if !types.MatchStringOptionalIfNonZero(row.Policy, row1.Policy) { + return false + } + return true +} + +func (row *LogicalRouterStaticRoute) HasExternalIds() bool { + return true +} + +func (row *LogicalRouterStaticRoute) SetExternalId(k, v string) { + if row.ExternalIds == nil { + row.ExternalIds = map[string]string{} + } + row.ExternalIds[k] = v +} + +func (row *LogicalRouterStaticRoute) GetExternalId(k string) (string, bool) { + if row.ExternalIds == nil { + return "", false + } + r, ok := row.ExternalIds[k] + return r, ok +} + +func (row *LogicalRouterStaticRoute) RemoveExternalId(k string) (string, bool) { + if row.ExternalIds == nil { + return "", false + } + r, ok := row.ExternalIds[k] + if ok { + delete(row.ExternalIds, k) + } + return r, ok +} + +type LogicalSwitchTable []LogicalSwitch + +var _ types.ITable = &LogicalSwitchTable{} + +func (tbl LogicalSwitchTable) OvsdbTableName() string { + return "Logical_Switch" +} + +func (tbl LogicalSwitchTable) OvsdbIsRoot() bool { + return true +} + +func (tbl LogicalSwitchTable) Rows() []types.IRow { + r := make([]types.IRow, len(tbl)) + for i := range tbl { + r[i] = &tbl[i] + } + return r +} + +func (tbl LogicalSwitchTable) NewRow() types.IRow { + return &LogicalSwitch{} +} + +func (tbl *LogicalSwitchTable) AppendRow(irow types.IRow) { + row := irow.(*LogicalSwitch) + *tbl = append(*tbl, *row) +} + +func (tbl LogicalSwitchTable) FindOneMatchNonZeros(row1 *LogicalSwitch) *LogicalSwitch { + for i := range tbl { + row := &tbl[i] + if row.MatchNonZeros(row1) { + return row + } + } + return nil +} + +type LogicalSwitch struct { + Uuid string `json:"_uuid"` + Version string `json:"_version"` + Acls []string `json:"acls"` + DnsRecords []string `json:"dns_records"` + ExternalIds map[string]string `json:"external_ids"` + LoadBalancer []string `json:"load_balancer"` + Name string `json:"name"` + OtherConfig map[string]string `json:"other_config"` + Ports []string `json:"ports"` + QosRules []string `json:"qos_rules"` +} + +var _ types.IRow = &LogicalSwitch{} + +func (row *LogicalSwitch) OvsdbTableName() string { + return "Logical_Switch" +} + +func (row *LogicalSwitch) OvsdbIsRoot() bool { + return true +} + +func (row *LogicalSwitch) OvsdbUuid() string { + return row.Uuid +} + +func (row *LogicalSwitch) OvsdbCmdArgs() []string { + r := []string{} + r = append(r, types.OvsdbCmdArgsUuidMultiples("acls", row.Acls)...) + r = append(r, types.OvsdbCmdArgsUuidMultiples("dns_records", row.DnsRecords)...) + r = append(r, types.OvsdbCmdArgsMapStringString("external_ids", row.ExternalIds)...) + r = append(r, types.OvsdbCmdArgsUuidMultiples("load_balancer", row.LoadBalancer)...) + r = append(r, types.OvsdbCmdArgsString("name", row.Name)...) + r = append(r, types.OvsdbCmdArgsMapStringString("other_config", row.OtherConfig)...) + r = append(r, types.OvsdbCmdArgsUuidMultiples("ports", row.Ports)...) + r = append(r, types.OvsdbCmdArgsUuidMultiples("qos_rules", row.QosRules)...) + return r +} + +func (row *LogicalSwitch) SetColumn(name string, val interface{}) (err error) { + defer func() { + if panicErr := recover(); panicErr != nil { + err = errors.Wrapf(panicErr.(error), "%s: %#v", name, fmt.Sprintf("%#v", val)) + } + }() + switch name { + case "_uuid": + row.Uuid = types.EnsureUuid(val) + case "_version": + row.Version = types.EnsureUuid(val) + case "acls": + row.Acls = types.EnsureUuidMultiples(val) + case "dns_records": + row.DnsRecords = types.EnsureUuidMultiples(val) + case "external_ids": + row.ExternalIds = types.EnsureMapStringString(val) + case "load_balancer": + row.LoadBalancer = types.EnsureUuidMultiples(val) + case "name": + row.Name = types.EnsureString(val) + case "other_config": + row.OtherConfig = types.EnsureMapStringString(val) + case "ports": + row.Ports = types.EnsureUuidMultiples(val) + case "qos_rules": + row.QosRules = types.EnsureUuidMultiples(val) + default: + panic(types.ErrUnknownColumn) + } + return +} + +func (row *LogicalSwitch) MatchNonZeros(row1 *LogicalSwitch) bool { + if !types.MatchUuidIfNonZero(row.Uuid, row1.Uuid) { + return false + } + if !types.MatchUuidIfNonZero(row.Version, row1.Version) { + return false + } + if !types.MatchUuidMultiplesIfNonZero(row.Acls, row1.Acls) { + return false + } + if !types.MatchUuidMultiplesIfNonZero(row.DnsRecords, row1.DnsRecords) { + return false + } + if !types.MatchMapStringStringIfNonZero(row.ExternalIds, row1.ExternalIds) { + return false + } + if !types.MatchUuidMultiplesIfNonZero(row.LoadBalancer, row1.LoadBalancer) { + return false + } + if !types.MatchStringIfNonZero(row.Name, row1.Name) { + return false + } + if !types.MatchMapStringStringIfNonZero(row.OtherConfig, row1.OtherConfig) { + return false + } + if !types.MatchUuidMultiplesIfNonZero(row.Ports, row1.Ports) { + return false + } + if !types.MatchUuidMultiplesIfNonZero(row.QosRules, row1.QosRules) { + return false + } + return true +} + +func (row *LogicalSwitch) HasExternalIds() bool { + return true +} + +func (row *LogicalSwitch) SetExternalId(k, v string) { + if row.ExternalIds == nil { + row.ExternalIds = map[string]string{} + } + row.ExternalIds[k] = v +} + +func (row *LogicalSwitch) GetExternalId(k string) (string, bool) { + if row.ExternalIds == nil { + return "", false + } + r, ok := row.ExternalIds[k] + return r, ok +} + +func (row *LogicalSwitch) RemoveExternalId(k string) (string, bool) { + if row.ExternalIds == nil { + return "", false + } + r, ok := row.ExternalIds[k] + if ok { + delete(row.ExternalIds, k) + } + return r, ok +} + +type LogicalSwitchPortTable []LogicalSwitchPort + +var _ types.ITable = &LogicalSwitchPortTable{} + +func (tbl LogicalSwitchPortTable) OvsdbTableName() string { + return "Logical_Switch_Port" +} + +func (tbl LogicalSwitchPortTable) OvsdbIsRoot() bool { + return false +} + +func (tbl LogicalSwitchPortTable) Rows() []types.IRow { + r := make([]types.IRow, len(tbl)) + for i := range tbl { + r[i] = &tbl[i] + } + return r +} + +func (tbl LogicalSwitchPortTable) NewRow() types.IRow { + return &LogicalSwitchPort{} +} + +func (tbl *LogicalSwitchPortTable) AppendRow(irow types.IRow) { + row := irow.(*LogicalSwitchPort) + *tbl = append(*tbl, *row) +} + +func (tbl LogicalSwitchPortTable) FindOneMatchNonZeros(row1 *LogicalSwitchPort) *LogicalSwitchPort { + for i := range tbl { + row := &tbl[i] + if row.MatchNonZeros(row1) { + return row + } + } + return nil +} + +type LogicalSwitchPort struct { + Uuid string `json:"_uuid"` + Version string `json:"_version"` + Addresses []string `json:"addresses"` + Dhcpv4Options *string `json:"dhcpv4_options"` + Dhcpv6Options *string `json:"dhcpv6_options"` + DynamicAddresses *string `json:"dynamic_addresses"` + Enabled *bool `json:"enabled"` + ExternalIds map[string]string `json:"external_ids"` + Name string `json:"name"` + Options map[string]string `json:"options"` + ParentName *string `json:"parent_name"` + PortSecurity []string `json:"port_security"` + Tag *int64 `json:"tag"` + TagRequest *int64 `json:"tag_request"` + Type string `json:"type"` + Up *bool `json:"up"` +} + +var _ types.IRow = &LogicalSwitchPort{} + +func (row *LogicalSwitchPort) OvsdbTableName() string { + return "Logical_Switch_Port" +} + +func (row *LogicalSwitchPort) OvsdbIsRoot() bool { + return false +} + +func (row *LogicalSwitchPort) OvsdbUuid() string { + return row.Uuid +} + +func (row *LogicalSwitchPort) OvsdbCmdArgs() []string { + r := []string{} + r = append(r, types.OvsdbCmdArgsStringMultiples("addresses", row.Addresses)...) + r = append(r, types.OvsdbCmdArgsUuidOptional("dhcpv4_options", row.Dhcpv4Options)...) + r = append(r, types.OvsdbCmdArgsUuidOptional("dhcpv6_options", row.Dhcpv6Options)...) + r = append(r, types.OvsdbCmdArgsStringOptional("dynamic_addresses", row.DynamicAddresses)...) + r = append(r, types.OvsdbCmdArgsBooleanOptional("enabled", row.Enabled)...) + r = append(r, types.OvsdbCmdArgsMapStringString("external_ids", row.ExternalIds)...) + r = append(r, types.OvsdbCmdArgsString("name", row.Name)...) + r = append(r, types.OvsdbCmdArgsMapStringString("options", row.Options)...) + r = append(r, types.OvsdbCmdArgsStringOptional("parent_name", row.ParentName)...) + r = append(r, types.OvsdbCmdArgsStringMultiples("port_security", row.PortSecurity)...) + r = append(r, types.OvsdbCmdArgsIntegerOptional("tag", row.Tag)...) + r = append(r, types.OvsdbCmdArgsIntegerOptional("tag_request", row.TagRequest)...) + r = append(r, types.OvsdbCmdArgsString("type", row.Type)...) + r = append(r, types.OvsdbCmdArgsBooleanOptional("up", row.Up)...) + return r +} + +func (row *LogicalSwitchPort) SetColumn(name string, val interface{}) (err error) { + defer func() { + if panicErr := recover(); panicErr != nil { + err = errors.Wrapf(panicErr.(error), "%s: %#v", name, fmt.Sprintf("%#v", val)) + } + }() + switch name { + case "_uuid": + row.Uuid = types.EnsureUuid(val) + case "_version": + row.Version = types.EnsureUuid(val) + case "addresses": + row.Addresses = types.EnsureStringMultiples(val) + case "dhcpv4_options": + row.Dhcpv4Options = types.EnsureUuidOptional(val) + case "dhcpv6_options": + row.Dhcpv6Options = types.EnsureUuidOptional(val) + case "dynamic_addresses": + row.DynamicAddresses = types.EnsureStringOptional(val) + case "enabled": + row.Enabled = types.EnsureBooleanOptional(val) + case "external_ids": + row.ExternalIds = types.EnsureMapStringString(val) + case "name": + row.Name = types.EnsureString(val) + case "options": + row.Options = types.EnsureMapStringString(val) + case "parent_name": + row.ParentName = types.EnsureStringOptional(val) + case "port_security": + row.PortSecurity = types.EnsureStringMultiples(val) + case "tag": + row.Tag = types.EnsureIntegerOptional(val) + case "tag_request": + row.TagRequest = types.EnsureIntegerOptional(val) + case "type": + row.Type = types.EnsureString(val) + case "up": + row.Up = types.EnsureBooleanOptional(val) + default: + panic(types.ErrUnknownColumn) + } + return +} + +func (row *LogicalSwitchPort) MatchNonZeros(row1 *LogicalSwitchPort) bool { + if !types.MatchUuidIfNonZero(row.Uuid, row1.Uuid) { + return false + } + if !types.MatchUuidIfNonZero(row.Version, row1.Version) { + return false + } + if !types.MatchStringMultiplesIfNonZero(row.Addresses, row1.Addresses) { + return false + } + if !types.MatchUuidOptionalIfNonZero(row.Dhcpv4Options, row1.Dhcpv4Options) { + return false + } + if !types.MatchUuidOptionalIfNonZero(row.Dhcpv6Options, row1.Dhcpv6Options) { + return false + } + if !types.MatchStringOptionalIfNonZero(row.DynamicAddresses, row1.DynamicAddresses) { + return false + } + if !types.MatchBooleanOptionalIfNonZero(row.Enabled, row1.Enabled) { + return false + } + if !types.MatchMapStringStringIfNonZero(row.ExternalIds, row1.ExternalIds) { + return false + } + if !types.MatchStringIfNonZero(row.Name, row1.Name) { + return false + } + if !types.MatchMapStringStringIfNonZero(row.Options, row1.Options) { + return false + } + if !types.MatchStringOptionalIfNonZero(row.ParentName, row1.ParentName) { + return false + } + if !types.MatchStringMultiplesIfNonZero(row.PortSecurity, row1.PortSecurity) { + return false + } + if !types.MatchIntegerOptionalIfNonZero(row.Tag, row1.Tag) { + return false + } + if !types.MatchIntegerOptionalIfNonZero(row.TagRequest, row1.TagRequest) { + return false + } + if !types.MatchStringIfNonZero(row.Type, row1.Type) { + return false + } + if !types.MatchBooleanOptionalIfNonZero(row.Up, row1.Up) { + return false + } + return true +} + +func (row *LogicalSwitchPort) HasExternalIds() bool { + return true +} + +func (row *LogicalSwitchPort) SetExternalId(k, v string) { + if row.ExternalIds == nil { + row.ExternalIds = map[string]string{} + } + row.ExternalIds[k] = v +} + +func (row *LogicalSwitchPort) GetExternalId(k string) (string, bool) { + if row.ExternalIds == nil { + return "", false + } + r, ok := row.ExternalIds[k] + return r, ok +} + +func (row *LogicalSwitchPort) RemoveExternalId(k string) (string, bool) { + if row.ExternalIds == nil { + return "", false + } + r, ok := row.ExternalIds[k] + if ok { + delete(row.ExternalIds, k) + } + return r, ok +} + +type NATTable []NAT + +var _ types.ITable = &NATTable{} + +func (tbl NATTable) OvsdbTableName() string { + return "NAT" +} + +func (tbl NATTable) OvsdbIsRoot() bool { + return false +} + +func (tbl NATTable) Rows() []types.IRow { + r := make([]types.IRow, len(tbl)) + for i := range tbl { + r[i] = &tbl[i] + } + return r +} + +func (tbl NATTable) NewRow() types.IRow { + return &NAT{} +} + +func (tbl *NATTable) AppendRow(irow types.IRow) { + row := irow.(*NAT) + *tbl = append(*tbl, *row) +} + +func (tbl NATTable) FindOneMatchNonZeros(row1 *NAT) *NAT { + for i := range tbl { + row := &tbl[i] + if row.MatchNonZeros(row1) { + return row + } + } + return nil +} + +type NAT struct { + Uuid string `json:"_uuid"` + Version string `json:"_version"` + ExternalIds map[string]string `json:"external_ids"` + ExternalIp string `json:"external_ip"` + ExternalMac *string `json:"external_mac"` + LogicalIp string `json:"logical_ip"` + LogicalPort *string `json:"logical_port"` + Type string `json:"type"` +} + +var _ types.IRow = &NAT{} + +func (row *NAT) OvsdbTableName() string { + return "NAT" +} + +func (row *NAT) OvsdbIsRoot() bool { + return false +} + +func (row *NAT) OvsdbUuid() string { + return row.Uuid +} + +func (row *NAT) OvsdbCmdArgs() []string { + r := []string{} + r = append(r, types.OvsdbCmdArgsMapStringString("external_ids", row.ExternalIds)...) + r = append(r, types.OvsdbCmdArgsString("external_ip", row.ExternalIp)...) + r = append(r, types.OvsdbCmdArgsStringOptional("external_mac", row.ExternalMac)...) + r = append(r, types.OvsdbCmdArgsString("logical_ip", row.LogicalIp)...) + r = append(r, types.OvsdbCmdArgsStringOptional("logical_port", row.LogicalPort)...) + r = append(r, types.OvsdbCmdArgsString("type", row.Type)...) + return r +} + +func (row *NAT) SetColumn(name string, val interface{}) (err error) { + defer func() { + if panicErr := recover(); panicErr != nil { + err = errors.Wrapf(panicErr.(error), "%s: %#v", name, fmt.Sprintf("%#v", val)) + } + }() + switch name { + case "_uuid": + row.Uuid = types.EnsureUuid(val) + case "_version": + row.Version = types.EnsureUuid(val) + case "external_ids": + row.ExternalIds = types.EnsureMapStringString(val) + case "external_ip": + row.ExternalIp = types.EnsureString(val) + case "external_mac": + row.ExternalMac = types.EnsureStringOptional(val) + case "logical_ip": + row.LogicalIp = types.EnsureString(val) + case "logical_port": + row.LogicalPort = types.EnsureStringOptional(val) + case "type": + row.Type = types.EnsureString(val) + default: + panic(types.ErrUnknownColumn) + } + return +} + +func (row *NAT) MatchNonZeros(row1 *NAT) bool { + if !types.MatchUuidIfNonZero(row.Uuid, row1.Uuid) { + return false + } + if !types.MatchUuidIfNonZero(row.Version, row1.Version) { + return false + } + if !types.MatchMapStringStringIfNonZero(row.ExternalIds, row1.ExternalIds) { + return false + } + if !types.MatchStringIfNonZero(row.ExternalIp, row1.ExternalIp) { + return false + } + if !types.MatchStringOptionalIfNonZero(row.ExternalMac, row1.ExternalMac) { + return false + } + if !types.MatchStringIfNonZero(row.LogicalIp, row1.LogicalIp) { + return false + } + if !types.MatchStringOptionalIfNonZero(row.LogicalPort, row1.LogicalPort) { + return false + } + if !types.MatchStringIfNonZero(row.Type, row1.Type) { + return false + } + return true +} + +func (row *NAT) HasExternalIds() bool { + return true +} + +func (row *NAT) SetExternalId(k, v string) { + if row.ExternalIds == nil { + row.ExternalIds = map[string]string{} + } + row.ExternalIds[k] = v +} + +func (row *NAT) GetExternalId(k string) (string, bool) { + if row.ExternalIds == nil { + return "", false + } + r, ok := row.ExternalIds[k] + return r, ok +} + +func (row *NAT) RemoveExternalId(k string) (string, bool) { + if row.ExternalIds == nil { + return "", false + } + r, ok := row.ExternalIds[k] + if ok { + delete(row.ExternalIds, k) + } + return r, ok +} + +type NBGlobalTable []NBGlobal + +var _ types.ITable = &NBGlobalTable{} + +func (tbl NBGlobalTable) OvsdbTableName() string { + return "NB_Global" +} + +func (tbl NBGlobalTable) OvsdbIsRoot() bool { + return true +} + +func (tbl NBGlobalTable) Rows() []types.IRow { + r := make([]types.IRow, len(tbl)) + for i := range tbl { + r[i] = &tbl[i] + } + return r +} + +func (tbl NBGlobalTable) NewRow() types.IRow { + return &NBGlobal{} +} + +func (tbl *NBGlobalTable) AppendRow(irow types.IRow) { + row := irow.(*NBGlobal) + *tbl = append(*tbl, *row) +} + +func (tbl NBGlobalTable) FindOneMatchNonZeros(row1 *NBGlobal) *NBGlobal { + for i := range tbl { + row := &tbl[i] + if row.MatchNonZeros(row1) { + return row + } + } + return nil +} + +type NBGlobal struct { + Uuid string `json:"_uuid"` + Version string `json:"_version"` + Connections []string `json:"connections"` + ExternalIds map[string]string `json:"external_ids"` + HvCfg int64 `json:"hv_cfg"` + NbCfg int64 `json:"nb_cfg"` + SbCfg int64 `json:"sb_cfg"` + Ssl *string `json:"ssl"` +} + +var _ types.IRow = &NBGlobal{} + +func (row *NBGlobal) OvsdbTableName() string { + return "NB_Global" +} + +func (row *NBGlobal) OvsdbIsRoot() bool { + return true +} + +func (row *NBGlobal) OvsdbUuid() string { + return row.Uuid +} + +func (row *NBGlobal) OvsdbCmdArgs() []string { + r := []string{} + r = append(r, types.OvsdbCmdArgsUuidMultiples("connections", row.Connections)...) + r = append(r, types.OvsdbCmdArgsMapStringString("external_ids", row.ExternalIds)...) + r = append(r, types.OvsdbCmdArgsInteger("hv_cfg", row.HvCfg)...) + r = append(r, types.OvsdbCmdArgsInteger("nb_cfg", row.NbCfg)...) + r = append(r, types.OvsdbCmdArgsInteger("sb_cfg", row.SbCfg)...) + r = append(r, types.OvsdbCmdArgsUuidOptional("ssl", row.Ssl)...) + return r +} + +func (row *NBGlobal) SetColumn(name string, val interface{}) (err error) { + defer func() { + if panicErr := recover(); panicErr != nil { + err = errors.Wrapf(panicErr.(error), "%s: %#v", name, fmt.Sprintf("%#v", val)) + } + }() + switch name { + case "_uuid": + row.Uuid = types.EnsureUuid(val) + case "_version": + row.Version = types.EnsureUuid(val) + case "connections": + row.Connections = types.EnsureUuidMultiples(val) + case "external_ids": + row.ExternalIds = types.EnsureMapStringString(val) + case "hv_cfg": + row.HvCfg = types.EnsureInteger(val) + case "nb_cfg": + row.NbCfg = types.EnsureInteger(val) + case "sb_cfg": + row.SbCfg = types.EnsureInteger(val) + case "ssl": + row.Ssl = types.EnsureUuidOptional(val) + default: + panic(types.ErrUnknownColumn) + } + return +} + +func (row *NBGlobal) MatchNonZeros(row1 *NBGlobal) bool { + if !types.MatchUuidIfNonZero(row.Uuid, row1.Uuid) { + return false + } + if !types.MatchUuidIfNonZero(row.Version, row1.Version) { + return false + } + if !types.MatchUuidMultiplesIfNonZero(row.Connections, row1.Connections) { + return false + } + if !types.MatchMapStringStringIfNonZero(row.ExternalIds, row1.ExternalIds) { + return false + } + if !types.MatchIntegerIfNonZero(row.HvCfg, row1.HvCfg) { + return false + } + if !types.MatchIntegerIfNonZero(row.NbCfg, row1.NbCfg) { + return false + } + if !types.MatchIntegerIfNonZero(row.SbCfg, row1.SbCfg) { + return false + } + if !types.MatchUuidOptionalIfNonZero(row.Ssl, row1.Ssl) { + return false + } + return true +} + +func (row *NBGlobal) HasExternalIds() bool { + return true +} + +func (row *NBGlobal) SetExternalId(k, v string) { + if row.ExternalIds == nil { + row.ExternalIds = map[string]string{} + } + row.ExternalIds[k] = v +} + +func (row *NBGlobal) GetExternalId(k string) (string, bool) { + if row.ExternalIds == nil { + return "", false + } + r, ok := row.ExternalIds[k] + return r, ok +} + +func (row *NBGlobal) RemoveExternalId(k string) (string, bool) { + if row.ExternalIds == nil { + return "", false + } + r, ok := row.ExternalIds[k] + if ok { + delete(row.ExternalIds, k) + } + return r, ok +} + +type QoSTable []QoS + +var _ types.ITable = &QoSTable{} + +func (tbl QoSTable) OvsdbTableName() string { + return "QoS" +} + +func (tbl QoSTable) OvsdbIsRoot() bool { + return false +} + +func (tbl QoSTable) Rows() []types.IRow { + r := make([]types.IRow, len(tbl)) + for i := range tbl { + r[i] = &tbl[i] + } + return r +} + +func (tbl QoSTable) NewRow() types.IRow { + return &QoS{} +} + +func (tbl *QoSTable) AppendRow(irow types.IRow) { + row := irow.(*QoS) + *tbl = append(*tbl, *row) +} + +func (tbl QoSTable) FindOneMatchNonZeros(row1 *QoS) *QoS { + for i := range tbl { + row := &tbl[i] + if row.MatchNonZeros(row1) { + return row + } + } + return nil +} + +type QoS struct { + Uuid string `json:"_uuid"` + Version string `json:"_version"` + Action map[string]int64 `json:"action"` + Bandwidth map[string]int64 `json:"bandwidth"` + Direction string `json:"direction"` + ExternalIds map[string]string `json:"external_ids"` + Match string `json:"match"` + Priority int64 `json:"priority"` +} + +var _ types.IRow = &QoS{} + +func (row *QoS) OvsdbTableName() string { + return "QoS" +} + +func (row *QoS) OvsdbIsRoot() bool { + return false +} + +func (row *QoS) OvsdbUuid() string { + return row.Uuid +} + +func (row *QoS) OvsdbCmdArgs() []string { + r := []string{} + r = append(r, types.OvsdbCmdArgsMapStringInteger("action", row.Action)...) + r = append(r, types.OvsdbCmdArgsMapStringInteger("bandwidth", row.Bandwidth)...) + r = append(r, types.OvsdbCmdArgsString("direction", row.Direction)...) + r = append(r, types.OvsdbCmdArgsMapStringString("external_ids", row.ExternalIds)...) + r = append(r, types.OvsdbCmdArgsString("match", row.Match)...) + r = append(r, types.OvsdbCmdArgsInteger("priority", row.Priority)...) + return r +} + +func (row *QoS) SetColumn(name string, val interface{}) (err error) { + defer func() { + if panicErr := recover(); panicErr != nil { + err = errors.Wrapf(panicErr.(error), "%s: %#v", name, fmt.Sprintf("%#v", val)) + } + }() + switch name { + case "_uuid": + row.Uuid = types.EnsureUuid(val) + case "_version": + row.Version = types.EnsureUuid(val) + case "action": + row.Action = types.EnsureMapStringInteger(val) + case "bandwidth": + row.Bandwidth = types.EnsureMapStringInteger(val) + case "direction": + row.Direction = types.EnsureString(val) + case "external_ids": + row.ExternalIds = types.EnsureMapStringString(val) + case "match": + row.Match = types.EnsureString(val) + case "priority": + row.Priority = types.EnsureInteger(val) + default: + panic(types.ErrUnknownColumn) + } + return +} + +func (row *QoS) MatchNonZeros(row1 *QoS) bool { + if !types.MatchUuidIfNonZero(row.Uuid, row1.Uuid) { + return false + } + if !types.MatchUuidIfNonZero(row.Version, row1.Version) { + return false + } + if !types.MatchMapStringIntegerIfNonZero(row.Action, row1.Action) { + return false + } + if !types.MatchMapStringIntegerIfNonZero(row.Bandwidth, row1.Bandwidth) { + return false + } + if !types.MatchStringIfNonZero(row.Direction, row1.Direction) { + return false + } + if !types.MatchMapStringStringIfNonZero(row.ExternalIds, row1.ExternalIds) { + return false + } + if !types.MatchStringIfNonZero(row.Match, row1.Match) { + return false + } + if !types.MatchIntegerIfNonZero(row.Priority, row1.Priority) { + return false + } + return true +} + +func (row *QoS) HasExternalIds() bool { + return true +} + +func (row *QoS) SetExternalId(k, v string) { + if row.ExternalIds == nil { + row.ExternalIds = map[string]string{} + } + row.ExternalIds[k] = v +} + +func (row *QoS) GetExternalId(k string) (string, bool) { + if row.ExternalIds == nil { + return "", false + } + r, ok := row.ExternalIds[k] + return r, ok +} + +func (row *QoS) RemoveExternalId(k string) (string, bool) { + if row.ExternalIds == nil { + return "", false + } + r, ok := row.ExternalIds[k] + if ok { + delete(row.ExternalIds, k) + } + return r, ok +} + +type SSLTable []SSL + +var _ types.ITable = &SSLTable{} + +func (tbl SSLTable) OvsdbTableName() string { + return "SSL" +} + +func (tbl SSLTable) OvsdbIsRoot() bool { + return false +} + +func (tbl SSLTable) Rows() []types.IRow { + r := make([]types.IRow, len(tbl)) + for i := range tbl { + r[i] = &tbl[i] + } + return r +} + +func (tbl SSLTable) NewRow() types.IRow { + return &SSL{} +} + +func (tbl *SSLTable) AppendRow(irow types.IRow) { + row := irow.(*SSL) + *tbl = append(*tbl, *row) +} + +func (tbl SSLTable) FindOneMatchNonZeros(row1 *SSL) *SSL { + for i := range tbl { + row := &tbl[i] + if row.MatchNonZeros(row1) { + return row + } + } + return nil +} + +type SSL struct { + Uuid string `json:"_uuid"` + Version string `json:"_version"` + BootstrapCaCert bool `json:"bootstrap_ca_cert"` + CaCert string `json:"ca_cert"` + Certificate string `json:"certificate"` + ExternalIds map[string]string `json:"external_ids"` + PrivateKey string `json:"private_key"` + SslCiphers string `json:"ssl_ciphers"` + SslProtocols string `json:"ssl_protocols"` +} + +var _ types.IRow = &SSL{} + +func (row *SSL) OvsdbTableName() string { + return "SSL" +} + +func (row *SSL) OvsdbIsRoot() bool { + return false +} + +func (row *SSL) OvsdbUuid() string { + return row.Uuid +} + +func (row *SSL) OvsdbCmdArgs() []string { + r := []string{} + r = append(r, types.OvsdbCmdArgsBoolean("bootstrap_ca_cert", row.BootstrapCaCert)...) + r = append(r, types.OvsdbCmdArgsString("ca_cert", row.CaCert)...) + r = append(r, types.OvsdbCmdArgsString("certificate", row.Certificate)...) + r = append(r, types.OvsdbCmdArgsMapStringString("external_ids", row.ExternalIds)...) + r = append(r, types.OvsdbCmdArgsString("private_key", row.PrivateKey)...) + r = append(r, types.OvsdbCmdArgsString("ssl_ciphers", row.SslCiphers)...) + r = append(r, types.OvsdbCmdArgsString("ssl_protocols", row.SslProtocols)...) + return r +} + +func (row *SSL) SetColumn(name string, val interface{}) (err error) { + defer func() { + if panicErr := recover(); panicErr != nil { + err = errors.Wrapf(panicErr.(error), "%s: %#v", name, fmt.Sprintf("%#v", val)) + } + }() + switch name { + case "_uuid": + row.Uuid = types.EnsureUuid(val) + case "_version": + row.Version = types.EnsureUuid(val) + case "bootstrap_ca_cert": + row.BootstrapCaCert = types.EnsureBoolean(val) + case "ca_cert": + row.CaCert = types.EnsureString(val) + case "certificate": + row.Certificate = types.EnsureString(val) + case "external_ids": + row.ExternalIds = types.EnsureMapStringString(val) + case "private_key": + row.PrivateKey = types.EnsureString(val) + case "ssl_ciphers": + row.SslCiphers = types.EnsureString(val) + case "ssl_protocols": + row.SslProtocols = types.EnsureString(val) + default: + panic(types.ErrUnknownColumn) + } + return +} + +func (row *SSL) MatchNonZeros(row1 *SSL) bool { + if !types.MatchUuidIfNonZero(row.Uuid, row1.Uuid) { + return false + } + if !types.MatchUuidIfNonZero(row.Version, row1.Version) { + return false + } + if !types.MatchBooleanIfNonZero(row.BootstrapCaCert, row1.BootstrapCaCert) { + return false + } + if !types.MatchStringIfNonZero(row.CaCert, row1.CaCert) { + return false + } + if !types.MatchStringIfNonZero(row.Certificate, row1.Certificate) { + return false + } + if !types.MatchMapStringStringIfNonZero(row.ExternalIds, row1.ExternalIds) { + return false + } + if !types.MatchStringIfNonZero(row.PrivateKey, row1.PrivateKey) { + return false + } + if !types.MatchStringIfNonZero(row.SslCiphers, row1.SslCiphers) { + return false + } + if !types.MatchStringIfNonZero(row.SslProtocols, row1.SslProtocols) { + return false + } + return true +} + +func (row *SSL) HasExternalIds() bool { + return true +} + +func (row *SSL) SetExternalId(k, v string) { + if row.ExternalIds == nil { + row.ExternalIds = map[string]string{} + } + row.ExternalIds[k] = v +} + +func (row *SSL) GetExternalId(k string) (string, bool) { + if row.ExternalIds == nil { + return "", false + } + r, ok := row.ExternalIds[k] + return r, ok +} + +func (row *SSL) RemoveExternalId(k string) (string, bool) { + if row.ExternalIds == nil { + return "", false + } + r, ok := row.ExternalIds[k] + if ok { + delete(row.ExternalIds, k) + } + return r, ok +} diff --git a/vendor/yunion.io/x/ovsdb/types/atomic.go b/vendor/yunion.io/x/ovsdb/types/atomic.go new file mode 100644 index 0000000000..4dbe6aef0b --- /dev/null +++ b/vendor/yunion.io/x/ovsdb/types/atomic.go @@ -0,0 +1,62 @@ +package types + +type Atomic string + +const ( + String Atomic = "string" + Integer Atomic = "integer" + Real Atomic = "real" + Boolean Atomic = "boolean" + Uuid Atomic = "uuid" +) + +var ( + atomicGoMap = map[Atomic]string{ + String: "string", + Integer: "int64", + Real: "float64", + Boolean: "bool", + Uuid: "string", + } + + atomicFmtStrs = map[Atomic]string{ + String: "%q", + Integer: "%d", + Real: "%f", + Boolean: "%v", + Uuid: "%s", + } + + atomicUnmarshalTyp = map[Atomic]string{ + String: "string", + Integer: "float64", + Real: "float64", + Boolean: "bool", + Uuid: "string", + } + + atomics = []Atomic{ + String, + Integer, + Real, + Boolean, + Uuid, + } +) + +func (a Atomic) exportName() string { + return ExportName(string(a)) +} + +func (a Atomic) goType() string { + return atomicGoMap[a] +} + +func (a Atomic) fmtStr() string { + return atomicFmtStrs[a] +} + +func (a Atomic) isValid() bool { + _, ok := atomicGoMap[a] + return ok +} diff --git a/vendor/yunion.io/x/ovsdb/types/atomic_gen.go b/vendor/yunion.io/x/ovsdb/types/atomic_gen.go new file mode 100644 index 0000000000..3c22338105 --- /dev/null +++ b/vendor/yunion.io/x/ovsdb/types/atomic_gen.go @@ -0,0 +1,423 @@ +package types + +import ( + "os" + "path/filepath" + "strings" + + "github.com/pkg/errors" +) + +type AtomicGen struct { + outDir string + gopkg string +} + +func NewAtomicGen() *AtomicGen { + return &AtomicGen{} +} + +func (g *AtomicGen) OutDir(outDir string) *AtomicGen { + d, gopkg := filepath.Split(outDir) + gopkg = strings.ReplaceAll(gopkg, "-", "_") + outDir = filepath.Join(d, gopkg) + g.outDir = outDir + g.gopkg = gopkg + return g +} + +func (ag *AtomicGen) Gen() error { + if err := ag.genEnsures(); err != nil { + return err + } + if err := ag.genCmdArgs(); err != nil { + return err + } + if err := ag.genMatches(); err != nil { + return err + } + return nil +} + +func (ag *AtomicGen) prepGen(fname string) (writer, error) { + os.MkdirAll(ag.outDir, os.FileMode(0755)) + fpath := filepath.Join(ag.outDir, fname) + f, err := os.OpenFile(fpath, os.O_CREATE|os.O_TRUNC|os.O_WRONLY, os.FileMode(0644)) + if err != nil { + return writer{}, errors.Wrapf(err, "open %s", fpath) + } + w := writer{ + w: f, + } + w.Writef(`// DO NOT EDIT: automatically generated code`) + w.Writef(``) + w.Writef(`package %s`, ag.gopkg) + return w, nil +} + +func (ag *AtomicGen) genEnsures() error { + w, err := ag.prepGen("atomic_gen_ensures_zz_generated.go") + if err != nil { + return err + } + ag.genEnsures_(w) + return nil +} + +func (ag *AtomicGen) genEnsures_(w writer) { + w.Writeln(`import "github.com/pkg/errors"`) + + w.Writeln(`func panicErr(msg string) {`) + w.Writeln(` panic(errors.Wrap(ErrBadType, msg))`) + w.Writeln(`}`) + w.Writeln(``) + + w.Writeln(`func panicErrf(fmtStr string, s ...interface{}) {`) + w.Writeln(` panic(errors.Wrapf(ErrBadType, fmtStr, s...))`) + w.Writeln(`}`) + w.Writeln(``) + + w.Writeln(`func ensureTypedPair(val interface{}) (string, interface{}) {`) + w.Writeln(` arr, ok := val.([]interface{})`) + w.Writeln(` if !ok {`) + w.Writeln(` panicErr("ensureTypedPair: not an array")`) + w.Writeln(` }`) + w.Writeln(` if len(arr) != 2 {`) + w.Writeln(` panicErrf("ensureTypedPair: length is %d, want 2", len(arr))`) + w.Writeln(` }`) + w.Writeln(` typ, ok := arr[0].(string)`) + w.Writeln(` if !ok {`) + w.Writeln(` panicErr("ensureTypedPair: type not a string")`) + w.Writeln(` }`) + w.Writeln(` return typ, arr[1]`) + w.Writeln(`}`) + w.Writeln(``) + + w.Writeln(`func ensureTyped(val interface{}, typ string) interface{} {`) + w.Writeln(` gotTyp, r := ensureTypedPair(val)`) + w.Writeln(` if gotTyp != typ {`) + w.Writeln(` panicErrf("ensureMultiples: got %s, want %s", gotTyp, typ)`) + w.Writeln(` }`) + w.Writeln(` return r`) + w.Writeln(`}`) + w.Writeln(``) + + w.Writeln(`func ensureMultiples(val interface{}, typ string) []interface{} {`) + w.Writeln(` val = ensureTyped(val, typ)`) + w.Writeln(` mulVal, ok := val.([]interface{})`) + w.Writeln(` if !ok {`) + w.Writeln(` panicErr("ensureMultiples: val is not an array")`) + w.Writeln(` }`) + w.Writeln(` return mulVal`) + w.Writeln(`}`) + w.Writeln(``) + + w.Writeln(`func probeEmpty(val interface{}) (r bool) {`) + w.Writeln(` defer func() {`) + w.Writeln(` recover()`) + w.Writeln(` }()`) + w.Writeln(` empty := ensureMultiples(val, "set")`) + w.Writeln(` if len(empty) != 0 {`) + w.Writeln(` return false`) + w.Writeln(` }`) + w.Writeln(` return true`) + w.Writeln(`}`) + w.Writeln(``) + + w.Writeln(`func EnsureUuid(val interface{}) string {`) + w.Writeln(` val = ensureTyped(val, "uuid")`) + w.Writeln(` r, ok := val.(string)`) + w.Writeln(` if !ok {`) + w.Writeln(` panicErr("bad uuid value")`) + w.Writeln(` }`) + w.Writeln(` return r`) + w.Writeln(`}`) + w.Writeln(``) + + w.Writeln(`func EnsureUuidMultiples(val interface{}) []string {`) + w.Writeln(` typ, val1 := ensureTypedPair(val)`) + w.Writeln(` if typ == "uuid" {`) + w.Writeln(` r, ok := val1.(string)`) + w.Writeln(` if !ok {`) + w.Writeln(` panicErr("uuid multiples: expect a string")`) + w.Writeln(` }`) + w.Writeln(` return []string{r}`) + w.Writeln(` }`) + w.Writeln(` if typ == "set" {`) + w.Writeln(` mulVal, ok := val1.([]interface{})`) + w.Writeln(` if !ok {`) + w.Writeln(` panicErr("uuid multiples: expect an array")`) + w.Writeln(` }`) + w.Writeln(` if len(mulVal) == 0 {`) + w.Writeln(` return nil`) + w.Writeln(` }`) + w.Writeln(` r := make([]string, len(mulVal))`) + w.Writeln(` for i, val := range mulVal {`) + w.Writeln(` r[i] = EnsureUuid(val)`) + w.Writeln(` }`) + w.Writeln(` return r`) + w.Writeln(` }`) + w.Writeln(` panic("uuid multiple: unexpected type: " + typ)`) + w.Writeln(`}`) + w.Writeln(``) + + for _, atom0 := range atomics { + var ( + name0 = atom0.exportName() + gotyp0 = atomicGoMap[atom0] + unmTyp0 = atomicUnmarshalTyp[atom0] + ) + + if atom0 != Uuid { + w.Writef(`func Ensure%s(val interface{}) %s {`, name0, gotyp0) + w.Writef(` if r, ok := val.(%s); ok {`, unmTyp0) + w.Writef(` return %s(r)`, gotyp0) + w.Writef(` }`) + w.Writef(` panic(ErrBadType)`) + w.Writef(`}`) + w.Writef(``) + + w.Writef(`func Ensure%sMultiples(val interface{}) []%s {`, name0, gotyp0) + w.Writef(` if ok := probeEmpty(val); ok {`) + w.Writef(` return nil`) + w.Writef(` }`) + w.Writef(` if r, ok := val.(%s); ok {`, unmTyp0) + w.Writef(` return []%s{%s(r)}`, gotyp0, gotyp0) + w.Writef(` }`) + w.Writef(` mulVal := ensureMultiples(val, "set")`) + w.Writef(` if len(mulVal) == 0 {`) + w.Writef(` return nil`) + w.Writef(` }`) + w.Writef(` r := make([]%s, len(mulVal))`, gotyp0) + w.Writef(` for i, val := range mulVal {`) + w.Writef(` r[i] = Ensure%s(val)`, name0) + w.Writef(` }`) + w.Writef(` return r`) + w.Writef(`}`) + w.Writef(``) + } + + w.Writef(`func Ensure%sOptional(val interface{}) *%s {`, name0, gotyp0) + w.Writef(` if ok := probeEmpty(val); ok {`) + w.Writef(` return nil`) + w.Writef(` }`) + w.Writef(` r := Ensure%s(val)`, name0) + w.Writef(` return &r`) + w.Writef(`}`) + w.Writef(``) + + for _, atom1 := range atomics { + var ( + name1 = atom1.exportName() + gotyp1 = atomicGoMap[atom1] + ) + w.Writef(`func EnsureMap%s%s(val interface{}) map[%s]%s {`, name0, name1, gotyp0, gotyp1) + w.Writef(` mulVal := ensureMultiples(val, "map")`) + w.Writef(` if len(mulVal) == 0 {`) + w.Writef(` return nil`) + w.Writef(` }`) + w.Writef(` r := map[%s]%s{}`, gotyp0, gotyp1) + w.Writef(` for _, pairVal := range mulVal {`) + w.Writef(` pair, ok := pairVal.([]interface{})`) + w.Writef(` if !ok {`) + w.Writef(` panicErr("map: not an array")`) + w.Writef(` }`) + w.Writef(` if len(pair) != 2 {`) + w.Writef(` panicErr("map: not a pair")`) + w.Writef(` }`) + w.Writef(` k := Ensure%s(pair[0])`, name0) + w.Writef(` v := Ensure%s(pair[1])`, name1) + w.Writef(` r[k] = v`) + w.Writef(` }`) + w.Writef(` return r`) + w.Writef(`}`) + w.Writef(``) + } + } +} + +func (ag *AtomicGen) genCmdArgs() error { + w, err := ag.prepGen("atomic_gen_cmdargs_zz_generated.go") + if err != nil { + return err + } + ag.genCmdArgs_(w) + return nil +} + +func (ag *AtomicGen) genCmdArgs_(w writer) { + w.Writeln(`import "fmt"`) + w.Writeln(`import "strings"`) + + for _, atom0 := range atomics { + var ( + name0 = atom0.exportName() + gotyp0 = atomicGoMap[atom0] + fmt0 = atom0.fmtStr() + ) + + w.Writef(`func OvsdbCmdArg%s(a %s) string {`, name0, gotyp0) + w.Writef(` return fmt.Sprintf("%s", a)`, fmt0) + w.Writeln(`}`) + w.Writeln(``) + + w.Writef(`func OvsdbCmdArgs%s(field string, a %s) []string {`, name0, gotyp0) + w.Writef(` return []string{fmt.Sprintf("%%s=%%s", field, OvsdbCmdArg%s(a))}`, name0) + w.Writeln(`}`) + w.Writeln(``) + + w.Writef(`func OvsdbCmdArgs%sOptional(field string, a *%s) []string {`, name0, gotyp0) + w.Writeln(` if a == nil {`) + w.Writeln(` return nil`) + w.Writeln(` }`) + w.Writef(` return OvsdbCmdArgs%s(field, *a)`, name0) + w.Writeln(`}`) + w.Writeln(``) + + w.Writef(`func OvsdbCmdArgs%sMultiples(field string, a []%s) []string {`, name0, gotyp0) + w.Writeln(` if len(a) == 0 {`) + w.Writeln(` return nil`) + w.Writeln(` }`) + w.Writeln(` elArgs := make([]string, len(a))`) + w.Writeln(` for i, el := range a {`) + w.Writef(` elArgs[i] = OvsdbCmdArg%s(el)`, name0) + w.Writeln(` }`) + w.Writeln(` arg := fmt.Sprintf("%s=[%s]", field, strings.Join(elArgs, ","))`) + w.Writeln(` return []string{arg}`) + w.Writeln(`}`) + w.Writeln(``) + + for _, atom1 := range atomics { + var ( + name1 = atom1.exportName() + gotyp1 = atomicGoMap[atom1] + ) + w.Writef(`func OvsdbCmdArgsMap%s%s(field string, a map[%s]%s) []string {`, name0, name1, gotyp0, gotyp1) + w.Writeln(` if len(a) == 0 {`) + w.Writeln(` return nil`) + w.Writeln(` }`) + w.Writeln(` r := make([]string, 0, len(a))`) + w.Writeln(` for aK, aV := range a {`) + w.Writef(` r = append(r, fmt.Sprintf("%%s:%%s=%%s", field, OvsdbCmdArg%s(aK), OvsdbCmdArg%s(aV)))`, name0, name1) + w.Writeln(` }`) + w.Writeln(` return r`) + w.Writeln(`}`) + w.Writeln(``) + } + } +} + +func (ag *AtomicGen) genMatches() error { + w, err := ag.prepGen("atomic_gen_matches_zz_generated.go") + if err != nil { + return err + } + ag.genMatches_(w) + return nil +} + +func (ag *AtomicGen) genMatches_(w writer) { + for _, atom0 := range atomics { + var ( + name0 = atom0.exportName() + gotyp0 = atomicGoMap[atom0] + ) + + w.Writef(`func Match%sIfNonZero(a, b %s) bool {`, name0, gotyp0) + w.Writef(` var z %s`, gotyp0) + w.Writeln(` if b == z {`) + w.Writeln(` return true`) + w.Writeln(` }`) + w.Writef(` return Match%s(a, b)`, name0) + w.Writeln(`}`) + w.Writeln(``) + + w.Writef(`func Match%s(a, b %s) bool {`, name0, gotyp0) + w.Writeln(` return a == b`) + w.Writeln(`}`) + w.Writeln(``) + + w.Writef(`func Match%sOptionalIfNonZero(a, b *%s) bool {`, name0, gotyp0) + w.Writeln(` if b == nil {`) + w.Writeln(` return true`) + w.Writeln(` }`) + w.Writef(` return Match%sOptional(a, b)`, name0) + w.Writeln(`}`) + w.Writeln(``) + + w.Writef(`func Match%sOptional(a, b *%s) bool {`, name0, gotyp0) + w.Writeln(` if a == nil && b == nil {`) + w.Writeln(` return true`) + w.Writeln(` } else if a != nil && b != nil {`) + w.Writeln(` return *a == *b`) + w.Writeln(` }`) + w.Writeln(` return false`) + w.Writeln(`}`) + w.Writeln(``) + + w.Writef(`func Match%sMultiplesIfNonZero(a, b []%s) bool {`, name0, gotyp0) + w.Writeln(` if b == nil {`) + w.Writeln(` return true`) + w.Writeln(` }`) + w.Writef(` return Match%sMultiples(a, b)`, name0) + w.Writeln(`}`) + w.Writeln(``) + + w.Writef(`func Match%sMultiples(a, b []%s) bool {`, name0, gotyp0) + w.Writeln(` if len(a) != len(b) {`) + w.Writeln(` return false`) + w.Writeln(` }`) + w.Writef(` bCopy := make([]%s, len(b))`, gotyp0) + w.Writeln(` copy(bCopy, b)`) + w.Writeln(` for _, elA := range a {`) + w.Writeln(` for i := len(bCopy) - 1; i >= 0; i-- {`) + w.Writeln(` elB := bCopy[i]`) + w.Writeln(` if elA == elB {`) + w.Writeln(` bCopy = append(bCopy[:i], bCopy[i+1:]...)`) + w.Writeln(` }`) + w.Writeln(` }`) + w.Writeln(` }`) + w.Writeln(` if len(bCopy) == 0 {`) + w.Writeln(` return true`) + w.Writeln(` }`) + w.Writeln(` return false`) + w.Writeln(`}`) + w.Writeln(``) + + for _, atom1 := range atomics { + var ( + name1 = atom1.exportName() + gotyp1 = atomicGoMap[atom1] + ) + w.Writef(`func MatchMap%s%sIfNonZero(a, b map[%s]%s) bool {`, name0, name1, gotyp0, gotyp1) + w.Writeln(` if b == nil {`) + w.Writeln(` return true`) + w.Writeln(` }`) + w.Writef(` return MatchMap%s%s(a, b)`, name0, name1) + w.Writeln(`}`) + w.Writeln(``) + + w.Writef(`func MatchMap%s%s(a, b map[%s]%s) bool {`, name0, name1, gotyp0, gotyp1) + w.Writeln(` if len(a) != len(b) {`) + w.Writeln(` return false`) + w.Writeln(` }`) + w.Writef(` bCopy := map[%s]%s{}`, gotyp0, gotyp1) + w.Writeln(` for k, v := range b {`) + w.Writeln(` bCopy[k] = v`) + w.Writeln(` }`) + w.Writeln(` for aK, aV := range a {`) + w.Writeln(` if bV, ok := bCopy[aK]; !ok || aV != bV {`) + w.Writeln(` return false`) + w.Writeln(` } else {`) + w.Writeln(` delete(bCopy, aK)`) + w.Writeln(` }`) + w.Writeln(` }`) + w.Writeln(` if len(bCopy) == 0 {`) + w.Writeln(` return true`) + w.Writeln(` }`) + w.Writeln(` return false`) + w.Writeln(`}`) + w.Writeln(``) + } + } +} diff --git a/vendor/yunion.io/x/ovsdb/types/atomic_gen_cmdargs_zz_generated.go b/vendor/yunion.io/x/ovsdb/types/atomic_gen_cmdargs_zz_generated.go new file mode 100644 index 0000000000..e7ad0120e1 --- /dev/null +++ b/vendor/yunion.io/x/ovsdb/types/atomic_gen_cmdargs_zz_generated.go @@ -0,0 +1,418 @@ +// DO NOT EDIT: automatically generated code + +package types + +import ( + "fmt" + "strings" +) + +func OvsdbCmdArgString(a string) string { + return fmt.Sprintf("%q", a) +} + +func OvsdbCmdArgsString(field string, a string) []string { + return []string{fmt.Sprintf("%s=%s", field, OvsdbCmdArgString(a))} +} + +func OvsdbCmdArgsStringOptional(field string, a *string) []string { + if a == nil { + return nil + } + return OvsdbCmdArgsString(field, *a) +} + +func OvsdbCmdArgsStringMultiples(field string, a []string) []string { + if len(a) == 0 { + return nil + } + elArgs := make([]string, len(a)) + for i, el := range a { + elArgs[i] = OvsdbCmdArgString(el) + } + arg := fmt.Sprintf("%s=[%s]", field, strings.Join(elArgs, ",")) + return []string{arg} +} + +func OvsdbCmdArgsMapStringString(field string, a map[string]string) []string { + if len(a) == 0 { + return nil + } + r := make([]string, 0, len(a)) + for aK, aV := range a { + r = append(r, fmt.Sprintf("%s:%s=%s", field, OvsdbCmdArgString(aK), OvsdbCmdArgString(aV))) + } + return r +} + +func OvsdbCmdArgsMapStringInteger(field string, a map[string]int64) []string { + if len(a) == 0 { + return nil + } + r := make([]string, 0, len(a)) + for aK, aV := range a { + r = append(r, fmt.Sprintf("%s:%s=%s", field, OvsdbCmdArgString(aK), OvsdbCmdArgInteger(aV))) + } + return r +} + +func OvsdbCmdArgsMapStringReal(field string, a map[string]float64) []string { + if len(a) == 0 { + return nil + } + r := make([]string, 0, len(a)) + for aK, aV := range a { + r = append(r, fmt.Sprintf("%s:%s=%s", field, OvsdbCmdArgString(aK), OvsdbCmdArgReal(aV))) + } + return r +} + +func OvsdbCmdArgsMapStringBoolean(field string, a map[string]bool) []string { + if len(a) == 0 { + return nil + } + r := make([]string, 0, len(a)) + for aK, aV := range a { + r = append(r, fmt.Sprintf("%s:%s=%s", field, OvsdbCmdArgString(aK), OvsdbCmdArgBoolean(aV))) + } + return r +} + +func OvsdbCmdArgsMapStringUuid(field string, a map[string]string) []string { + if len(a) == 0 { + return nil + } + r := make([]string, 0, len(a)) + for aK, aV := range a { + r = append(r, fmt.Sprintf("%s:%s=%s", field, OvsdbCmdArgString(aK), OvsdbCmdArgUuid(aV))) + } + return r +} + +func OvsdbCmdArgInteger(a int64) string { + return fmt.Sprintf("%d", a) +} + +func OvsdbCmdArgsInteger(field string, a int64) []string { + return []string{fmt.Sprintf("%s=%s", field, OvsdbCmdArgInteger(a))} +} + +func OvsdbCmdArgsIntegerOptional(field string, a *int64) []string { + if a == nil { + return nil + } + return OvsdbCmdArgsInteger(field, *a) +} + +func OvsdbCmdArgsIntegerMultiples(field string, a []int64) []string { + if len(a) == 0 { + return nil + } + elArgs := make([]string, len(a)) + for i, el := range a { + elArgs[i] = OvsdbCmdArgInteger(el) + } + arg := fmt.Sprintf("%s=[%s]", field, strings.Join(elArgs, ",")) + return []string{arg} +} + +func OvsdbCmdArgsMapIntegerString(field string, a map[int64]string) []string { + if len(a) == 0 { + return nil + } + r := make([]string, 0, len(a)) + for aK, aV := range a { + r = append(r, fmt.Sprintf("%s:%s=%s", field, OvsdbCmdArgInteger(aK), OvsdbCmdArgString(aV))) + } + return r +} + +func OvsdbCmdArgsMapIntegerInteger(field string, a map[int64]int64) []string { + if len(a) == 0 { + return nil + } + r := make([]string, 0, len(a)) + for aK, aV := range a { + r = append(r, fmt.Sprintf("%s:%s=%s", field, OvsdbCmdArgInteger(aK), OvsdbCmdArgInteger(aV))) + } + return r +} + +func OvsdbCmdArgsMapIntegerReal(field string, a map[int64]float64) []string { + if len(a) == 0 { + return nil + } + r := make([]string, 0, len(a)) + for aK, aV := range a { + r = append(r, fmt.Sprintf("%s:%s=%s", field, OvsdbCmdArgInteger(aK), OvsdbCmdArgReal(aV))) + } + return r +} + +func OvsdbCmdArgsMapIntegerBoolean(field string, a map[int64]bool) []string { + if len(a) == 0 { + return nil + } + r := make([]string, 0, len(a)) + for aK, aV := range a { + r = append(r, fmt.Sprintf("%s:%s=%s", field, OvsdbCmdArgInteger(aK), OvsdbCmdArgBoolean(aV))) + } + return r +} + +func OvsdbCmdArgsMapIntegerUuid(field string, a map[int64]string) []string { + if len(a) == 0 { + return nil + } + r := make([]string, 0, len(a)) + for aK, aV := range a { + r = append(r, fmt.Sprintf("%s:%s=%s", field, OvsdbCmdArgInteger(aK), OvsdbCmdArgUuid(aV))) + } + return r +} + +func OvsdbCmdArgReal(a float64) string { + return fmt.Sprintf("%f", a) +} + +func OvsdbCmdArgsReal(field string, a float64) []string { + return []string{fmt.Sprintf("%s=%s", field, OvsdbCmdArgReal(a))} +} + +func OvsdbCmdArgsRealOptional(field string, a *float64) []string { + if a == nil { + return nil + } + return OvsdbCmdArgsReal(field, *a) +} + +func OvsdbCmdArgsRealMultiples(field string, a []float64) []string { + if len(a) == 0 { + return nil + } + elArgs := make([]string, len(a)) + for i, el := range a { + elArgs[i] = OvsdbCmdArgReal(el) + } + arg := fmt.Sprintf("%s=[%s]", field, strings.Join(elArgs, ",")) + return []string{arg} +} + +func OvsdbCmdArgsMapRealString(field string, a map[float64]string) []string { + if len(a) == 0 { + return nil + } + r := make([]string, 0, len(a)) + for aK, aV := range a { + r = append(r, fmt.Sprintf("%s:%s=%s", field, OvsdbCmdArgReal(aK), OvsdbCmdArgString(aV))) + } + return r +} + +func OvsdbCmdArgsMapRealInteger(field string, a map[float64]int64) []string { + if len(a) == 0 { + return nil + } + r := make([]string, 0, len(a)) + for aK, aV := range a { + r = append(r, fmt.Sprintf("%s:%s=%s", field, OvsdbCmdArgReal(aK), OvsdbCmdArgInteger(aV))) + } + return r +} + +func OvsdbCmdArgsMapRealReal(field string, a map[float64]float64) []string { + if len(a) == 0 { + return nil + } + r := make([]string, 0, len(a)) + for aK, aV := range a { + r = append(r, fmt.Sprintf("%s:%s=%s", field, OvsdbCmdArgReal(aK), OvsdbCmdArgReal(aV))) + } + return r +} + +func OvsdbCmdArgsMapRealBoolean(field string, a map[float64]bool) []string { + if len(a) == 0 { + return nil + } + r := make([]string, 0, len(a)) + for aK, aV := range a { + r = append(r, fmt.Sprintf("%s:%s=%s", field, OvsdbCmdArgReal(aK), OvsdbCmdArgBoolean(aV))) + } + return r +} + +func OvsdbCmdArgsMapRealUuid(field string, a map[float64]string) []string { + if len(a) == 0 { + return nil + } + r := make([]string, 0, len(a)) + for aK, aV := range a { + r = append(r, fmt.Sprintf("%s:%s=%s", field, OvsdbCmdArgReal(aK), OvsdbCmdArgUuid(aV))) + } + return r +} + +func OvsdbCmdArgBoolean(a bool) string { + return fmt.Sprintf("%v", a) +} + +func OvsdbCmdArgsBoolean(field string, a bool) []string { + return []string{fmt.Sprintf("%s=%s", field, OvsdbCmdArgBoolean(a))} +} + +func OvsdbCmdArgsBooleanOptional(field string, a *bool) []string { + if a == nil { + return nil + } + return OvsdbCmdArgsBoolean(field, *a) +} + +func OvsdbCmdArgsBooleanMultiples(field string, a []bool) []string { + if len(a) == 0 { + return nil + } + elArgs := make([]string, len(a)) + for i, el := range a { + elArgs[i] = OvsdbCmdArgBoolean(el) + } + arg := fmt.Sprintf("%s=[%s]", field, strings.Join(elArgs, ",")) + return []string{arg} +} + +func OvsdbCmdArgsMapBooleanString(field string, a map[bool]string) []string { + if len(a) == 0 { + return nil + } + r := make([]string, 0, len(a)) + for aK, aV := range a { + r = append(r, fmt.Sprintf("%s:%s=%s", field, OvsdbCmdArgBoolean(aK), OvsdbCmdArgString(aV))) + } + return r +} + +func OvsdbCmdArgsMapBooleanInteger(field string, a map[bool]int64) []string { + if len(a) == 0 { + return nil + } + r := make([]string, 0, len(a)) + for aK, aV := range a { + r = append(r, fmt.Sprintf("%s:%s=%s", field, OvsdbCmdArgBoolean(aK), OvsdbCmdArgInteger(aV))) + } + return r +} + +func OvsdbCmdArgsMapBooleanReal(field string, a map[bool]float64) []string { + if len(a) == 0 { + return nil + } + r := make([]string, 0, len(a)) + for aK, aV := range a { + r = append(r, fmt.Sprintf("%s:%s=%s", field, OvsdbCmdArgBoolean(aK), OvsdbCmdArgReal(aV))) + } + return r +} + +func OvsdbCmdArgsMapBooleanBoolean(field string, a map[bool]bool) []string { + if len(a) == 0 { + return nil + } + r := make([]string, 0, len(a)) + for aK, aV := range a { + r = append(r, fmt.Sprintf("%s:%s=%s", field, OvsdbCmdArgBoolean(aK), OvsdbCmdArgBoolean(aV))) + } + return r +} + +func OvsdbCmdArgsMapBooleanUuid(field string, a map[bool]string) []string { + if len(a) == 0 { + return nil + } + r := make([]string, 0, len(a)) + for aK, aV := range a { + r = append(r, fmt.Sprintf("%s:%s=%s", field, OvsdbCmdArgBoolean(aK), OvsdbCmdArgUuid(aV))) + } + return r +} + +func OvsdbCmdArgUuid(a string) string { + return fmt.Sprintf("%s", a) +} + +func OvsdbCmdArgsUuid(field string, a string) []string { + return []string{fmt.Sprintf("%s=%s", field, OvsdbCmdArgUuid(a))} +} + +func OvsdbCmdArgsUuidOptional(field string, a *string) []string { + if a == nil { + return nil + } + return OvsdbCmdArgsUuid(field, *a) +} + +func OvsdbCmdArgsUuidMultiples(field string, a []string) []string { + if len(a) == 0 { + return nil + } + elArgs := make([]string, len(a)) + for i, el := range a { + elArgs[i] = OvsdbCmdArgUuid(el) + } + arg := fmt.Sprintf("%s=[%s]", field, strings.Join(elArgs, ",")) + return []string{arg} +} + +func OvsdbCmdArgsMapUuidString(field string, a map[string]string) []string { + if len(a) == 0 { + return nil + } + r := make([]string, 0, len(a)) + for aK, aV := range a { + r = append(r, fmt.Sprintf("%s:%s=%s", field, OvsdbCmdArgUuid(aK), OvsdbCmdArgString(aV))) + } + return r +} + +func OvsdbCmdArgsMapUuidInteger(field string, a map[string]int64) []string { + if len(a) == 0 { + return nil + } + r := make([]string, 0, len(a)) + for aK, aV := range a { + r = append(r, fmt.Sprintf("%s:%s=%s", field, OvsdbCmdArgUuid(aK), OvsdbCmdArgInteger(aV))) + } + return r +} + +func OvsdbCmdArgsMapUuidReal(field string, a map[string]float64) []string { + if len(a) == 0 { + return nil + } + r := make([]string, 0, len(a)) + for aK, aV := range a { + r = append(r, fmt.Sprintf("%s:%s=%s", field, OvsdbCmdArgUuid(aK), OvsdbCmdArgReal(aV))) + } + return r +} + +func OvsdbCmdArgsMapUuidBoolean(field string, a map[string]bool) []string { + if len(a) == 0 { + return nil + } + r := make([]string, 0, len(a)) + for aK, aV := range a { + r = append(r, fmt.Sprintf("%s:%s=%s", field, OvsdbCmdArgUuid(aK), OvsdbCmdArgBoolean(aV))) + } + return r +} + +func OvsdbCmdArgsMapUuidUuid(field string, a map[string]string) []string { + if len(a) == 0 { + return nil + } + r := make([]string, 0, len(a)) + for aK, aV := range a { + r = append(r, fmt.Sprintf("%s:%s=%s", field, OvsdbCmdArgUuid(aK), OvsdbCmdArgUuid(aV))) + } + return r +} diff --git a/vendor/yunion.io/x/ovsdb/types/atomic_gen_ensures_zz_generated.go b/vendor/yunion.io/x/ovsdb/types/atomic_gen_ensures_zz_generated.go new file mode 100644 index 0000000000..ed943747bc --- /dev/null +++ b/vendor/yunion.io/x/ovsdb/types/atomic_gen_ensures_zz_generated.go @@ -0,0 +1,756 @@ +// DO NOT EDIT: automatically generated code + +package types + +import "github.com/pkg/errors" + +func panicErr(msg string) { + panic(errors.Wrap(ErrBadType, msg)) +} + +func panicErrf(fmtStr string, s ...interface{}) { + panic(errors.Wrapf(ErrBadType, fmtStr, s...)) +} + +func ensureTypedPair(val interface{}) (string, interface{}) { + arr, ok := val.([]interface{}) + if !ok { + panicErr("ensureTypedPair: not an array") + } + if len(arr) != 2 { + panicErrf("ensureTypedPair: length is %d, want 2", len(arr)) + } + typ, ok := arr[0].(string) + if !ok { + panicErr("ensureTypedPair: type not a string") + } + return typ, arr[1] +} + +func ensureTyped(val interface{}, typ string) interface{} { + gotTyp, r := ensureTypedPair(val) + if gotTyp != typ { + panicErrf("ensureMultiples: got %s, want %s", gotTyp, typ) + } + return r +} + +func ensureMultiples(val interface{}, typ string) []interface{} { + val = ensureTyped(val, typ) + mulVal, ok := val.([]interface{}) + if !ok { + panicErr("ensureMultiples: val is not an array") + } + return mulVal +} + +func probeEmpty(val interface{}) (r bool) { + defer func() { + recover() + }() + empty := ensureMultiples(val, "set") + if len(empty) != 0 { + return false + } + return true +} + +func EnsureUuid(val interface{}) string { + val = ensureTyped(val, "uuid") + r, ok := val.(string) + if !ok { + panicErr("bad uuid value") + } + return r +} + +func EnsureUuidMultiples(val interface{}) []string { + typ, val1 := ensureTypedPair(val) + if typ == "uuid" { + r, ok := val1.(string) + if !ok { + panicErr("uuid multiples: expect a string") + } + return []string{r} + } + if typ == "set" { + mulVal, ok := val1.([]interface{}) + if !ok { + panicErr("uuid multiples: expect an array") + } + if len(mulVal) == 0 { + return nil + } + r := make([]string, len(mulVal)) + for i, val := range mulVal { + r[i] = EnsureUuid(val) + } + return r + } + panic("uuid multiple: unexpected type: " + typ) +} + +func EnsureString(val interface{}) string { + if r, ok := val.(string); ok { + return string(r) + } + panic(ErrBadType) +} + +func EnsureStringMultiples(val interface{}) []string { + if ok := probeEmpty(val); ok { + return nil + } + if r, ok := val.(string); ok { + return []string{string(r)} + } + mulVal := ensureMultiples(val, "set") + if len(mulVal) == 0 { + return nil + } + r := make([]string, len(mulVal)) + for i, val := range mulVal { + r[i] = EnsureString(val) + } + return r +} + +func EnsureStringOptional(val interface{}) *string { + if ok := probeEmpty(val); ok { + return nil + } + r := EnsureString(val) + return &r +} + +func EnsureMapStringString(val interface{}) map[string]string { + mulVal := ensureMultiples(val, "map") + if len(mulVal) == 0 { + return nil + } + r := map[string]string{} + for _, pairVal := range mulVal { + pair, ok := pairVal.([]interface{}) + if !ok { + panicErr("map: not an array") + } + if len(pair) != 2 { + panicErr("map: not a pair") + } + k := EnsureString(pair[0]) + v := EnsureString(pair[1]) + r[k] = v + } + return r +} + +func EnsureMapStringInteger(val interface{}) map[string]int64 { + mulVal := ensureMultiples(val, "map") + if len(mulVal) == 0 { + return nil + } + r := map[string]int64{} + for _, pairVal := range mulVal { + pair, ok := pairVal.([]interface{}) + if !ok { + panicErr("map: not an array") + } + if len(pair) != 2 { + panicErr("map: not a pair") + } + k := EnsureString(pair[0]) + v := EnsureInteger(pair[1]) + r[k] = v + } + return r +} + +func EnsureMapStringReal(val interface{}) map[string]float64 { + mulVal := ensureMultiples(val, "map") + if len(mulVal) == 0 { + return nil + } + r := map[string]float64{} + for _, pairVal := range mulVal { + pair, ok := pairVal.([]interface{}) + if !ok { + panicErr("map: not an array") + } + if len(pair) != 2 { + panicErr("map: not a pair") + } + k := EnsureString(pair[0]) + v := EnsureReal(pair[1]) + r[k] = v + } + return r +} + +func EnsureMapStringBoolean(val interface{}) map[string]bool { + mulVal := ensureMultiples(val, "map") + if len(mulVal) == 0 { + return nil + } + r := map[string]bool{} + for _, pairVal := range mulVal { + pair, ok := pairVal.([]interface{}) + if !ok { + panicErr("map: not an array") + } + if len(pair) != 2 { + panicErr("map: not a pair") + } + k := EnsureString(pair[0]) + v := EnsureBoolean(pair[1]) + r[k] = v + } + return r +} + +func EnsureMapStringUuid(val interface{}) map[string]string { + mulVal := ensureMultiples(val, "map") + if len(mulVal) == 0 { + return nil + } + r := map[string]string{} + for _, pairVal := range mulVal { + pair, ok := pairVal.([]interface{}) + if !ok { + panicErr("map: not an array") + } + if len(pair) != 2 { + panicErr("map: not a pair") + } + k := EnsureString(pair[0]) + v := EnsureUuid(pair[1]) + r[k] = v + } + return r +} + +func EnsureInteger(val interface{}) int64 { + if r, ok := val.(float64); ok { + return int64(r) + } + panic(ErrBadType) +} + +func EnsureIntegerMultiples(val interface{}) []int64 { + if ok := probeEmpty(val); ok { + return nil + } + if r, ok := val.(float64); ok { + return []int64{int64(r)} + } + mulVal := ensureMultiples(val, "set") + if len(mulVal) == 0 { + return nil + } + r := make([]int64, len(mulVal)) + for i, val := range mulVal { + r[i] = EnsureInteger(val) + } + return r +} + +func EnsureIntegerOptional(val interface{}) *int64 { + if ok := probeEmpty(val); ok { + return nil + } + r := EnsureInteger(val) + return &r +} + +func EnsureMapIntegerString(val interface{}) map[int64]string { + mulVal := ensureMultiples(val, "map") + if len(mulVal) == 0 { + return nil + } + r := map[int64]string{} + for _, pairVal := range mulVal { + pair, ok := pairVal.([]interface{}) + if !ok { + panicErr("map: not an array") + } + if len(pair) != 2 { + panicErr("map: not a pair") + } + k := EnsureInteger(pair[0]) + v := EnsureString(pair[1]) + r[k] = v + } + return r +} + +func EnsureMapIntegerInteger(val interface{}) map[int64]int64 { + mulVal := ensureMultiples(val, "map") + if len(mulVal) == 0 { + return nil + } + r := map[int64]int64{} + for _, pairVal := range mulVal { + pair, ok := pairVal.([]interface{}) + if !ok { + panicErr("map: not an array") + } + if len(pair) != 2 { + panicErr("map: not a pair") + } + k := EnsureInteger(pair[0]) + v := EnsureInteger(pair[1]) + r[k] = v + } + return r +} + +func EnsureMapIntegerReal(val interface{}) map[int64]float64 { + mulVal := ensureMultiples(val, "map") + if len(mulVal) == 0 { + return nil + } + r := map[int64]float64{} + for _, pairVal := range mulVal { + pair, ok := pairVal.([]interface{}) + if !ok { + panicErr("map: not an array") + } + if len(pair) != 2 { + panicErr("map: not a pair") + } + k := EnsureInteger(pair[0]) + v := EnsureReal(pair[1]) + r[k] = v + } + return r +} + +func EnsureMapIntegerBoolean(val interface{}) map[int64]bool { + mulVal := ensureMultiples(val, "map") + if len(mulVal) == 0 { + return nil + } + r := map[int64]bool{} + for _, pairVal := range mulVal { + pair, ok := pairVal.([]interface{}) + if !ok { + panicErr("map: not an array") + } + if len(pair) != 2 { + panicErr("map: not a pair") + } + k := EnsureInteger(pair[0]) + v := EnsureBoolean(pair[1]) + r[k] = v + } + return r +} + +func EnsureMapIntegerUuid(val interface{}) map[int64]string { + mulVal := ensureMultiples(val, "map") + if len(mulVal) == 0 { + return nil + } + r := map[int64]string{} + for _, pairVal := range mulVal { + pair, ok := pairVal.([]interface{}) + if !ok { + panicErr("map: not an array") + } + if len(pair) != 2 { + panicErr("map: not a pair") + } + k := EnsureInteger(pair[0]) + v := EnsureUuid(pair[1]) + r[k] = v + } + return r +} + +func EnsureReal(val interface{}) float64 { + if r, ok := val.(float64); ok { + return float64(r) + } + panic(ErrBadType) +} + +func EnsureRealMultiples(val interface{}) []float64 { + if ok := probeEmpty(val); ok { + return nil + } + if r, ok := val.(float64); ok { + return []float64{float64(r)} + } + mulVal := ensureMultiples(val, "set") + if len(mulVal) == 0 { + return nil + } + r := make([]float64, len(mulVal)) + for i, val := range mulVal { + r[i] = EnsureReal(val) + } + return r +} + +func EnsureRealOptional(val interface{}) *float64 { + if ok := probeEmpty(val); ok { + return nil + } + r := EnsureReal(val) + return &r +} + +func EnsureMapRealString(val interface{}) map[float64]string { + mulVal := ensureMultiples(val, "map") + if len(mulVal) == 0 { + return nil + } + r := map[float64]string{} + for _, pairVal := range mulVal { + pair, ok := pairVal.([]interface{}) + if !ok { + panicErr("map: not an array") + } + if len(pair) != 2 { + panicErr("map: not a pair") + } + k := EnsureReal(pair[0]) + v := EnsureString(pair[1]) + r[k] = v + } + return r +} + +func EnsureMapRealInteger(val interface{}) map[float64]int64 { + mulVal := ensureMultiples(val, "map") + if len(mulVal) == 0 { + return nil + } + r := map[float64]int64{} + for _, pairVal := range mulVal { + pair, ok := pairVal.([]interface{}) + if !ok { + panicErr("map: not an array") + } + if len(pair) != 2 { + panicErr("map: not a pair") + } + k := EnsureReal(pair[0]) + v := EnsureInteger(pair[1]) + r[k] = v + } + return r +} + +func EnsureMapRealReal(val interface{}) map[float64]float64 { + mulVal := ensureMultiples(val, "map") + if len(mulVal) == 0 { + return nil + } + r := map[float64]float64{} + for _, pairVal := range mulVal { + pair, ok := pairVal.([]interface{}) + if !ok { + panicErr("map: not an array") + } + if len(pair) != 2 { + panicErr("map: not a pair") + } + k := EnsureReal(pair[0]) + v := EnsureReal(pair[1]) + r[k] = v + } + return r +} + +func EnsureMapRealBoolean(val interface{}) map[float64]bool { + mulVal := ensureMultiples(val, "map") + if len(mulVal) == 0 { + return nil + } + r := map[float64]bool{} + for _, pairVal := range mulVal { + pair, ok := pairVal.([]interface{}) + if !ok { + panicErr("map: not an array") + } + if len(pair) != 2 { + panicErr("map: not a pair") + } + k := EnsureReal(pair[0]) + v := EnsureBoolean(pair[1]) + r[k] = v + } + return r +} + +func EnsureMapRealUuid(val interface{}) map[float64]string { + mulVal := ensureMultiples(val, "map") + if len(mulVal) == 0 { + return nil + } + r := map[float64]string{} + for _, pairVal := range mulVal { + pair, ok := pairVal.([]interface{}) + if !ok { + panicErr("map: not an array") + } + if len(pair) != 2 { + panicErr("map: not a pair") + } + k := EnsureReal(pair[0]) + v := EnsureUuid(pair[1]) + r[k] = v + } + return r +} + +func EnsureBoolean(val interface{}) bool { + if r, ok := val.(bool); ok { + return bool(r) + } + panic(ErrBadType) +} + +func EnsureBooleanMultiples(val interface{}) []bool { + if ok := probeEmpty(val); ok { + return nil + } + if r, ok := val.(bool); ok { + return []bool{bool(r)} + } + mulVal := ensureMultiples(val, "set") + if len(mulVal) == 0 { + return nil + } + r := make([]bool, len(mulVal)) + for i, val := range mulVal { + r[i] = EnsureBoolean(val) + } + return r +} + +func EnsureBooleanOptional(val interface{}) *bool { + if ok := probeEmpty(val); ok { + return nil + } + r := EnsureBoolean(val) + return &r +} + +func EnsureMapBooleanString(val interface{}) map[bool]string { + mulVal := ensureMultiples(val, "map") + if len(mulVal) == 0 { + return nil + } + r := map[bool]string{} + for _, pairVal := range mulVal { + pair, ok := pairVal.([]interface{}) + if !ok { + panicErr("map: not an array") + } + if len(pair) != 2 { + panicErr("map: not a pair") + } + k := EnsureBoolean(pair[0]) + v := EnsureString(pair[1]) + r[k] = v + } + return r +} + +func EnsureMapBooleanInteger(val interface{}) map[bool]int64 { + mulVal := ensureMultiples(val, "map") + if len(mulVal) == 0 { + return nil + } + r := map[bool]int64{} + for _, pairVal := range mulVal { + pair, ok := pairVal.([]interface{}) + if !ok { + panicErr("map: not an array") + } + if len(pair) != 2 { + panicErr("map: not a pair") + } + k := EnsureBoolean(pair[0]) + v := EnsureInteger(pair[1]) + r[k] = v + } + return r +} + +func EnsureMapBooleanReal(val interface{}) map[bool]float64 { + mulVal := ensureMultiples(val, "map") + if len(mulVal) == 0 { + return nil + } + r := map[bool]float64{} + for _, pairVal := range mulVal { + pair, ok := pairVal.([]interface{}) + if !ok { + panicErr("map: not an array") + } + if len(pair) != 2 { + panicErr("map: not a pair") + } + k := EnsureBoolean(pair[0]) + v := EnsureReal(pair[1]) + r[k] = v + } + return r +} + +func EnsureMapBooleanBoolean(val interface{}) map[bool]bool { + mulVal := ensureMultiples(val, "map") + if len(mulVal) == 0 { + return nil + } + r := map[bool]bool{} + for _, pairVal := range mulVal { + pair, ok := pairVal.([]interface{}) + if !ok { + panicErr("map: not an array") + } + if len(pair) != 2 { + panicErr("map: not a pair") + } + k := EnsureBoolean(pair[0]) + v := EnsureBoolean(pair[1]) + r[k] = v + } + return r +} + +func EnsureMapBooleanUuid(val interface{}) map[bool]string { + mulVal := ensureMultiples(val, "map") + if len(mulVal) == 0 { + return nil + } + r := map[bool]string{} + for _, pairVal := range mulVal { + pair, ok := pairVal.([]interface{}) + if !ok { + panicErr("map: not an array") + } + if len(pair) != 2 { + panicErr("map: not a pair") + } + k := EnsureBoolean(pair[0]) + v := EnsureUuid(pair[1]) + r[k] = v + } + return r +} + +func EnsureUuidOptional(val interface{}) *string { + if ok := probeEmpty(val); ok { + return nil + } + r := EnsureUuid(val) + return &r +} + +func EnsureMapUuidString(val interface{}) map[string]string { + mulVal := ensureMultiples(val, "map") + if len(mulVal) == 0 { + return nil + } + r := map[string]string{} + for _, pairVal := range mulVal { + pair, ok := pairVal.([]interface{}) + if !ok { + panicErr("map: not an array") + } + if len(pair) != 2 { + panicErr("map: not a pair") + } + k := EnsureUuid(pair[0]) + v := EnsureString(pair[1]) + r[k] = v + } + return r +} + +func EnsureMapUuidInteger(val interface{}) map[string]int64 { + mulVal := ensureMultiples(val, "map") + if len(mulVal) == 0 { + return nil + } + r := map[string]int64{} + for _, pairVal := range mulVal { + pair, ok := pairVal.([]interface{}) + if !ok { + panicErr("map: not an array") + } + if len(pair) != 2 { + panicErr("map: not a pair") + } + k := EnsureUuid(pair[0]) + v := EnsureInteger(pair[1]) + r[k] = v + } + return r +} + +func EnsureMapUuidReal(val interface{}) map[string]float64 { + mulVal := ensureMultiples(val, "map") + if len(mulVal) == 0 { + return nil + } + r := map[string]float64{} + for _, pairVal := range mulVal { + pair, ok := pairVal.([]interface{}) + if !ok { + panicErr("map: not an array") + } + if len(pair) != 2 { + panicErr("map: not a pair") + } + k := EnsureUuid(pair[0]) + v := EnsureReal(pair[1]) + r[k] = v + } + return r +} + +func EnsureMapUuidBoolean(val interface{}) map[string]bool { + mulVal := ensureMultiples(val, "map") + if len(mulVal) == 0 { + return nil + } + r := map[string]bool{} + for _, pairVal := range mulVal { + pair, ok := pairVal.([]interface{}) + if !ok { + panicErr("map: not an array") + } + if len(pair) != 2 { + panicErr("map: not a pair") + } + k := EnsureUuid(pair[0]) + v := EnsureBoolean(pair[1]) + r[k] = v + } + return r +} + +func EnsureMapUuidUuid(val interface{}) map[string]string { + mulVal := ensureMultiples(val, "map") + if len(mulVal) == 0 { + return nil + } + r := map[string]string{} + for _, pairVal := range mulVal { + pair, ok := pairVal.([]interface{}) + if !ok { + panicErr("map: not an array") + } + if len(pair) != 2 { + panicErr("map: not a pair") + } + k := EnsureUuid(pair[0]) + v := EnsureUuid(pair[1]) + r[k] = v + } + return r +} diff --git a/vendor/yunion.io/x/ovsdb/types/atomic_gen_matches_zz_generated.go b/vendor/yunion.io/x/ovsdb/types/atomic_gen_matches_zz_generated.go new file mode 100644 index 0000000000..0013db8688 --- /dev/null +++ b/vendor/yunion.io/x/ovsdb/types/atomic_gen_matches_zz_generated.go @@ -0,0 +1,978 @@ +// DO NOT EDIT: automatically generated code + +package types + +func MatchStringIfNonZero(a, b string) bool { + var z string + if b == z { + return true + } + return MatchString(a, b) +} + +func MatchString(a, b string) bool { + return a == b +} + +func MatchStringOptionalIfNonZero(a, b *string) bool { + if b == nil { + return true + } + return MatchStringOptional(a, b) +} + +func MatchStringOptional(a, b *string) bool { + if a == nil && b == nil { + return true + } else if a != nil && b != nil { + return *a == *b + } + return false +} + +func MatchStringMultiplesIfNonZero(a, b []string) bool { + if b == nil { + return true + } + return MatchStringMultiples(a, b) +} + +func MatchStringMultiples(a, b []string) bool { + if len(a) != len(b) { + return false + } + bCopy := make([]string, len(b)) + copy(bCopy, b) + for _, elA := range a { + for i := len(bCopy) - 1; i >= 0; i-- { + elB := bCopy[i] + if elA == elB { + bCopy = append(bCopy[:i], bCopy[i+1:]...) + } + } + } + if len(bCopy) == 0 { + return true + } + return false +} + +func MatchMapStringStringIfNonZero(a, b map[string]string) bool { + if b == nil { + return true + } + return MatchMapStringString(a, b) +} + +func MatchMapStringString(a, b map[string]string) bool { + if len(a) != len(b) { + return false + } + bCopy := map[string]string{} + for k, v := range b { + bCopy[k] = v + } + for aK, aV := range a { + if bV, ok := bCopy[aK]; !ok || aV != bV { + return false + } else { + delete(bCopy, aK) + } + } + if len(bCopy) == 0 { + return true + } + return false +} + +func MatchMapStringIntegerIfNonZero(a, b map[string]int64) bool { + if b == nil { + return true + } + return MatchMapStringInteger(a, b) +} + +func MatchMapStringInteger(a, b map[string]int64) bool { + if len(a) != len(b) { + return false + } + bCopy := map[string]int64{} + for k, v := range b { + bCopy[k] = v + } + for aK, aV := range a { + if bV, ok := bCopy[aK]; !ok || aV != bV { + return false + } else { + delete(bCopy, aK) + } + } + if len(bCopy) == 0 { + return true + } + return false +} + +func MatchMapStringRealIfNonZero(a, b map[string]float64) bool { + if b == nil { + return true + } + return MatchMapStringReal(a, b) +} + +func MatchMapStringReal(a, b map[string]float64) bool { + if len(a) != len(b) { + return false + } + bCopy := map[string]float64{} + for k, v := range b { + bCopy[k] = v + } + for aK, aV := range a { + if bV, ok := bCopy[aK]; !ok || aV != bV { + return false + } else { + delete(bCopy, aK) + } + } + if len(bCopy) == 0 { + return true + } + return false +} + +func MatchMapStringBooleanIfNonZero(a, b map[string]bool) bool { + if b == nil { + return true + } + return MatchMapStringBoolean(a, b) +} + +func MatchMapStringBoolean(a, b map[string]bool) bool { + if len(a) != len(b) { + return false + } + bCopy := map[string]bool{} + for k, v := range b { + bCopy[k] = v + } + for aK, aV := range a { + if bV, ok := bCopy[aK]; !ok || aV != bV { + return false + } else { + delete(bCopy, aK) + } + } + if len(bCopy) == 0 { + return true + } + return false +} + +func MatchMapStringUuidIfNonZero(a, b map[string]string) bool { + if b == nil { + return true + } + return MatchMapStringUuid(a, b) +} + +func MatchMapStringUuid(a, b map[string]string) bool { + if len(a) != len(b) { + return false + } + bCopy := map[string]string{} + for k, v := range b { + bCopy[k] = v + } + for aK, aV := range a { + if bV, ok := bCopy[aK]; !ok || aV != bV { + return false + } else { + delete(bCopy, aK) + } + } + if len(bCopy) == 0 { + return true + } + return false +} + +func MatchIntegerIfNonZero(a, b int64) bool { + var z int64 + if b == z { + return true + } + return MatchInteger(a, b) +} + +func MatchInteger(a, b int64) bool { + return a == b +} + +func MatchIntegerOptionalIfNonZero(a, b *int64) bool { + if b == nil { + return true + } + return MatchIntegerOptional(a, b) +} + +func MatchIntegerOptional(a, b *int64) bool { + if a == nil && b == nil { + return true + } else if a != nil && b != nil { + return *a == *b + } + return false +} + +func MatchIntegerMultiplesIfNonZero(a, b []int64) bool { + if b == nil { + return true + } + return MatchIntegerMultiples(a, b) +} + +func MatchIntegerMultiples(a, b []int64) bool { + if len(a) != len(b) { + return false + } + bCopy := make([]int64, len(b)) + copy(bCopy, b) + for _, elA := range a { + for i := len(bCopy) - 1; i >= 0; i-- { + elB := bCopy[i] + if elA == elB { + bCopy = append(bCopy[:i], bCopy[i+1:]...) + } + } + } + if len(bCopy) == 0 { + return true + } + return false +} + +func MatchMapIntegerStringIfNonZero(a, b map[int64]string) bool { + if b == nil { + return true + } + return MatchMapIntegerString(a, b) +} + +func MatchMapIntegerString(a, b map[int64]string) bool { + if len(a) != len(b) { + return false + } + bCopy := map[int64]string{} + for k, v := range b { + bCopy[k] = v + } + for aK, aV := range a { + if bV, ok := bCopy[aK]; !ok || aV != bV { + return false + } else { + delete(bCopy, aK) + } + } + if len(bCopy) == 0 { + return true + } + return false +} + +func MatchMapIntegerIntegerIfNonZero(a, b map[int64]int64) bool { + if b == nil { + return true + } + return MatchMapIntegerInteger(a, b) +} + +func MatchMapIntegerInteger(a, b map[int64]int64) bool { + if len(a) != len(b) { + return false + } + bCopy := map[int64]int64{} + for k, v := range b { + bCopy[k] = v + } + for aK, aV := range a { + if bV, ok := bCopy[aK]; !ok || aV != bV { + return false + } else { + delete(bCopy, aK) + } + } + if len(bCopy) == 0 { + return true + } + return false +} + +func MatchMapIntegerRealIfNonZero(a, b map[int64]float64) bool { + if b == nil { + return true + } + return MatchMapIntegerReal(a, b) +} + +func MatchMapIntegerReal(a, b map[int64]float64) bool { + if len(a) != len(b) { + return false + } + bCopy := map[int64]float64{} + for k, v := range b { + bCopy[k] = v + } + for aK, aV := range a { + if bV, ok := bCopy[aK]; !ok || aV != bV { + return false + } else { + delete(bCopy, aK) + } + } + if len(bCopy) == 0 { + return true + } + return false +} + +func MatchMapIntegerBooleanIfNonZero(a, b map[int64]bool) bool { + if b == nil { + return true + } + return MatchMapIntegerBoolean(a, b) +} + +func MatchMapIntegerBoolean(a, b map[int64]bool) bool { + if len(a) != len(b) { + return false + } + bCopy := map[int64]bool{} + for k, v := range b { + bCopy[k] = v + } + for aK, aV := range a { + if bV, ok := bCopy[aK]; !ok || aV != bV { + return false + } else { + delete(bCopy, aK) + } + } + if len(bCopy) == 0 { + return true + } + return false +} + +func MatchMapIntegerUuidIfNonZero(a, b map[int64]string) bool { + if b == nil { + return true + } + return MatchMapIntegerUuid(a, b) +} + +func MatchMapIntegerUuid(a, b map[int64]string) bool { + if len(a) != len(b) { + return false + } + bCopy := map[int64]string{} + for k, v := range b { + bCopy[k] = v + } + for aK, aV := range a { + if bV, ok := bCopy[aK]; !ok || aV != bV { + return false + } else { + delete(bCopy, aK) + } + } + if len(bCopy) == 0 { + return true + } + return false +} + +func MatchRealIfNonZero(a, b float64) bool { + var z float64 + if b == z { + return true + } + return MatchReal(a, b) +} + +func MatchReal(a, b float64) bool { + return a == b +} + +func MatchRealOptionalIfNonZero(a, b *float64) bool { + if b == nil { + return true + } + return MatchRealOptional(a, b) +} + +func MatchRealOptional(a, b *float64) bool { + if a == nil && b == nil { + return true + } else if a != nil && b != nil { + return *a == *b + } + return false +} + +func MatchRealMultiplesIfNonZero(a, b []float64) bool { + if b == nil { + return true + } + return MatchRealMultiples(a, b) +} + +func MatchRealMultiples(a, b []float64) bool { + if len(a) != len(b) { + return false + } + bCopy := make([]float64, len(b)) + copy(bCopy, b) + for _, elA := range a { + for i := len(bCopy) - 1; i >= 0; i-- { + elB := bCopy[i] + if elA == elB { + bCopy = append(bCopy[:i], bCopy[i+1:]...) + } + } + } + if len(bCopy) == 0 { + return true + } + return false +} + +func MatchMapRealStringIfNonZero(a, b map[float64]string) bool { + if b == nil { + return true + } + return MatchMapRealString(a, b) +} + +func MatchMapRealString(a, b map[float64]string) bool { + if len(a) != len(b) { + return false + } + bCopy := map[float64]string{} + for k, v := range b { + bCopy[k] = v + } + for aK, aV := range a { + if bV, ok := bCopy[aK]; !ok || aV != bV { + return false + } else { + delete(bCopy, aK) + } + } + if len(bCopy) == 0 { + return true + } + return false +} + +func MatchMapRealIntegerIfNonZero(a, b map[float64]int64) bool { + if b == nil { + return true + } + return MatchMapRealInteger(a, b) +} + +func MatchMapRealInteger(a, b map[float64]int64) bool { + if len(a) != len(b) { + return false + } + bCopy := map[float64]int64{} + for k, v := range b { + bCopy[k] = v + } + for aK, aV := range a { + if bV, ok := bCopy[aK]; !ok || aV != bV { + return false + } else { + delete(bCopy, aK) + } + } + if len(bCopy) == 0 { + return true + } + return false +} + +func MatchMapRealRealIfNonZero(a, b map[float64]float64) bool { + if b == nil { + return true + } + return MatchMapRealReal(a, b) +} + +func MatchMapRealReal(a, b map[float64]float64) bool { + if len(a) != len(b) { + return false + } + bCopy := map[float64]float64{} + for k, v := range b { + bCopy[k] = v + } + for aK, aV := range a { + if bV, ok := bCopy[aK]; !ok || aV != bV { + return false + } else { + delete(bCopy, aK) + } + } + if len(bCopy) == 0 { + return true + } + return false +} + +func MatchMapRealBooleanIfNonZero(a, b map[float64]bool) bool { + if b == nil { + return true + } + return MatchMapRealBoolean(a, b) +} + +func MatchMapRealBoolean(a, b map[float64]bool) bool { + if len(a) != len(b) { + return false + } + bCopy := map[float64]bool{} + for k, v := range b { + bCopy[k] = v + } + for aK, aV := range a { + if bV, ok := bCopy[aK]; !ok || aV != bV { + return false + } else { + delete(bCopy, aK) + } + } + if len(bCopy) == 0 { + return true + } + return false +} + +func MatchMapRealUuidIfNonZero(a, b map[float64]string) bool { + if b == nil { + return true + } + return MatchMapRealUuid(a, b) +} + +func MatchMapRealUuid(a, b map[float64]string) bool { + if len(a) != len(b) { + return false + } + bCopy := map[float64]string{} + for k, v := range b { + bCopy[k] = v + } + for aK, aV := range a { + if bV, ok := bCopy[aK]; !ok || aV != bV { + return false + } else { + delete(bCopy, aK) + } + } + if len(bCopy) == 0 { + return true + } + return false +} + +func MatchBooleanIfNonZero(a, b bool) bool { + var z bool + if b == z { + return true + } + return MatchBoolean(a, b) +} + +func MatchBoolean(a, b bool) bool { + return a == b +} + +func MatchBooleanOptionalIfNonZero(a, b *bool) bool { + if b == nil { + return true + } + return MatchBooleanOptional(a, b) +} + +func MatchBooleanOptional(a, b *bool) bool { + if a == nil && b == nil { + return true + } else if a != nil && b != nil { + return *a == *b + } + return false +} + +func MatchBooleanMultiplesIfNonZero(a, b []bool) bool { + if b == nil { + return true + } + return MatchBooleanMultiples(a, b) +} + +func MatchBooleanMultiples(a, b []bool) bool { + if len(a) != len(b) { + return false + } + bCopy := make([]bool, len(b)) + copy(bCopy, b) + for _, elA := range a { + for i := len(bCopy) - 1; i >= 0; i-- { + elB := bCopy[i] + if elA == elB { + bCopy = append(bCopy[:i], bCopy[i+1:]...) + } + } + } + if len(bCopy) == 0 { + return true + } + return false +} + +func MatchMapBooleanStringIfNonZero(a, b map[bool]string) bool { + if b == nil { + return true + } + return MatchMapBooleanString(a, b) +} + +func MatchMapBooleanString(a, b map[bool]string) bool { + if len(a) != len(b) { + return false + } + bCopy := map[bool]string{} + for k, v := range b { + bCopy[k] = v + } + for aK, aV := range a { + if bV, ok := bCopy[aK]; !ok || aV != bV { + return false + } else { + delete(bCopy, aK) + } + } + if len(bCopy) == 0 { + return true + } + return false +} + +func MatchMapBooleanIntegerIfNonZero(a, b map[bool]int64) bool { + if b == nil { + return true + } + return MatchMapBooleanInteger(a, b) +} + +func MatchMapBooleanInteger(a, b map[bool]int64) bool { + if len(a) != len(b) { + return false + } + bCopy := map[bool]int64{} + for k, v := range b { + bCopy[k] = v + } + for aK, aV := range a { + if bV, ok := bCopy[aK]; !ok || aV != bV { + return false + } else { + delete(bCopy, aK) + } + } + if len(bCopy) == 0 { + return true + } + return false +} + +func MatchMapBooleanRealIfNonZero(a, b map[bool]float64) bool { + if b == nil { + return true + } + return MatchMapBooleanReal(a, b) +} + +func MatchMapBooleanReal(a, b map[bool]float64) bool { + if len(a) != len(b) { + return false + } + bCopy := map[bool]float64{} + for k, v := range b { + bCopy[k] = v + } + for aK, aV := range a { + if bV, ok := bCopy[aK]; !ok || aV != bV { + return false + } else { + delete(bCopy, aK) + } + } + if len(bCopy) == 0 { + return true + } + return false +} + +func MatchMapBooleanBooleanIfNonZero(a, b map[bool]bool) bool { + if b == nil { + return true + } + return MatchMapBooleanBoolean(a, b) +} + +func MatchMapBooleanBoolean(a, b map[bool]bool) bool { + if len(a) != len(b) { + return false + } + bCopy := map[bool]bool{} + for k, v := range b { + bCopy[k] = v + } + for aK, aV := range a { + if bV, ok := bCopy[aK]; !ok || aV != bV { + return false + } else { + delete(bCopy, aK) + } + } + if len(bCopy) == 0 { + return true + } + return false +} + +func MatchMapBooleanUuidIfNonZero(a, b map[bool]string) bool { + if b == nil { + return true + } + return MatchMapBooleanUuid(a, b) +} + +func MatchMapBooleanUuid(a, b map[bool]string) bool { + if len(a) != len(b) { + return false + } + bCopy := map[bool]string{} + for k, v := range b { + bCopy[k] = v + } + for aK, aV := range a { + if bV, ok := bCopy[aK]; !ok || aV != bV { + return false + } else { + delete(bCopy, aK) + } + } + if len(bCopy) == 0 { + return true + } + return false +} + +func MatchUuidIfNonZero(a, b string) bool { + var z string + if b == z { + return true + } + return MatchUuid(a, b) +} + +func MatchUuid(a, b string) bool { + return a == b +} + +func MatchUuidOptionalIfNonZero(a, b *string) bool { + if b == nil { + return true + } + return MatchUuidOptional(a, b) +} + +func MatchUuidOptional(a, b *string) bool { + if a == nil && b == nil { + return true + } else if a != nil && b != nil { + return *a == *b + } + return false +} + +func MatchUuidMultiplesIfNonZero(a, b []string) bool { + if b == nil { + return true + } + return MatchUuidMultiples(a, b) +} + +func MatchUuidMultiples(a, b []string) bool { + if len(a) != len(b) { + return false + } + bCopy := make([]string, len(b)) + copy(bCopy, b) + for _, elA := range a { + for i := len(bCopy) - 1; i >= 0; i-- { + elB := bCopy[i] + if elA == elB { + bCopy = append(bCopy[:i], bCopy[i+1:]...) + } + } + } + if len(bCopy) == 0 { + return true + } + return false +} + +func MatchMapUuidStringIfNonZero(a, b map[string]string) bool { + if b == nil { + return true + } + return MatchMapUuidString(a, b) +} + +func MatchMapUuidString(a, b map[string]string) bool { + if len(a) != len(b) { + return false + } + bCopy := map[string]string{} + for k, v := range b { + bCopy[k] = v + } + for aK, aV := range a { + if bV, ok := bCopy[aK]; !ok || aV != bV { + return false + } else { + delete(bCopy, aK) + } + } + if len(bCopy) == 0 { + return true + } + return false +} + +func MatchMapUuidIntegerIfNonZero(a, b map[string]int64) bool { + if b == nil { + return true + } + return MatchMapUuidInteger(a, b) +} + +func MatchMapUuidInteger(a, b map[string]int64) bool { + if len(a) != len(b) { + return false + } + bCopy := map[string]int64{} + for k, v := range b { + bCopy[k] = v + } + for aK, aV := range a { + if bV, ok := bCopy[aK]; !ok || aV != bV { + return false + } else { + delete(bCopy, aK) + } + } + if len(bCopy) == 0 { + return true + } + return false +} + +func MatchMapUuidRealIfNonZero(a, b map[string]float64) bool { + if b == nil { + return true + } + return MatchMapUuidReal(a, b) +} + +func MatchMapUuidReal(a, b map[string]float64) bool { + if len(a) != len(b) { + return false + } + bCopy := map[string]float64{} + for k, v := range b { + bCopy[k] = v + } + for aK, aV := range a { + if bV, ok := bCopy[aK]; !ok || aV != bV { + return false + } else { + delete(bCopy, aK) + } + } + if len(bCopy) == 0 { + return true + } + return false +} + +func MatchMapUuidBooleanIfNonZero(a, b map[string]bool) bool { + if b == nil { + return true + } + return MatchMapUuidBoolean(a, b) +} + +func MatchMapUuidBoolean(a, b map[string]bool) bool { + if len(a) != len(b) { + return false + } + bCopy := map[string]bool{} + for k, v := range b { + bCopy[k] = v + } + for aK, aV := range a { + if bV, ok := bCopy[aK]; !ok || aV != bV { + return false + } else { + delete(bCopy, aK) + } + } + if len(bCopy) == 0 { + return true + } + return false +} + +func MatchMapUuidUuidIfNonZero(a, b map[string]string) bool { + if b == nil { + return true + } + return MatchMapUuidUuid(a, b) +} + +func MatchMapUuidUuid(a, b map[string]string) bool { + if len(a) != len(b) { + return false + } + bCopy := map[string]string{} + for k, v := range b { + bCopy[k] = v + } + for aK, aV := range a { + if bV, ok := bCopy[aK]; !ok || aV != bV { + return false + } else { + delete(bCopy, aK) + } + } + if len(bCopy) == 0 { + return true + } + return false +} diff --git a/vendor/yunion.io/x/ovsdb/types/errors.go b/vendor/yunion.io/x/ovsdb/types/errors.go new file mode 100644 index 0000000000..e27bd3ec4e --- /dev/null +++ b/vendor/yunion.io/x/ovsdb/types/errors.go @@ -0,0 +1,12 @@ +package types + +import ( + "errors" +) + +var ( + ErrUnknownColumn = errors.New("unknown column") + ErrUnknownTable = errors.New("unknown table") + + ErrBadType = errors.New("bad type") +) diff --git a/vendor/yunion.io/x/ovsdb/types/generator.go b/vendor/yunion.io/x/ovsdb/types/generator.go new file mode 100644 index 0000000000..6871c92e9f --- /dev/null +++ b/vendor/yunion.io/x/ovsdb/types/generator.go @@ -0,0 +1,52 @@ +package types + +import ( + "os" + "path/filepath" + "strings" + + "github.com/pkg/errors" +) + +type Generator struct { + schema *Schema + + outDir string + gopkg string +} + +func NewGenerator() *Generator { + g := &Generator{} + return g +} + +func (g *Generator) OutDir(outDir string) *Generator { + d, gopkg := filepath.Split(outDir) + gopkg = strings.ReplaceAll(gopkg, "-", "_") + outDir = filepath.Join(d, gopkg) + g.outDir = outDir + g.gopkg = gopkg + return g +} + +func (g *Generator) Schema(schema *Schema) *Generator { + g.schema = schema + return g +} + +func (g *Generator) Gen() error { + os.MkdirAll(g.outDir, os.FileMode(0755)) + fname := filepath.Join(g.outDir, "schema.go") + fSchema, err := os.OpenFile(fname, os.O_CREATE|os.O_TRUNC|os.O_WRONLY, os.FileMode(0644)) + if err != nil { + return errors.Wrapf(err, "open %s", fname) + } + w := writer{ + w: fSchema, + } + w.Writef(`// DO NOT EDIT: automatically generated code`) + w.Writef(``) + w.Writef(`package %s`, g.gopkg) + g.schema.gen(w) + return nil +} diff --git a/vendor/yunion.io/x/ovsdb/types/interface.go b/vendor/yunion.io/x/ovsdb/types/interface.go new file mode 100644 index 0000000000..0e1edba183 --- /dev/null +++ b/vendor/yunion.io/x/ovsdb/types/interface.go @@ -0,0 +1,25 @@ +package types + +type IRow interface { + OvsdbTableName() string + OvsdbIsRoot() bool + OvsdbUuid() string + + SetColumn(name string, val interface{}) error + + OvsdbCmdArgs() []string + + HasExternalIds() bool + SetExternalId(k, v string) + GetExternalId(k string) (string, bool) + RemoveExternalId(k string) (string, bool) +} + +type ITable interface { + OvsdbTableName() string + OvsdbIsRoot() bool + + Rows() []IRow + NewRow() IRow + AppendRow(IRow) +} diff --git a/vendor/yunion.io/x/ovsdb/types/names.go b/vendor/yunion.io/x/ovsdb/types/names.go new file mode 100644 index 0000000000..3885a56293 --- /dev/null +++ b/vendor/yunion.io/x/ovsdb/types/names.go @@ -0,0 +1,30 @@ +package types + +import ( + "unicode" + "unicode/utf8" +) + +func Kebab2Camel(s string) string { + var ( + rs = make([]rune, 0, len(s)) + up bool + ) + for _, r := range s { + if r != '_' { + if up { + r = unicode.ToUpper(r) + up = false + } + rs = append(rs, r) + } else { + up = true + } + } + return string(rs) +} + +func ExportName(s string) string { + r, n := utf8.DecodeRuneInString(s) + return string(unicode.ToUpper(r)) + s[n:] +} diff --git a/vendor/yunion.io/x/ovsdb/types/ovn-nb.ovsschema b/vendor/yunion.io/x/ovsdb/types/ovn-nb.ovsschema new file mode 100644 index 0000000000..32f9d5a394 --- /dev/null +++ b/vendor/yunion.io/x/ovsdb/types/ovn-nb.ovsschema @@ -0,0 +1,344 @@ +{ + "name": "OVN_Northbound", + "version": "5.10.0", + "cksum": "626737541 17810", + "tables": { + "NB_Global": { + "columns": { + "nb_cfg": {"type": {"key": "integer"}}, + "sb_cfg": {"type": {"key": "integer"}}, + "hv_cfg": {"type": {"key": "integer"}}, + "external_ids": { + "type": {"key": "string", "value": "string", + "min": 0, "max": "unlimited"}}, + "connections": { + "type": {"key": {"type": "uuid", + "refTable": "Connection"}, + "min": 0, + "max": "unlimited"}}, + "ssl": { + "type": {"key": {"type": "uuid", + "refTable": "SSL"}, + "min": 0, "max": 1}}}, + "maxRows": 1, + "isRoot": true}, + "Logical_Switch": { + "columns": { + "name": {"type": "string"}, + "ports": {"type": {"key": {"type": "uuid", + "refTable": "Logical_Switch_Port", + "refType": "strong"}, + "min": 0, + "max": "unlimited"}}, + "acls": {"type": {"key": {"type": "uuid", + "refTable": "ACL", + "refType": "strong"}, + "min": 0, + "max": "unlimited"}}, + "qos_rules": {"type": {"key": {"type": "uuid", + "refTable": "QoS", + "refType": "strong"}, + "min": 0, + "max": "unlimited"}}, + "load_balancer": {"type": {"key": {"type": "uuid", + "refTable": "Load_Balancer", + "refType": "strong"}, + "min": 0, + "max": "unlimited"}}, + "dns_records": {"type": {"key": {"type": "uuid", + "refTable": "DNS", + "refType": "weak"}, + "min": 0, + "max": "unlimited"}}, + "other_config": { + "type": {"key": "string", "value": "string", + "min": 0, "max": "unlimited"}}, + "external_ids": { + "type": {"key": "string", "value": "string", + "min": 0, "max": "unlimited"}}}, + "isRoot": true}, + "Logical_Switch_Port": { + "columns": { + "name": {"type": "string"}, + "type": {"type": "string"}, + "options": { + "type": {"key": "string", + "value": "string", + "min": 0, + "max": "unlimited"}}, + "parent_name": {"type": {"key": "string", "min": 0, "max": 1}}, + "tag_request": { + "type": {"key": {"type": "integer", + "minInteger": 0, + "maxInteger": 4095}, + "min": 0, "max": 1}}, + "tag": { + "type": {"key": {"type": "integer", + "minInteger": 1, + "maxInteger": 4095}, + "min": 0, "max": 1}}, + "addresses": {"type": {"key": "string", + "min": 0, + "max": "unlimited"}}, + "dynamic_addresses": {"type": {"key": "string", + "min": 0, + "max": 1}}, + "port_security": {"type": {"key": "string", + "min": 0, + "max": "unlimited"}}, + "up": {"type": {"key": "boolean", "min": 0, "max": 1}}, + "enabled": {"type": {"key": "boolean", "min": 0, "max": 1}}, + "dhcpv4_options": {"type": {"key": {"type": "uuid", + "refTable": "DHCP_Options", + "refType": "weak"}, + "min": 0, + "max": 1}}, + "dhcpv6_options": {"type": {"key": {"type": "uuid", + "refTable": "DHCP_Options", + "refType": "weak"}, + "min": 0, + "max": 1}}, + "external_ids": { + "type": {"key": "string", "value": "string", + "min": 0, "max": "unlimited"}}}, + "indexes": [["name"]], + "isRoot": false}, + "Address_Set": { + "columns": { + "name": {"type": "string"}, + "addresses": {"type": {"key": "string", + "min": 0, + "max": "unlimited"}}, + "external_ids": { + "type": {"key": "string", "value": "string", + "min": 0, "max": "unlimited"}}}, + "indexes": [["name"]], + "isRoot": true}, + "Load_Balancer": { + "columns": { + "name": {"type": "string"}, + "vips": { + "type": {"key": "string", "value": "string", + "min": 0, "max": "unlimited"}}, + "protocol": { + "type": {"key": {"type": "string", + "enum": ["set", ["tcp", "udp"]]}, + "min": 0, "max": 1}}, + "external_ids": { + "type": {"key": "string", "value": "string", + "min": 0, "max": "unlimited"}}}, + "isRoot": true}, + "ACL": { + "columns": { + "name": {"type": {"key": {"type": "string", + "maxLength": 63}, + "min": 0, "max": 1}}, + "priority": {"type": {"key": {"type": "integer", + "minInteger": 0, + "maxInteger": 32767}}}, + "direction": {"type": {"key": {"type": "string", + "enum": ["set", ["from-lport", "to-lport"]]}}}, + "match": {"type": "string"}, + "action": {"type": {"key": {"type": "string", + "enum": ["set", ["allow", "allow-related", "drop", "reject"]]}}}, + "log": {"type": "boolean"}, + "severity": {"type": {"key": {"type": "string", + "enum": ["set", + ["alert", "warning", + "notice", "info", + "debug"]]}, + "min": 0, "max": 1}}, + "external_ids": { + "type": {"key": "string", "value": "string", + "min": 0, "max": "unlimited"}}}, + "isRoot": false}, + "QoS": { + "columns": { + "priority": {"type": {"key": {"type": "integer", + "minInteger": 0, + "maxInteger": 32767}}}, + "direction": {"type": {"key": {"type": "string", + "enum": ["set", ["from-lport", "to-lport"]]}}}, + "match": {"type": "string"}, + "action": {"type": {"key": {"type": "string", + "enum": ["set", ["dscp"]]}, + "value": {"type": "integer", + "minInteger": 0, + "maxInteger": 63}, + "min": 0, "max": "unlimited"}}, + "bandwidth": {"type": {"key": {"type": "string", + "enum": ["set", ["rate", + "burst"]]}, + "value": {"type": "integer", + "minInteger": 1, + "maxInteger": 4294967295}, + "min": 0, "max": "unlimited"}}, + "external_ids": { + "type": {"key": "string", "value": "string", + "min": 0, "max": "unlimited"}}}, + "isRoot": false}, + "Logical_Router": { + "columns": { + "name": {"type": "string"}, + "ports": {"type": {"key": {"type": "uuid", + "refTable": "Logical_Router_Port", + "refType": "strong"}, + "min": 0, + "max": "unlimited"}}, + "static_routes": {"type": {"key": {"type": "uuid", + "refTable": "Logical_Router_Static_Route", + "refType": "strong"}, + "min": 0, + "max": "unlimited"}}, + "enabled": {"type": {"key": "boolean", "min": 0, "max": 1}}, + "nat": {"type": {"key": {"type": "uuid", + "refTable": "NAT", + "refType": "strong"}, + "min": 0, + "max": "unlimited"}}, + "load_balancer": {"type": {"key": {"type": "uuid", + "refTable": "Load_Balancer", + "refType": "strong"}, + "min": 0, + "max": "unlimited"}}, + "options": { + "type": {"key": "string", + "value": "string", + "min": 0, + "max": "unlimited"}}, + "external_ids": { + "type": {"key": "string", "value": "string", + "min": 0, "max": "unlimited"}}}, + "isRoot": true}, + "Logical_Router_Port": { + "columns": { + "name": {"type": "string"}, + "gateway_chassis": { + "type": {"key": {"type": "uuid", + "refTable": "Gateway_Chassis", + "refType": "strong"}, + "min": 0, + "max": "unlimited"}}, + "options": { + "type": {"key": "string", + "value": "string", + "min": 0, + "max": "unlimited"}}, + "networks": {"type": {"key": "string", + "min": 1, + "max": "unlimited"}}, + "mac": {"type": "string"}, + "peer": {"type": {"key": "string", "min": 0, "max": 1}}, + "enabled": {"type": {"key": "boolean", "min": 0, "max": 1}}, + "ipv6_ra_configs": { + "type": {"key": "string", "value": "string", + "min": 0, "max": "unlimited"}}, + "external_ids": { + "type": {"key": "string", "value": "string", + "min": 0, "max": "unlimited"}}}, + "indexes": [["name"]], + "isRoot": false}, + "Logical_Router_Static_Route": { + "columns": { + "ip_prefix": {"type": "string"}, + "policy": {"type": {"key": {"type": "string", + "enum": ["set", ["src-ip", + "dst-ip"]]}, + "min": 0, "max": 1}}, + "nexthop": {"type": "string"}, + "output_port": {"type": {"key": "string", "min": 0, "max": 1}}, + "external_ids": { + "type": {"key": "string", "value": "string", + "min": 0, "max": "unlimited"}}}, + "isRoot": false}, + "NAT": { + "columns": { + "external_ip": {"type": "string"}, + "external_mac": {"type": {"key": "string", + "min": 0, "max": 1}}, + "logical_ip": {"type": "string"}, + "logical_port": {"type": {"key": "string", + "min": 0, "max": 1}}, + "type": {"type": {"key": {"type": "string", + "enum": ["set", ["dnat", + "snat", + "dnat_and_snat" + ]]}}}, + "external_ids": { + "type": {"key": "string", "value": "string", + "min": 0, "max": "unlimited"}}}, + "isRoot": false}, + "DHCP_Options": { + "columns": { + "cidr": {"type": "string"}, + "options": {"type": {"key": "string", "value": "string", + "min": 0, "max": "unlimited"}}, + "external_ids": { + "type": {"key": "string", "value": "string", + "min": 0, "max": "unlimited"}}}, + "isRoot": true}, + "Connection": { + "columns": { + "target": {"type": "string"}, + "max_backoff": {"type": {"key": {"type": "integer", + "minInteger": 1000}, + "min": 0, + "max": 1}}, + "inactivity_probe": {"type": {"key": "integer", + "min": 0, + "max": 1}}, + "other_config": {"type": {"key": "string", + "value": "string", + "min": 0, + "max": "unlimited"}}, + "external_ids": {"type": {"key": "string", + "value": "string", + "min": 0, + "max": "unlimited"}}, + "is_connected": {"type": "boolean", "ephemeral": true}, + "status": {"type": {"key": "string", + "value": "string", + "min": 0, + "max": "unlimited"}, + "ephemeral": true}}, + "indexes": [["target"]]}, + "DNS": { + "columns": { + "records": {"type": {"key": "string", + "value": "string", + "min": 0, + "max": "unlimited"}}, + "external_ids": {"type": {"key": "string", + "value": "string", + "min": 0, + "max": "unlimited"}}}, + "isRoot": true}, + "SSL": { + "columns": { + "private_key": {"type": "string"}, + "certificate": {"type": "string"}, + "ca_cert": {"type": "string"}, + "bootstrap_ca_cert": {"type": "boolean"}, + "ssl_protocols": {"type": "string"}, + "ssl_ciphers": {"type": "string"}, + "external_ids": {"type": {"key": "string", + "value": "string", + "min": 0, + "max": "unlimited"}}}, + "maxRows": 1}, + "Gateway_Chassis": { + "columns": { + "name": {"type": "string"}, + "chassis_name": {"type": "string"}, + "priority": {"type": {"key": {"type": "integer", + "minInteger": 0, + "maxInteger": 32767}}}, + "external_ids": { + "type": {"key": "string", "value": "string", + "min": 0, "max": "unlimited"}}, + "options": { + "type": {"key": "string", "value": "string", + "min": 0, "max": "unlimited"}}}, + "indexes": [["name"]], + "isRoot": false}} + } diff --git a/vendor/yunion.io/x/ovsdb/types/ovn-sb.ovsschema b/vendor/yunion.io/x/ovsdb/types/ovn-sb.ovsschema new file mode 100644 index 0000000000..2abcc6b70c --- /dev/null +++ b/vendor/yunion.io/x/ovsdb/types/ovn-sb.ovsschema @@ -0,0 +1,272 @@ +{ + "name": "OVN_Southbound", + "version": "1.15.0", + "cksum": "70426956 13327", + "tables": { + "SB_Global": { + "columns": { + "nb_cfg": {"type": {"key": "integer"}}, + "external_ids": { + "type": {"key": "string", "value": "string", + "min": 0, "max": "unlimited"}}, + "connections": { + "type": {"key": {"type": "uuid", + "refTable": "Connection"}, + "min": 0, + "max": "unlimited"}}, + "ssl": { + "type": {"key": {"type": "uuid", + "refTable": "SSL"}, + "min": 0, "max": 1}}}, + "maxRows": 1, + "isRoot": true}, + "Chassis": { + "columns": { + "name": {"type": "string"}, + "hostname": {"type": "string"}, + "encaps": {"type": {"key": {"type": "uuid", + "refTable": "Encap"}, + "min": 1, "max": "unlimited"}}, + "vtep_logical_switches" : {"type": {"key": "string", + "min": 0, + "max": "unlimited"}}, + "nb_cfg": {"type": {"key": "integer"}}, + "external_ids": { + "type": {"key": "string", "value": "string", + "min": 0, "max": "unlimited"}}}, + "isRoot": true, + "indexes": [["name"]]}, + "Encap": { + "columns": { + "type": {"type": {"key": { + "type": "string", + "enum": ["set", ["geneve", "stt", "vxlan"]]}}}, + "options": {"type": {"key": "string", + "value": "string", + "min": 0, + "max": "unlimited"}}, + "ip": {"type": "string"}, + "chassis_name": {"type": "string"}}}, + "Address_Set": { + "columns": { + "name": {"type": "string"}, + "addresses": {"type": {"key": "string", + "min": 0, + "max": "unlimited"}}}, + "indexes": [["name"]], + "isRoot": true}, + "Logical_Flow": { + "columns": { + "logical_datapath": {"type": {"key": {"type": "uuid", + "refTable": "Datapath_Binding"}}}, + "pipeline": {"type": {"key": {"type": "string", + "enum": ["set", ["ingress", + "egress"]]}}}, + "table_id": {"type": {"key": {"type": "integer", + "minInteger": 0, + "maxInteger": 23}}}, + "priority": {"type": {"key": {"type": "integer", + "minInteger": 0, + "maxInteger": 65535}}}, + "match": {"type": "string"}, + "actions": {"type": "string"}, + "external_ids": { + "type": {"key": "string", "value": "string", + "min": 0, "max": "unlimited"}}}, + "isRoot": true}, + "Multicast_Group": { + "columns": { + "datapath": {"type": {"key": {"type": "uuid", + "refTable": "Datapath_Binding"}}}, + "name": {"type": "string"}, + "tunnel_key": { + "type": {"key": {"type": "integer", + "minInteger": 32768, + "maxInteger": 65535}}}, + "ports": {"type": {"key": {"type": "uuid", + "refTable": "Port_Binding", + "refType": "weak"}, + "min": 1, "max": "unlimited"}}}, + "indexes": [["datapath", "tunnel_key"], + ["datapath", "name"]], + "isRoot": true}, + "Datapath_Binding": { + "columns": { + "tunnel_key": { + "type": {"key": {"type": "integer", + "minInteger": 1, + "maxInteger": 16777215}}}, + "external_ids": { + "type": {"key": "string", "value": "string", + "min": 0, "max": "unlimited"}}}, + "indexes": [["tunnel_key"]], + "isRoot": true}, + "Port_Binding": { + "columns": { + "logical_port": {"type": "string"}, + "type": {"type": "string"}, + "gateway_chassis": { + "type": {"key": {"type": "uuid", + "refTable": "Gateway_Chassis", + "refType": "strong"}, + "min": 0, + "max": "unlimited"}}, + "options": { + "type": {"key": "string", + "value": "string", + "min": 0, + "max": "unlimited"}}, + "datapath": {"type": {"key": {"type": "uuid", + "refTable": "Datapath_Binding"}}}, + "tunnel_key": { + "type": {"key": {"type": "integer", + "minInteger": 1, + "maxInteger": 32767}}}, + "parent_port": {"type": {"key": "string", "min": 0, "max": 1}}, + "tag": { + "type": {"key": {"type": "integer", + "minInteger": 1, + "maxInteger": 4095}, + "min": 0, "max": 1}}, + "chassis": {"type": {"key": {"type": "uuid", + "refTable": "Chassis", + "refType": "weak"}, + "min": 0, "max": 1}}, + "mac": {"type": {"key": "string", + "min": 0, + "max": "unlimited"}}, + "nat_addresses": {"type": {"key": "string", + "min": 0, + "max": "unlimited"}}, + "external_ids": {"type": {"key": "string", + "value": "string", + "min": 0, + "max": "unlimited"}}}, + "indexes": [["datapath", "tunnel_key"], ["logical_port"]], + "isRoot": true}, + "MAC_Binding": { + "columns": { + "logical_port": {"type": "string"}, + "ip": {"type": "string"}, + "mac": {"type": "string"}, + "datapath": {"type": {"key": {"type": "uuid", + "refTable": "Datapath_Binding"}}}}, + "indexes": [["logical_port", "ip"]], + "isRoot": true}, + "DHCP_Options": { + "columns": { + "name": {"type": "string"}, + "code": { + "type": {"key": {"type": "integer", + "minInteger": 0, "maxInteger": 254}}}, + "type": { + "type": {"key": { + "type": "string", + "enum": ["set", ["bool", "uint8", "uint16", "uint32", + "ipv4", "static_routes", "str"]]}}}}, + "isRoot": true}, + "DHCPv6_Options": { + "columns": { + "name": {"type": "string"}, + "code": { + "type": {"key": {"type": "integer", + "minInteger": 0, "maxInteger": 254}}}, + "type": { + "type": {"key": { + "type": "string", + "enum": ["set", ["ipv6", "str", "mac"]]}}}}, + "isRoot": true}, + "Connection": { + "columns": { + "target": {"type": "string"}, + "max_backoff": {"type": {"key": {"type": "integer", + "minInteger": 1000}, + "min": 0, + "max": 1}}, + "inactivity_probe": {"type": {"key": "integer", + "min": 0, + "max": 1}}, + "read_only": {"type": "boolean"}, + "role": {"type": "string"}, + "other_config": {"type": {"key": "string", + "value": "string", + "min": 0, + "max": "unlimited"}}, + "external_ids": {"type": {"key": "string", + "value": "string", + "min": 0, + "max": "unlimited"}}, + "is_connected": {"type": "boolean", "ephemeral": true}, + "status": {"type": {"key": "string", + "value": "string", + "min": 0, + "max": "unlimited"}, + "ephemeral": true}}, + "indexes": [["target"]]}, + "SSL": { + "columns": { + "private_key": {"type": "string"}, + "certificate": {"type": "string"}, + "ca_cert": {"type": "string"}, + "bootstrap_ca_cert": {"type": "boolean"}, + "ssl_protocols": {"type": "string"}, + "ssl_ciphers": {"type": "string"}, + "external_ids": {"type": {"key": "string", + "value": "string", + "min": 0, + "max": "unlimited"}}}, + "maxRows": 1}, + "DNS": { + "columns": { + "records": {"type": {"key": "string", + "value": "string", + "min": 0, + "max": "unlimited"}}, + "datapaths": {"type": {"key": {"type": "uuid", + "refTable": "Datapath_Binding"}, + "min": 1, + "max": "unlimited"}}, + "external_ids": {"type": {"key": "string", + "value": "string", + "min": 0, + "max": "unlimited"}}}, + "isRoot": true}, + "RBAC_Role": { + "columns": { + "name": {"type": "string"}, + "permissions": { + "type": {"key": {"type": "string"}, + "value": {"type": "uuid", + "refTable": "RBAC_Permission", + "refType": "weak"}, + "min": 0, "max": "unlimited"}}}, + "isRoot": true}, + "RBAC_Permission": { + "columns": { + "table": {"type": "string"}, + "authorization": {"type": {"key": "string", + "min": 0, + "max": "unlimited"}}, + "insert_delete": {"type": "boolean"}, + "update" : {"type": {"key": "string", + "min": 0, + "max": "unlimited"}}}, + "isRoot": true}, + "Gateway_Chassis": { + "columns": { + "name": {"type": "string"}, + "chassis": {"type": {"key": {"type": "uuid", + "refTable": "Chassis", + "refType": "weak"}, + "min": 0, "max": 1}}, + "priority": {"type": {"key": {"type": "integer", + "minInteger": 0, + "maxInteger": 32767}}}, + "external_ids": { + "type": {"key": "string", "value": "string", + "min": 0, "max": "unlimited"}}, + "options": { + "type": {"key": "string", "value": "string", + "min": 0, "max": "unlimited"}}}, + "indexes": [["name"]], + "isRoot": false}}} diff --git a/vendor/yunion.io/x/ovsdb/types/schema.go b/vendor/yunion.io/x/ovsdb/types/schema.go new file mode 100644 index 0000000000..b44df63521 --- /dev/null +++ b/vendor/yunion.io/x/ovsdb/types/schema.go @@ -0,0 +1,199 @@ +package types + +import ( + "bytes" + "encoding/json" + "io" + + "github.com/pkg/errors" +) + +type Schema struct { + Name string + Version string + Cksum string + Tables Tables +} + +type Tables map[string]Table +type Table struct { + Name string + Columns map[string]Column + MaxRows int + IsRoot bool + Indexes [][]string +} + +type Columns map[string]Column +type Column struct { + Name string + Type Type + Ephemeral bool + Mutable bool +} + +type Type struct { + Key BaseType + Value BaseType + Min int + Max int + MaxUnlimited bool +} + +type BaseType struct { + Type Atomic + Enum interface{} // TODO + MinInteger int + MaxInteger int + MinReal int + MaxReal int + MinLength int // strings only + MaxLength int // strings only + RefTable string // uuids only + RefType string // only with refTable +} + +var ( + errSchema = errors.New("bad schema") +) + +func ParseSchema(r io.Reader) (*Schema, error) { + type ( + PColumn struct { + Type interface{} + Ephemeral bool + Mutable bool + } + PTable struct { + Columns map[string]PColumn + MaxRows int + IsRoot bool + Indexes [][]string + } + PSchema struct { + Name string + Version string + Cksum string + Tables map[string]PTable + } + ) + + psch := &PSchema{} + dec := json.NewDecoder(r) + err := dec.Decode(psch) + if err != nil { + return nil, err + } + sch := &Schema{ + Name: psch.Name, + Version: psch.Version, + Cksum: psch.Cksum, + Tables: Tables{}, + } + for tblName, ptbl := range psch.Tables { + tbl := Table{ + Name: tblName, + MaxRows: ptbl.MaxRows, + IsRoot: ptbl.IsRoot, + Indexes: ptbl.Indexes, + Columns: Columns{ + "_uuid": Column{ + Name: "_uuid", + Type: Type{ + Key: BaseType{ + Type: Uuid, + }, + Min: 1, + Max: 1, + }, + }, + "_version": Column{ + Name: "_version", + Type: Type{ + Key: BaseType{ + Type: Uuid, + }, + Min: 1, + Max: 1, + }, + }, + }, + } + for colName, pcol := range ptbl.Columns { + col := Column{ + Name: colName, + Ephemeral: pcol.Ephemeral, + Mutable: pcol.Mutable, + Type: Type{ + Min: 1, + Max: 1, + }, + } + switch t0 := pcol.Type.(type) { + case string: + col.Type.Key.Type = Atomic(t0) + case map[string]interface{}: + if kbt, err := parseBaseType(t0["key"]); err != nil { + return nil, errors.Wrap(err, "bad key type") + } else { + col.Type.Key = kbt + } + + if vbt, err := parseBaseType(t0["value"]); err != nil { + return nil, errors.Wrap(err, "bad value type") + } else { + col.Type.Value = vbt + } + + if minv, exist := t0["min"]; exist { + if min, ok := minv.(float64); ok { + col.Type.Min = int(min) + } else { + return nil, errors.Wrapf(errSchema, "bad min: %#v", minv) + } + } + if maxv, exist := t0["max"]; exist { + if max, ok := maxv.(float64); ok { + col.Type.Max = int(max) + } else if unlimited, ok := maxv.(string); ok && unlimited == "unlimited" { + col.Type.Max = -1 + col.Type.MaxUnlimited = true + } else { + return nil, errors.Wrapf(errSchema, "bad max: %#v", maxv) + } + } + default: + return nil, errors.Wrapf(errSchema, "bad type: %#v", t0) + } + tbl.Columns[colName] = col + } + sch.Tables[tblName] = tbl + } + return sch, nil +} + +// rfc7047, 3.2 Schema Format, +func parseBaseType(bti interface{}) (BaseType, error) { + bt := BaseType{} + switch btv := bti.(type) { + case string: + bt.Type = Atomic(btv) + return bt, nil + case map[string]interface{}: + buf := &bytes.Buffer{} + enc := json.NewEncoder(buf) + if err := enc.Encode(btv); err != nil { + return bt, errors.Wrapf(errSchema, "encode %v", err) + } + dec := json.NewDecoder(buf) + dec.DisallowUnknownFields() + if err := dec.Decode(&bt); err != nil { + return bt, errors.Wrapf(errSchema, "decode %v", err) + } + return bt, nil + case nil: + return bt, nil + default: + return BaseType{}, errors.Wrapf(errSchema, "unexpected base type %#v", bti) + } +} diff --git a/vendor/yunion.io/x/ovsdb/types/schema_gen.go b/vendor/yunion.io/x/ovsdb/types/schema_gen.go new file mode 100644 index 0000000000..dc78439404 --- /dev/null +++ b/vendor/yunion.io/x/ovsdb/types/schema_gen.go @@ -0,0 +1,362 @@ +package types + +import ( + "fmt" + "sort" +) + +func (sch *Schema) OrderedTableNames() []string { + s := make([]string, 0, len(sch.Tables)) + for name, _ := range sch.Tables { + s = append(s, name) + } + sort.Strings(s) + return s +} + +func (sch *Schema) typeName() string { + name := Kebab2Camel(sch.Name) + name = ExportName(name) + for _, tblName := range sch.OrderedTableNames() { + var ( + tbl = sch.Tables[tblName] + tblTypName = tbl.rowTypeName() + ) + if name == tblTypName { + return "Ovsdb" + name + } + } + return name +} + +func (sch *Schema) gen(w writer) { + w.Writef(`import "yunion.io/x/ovsdb/types"`) + w.Writef(`import "github.com/pkg/errors"`) + w.Writef(`import "fmt"`) + + var schTyp = sch.typeName() + w.Writef(`type %s struct {`, schTyp) + for _, name := range sch.OrderedTableNames() { + var ( + tbl = sch.Tables[name] + tblTyp = tbl.tblTypeName() + fieldName = tbl.tblField() + ) + w.Writef(`%s %s`, fieldName, tblTyp) + } + w.Writef(`}`) + w.Writef(``) + + w.Writef(`func (db %s) FindOneMatchNonZeros(irow types.IRow) types.IRow {`, schTyp) + for _, name := range sch.OrderedTableNames() { + var ( + tbl = sch.Tables[name] + rowTyp = tbl.rowTypeName() + fieldName = tbl.tblField() + ) + w.Writef(`switch row := irow.(type) {`) + w.Writef(`case *%s:`, rowTyp) + w.Writef(` if r := db.%s.FindOneMatchNonZeros(row); r != nil {`, fieldName) + w.Writef(` return r`) + w.Writef(` }`) + w.Writef(` return nil`) + w.Writef(`}`) + } + w.Writef(` panic(types.ErrBadType)`) + w.Writef(`}`) + w.Writef(``) + + for _, name := range sch.OrderedTableNames() { + tbl := sch.Tables[name] + tbl.gen(w) + } +} + +func (tbl *Table) tblTypeName() string { + name := Kebab2Camel(tbl.Name) + "Table" + name = ExportName(name) + return name +} + +func (tbl *Table) tblField() string { + name := Kebab2Camel(tbl.Name) + name = ExportName(name) + return name +} + +func (tbl *Table) rowTypeName() string { + name := Kebab2Camel(tbl.Name) + name = ExportName(name) + return name +} + +// TODO use sync +func (tbl *Table) OrderedColumnNames() []string { + s := make([]string, 0, len(tbl.Columns)) + for name, _ := range tbl.Columns { + s = append(s, name) + } + sort.Strings(s) + return s +} + +func (tbl *Table) gen(w writer) { + var ( + tblTyp = tbl.tblTypeName() + rowTyp = tbl.rowTypeName() + ) + + w.Writef(`type %s []%s`, tblTyp, rowTyp) + w.Writef(`var _ types.ITable = &%s{}`, tblTyp) + w.Writef(`func (tbl %s) OvsdbTableName() string {`, tblTyp) + w.Writef(` return %q`, tbl.Name) + w.Writef(`}`) + w.Writef(``) + + w.Writef(`func (tbl %s) OvsdbIsRoot() bool {`, tblTyp) + w.Writef(` return %v`, tbl.IsRoot) + w.Writef(`}`) + w.Writef(``) + + w.Writef(`func (tbl %s) Rows() []types.IRow {`, tblTyp) + w.Writef(` r := make([]types.IRow, len(tbl))`) + w.Writef(` for i := range tbl {`) + w.Writef(` r[i] = &tbl[i]`) + w.Writef(` }`) + w.Writef(` return r`) + w.Writef(`}`) + w.Writef(``) + + w.Writef(`func (tbl %s) NewRow() types.IRow {`, tblTyp) + w.Writef(` return &%s{}`, rowTyp) + w.Writef(`}`) + w.Writef(``) + + w.Writef(`func (tbl *%s) AppendRow(irow types.IRow) {`, tblTyp) + w.Writef(` row := irow.(*%s)`, rowTyp) + w.Writef(` *tbl = append(*tbl, *row)`) + w.Writef(`}`) + w.Writef(``) + + w.Writef(`func (tbl %s) FindOneMatchNonZeros(row1 *%s) *%s {`, tblTyp, rowTyp, rowTyp) + w.Writef(` for i := range tbl {`) + w.Writef(` row := &tbl[i]`) + w.Writef(` if row.MatchNonZeros(row1) {`) + w.Writef(` return row`) + w.Writef(` }`) + w.Writef(` }`) + w.Writef(` return nil`) + w.Writef(`}`) + w.Writef(``) + + w.Writef(`type %s struct {`, rowTyp) + for _, colName := range tbl.OrderedColumnNames() { + col := tbl.Columns[colName] + w.Writef(`%s %s %s`, col.goField(), col.goType(), col.goTags()) + } + w.Writef(`}`) + w.Writef(``) + + w.Writef(`var _ types.IRow = &%s{}`, rowTyp) + + w.Writef(`func (row *%s) OvsdbTableName() string {`, rowTyp) + w.Writef(` return %q`, tbl.Name) + w.Writef(`}`) + w.Writef(``) + + w.Writef(`func (row *%s) OvsdbIsRoot() bool {`, rowTyp) + w.Writef(` return %v`, tbl.IsRoot) + w.Writef(`}`) + w.Writef(``) + + w.Writef(`func (row *%s) OvsdbUuid() string {`, rowTyp) + w.Writef(` return row.Uuid`) + w.Writef(`}`) + w.Writef(``) + + w.Writef(`func (row *%s) OvsdbCmdArgs() []string {`, rowTyp) + w.Writef(` r := []string{}`) + for _, colName := range tbl.OrderedColumnNames() { + col := tbl.Columns[colName] + if !col.readOnly() { + w.Writef(`r = append(r, types.%s(%q, row.%s)...)`, col.cmdArgsFuncName(), colName, col.goField()) + } + } + w.Writef(` return r`) + w.Writef(`}`) + w.Writef(``) + + w.Writef(`func (row *%s) SetColumn(name string, val interface{}) (err error) {`, rowTyp) + w.Writef(` defer func() {`) + w.Writef(` if panicErr := recover(); panicErr != nil {`) + w.Writeln(` err = errors.Wrapf(panicErr.(error), "%s: %#v", name, fmt.Sprintf("%#v", val))`) + w.Writef(` }`) + w.Writef(` }()`) + w.Writef(` switch name {`) + for _, colName := range tbl.OrderedColumnNames() { + col := tbl.Columns[colName] + w.Writef(`case %q:`, colName) + w.Writef(` row.%s = types.%s(val)`, col.goField(), col.ensureFuncName()) + } + w.Writef(` default:`) + w.Writef(` panic(types.ErrUnknownColumn)`) + w.Writef(` }`) + w.Writef(` return`) + w.Writef(`}`) + w.Writef(``) + + w.Writef(`func (row *%s) MatchNonZeros(row1 *%s) bool {`, rowTyp, rowTyp) + for _, colName := range tbl.OrderedColumnNames() { + col := tbl.Columns[colName] + w.Writef(`if !types.%s(row.%s, row1.%s) {`, col.matchFuncName(), col.goField(), col.goField()) + w.Writef(` return false`) + w.Writef(`}`) + } + w.Writef(` return true`) + w.Writef(`}`) + w.Writef(``) + + { + _, ok := tbl.Columns["external_ids"] + g := func(f func()) { + if ok { + f() + } else { + w.Writef(` panic(errors.Wrap(types.ErrUnknownColumn, "external_ids"))`) + } + } + w.Writef(`func (row *%s) HasExternalIds() bool {`, rowTyp) + w.Writef(` return %v`, ok) + w.Writef(`}`) + w.Writef(``) + + w.Writef(`func (row *%s) SetExternalId(k, v string) {`, rowTyp) + g(func() { + w.Writef(` if row.ExternalIds == nil {`) + w.Writef(` row.ExternalIds = map[string]string{}`) + w.Writef(` }`) + w.Writef(` row.ExternalIds[k] = v`) + }) + w.Writef(`}`) + w.Writef(``) + + w.Writef(`func (row *%s) GetExternalId(k string) (string, bool) {`, rowTyp) + g(func() { + w.Writef(` if row.ExternalIds == nil {`) + w.Writef(` return "", false`) + w.Writef(` }`) + w.Writef(` r, ok := row.ExternalIds[k]`) + w.Writef(` return r, ok`) + }) + w.Writef(`}`) + w.Writef(``) + + w.Writef(`func (row *%s) RemoveExternalId(k string) (string, bool) {`, rowTyp) + g(func() { + w.Writef(` if row.ExternalIds == nil {`) + w.Writef(` return "", false`) + w.Writef(` }`) + w.Writef(` r, ok := row.ExternalIds[k]`) + w.Writef(` if ok {`) + w.Writef(` delete(row.ExternalIds, k)`) + w.Writef(` }`) + w.Writef(` return r, ok`) + }) + w.Writef(`}`) + w.Writef(``) + } +} + +func (col *Column) readOnly() bool { + name := col.Name + return name == "_uuid" || name == "_version" +} + +func (col *Column) goField() string { + // TODO + name := col.Name + if name == "_uuid" || name == "_version" { + name = name[1:] + } + name = Kebab2Camel(col.Name) + name = ExportName(name) + return name +} + +func (col *Column) goType() string { + typ := &col.Type + kType := typ.Key.Type.goType() + + if typ.Value.Type.isValid() { + vType := typ.Value.Type.goType() + return fmt.Sprintf("map[%s]%s", kType, vType) + } + + if typ.MaxUnlimited { + return fmt.Sprintf("[]%s", kType) + } + + min, max := typ.Min, typ.Max + if min == 0 { + if max == 0 { + panic(fmt.Sprintf("column type with min, max both being 0")) + } else if max == 1 { + return fmt.Sprintf("*%s", kType) + } else { + return fmt.Sprintf("[]%s", kType) + } + } else if max == 1 { + return kType + } else { + return fmt.Sprintf("[]%s", kType) + } +} + +func (col *Column) goTags() string { + return fmt.Sprintf("`json:\"%s\"`", col.Name) +} + +func (col *Column) funcNameSuffix() string { + var ( + typ = &col.Type + atomK = typ.Key.Type + atomV = typ.Value.Type + nameK = atomK.exportName() + ) + + if atomV.isValid() { + nameV := atomV.exportName() + return fmt.Sprintf("Map%s%s", nameK, nameV) + } + + if typ.MaxUnlimited { + return fmt.Sprintf("%sMultiples", nameK) + } + + min, max := typ.Min, typ.Max + if min == 0 { + if max == 0 { + panic(fmt.Sprintf("column type with min, max both being 0")) + } else if max == 1 { + return fmt.Sprintf("%sOptional", nameK) + } else { + return fmt.Sprintf("%sMultiples", nameK) + } + } else if max == 1 { + return fmt.Sprintf("%s", nameK) + } else { + return fmt.Sprintf("%sMultiples", nameK) + } +} + +func (col *Column) ensureFuncName() string { + return "Ensure" + col.funcNameSuffix() +} + +func (col *Column) cmdArgsFuncName() string { + return "OvsdbCmdArgs" + col.funcNameSuffix() +} + +func (col *Column) matchFuncName() string { + return "Match" + col.funcNameSuffix() + "IfNonZero" +} diff --git a/vendor/yunion.io/x/ovsdb/types/vswitch.ovsschema b/vendor/yunion.io/x/ovsdb/types/vswitch.ovsschema new file mode 100644 index 0000000000..90e50b6261 --- /dev/null +++ b/vendor/yunion.io/x/ovsdb/types/vswitch.ovsschema @@ -0,0 +1,651 @@ +{"name": "Open_vSwitch", + "version": "7.15.1", + "cksum": "3682332033 23608", + "tables": { + "Open_vSwitch": { + "columns": { + "bridges": { + "type": {"key": {"type": "uuid", + "refTable": "Bridge"}, + "min": 0, "max": "unlimited"}}, + "manager_options": { + "type": {"key": {"type": "uuid", + "refTable": "Manager"}, + "min": 0, "max": "unlimited"}}, + "ssl": { + "type": {"key": {"type": "uuid", + "refTable": "SSL"}, + "min": 0, "max": 1}}, + "other_config": { + "type": {"key": "string", "value": "string", + "min": 0, "max": "unlimited"}}, + "external_ids": { + "type": {"key": "string", "value": "string", + "min": 0, "max": "unlimited"}}, + "next_cfg": { + "type": "integer"}, + "cur_cfg": { + "type": "integer"}, + "statistics": { + "type": {"key": "string", "value": "string", + "min": 0, "max": "unlimited"}, + "ephemeral": true}, + "ovs_version": { + "type": {"key": {"type": "string"}, + "min": 0, "max": 1}}, + "db_version": { + "type": {"key": {"type": "string"}, + "min": 0, "max": 1}}, + "system_type": { + "type": {"key": {"type": "string"}, + "min": 0, "max": 1}}, + "system_version": { + "type": {"key": {"type": "string"}, + "min": 0, "max": 1}}, + "datapath_types": { + "type": {"key": {"type": "string"}, + "min": 0, "max": "unlimited"}}, + "iface_types": { + "type": {"key": {"type": "string"}, + "min": 0, "max": "unlimited"}}}, + "isRoot": true, + "maxRows": 1}, + "Bridge": { + "columns": { + "name": { + "type": "string", + "mutable": false}, + "datapath_type": { + "type": "string"}, + "datapath_version": { + "type": "string"}, + "datapath_id": { + "type": {"key": "string", "min": 0, "max": 1}, + "ephemeral": true}, + "stp_enable": { + "type": "boolean"}, + "rstp_enable": { + "type": "boolean"}, + "mcast_snooping_enable": { + "type": "boolean"}, + "ports": { + "type": {"key": {"type": "uuid", + "refTable": "Port"}, + "min": 0, "max": "unlimited"}}, + "mirrors": { + "type": {"key": {"type": "uuid", + "refTable": "Mirror"}, + "min": 0, "max": "unlimited"}}, + "netflow": { + "type": {"key": {"type": "uuid", + "refTable": "NetFlow"}, + "min": 0, "max": 1}}, + "sflow": { + "type": {"key": {"type": "uuid", + "refTable": "sFlow"}, + "min": 0, "max": 1}}, + "ipfix": { + "type": {"key": {"type": "uuid", + "refTable": "IPFIX"}, + "min": 0, "max": 1}}, + "controller": { + "type": {"key": {"type": "uuid", + "refTable": "Controller"}, + "min": 0, "max": "unlimited"}}, + "protocols": { + "type": {"key": {"type": "string", + "enum": ["set", ["OpenFlow10", + "OpenFlow11", + "OpenFlow12", + "OpenFlow13", + "OpenFlow14", + "OpenFlow15", + "OpenFlow16"]]}, + "min": 0, "max": "unlimited"}}, + "fail_mode": { + "type": {"key": {"type": "string", + "enum": ["set", ["standalone", "secure"]]}, + "min": 0, "max": 1}}, + "status": { + "type": {"key": "string", "value": "string", + "min": 0, "max": "unlimited"}, + "ephemeral": true}, + "rstp_status": { + "type": {"key": "string", "value": "string", + "min": 0, "max": "unlimited"}, + "ephemeral": true}, + "other_config": { + "type": {"key": "string", "value": "string", + "min": 0, "max": "unlimited"}}, + "external_ids": { + "type": {"key": "string", "value": "string", + "min": 0, "max": "unlimited"}}, + "flood_vlans": { + "type": {"key": {"type": "integer", + "minInteger": 0, + "maxInteger": 4095}, + "min": 0, "max": 4096}}, + "flow_tables": { + "type": {"key": {"type": "integer", + "minInteger": 0, + "maxInteger": 254}, + "value": {"type": "uuid", + "refTable": "Flow_Table"}, + "min": 0, "max": "unlimited"}}, + "auto_attach": { + "type": {"key": {"type": "uuid", + "refTable": "AutoAttach"}, + "min": 0, "max": 1}}}, + "indexes": [["name"]]}, + "Port": { + "columns": { + "name": { + "type": "string", + "mutable": false}, + "interfaces": { + "type": {"key": {"type": "uuid", + "refTable": "Interface"}, + "min": 1, "max": "unlimited"}}, + "trunks": { + "type": {"key": {"type": "integer", + "minInteger": 0, + "maxInteger": 4095}, + "min": 0, "max": 4096}}, + "cvlans": { + "type": {"key": {"type": "integer", + "minInteger": 0, + "maxInteger": 4095}, + "min": 0, "max": 4096}}, + "tag": { + "type": {"key": {"type": "integer", + "minInteger": 0, + "maxInteger": 4095}, + "min": 0, "max": 1}}, + "vlan_mode": { + "type": {"key": {"type": "string", + "enum": ["set", ["trunk", "access", "native-tagged", + "native-untagged", "dot1q-tunnel"]]}, + "min": 0, "max": 1}}, + "qos": { + "type": {"key": {"type": "uuid", + "refTable": "QoS"}, + "min": 0, "max": 1}}, + "mac": { + "type": {"key": {"type": "string"}, + "min": 0, "max": 1}}, + "bond_mode": { + "type": {"key": {"type": "string", + "enum": ["set", ["balance-tcp", "balance-slb", "active-backup"]]}, + "min": 0, "max": 1}}, + "lacp": { + "type": {"key": {"type": "string", + "enum": ["set", ["active", "passive", "off"]]}, + "min": 0, "max": 1}}, + "bond_updelay": { + "type": "integer"}, + "bond_downdelay": { + "type": "integer"}, + "bond_active_slave": { + "type": {"key": {"type": "string"}, + "min": 0, "max": 1}}, + "bond_fake_iface": { + "type": "boolean"}, + "fake_bridge": { + "type": "boolean"}, + "status": { + "type": {"key": "string", "value": "string", + "min": 0, "max": "unlimited"}, + "ephemeral": true}, + "rstp_status": { + "type": {"key": "string", "value": "string", + "min": 0, "max": "unlimited"}, + "ephemeral": true}, + "rstp_statistics": { + "type": {"key": "string", "value": "integer", + "min": 0, "max": "unlimited"}, + "ephemeral": true}, + "statistics": { + "type": {"key": "string", "value": "integer", + "min": 0, "max": "unlimited"}, + "ephemeral": true}, + "protected": { + "type": "boolean"}, + "other_config": { + "type": {"key": "string", "value": "string", + "min": 0, "max": "unlimited"}}, + "external_ids": { + "type": {"key": "string", "value": "string", + "min": 0, "max": "unlimited"}}}, + "indexes": [["name"]]}, + "Interface": { + "columns": { + "name": { + "type": "string", + "mutable": false}, + "type": { + "type": "string"}, + "options": { + "type": {"key": "string", "value": "string", + "min": 0, "max": "unlimited"}}, + "ingress_policing_rate": { + "type": {"key": {"type": "integer", + "minInteger": 0}}}, + "ingress_policing_burst": { + "type": {"key": {"type": "integer", + "minInteger": 0}}}, + "mac_in_use": { + "type": {"key": {"type": "string"}, + "min": 0, "max": 1}, + "ephemeral": true}, + "mac": { + "type": {"key": {"type": "string"}, + "min": 0, "max": 1}}, + "ifindex": { + "type": { + "key": {"type": "integer", + "minInteger": 0, + "maxInteger": 4294967295}, + "min": 0, + "max": 1}, + "ephemeral": true}, + "external_ids": { + "type": {"key": "string", "value": "string", + "min": 0, "max": "unlimited"}}, + "ofport": { + "type": {"key": "integer", "min": 0, "max": 1}}, + "ofport_request": { + "type": { + "key": {"type": "integer", + "minInteger": 1, + "maxInteger": 65279}, + "min": 0, + "max": 1}}, + "bfd": { + "type": {"key": "string", "value": "string", + "min": 0, "max": "unlimited"}}, + "bfd_status": { + "type": {"key": "string", "value": "string", + "min": 0, "max": "unlimited"}}, + "cfm_mpid": { + "type": { + "key": {"type": "integer"}, + "min": 0, + "max": 1}}, + "cfm_remote_mpids": { + "type": { + "key": {"type": "integer"}, + "min": 0, + "max": "unlimited"}, + "ephemeral": true}, + "cfm_flap_count": { + "type": { + "key": {"type": "integer"}, + "min": 0, + "max": 1}}, + "cfm_fault": { + "type": { + "key": { "type": "boolean"}, + "min": 0, + "max": 1}, + "ephemeral": true}, + "cfm_fault_status": { + "type": { + "key": "string", "min": 0, "max": "unlimited"}, + "ephemeral": true}, + "cfm_remote_opstate": { + "type": {"key": {"type": "string", + "enum": ["set", ["up", "down"]]}, + "min": 0, "max": 1}, + "ephemeral": true}, + "cfm_health": { + "type": {"key": {"type": "integer", + "minInteger": 0, + "maxInteger": 100}, + "min": 0, "max": 1}, + "ephemeral": true}, + "lacp_current": { + "type": {"key": {"type": "boolean"}, + "min": 0, "max": 1}, + "ephemeral": true}, + "lldp": { + "type": {"key": "string", "value": "string", + "min": 0, "max": "unlimited"}}, + "other_config": { + "type": {"key": "string", "value": "string", + "min": 0, "max": "unlimited"}}, + "statistics": { + "type": {"key": "string", "value": "integer", + "min": 0, "max": "unlimited"}, + "ephemeral": true}, + "status": { + "type": {"key": "string", "value": "string", + "min": 0, "max": "unlimited"}, + "ephemeral": true}, + "admin_state": { + "type": {"key": {"type": "string", + "enum": ["set", ["up", "down"]]}, + "min": 0, "max": 1}, + "ephemeral": true}, + "link_state": { + "type": {"key": {"type": "string", + "enum": ["set", ["up", "down"]]}, + "min": 0, "max": 1}, + "ephemeral": true}, + "link_resets": { + "type": {"key": {"type": "integer"}, + "min": 0, "max": 1}, + "ephemeral": true}, + "link_speed": { + "type": {"key": "integer", "min": 0, "max": 1}, + "ephemeral": true}, + "duplex": { + "type": {"key": {"type": "string", + "enum": ["set", ["half", "full"]]}, + "min": 0, "max": 1}, + "ephemeral": true}, + "mtu": { + "type": {"key": "integer", "min": 0, "max": 1}, + "ephemeral": true}, + "mtu_request": { + "type": { + "key": {"type": "integer", + "minInteger": 1}, + "min": 0, + "max": 1}}, + "error": { + "type": {"key": "string", "min": 0, "max": 1}}}, + "indexes": [["name"]]}, + "Flow_Table": { + "columns": { + "name": { + "type": {"key": "string", "min": 0, "max": 1}}, + "flow_limit": { + "type": {"key": {"type": "integer", "minInteger": 0}, + "min": 0, "max": 1}}, + "overflow_policy": { + "type": {"key": {"type": "string", + "enum": ["set", ["refuse", "evict"]]}, + "min": 0, "max": 1}}, + "groups": { + "type": {"key": "string", "min": 0, "max": "unlimited"}}, + "prefixes": { + "type": {"key": "string", "min": 0, "max": 3}}, + "external_ids": { + "type": {"key": "string", "value": "string", + "min": 0, "max": "unlimited"}}}}, + "QoS": { + "columns": { + "type": { + "type": "string"}, + "queues": { + "type": {"key": {"type": "integer", + "minInteger": 0, + "maxInteger": 4294967295}, + "value": {"type": "uuid", + "refTable": "Queue"}, + "min": 0, "max": "unlimited"}}, + "other_config": { + "type": {"key": "string", "value": "string", + "min": 0, "max": "unlimited"}}, + "external_ids": { + "type": {"key": "string", "value": "string", + "min": 0, "max": "unlimited"}}}, + "isRoot": true}, + "Queue": { + "columns": { + "dscp": { + "type": {"key": {"type": "integer", + "minInteger": 0, + "maxInteger": 63}, + "min": 0, "max": 1}}, + "other_config": { + "type": {"key": "string", "value": "string", + "min": 0, "max": "unlimited"}}, + "external_ids": { + "type": {"key": "string", "value": "string", + "min": 0, "max": "unlimited"}}}, + "isRoot": true}, + "Mirror": { + "columns": { + "name": { + "type": "string"}, + "select_all": { + "type": "boolean"}, + "select_src_port": { + "type": {"key": {"type": "uuid", + "refTable": "Port", + "refType": "weak"}, + "min": 0, "max": "unlimited"}}, + "select_dst_port": { + "type": {"key": {"type": "uuid", + "refTable": "Port", + "refType": "weak"}, + "min": 0, "max": "unlimited"}}, + "select_vlan": { + "type": {"key": {"type": "integer", + "minInteger": 0, + "maxInteger": 4095}, + "min": 0, "max": 4096}}, + "output_port": { + "type": {"key": {"type": "uuid", + "refTable": "Port", + "refType": "weak"}, + "min": 0, "max": 1}}, + "output_vlan": { + "type": {"key": {"type": "integer", + "minInteger": 1, + "maxInteger": 4095}, + "min": 0, "max": 1}}, + "snaplen": { + "type": {"key": {"type": "integer", + "minInteger": 14, + "maxInteger": 65535}, + "min": 0, "max": 1}}, + "statistics": { + "type": {"key": "string", "value": "integer", + "min": 0, "max": "unlimited"}, + "ephemeral": true}, + "external_ids": { + "type": {"key": "string", "value": "string", + "min": 0, "max": "unlimited"}}}}, + "NetFlow": { + "columns": { + "targets": { + "type": {"key": {"type": "string"}, + "min": 1, "max": "unlimited"}}, + "engine_type": { + "type": {"key": {"type": "integer", + "minInteger": 0, + "maxInteger": 255}, + "min": 0, "max": 1}}, + "engine_id": { + "type": {"key": {"type": "integer", + "minInteger": 0, + "maxInteger": 255}, + "min": 0, "max": 1}}, + "add_id_to_interface": { + "type": "boolean"}, + "active_timeout": { + "type": {"key": {"type": "integer", + "minInteger": -1}}}, + "external_ids": { + "type": {"key": "string", "value": "string", + "min": 0, "max": "unlimited"}}}}, + "sFlow": { + "columns": { + "targets": { + "type": {"key": "string", "min": 1, "max": "unlimited"}}, + "sampling": { + "type": {"key": "integer", "min": 0, "max": 1}}, + "polling": { + "type": {"key": "integer", "min": 0, "max": 1}}, + "header": { + "type": {"key": "integer", "min": 0, "max": 1}}, + "agent": { + "type": {"key": "string", "min": 0, "max": 1}}, + "external_ids": { + "type": {"key": "string", "value": "string", + "min": 0, "max": "unlimited"}}}}, + "IPFIX": { + "columns": { + "targets": { + "type": {"key": "string", "min": 0, "max": "unlimited"}}, + "sampling": { + "type": {"key": {"type": "integer", + "minInteger": 1, + "maxInteger": 4294967295}, + "min": 0, "max": 1}}, + "obs_domain_id": { + "type": {"key": {"type": "integer", + "minInteger": 0, + "maxInteger": 4294967295}, + "min": 0, "max": 1}}, + "obs_point_id": { + "type": {"key": {"type": "integer", + "minInteger": 0, + "maxInteger": 4294967295}, + "min": 0, "max": 1}}, + "cache_active_timeout": { + "type": {"key": {"type": "integer", + "minInteger": 0, + "maxInteger": 4200}, + "min": 0, "max": 1}}, + "cache_max_flows": { + "type": {"key": {"type": "integer", + "minInteger": 0, + "maxInteger": 4294967295}, + "min": 0, "max": 1}}, + "other_config": { + "type": {"key": "string", "value": "string", + "min": 0, "max": "unlimited"}}, + "external_ids": { + "type": {"key": "string", "value": "string", + "min": 0, "max": "unlimited"}}}}, + "Flow_Sample_Collector_Set": { + "columns": { + "id": { + "type": {"key": {"type": "integer", + "minInteger": 0, + "maxInteger": 4294967295}, + "min": 1, "max": 1}}, + "bridge": { + "type": {"key": {"type": "uuid", + "refTable": "Bridge"}, + "min": 1, "max": 1}}, + "ipfix": { + "type": {"key": {"type": "uuid", + "refTable": "IPFIX"}, + "min": 0, "max": 1}}, + "external_ids": { + "type": {"key": "string", "value": "string", + "min": 0, "max": "unlimited"}}}, + "isRoot": true, + "indexes": [["id", "bridge"]]}, + "Controller": { + "columns": { + "target": { + "type": "string"}, + "max_backoff": { + "type": {"key": {"type": "integer", + "minInteger": 1000}, + "min": 0, "max": 1}}, + "inactivity_probe": { + "type": {"key": "integer", "min": 0, "max": 1}}, + "connection_mode": { + "type": {"key": {"type": "string", + "enum": ["set", ["in-band", "out-of-band"]]}, + "min": 0, "max": 1}}, + "local_ip": { + "type": {"key": {"type": "string"}, + "min": 0, "max": 1}}, + "local_netmask": { + "type": {"key": {"type": "string"}, + "min": 0, "max": 1}}, + "local_gateway": { + "type": {"key": {"type": "string"}, + "min": 0, "max": 1}}, + "enable_async_messages": { + "type": {"key": {"type": "boolean"}, + "min": 0, "max": 1}}, + "controller_rate_limit": { + "type": {"key": {"type": "integer", + "minInteger": 100}, + "min": 0, "max": 1}}, + "controller_burst_limit": { + "type": {"key": {"type": "integer", + "minInteger": 25}, + "min": 0, "max": 1}}, + "other_config": { + "type": {"key": "string", "value": "string", + "min": 0, "max": "unlimited"}}, + "external_ids": { + "type": {"key": "string", "value": "string", + "min": 0, "max": "unlimited"}}, + "is_connected": { + "type": "boolean", + "ephemeral": true}, + "role": { + "type": {"key": {"type": "string", + "enum": ["set", ["other", "master", "slave"]]}, + "min": 0, "max": 1}, + "ephemeral": true}, + "status": { + "type": {"key": "string", "value": "string", + "min": 0, "max": "unlimited"}, + "ephemeral": true}}}, + "Manager": { + "columns": { + "target": { + "type": "string"}, + "max_backoff": { + "type": {"key": {"type": "integer", + "minInteger": 1000}, + "min": 0, "max": 1}}, + "inactivity_probe": { + "type": {"key": "integer", "min": 0, "max": 1}}, + "connection_mode": { + "type": {"key": {"type": "string", + "enum": ["set", ["in-band", "out-of-band"]]}, + "min": 0, "max": 1}}, + "other_config": { + "type": {"key": "string", "value": "string", + "min": 0, "max": "unlimited"}}, + "external_ids": { + "type": {"key": "string", "value": "string", + "min": 0, "max": "unlimited"}}, + "is_connected": { + "type": "boolean", + "ephemeral": true}, + "status": { + "type": {"key": "string", "value": "string", + "min": 0, "max": "unlimited"}, + "ephemeral": true}}, + "indexes": [["target"]]}, + "SSL": { + "columns": { + "private_key": { + "type": "string"}, + "certificate": { + "type": "string"}, + "ca_cert": { + "type": "string"}, + "bootstrap_ca_cert": { + "type": "boolean"}, + "external_ids": { + "type": {"key": "string", "value": "string", + "min": 0, "max": "unlimited"}}}, + "maxRows": 1}, + "AutoAttach": { + "columns": { + "system_name": { + "type": "string"}, + "system_description": { + "type": "string"}, + "mappings": { + "type": {"key": {"type": "integer", + "minInteger": 0, + "maxInteger": 16777215}, + "value": {"type": "integer", + "minInteger": 0, + "maxInteger": 4095}, + "min": 0, "max": "unlimited"}}}}}} diff --git a/vendor/yunion.io/x/ovsdb/types/vtep.ovsschema b/vendor/yunion.io/x/ovsdb/types/vtep.ovsschema new file mode 100644 index 0000000000..3a24318ee1 --- /dev/null +++ b/vendor/yunion.io/x/ovsdb/types/vtep.ovsschema @@ -0,0 +1,307 @@ +{ + "name": "hardware_vtep", + "cksum": "353943336 11434", + "tables": { + "Global": { + "columns": { + "managers": { + "type": {"key": {"type": "uuid", + "refTable": "Manager"}, + "min": 0, "max": "unlimited"}}, + "switches": { + "type": {"key": {"type": "uuid", "refTable": "Physical_Switch"}, + "min": 0, "max": "unlimited"}}, + "other_config": { + "type": {"key": "string", "value": "string", + "min": 0, "max": "unlimited"}} + }, + "maxRows": 1, + "isRoot": true}, + "Physical_Switch": { + "columns": { + "ports": { + "type": {"key": {"type": "uuid", "refTable": "Physical_Port"}, + "min": 0, "max": "unlimited"}}, + "name": {"type": "string"}, + "description": {"type": "string"}, + "management_ips": { + "type": {"key": {"type": "string"}, "min": 0, "max": "unlimited"}}, + "tunnel_ips": { + "type": {"key": {"type": "string"}, "min": 0, "max": "unlimited"}}, + "tunnels": { + "type": {"key": {"type": "uuid", "refTable": "Tunnel"}, + "min": 0, "max": "unlimited"}}, + "other_config": { + "type": {"key": "string", "value": "string", + "min": 0, "max": "unlimited"}}, + "switch_fault_status": { + "type": { + "key": "string", "min": 0, "max": "unlimited"}, + "ephemeral": true}}, + "indexes": [["name"]]}, + "Physical_Port": { + "columns": { + "name": {"type": "string"}, + "description": {"type": "string"}, + "vlan_bindings": { + "type": {"key": {"type": "integer", + "minInteger": 0, "maxInteger": 4095}, + "value": {"type": "uuid", "refTable": "Logical_Switch"}, + "min": 0, "max": "unlimited"}}, + "acl_bindings": { + "type": {"key": {"type": "integer", + "minInteger": 0, "maxInteger": 4095}, + "value": {"type": "uuid", "refTable": "ACL"}, + "min": 0, "max": "unlimited"}}, + "vlan_stats": { + "type": {"key": {"type": "integer", + "minInteger": 0, "maxInteger": 4095}, + "value": {"type": "uuid", + "refTable": "Logical_Binding_Stats"}, + "min": 0, "max": "unlimited"}, + "ephemeral": true}, + "other_config": { + "type": {"key": "string", "value": "string", + "min": 0, "max": "unlimited"}}, + "port_fault_status": { + "type": { + "key": "string", "min": 0, "max": "unlimited"}, + "ephemeral": true}}}, + "Tunnel": { + "columns": { + "local": { + "type": {"key": {"type": "uuid", + "refTable": "Physical_Locator"}}}, + "remote": { + "type": {"key": {"type": "uuid", + "refTable": "Physical_Locator"}}}, + "bfd_config_local": { + "type": {"key": "string", "value": "string", + "min": 0, "max": "unlimited"}}, + "bfd_config_remote": { + "type": {"key": "string", "value": "string", + "min": 0, "max": "unlimited"}}, + "bfd_params": { + "type": {"key": "string", "value": "string", + "min": 0, "max": "unlimited"}}, + "bfd_status": { + "type": {"key": "string", "value": "string", + "min": 0, "max": "unlimited"}, + "ephemeral": true}}}, + "Logical_Binding_Stats": { + "columns": { + "bytes_from_local": {"type": "integer", "ephemeral": true}, + "packets_from_local": {"type": "integer", "ephemeral": true}, + "bytes_to_local": {"type": "integer", "ephemeral": true}, + "packets_to_local": {"type": "integer", "ephemeral": true}}}, + "Logical_Switch": { + "columns": { + "name": {"type": "string"}, + "description": {"type": "string"}, + "tunnel_key": {"type": {"key": "integer", "min": 0, "max": 1}}, + "replication_mode": { + "type": { + "key": { + "enum": ["set", ["service_node", "source_node"]], + "type": "string"},"min": 0, "max": 1}}, + "other_config": { + "type": {"key": "string", "value": "string", + "min": 0, "max": "unlimited"}}}, + "isRoot": true, + "indexes": [["name"]]}, + "Ucast_Macs_Local": { + "columns": { + "MAC": {"type": "string"}, + "logical_switch": { + "type": {"key": {"type": "uuid", + "refTable": "Logical_Switch"}}}, + "locator": { + "type": {"key": {"type": "uuid", + "refTable": "Physical_Locator"}}}, + "ipaddr": {"type": "string"}}, + "isRoot": true}, + "Ucast_Macs_Remote": { + "columns": { + "MAC": {"type": "string"}, + "logical_switch": { + "type": {"key": {"type": "uuid", + "refTable": "Logical_Switch"}}}, + "locator": { + "type": {"key": {"type": "uuid", + "refTable": "Physical_Locator"}}}, + "ipaddr": {"type": "string"}}, + "isRoot": true}, + "Mcast_Macs_Local": { + "columns": { + "MAC": {"type": "string"}, + "logical_switch": { + "type": {"key": {"type": "uuid", + "refTable": "Logical_Switch"}}}, + "locator_set": { + "type": {"key": {"type": "uuid", + "refTable": "Physical_Locator_Set"}}}, + "ipaddr": {"type": "string"}}, + "isRoot": true}, + "Mcast_Macs_Remote": { + "columns": { + "MAC": {"type": "string"}, + "logical_switch": { + "type": {"key": {"type": "uuid", + "refTable": "Logical_Switch"}}}, + "locator_set": { + "type": {"key": {"type": "uuid", + "refTable": "Physical_Locator_Set"}}}, + "ipaddr": {"type": "string"}}, + "isRoot": true}, + "Logical_Router": { + "columns": { + "name": {"type": "string"}, + "description": {"type": "string"}, + "switch_binding": { + "type": {"key": {"type": "string"}, + "value": {"type": "uuid", + "refTable": "Logical_Switch"}, + "min": 0, "max": "unlimited"}}, + "static_routes": { + "type": {"key": {"type": "string"}, + "value": {"type" : "string"}, + "min": 0, "max": "unlimited"}}, + "acl_binding": { + "type": {"key": {"type": "string"}, + "value": {"type": "uuid", + "refTable": "ACL"}, + "min": 0, "max": "unlimited"}}, + "other_config": { + "type": {"key": "string", "value": "string", + "min": 0, "max": "unlimited"}}, + "LR_fault_status": { + "type": { + "key": "string", "min": 0, "max": "unlimited"}, + "ephemeral": true}}, + "isRoot": true, + "indexes": [["name"]]}, + "Arp_Sources_Local": { + "columns": { + "src_mac": {"type": "string"}, + "locator": { + "type": {"key": {"type": "uuid", + "refTable": "Physical_Locator"}}}}, + "isRoot": true}, + "Arp_Sources_Remote": { + "columns": { + "src_mac": {"type": "string"}, + "locator": { + "type": {"key": {"type": "uuid", + "refTable": "Physical_Locator"}}}}, + "isRoot": true}, + "Physical_Locator_Set": { + "columns": { + "locators": { + "type": {"key": {"type": "uuid", "refTable": "Physical_Locator"}, + "min": 1, "max": "unlimited"}, + "mutable": false}}}, + "Physical_Locator": { + "columns": { + "encapsulation_type": { + "type": { + "key": { + "enum": ["set", ["vxlan_over_ipv4"]], + "type": "string"}}, + "mutable": false}, + "dst_ip": {"type": "string", "mutable": false}, + "tunnel_key": {"type": {"key": "integer", "min": 0, "max": 1}}}, + "indexes": [["encapsulation_type", "dst_ip", "tunnel_key"]]}, + "ACL_entry": { + "columns": { + "sequence": {"type": "integer"}, + "source_mac": { + "type": { + "key": "string", "min": 0, "max": 1}}, + "dest_mac": { + "type": { + "key": "string", "min": 0, "max": 1}}, + "ethertype": { + "type": { + "key": "string", "min": 0, "max": 1}}, + "source_ip": { + "type": { + "key": "string", "min": 0, "max": 1}}, + "source_mask": { + "type": { + "key": "string", "min": 0, "max": 1}}, + "dest_ip": { + "type": { + "key": "string", "min": 0, "max": 1}}, + "dest_mask": { + "type": { + "key": "string", "min": 0, "max": 1}}, + "protocol": { + "type": { + "key": "integer", "min": 0, "max": 1}}, + "source_port_min": { + "type": { + "key": "integer", "min": 0, "max": 1}}, + "source_port_max": { + "type": { + "key": "integer", "min": 0, "max": 1}}, + "dest_port_min": { + "type": { + "key": "integer", "min": 0, "max": 1}}, + "dest_port_max": { + "type": { + "key": "integer", "min": 0, "max": 1}}, + "tcp_flags": { + "type": { + "key": "integer", "min": 0, "max": 1}}, + "tcp_flags_mask": { + "type": { + "key": "integer", "min": 0, "max": 1}}, + "icmp_code": { + "type": { + "key": "integer", "min": 0, "max": 1}}, + "icmp_type": { + "type": { + "key": "integer", "min": 0, "max": 1}}, + "direction": { + "type": { + "key": {"type": "string", "enum": ["set", ["ingress", "egress"]]}}}, + "action": { + "type": { + "key": {"type": "string", "enum": ["set", ["permit", "deny"]]}}}, + "acle_fault_status": { + "type": { + "key": "string", "min": 0, "max": "unlimited"}, + "ephemeral": true}}, + "isRoot": true}, + "ACL": { + "columns": { + "acl_entries": { + "type": {"key": {"type": "uuid", "refTable": "ACL_entry"}, + "min": 1, "max": "unlimited"}}, + "acl_name": {"type": "string"}, + "acl_fault_status": { + "type": { + "key": "string", "min": 0, "max": "unlimited"}, + "ephemeral": true}}, + "indexes": [["acl_name"]], + "isRoot": true}, + "Manager": { + "columns": { + "target": {"type": "string"}, + "max_backoff": { + "type": {"key": {"type": "integer", + "minInteger": 1000}, + "min": 0, "max": 1}}, + "inactivity_probe": { + "type": {"key": "integer", "min": 0, "max": 1}}, + "other_config": { + "type": {"key": "string", "value": "string", "min": 0, "max": "unlimited"}}, + "is_connected": { + "type": "boolean", + "ephemeral": true}, + "status": { + "type": {"key": "string", "value": "string", "min": 0, "max": "unlimited"}, + "ephemeral": true}}, + "indexes": [["target"]], + "isRoot": false}}, + "version": "1.7.0"} diff --git a/vendor/yunion.io/x/ovsdb/types/writer.go b/vendor/yunion.io/x/ovsdb/types/writer.go new file mode 100644 index 0000000000..3f5504fd9c --- /dev/null +++ b/vendor/yunion.io/x/ovsdb/types/writer.go @@ -0,0 +1,21 @@ +package types + +import ( + "fmt" + "io" +) + +type writer struct { + w io.Writer +} + +func (w *writer) Writef(f string, as ...interface{}) { + b := fmt.Sprintf(f, as...) + w.w.Write([]byte(b)) + w.w.Write([]byte("\n")) +} + +func (w *writer) Writeln(ln string) { + w.w.Write([]byte(ln)) + w.w.Write([]byte("\n")) +} From cae9594da9044c8a28dcc68b96c421365bc460df Mon Sep 17 00:00:00 2001 From: Yousong Zhou Date: Fri, 8 May 2020 18:48:49 +0800 Subject: [PATCH 03/13] vpcagent: ovn: use yunion.io/x/ovsdb --- pkg/vpcagent/ovn/cmp.go | 15 ++++--- pkg/vpcagent/ovn/keeper.go | 69 ++++++++++++++++--------------- pkg/vpcagent/ovnutil/ovn_nbctl.go | 24 ++++++----- 3 files changed, 58 insertions(+), 50 deletions(-) diff --git a/pkg/vpcagent/ovn/cmp.go b/pkg/vpcagent/ovn/cmp.go index 6bff5505cd..f66ebff733 100644 --- a/pkg/vpcagent/ovn/cmp.go +++ b/pkg/vpcagent/ovn/cmp.go @@ -1,15 +1,18 @@ package ovn import ( + "yunion.io/x/ovsdb/schema/ovn_nb" + "yunion.io/x/ovsdb/types" + "yunion.io/x/onecloud/pkg/vpcagent/ovnutil" ) // cmp scans the database for irows. For those present, mark them with ocver. // If all rows are found, return true to indicate this. Otherwise return as // 2nd value the args to destroy these found records -func cmp(db *ovnutil.OVNNorthbound, ocver string, irows ...ovnutil.IRow) (bool, []string) { - irowsFound := make([]ovnutil.IRow, 0, len(irows)) - irowsDiff := make([]ovnutil.IRow, 0) +func cmp(db *ovn_nb.OVNNorthbound, ocver string, irows ...types.IRow) (bool, []string) { + irowsFound := make([]types.IRow, 0, len(irows)) + irowsDiff := make([]types.IRow, 0) for _, irow := range irows { irowFound := db.FindOneMatchNonZeros(irow) @@ -18,8 +21,8 @@ func cmp(db *ovnutil.OVNNorthbound, ocver string, irows ...ovnutil.IRow) (bool, } else { // TODO db.FindByIndex() switch row := irow.(type) { - case *ovnutil.LogicalSwitchPort: - rowQ := &ovnutil.LogicalSwitchPort{ + case *ovn_nb.LogicalSwitchPort: + rowQ := &ovn_nb.LogicalSwitchPort{ Name: row.Name, } if irow := db.FindOneMatchNonZeros(rowQ); irow != nil { @@ -31,7 +34,7 @@ func cmp(db *ovnutil.OVNNorthbound, ocver string, irows ...ovnutil.IRow) (bool, // mark them anyway even if not all found, to avoid the destroy // call at sweep stage for _, irowFound := range irowsFound { - irowFound.OvnSetExternalIds(externalKeyOcVersion, ocver) + irowFound.SetExternalId(externalKeyOcVersion, ocver) } if len(irowsFound) == len(irows) { return true, nil diff --git a/pkg/vpcagent/ovn/keeper.go b/pkg/vpcagent/ovn/keeper.go index a209984167..13a2b44bd9 100644 --- a/pkg/vpcagent/ovn/keeper.go +++ b/pkg/vpcagent/ovn/keeper.go @@ -19,6 +19,9 @@ import ( "fmt" "strings" + "yunion.io/x/ovsdb/cli_util" + "yunion.io/x/ovsdb/schema/ovn_nb" + "yunion.io/x/ovsdb/types" "yunion.io/x/pkg/errors" apis "yunion.io/x/onecloud/pkg/apis/compute" @@ -33,13 +36,13 @@ const ( ) type OVNNorthboundKeeper struct { - DB ovnutil.OVNNorthbound + DB ovn_nb.OVNNorthbound cli *ovnutil.OvnNbCtl } func DumpOVNNorthbound(ctx context.Context, cli *ovnutil.OvnNbCtl) (*OVNNorthboundKeeper, error) { - db := ovnutil.OVNNorthbound{} - itbls := []ovnutil.ITable{ + db := ovn_nb.OVNNorthbound{} + itbls := []types.ITable{ &db.LogicalSwitch, &db.LogicalSwitchPort, &db.LogicalRouter, @@ -49,12 +52,12 @@ func DumpOVNNorthbound(ctx context.Context, cli *ovnutil.OvnNbCtl) (*OVNNorthbou } args := []string{"--format=json", "list", ""} for _, itbl := range itbls { - tbl := itbl.OvnTableName() + tbl := itbl.OvsdbTableName() args[2] = tbl res := cli.Must(ctx, "List "+tbl, args) - if err := ovnutil.UnmarshalJSON([]byte(res.Output), itbl); err != nil { + if err := cli_util.UnmarshalJSON([]byte(res.Output), itbl); err != nil { return nil, errors.Wrapf(err, "Unmarshal %s:\n%s", - itbl.OvnTableName(), res.Output) + itbl.OvsdbTableName(), res.Output) } } keeper := &OVNNorthboundKeeper{ @@ -64,10 +67,10 @@ func DumpOVNNorthbound(ctx context.Context, cli *ovnutil.OvnNbCtl) (*OVNNorthbou return keeper, nil } -func ovnCreateArgs(irow ovnutil.IRow, idRef string) []string { +func ovnCreateArgs(irow types.IRow, idRef string) []string { args := append([]string{ - "--", "--id=@" + idRef, "create", irow.OvnTableName(), - }, irow.OvnArgs()...) + "--", "--id=@" + idRef, "create", irow.OvsdbTableName(), + }, irow.OvsdbCmdArgs()...) return args } @@ -77,18 +80,18 @@ func (keeper *OVNNorthboundKeeper) ClaimVpc(ctx context.Context, vpc *agentmodel ocVersion = fmt.Sprintf("%s.%d", vpc.UpdatedAt, vpc.UpdateVersion) ) - vpcLr := &ovnutil.LogicalRouter{ + vpcLr := &ovn_nb.LogicalRouter{ Name: vpcLrName(vpc.Id), } - vpcHostLs := &ovnutil.LogicalSwitch{ + vpcHostLs := &ovn_nb.LogicalSwitch{ Name: vpcHostLsName(vpc.Id), } - vpcRhp := &ovnutil.LogicalRouterPort{ + vpcRhp := &ovn_nb.LogicalRouterPort{ Name: vpcRhpName(vpc.Id), Mac: apis.VpcMappedGatewayMac, Networks: []string{fmt.Sprintf("%s/%d", apis.VpcMappedGatewayIP(), apis.VpcMappedIPMask)}, } - vpcHrp := &ovnutil.LogicalSwitchPort{ + vpcHrp := &ovn_nb.LogicalSwitchPort{ Name: vpcHrpName(vpc.Id), Type: "router", Addresses: []string{"router"}, @@ -121,15 +124,15 @@ func (keeper *OVNNorthboundKeeper) ClaimNetwork(ctx context.Context, network *ag mdMac = mac.HashMac(network.Id, "md") mdIp = "169.254.169.254" ) - netLs := &ovnutil.LogicalSwitch{ + netLs := &ovn_nb.LogicalSwitch{ Name: netLsName(network.Id), } - netRnp := &ovnutil.LogicalRouterPort{ + netRnp := &ovn_nb.LogicalRouterPort{ Name: netRnpName(network.Id), Mac: rpMac, Networks: []string{fmt.Sprintf("%s/%d", network.GuestGateway, network.GuestIpMask)}, } - netNrp := &ovnutil.LogicalSwitchPort{ + netNrp := &ovn_nb.LogicalSwitchPort{ Name: netNrpName(network.Id), Type: "router", Addresses: []string{"router"}, @@ -137,7 +140,7 @@ func (keeper *OVNNorthboundKeeper) ClaimNetwork(ctx context.Context, network *ag "router-port": netRnpName(network.Id), }, } - netMdp := &ovnutil.LogicalSwitchPort{ + netMdp := &ovn_nb.LogicalSwitchPort{ Name: netMdpName(network.Id), Type: "localport", Addresses: []string{fmt.Sprintf("%s %s", mdMac, mdIp)}, @@ -146,7 +149,7 @@ func (keeper *OVNNorthboundKeeper) ClaimNetwork(ctx context.Context, network *ag mdIp, "0.0.0.0", "0.0.0.0/0", network.GuestGateway, } - dhcpopts := &ovnutil.DHCPOptions{ + dhcpopts := &ovn_nb.DHCPOptions{ Cidr: fmt.Sprintf("%s/%d", network.GuestIpStart, network.GuestIpMask), Options: map[string]string{ "server_id": network.GuestGateway, @@ -193,16 +196,16 @@ func (keeper *OVNNorthboundKeeper) ClaimVpcHost(ctx context.Context, vpc *agentm var ( ocVersion = fmt.Sprintf("%s.%d", host.UpdatedAt, host.UpdateVersion) ) - vpcHostLsp := &ovnutil.LogicalSwitchPort{ + vpcHostLsp := &ovn_nb.LogicalSwitchPort{ Name: vpcHostLspName(vpc.Id, host.Id), Addresses: []string{fmt.Sprintf("%s %s", mac.HashMac(host.Id), host.OvnMappedIpAddr)}, } if m := keeper.DB.LogicalSwitchPort.FindOneMatchNonZeros(vpcHostLsp); m != nil { - m.OvnSetExternalIds(externalKeyOcVersion, ocVersion) + m.SetExternalId(externalKeyOcVersion, ocVersion) return nil } else { args := []string{ - "--bare", "--columns=_uuid", "find", vpcHostLsp.OvnTableName(), + "--bare", "--columns=_uuid", "find", vpcHostLsp.OvsdbTableName(), fmt.Sprintf("name=%q", vpcHostLsp.Name), } res := keeper.cli.Must(ctx, "find vpcHostLsp", args) @@ -230,13 +233,13 @@ func (keeper *OVNNorthboundKeeper) ClaimGuestnetwork(ctx context.Context, guestn ) { - dhcpOptQuery := &ovnutil.DHCPOptions{ + dhcpOptQuery := &ovn_nb.DHCPOptions{ ExternalIds: map[string]string{ externalKeyOcRef: guestnetwork.NetworkId, }, } if m := keeper.DB.DHCPOptions.FindOneMatchNonZeros(dhcpOptQuery); m != nil { - dhcpOpt = m.OvnUuid() + dhcpOpt = m.OvsdbUuid() } else { args := []string{ "--bare", "--columns=_uuid", "find", "DHCP_Options", @@ -250,7 +253,7 @@ func (keeper *OVNNorthboundKeeper) ClaimGuestnetwork(ctx context.Context, guestn } } - gnp := &ovnutil.LogicalSwitchPort{ + gnp := &ovn_nb.LogicalSwitchPort{ Name: gnpName(guestnetwork.NetworkId, guestnetwork.Ifname), Addresses: []string{fmt.Sprintf("%s %s", guestnetwork.MacAddr, guestnetwork.IpAddr)}, PortSecurity: []string{fmt.Sprintf("%s %s/%d", guestnetwork.MacAddr, guestnetwork.IpAddr, guestnetwork.Network.GuestIpMask)}, @@ -258,7 +261,7 @@ func (keeper *OVNNorthboundKeeper) ClaimGuestnetwork(ctx context.Context, guestn } gnrPolicy := "src-ip" - gnr := &ovnutil.LogicalRouterStaticRoute{ + gnr := &ovn_nb.LogicalRouterStaticRoute{ Policy: &gnrPolicy, IpPrefix: guestnetwork.IpAddr + "/32", Nexthop: host.OvnMappedIpAddr, @@ -283,7 +286,7 @@ func (keeper *OVNNorthboundKeeper) ClaimGuestnetwork(ctx context.Context, guestn func (keeper *OVNNorthboundKeeper) Mark(ctx context.Context) { db := &keeper.DB - itbls := []ovnutil.ITable{ + itbls := []types.ITable{ &db.LogicalSwitch, &db.LogicalSwitchPort, &db.LogicalRouter, @@ -293,7 +296,7 @@ func (keeper *OVNNorthboundKeeper) Mark(ctx context.Context) { } for _, itbl := range itbls { for _, irow := range itbl.Rows() { - irow.OvnRemoveExternalIds(externalKeyOcVersion) + irow.RemoveExternalId(externalKeyOcVersion) } } } @@ -301,17 +304,17 @@ func (keeper *OVNNorthboundKeeper) Mark(ctx context.Context) { func (keeper *OVNNorthboundKeeper) Sweep(ctx context.Context) error { db := &keeper.DB // isRoot=false tables at the end - itbls := []ovnutil.ITable{ + itbls := []types.ITable{ &db.LogicalSwitchPort, &db.LogicalRouterPort, &db.LogicalSwitch, &db.LogicalRouter, &db.DHCPOptions, } - var irows []ovnutil.IRow + var irows []types.IRow for _, itbl := range itbls { for _, irow := range itbl.Rows() { - _, ok := irow.OvnGetExternalIds(externalKeyOcVersion) + _, ok := irow.GetExternalId(externalKeyOcVersion) if !ok { irows = append(irows, irow) } @@ -325,14 +328,14 @@ func (keeper *OVNNorthboundKeeper) Sweep(ctx context.Context) error { { var args []string for _, irow := range db.LogicalRouterStaticRoute.Rows() { - _, ok := irow.OvnGetExternalIds(externalKeyOcVersion) + _, ok := irow.GetExternalId(externalKeyOcVersion) if !ok { - ref, ok := irow.OvnGetExternalIds(externalKeyOcRef) + ref, ok := irow.GetExternalId(externalKeyOcRef) if ok { parts := strings.SplitN(ref, "/", 4) if len(parts) == 4 { vpcId := parts[1] - args = append(args, "--", "remove", "Logical_Router", vpcLrName(vpcId), "static_routes", irow.OvnUuid()) + args = append(args, "--", "remove", "Logical_Router", vpcLrName(vpcId), "static_routes", irow.OvsdbUuid()) } } } diff --git a/pkg/vpcagent/ovnutil/ovn_nbctl.go b/pkg/vpcagent/ovnutil/ovn_nbctl.go index f9039c7bcf..0d34e8ce4c 100644 --- a/pkg/vpcagent/ovnutil/ovn_nbctl.go +++ b/pkg/vpcagent/ovnutil/ovn_nbctl.go @@ -23,6 +23,8 @@ import ( "time" "yunion.io/x/log" + "yunion.io/x/ovsdb/schema/ovn_nb" + "yunion.io/x/ovsdb/types" "yunion.io/x/pkg/errors" ) @@ -138,12 +140,12 @@ func ovnNbctlArgsString(args []string) string { return s } -func OvnNbctlArgsDestroy(irows []IRow) []string { +func OvnNbctlArgsDestroy(irows []types.IRow) []string { sort.Slice(irows, func(i, j int) bool { ri := irows[i] rj := irows[j] - iri := ri.OvnIsRoot() - irj := rj.OvnIsRoot() + iri := ri.OvsdbIsRoot() + irj := rj.OvsdbIsRoot() if !iri && irj { return true } @@ -152,17 +154,17 @@ func OvnNbctlArgsDestroy(irows []IRow) []string { var args []string for _, irow := range irows { switch irow.(type) { - case *LogicalSwitchPort: - args = append(args, "--", "--if-exists", "lsp-del", irow.OvnUuid()) - case *LogicalRouterPort: - args = append(args, "--", "--if-exists", "lrp-del", irow.OvnUuid()) - case *LogicalRouterStaticRoute: + case *ovn_nb.LogicalSwitchPort: + args = append(args, "--", "--if-exists", "lsp-del", irow.OvsdbUuid()) + case *ovn_nb.LogicalRouterPort: + args = append(args, "--", "--if-exists", "lrp-del", irow.OvsdbUuid()) + case *ovn_nb.LogicalRouterStaticRoute: // find out vpc id/logical router from external_ids default: - if !irow.OvnIsRoot() { - panic(irow.OvnTableName()) + if !irow.OvsdbIsRoot() { + panic(irow.OvsdbTableName()) } - args = append(args, "--", "--if-exists", "destroy", irow.OvnTableName(), irow.OvnUuid()) + args = append(args, "--", "--if-exists", "destroy", irow.OvsdbTableName(), irow.OvsdbUuid()) } } return args From 654845fd498767a91ebd646f34fdfe3793ab038a Mon Sep 17 00:00:00 2001 From: Yousong Zhou Date: Wed, 29 Apr 2020 20:30:14 +0800 Subject: [PATCH 04/13] vpcagent: ovnutil: remove old generated code --- pkg/vpcagent/ovnutil/atomics_ensure.go | 774 ------- pkg/vpcagent/ovnutil/atomics_match.go | 990 --------- pkg/vpcagent/ovnutil/atomics_ovn_args.go | 425 ---- pkg/vpcagent/ovnutil/schema.go | 2440 ---------------------- pkg/vpcagent/ovnutil/schema_test.go | 47 - pkg/vpcagent/ovnutil/unmarshal.go | 61 - 6 files changed, 4737 deletions(-) delete mode 100644 pkg/vpcagent/ovnutil/atomics_ensure.go delete mode 100644 pkg/vpcagent/ovnutil/atomics_match.go delete mode 100644 pkg/vpcagent/ovnutil/atomics_ovn_args.go delete mode 100644 pkg/vpcagent/ovnutil/schema.go delete mode 100644 pkg/vpcagent/ovnutil/schema_test.go delete mode 100644 pkg/vpcagent/ovnutil/unmarshal.go diff --git a/pkg/vpcagent/ovnutil/atomics_ensure.go b/pkg/vpcagent/ovnutil/atomics_ensure.go deleted file mode 100644 index 966eb7fa93..0000000000 --- a/pkg/vpcagent/ovnutil/atomics_ensure.go +++ /dev/null @@ -1,774 +0,0 @@ -// Copyright 2019 Yunion -// -// 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 ovnutil - -import ( - "yunion.io/x/pkg/errors" -) - -const ( - ErrBadType = errors.Error("bad type") -) - -func panicErr(msg string) { - panic(errors.Wrap(ErrBadType, msg)) -} - -func panicErrf(fmtStr string, s ...interface{}) { - panic(errors.Wrapf(ErrBadType, fmtStr, s...)) -} - -func ensureTypedPair(val interface{}) (string, interface{}) { - arr, ok := val.([]interface{}) - if !ok { - panicErr("ensureTypedPair: not an array") - } - if len(arr) != 2 { - panicErrf("ensureTypedPair: length is %d, want 2", len(arr)) - } - typ, ok := arr[0].(string) - if !ok { - panicErr("ensureTypedPair: type not a string") - } - return typ, arr[1] -} - -func ensureTyped(val interface{}, typ string) interface{} { - gotTyp, r := ensureTypedPair(val) - if gotTyp != typ { - panicErrf("ensureMultiples: got %s, want %s", gotTyp, typ) - } - return r -} - -func ensureMultiples(val interface{}, typ string) []interface{} { - val = ensureTyped(val, typ) - mulVal, ok := val.([]interface{}) - if !ok { - panicErr("ensureMultiples: val is not an array") - } - return mulVal -} - -func probeEmpty(val interface{}) (r bool) { - defer func() { - recover() - }() - empty := ensureMultiples(val, "set") - if len(empty) != 0 { - return false - } - return true -} - -func ensureUuid(val interface{}) string { - val = ensureTyped(val, "uuid") - r, ok := val.(string) - if !ok { - panicErr("bad uuid value") - } - return r -} - -func ensureUuidMultiples(val interface{}) []string { - typ, val1 := ensureTypedPair(val) - if typ == "uuid" { - r, ok := val1.(string) - if !ok { - panicErr("uuid multiples: expect a string") - } - return []string{r} - } - if typ == "set" { - mulVal, ok := val1.([]interface{}) - if !ok { - panicErr("uuid multiples: expect an array") - } - if len(mulVal) == 0 { - return nil - } - r := make([]string, len(mulVal)) - for i, val := range mulVal { - r[i] = ensureUuid(val) - } - return r - } - panic("uuid multiple: unexpected type: " + typ) -} - -func ensureBoolean(val interface{}) bool { - if r, ok := val.(bool); ok { - return r - } - panic(ErrBadType) -} - -func ensureBooleanMultiples(val interface{}) []bool { - if ok := probeEmpty(val); ok { - return nil - } - if r, ok := val.(bool); ok { - return []bool{r} - } - mulVal := ensureMultiples(val, "set") - if len(mulVal) == 0 { - return nil - } - r := make([]bool, len(mulVal)) - for i, val := range mulVal { - r[i] = ensureBoolean(val) - } - return r -} - -func ensureBooleanOptional(val interface{}) *bool { - if ok := probeEmpty(val); ok { - return nil - } - r := ensureBoolean(val) - return &r -} - -func ensureMapBooleanUuid(val interface{}) map[bool]string { - mulVal := ensureMultiples(val, "map") - if len(mulVal) == 0 { - return nil - } - r := map[bool]string{} - for _, pairVal := range mulVal { - pair, ok := pairVal.([]interface{}) - if !ok { - panicErr("map: not an array") - } - if len(pair) != 2 { - panicErr("map: not a pair") - } - k := ensureBoolean(pair[0]) - v := ensureUuid(pair[1]) - r[k] = v - } - return r -} - -func ensureMapBooleanString(val interface{}) map[bool]string { - mulVal := ensureMultiples(val, "map") - if len(mulVal) == 0 { - return nil - } - r := map[bool]string{} - for _, pairVal := range mulVal { - pair, ok := pairVal.([]interface{}) - if !ok { - panicErr("map: not an array") - } - if len(pair) != 2 { - panicErr("map: not a pair") - } - k := ensureBoolean(pair[0]) - v := ensureString(pair[1]) - r[k] = v - } - return r -} - -func ensureMapBooleanInteger(val interface{}) map[bool]int64 { - mulVal := ensureMultiples(val, "map") - if len(mulVal) == 0 { - return nil - } - r := map[bool]int64{} - for _, pairVal := range mulVal { - pair, ok := pairVal.([]interface{}) - if !ok { - panicErr("map: not an array") - } - if len(pair) != 2 { - panicErr("map: not a pair") - } - k := ensureBoolean(pair[0]) - v := ensureInteger(pair[1]) - r[k] = v - } - return r -} - -func ensureMapBooleanBoolean(val interface{}) map[bool]bool { - mulVal := ensureMultiples(val, "map") - if len(mulVal) == 0 { - return nil - } - r := map[bool]bool{} - for _, pairVal := range mulVal { - pair, ok := pairVal.([]interface{}) - if !ok { - panicErr("map: not an array") - } - if len(pair) != 2 { - panicErr("map: not a pair") - } - k := ensureBoolean(pair[0]) - v := ensureBoolean(pair[1]) - r[k] = v - } - return r -} - -func ensureMapBooleanReal(val interface{}) map[bool]float64 { - mulVal := ensureMultiples(val, "map") - if len(mulVal) == 0 { - return nil - } - r := map[bool]float64{} - for _, pairVal := range mulVal { - pair, ok := pairVal.([]interface{}) - if !ok { - panicErr("map: not an array") - } - if len(pair) != 2 { - panicErr("map: not a pair") - } - k := ensureBoolean(pair[0]) - v := ensureReal(pair[1]) - r[k] = v - } - return r -} - -func ensureReal(val interface{}) float64 { - if r, ok := val.(float64); ok { - return r - } - panic(ErrBadType) -} - -func ensureRealMultiples(val interface{}) []float64 { - if ok := probeEmpty(val); ok { - return nil - } - if r, ok := val.(float64); ok { - return []float64{r} - } - mulVal := ensureMultiples(val, "set") - if len(mulVal) == 0 { - return nil - } - r := make([]float64, len(mulVal)) - for i, val := range mulVal { - r[i] = ensureReal(val) - } - return r -} - -func ensureRealOptional(val interface{}) *float64 { - if ok := probeEmpty(val); ok { - return nil - } - r := ensureReal(val) - return &r -} - -func ensureMapRealString(val interface{}) map[float64]string { - mulVal := ensureMultiples(val, "map") - if len(mulVal) == 0 { - return nil - } - r := map[float64]string{} - for _, pairVal := range mulVal { - pair, ok := pairVal.([]interface{}) - if !ok { - panicErr("map: not an array") - } - if len(pair) != 2 { - panicErr("map: not a pair") - } - k := ensureReal(pair[0]) - v := ensureString(pair[1]) - r[k] = v - } - return r -} - -func ensureMapRealInteger(val interface{}) map[float64]int64 { - mulVal := ensureMultiples(val, "map") - if len(mulVal) == 0 { - return nil - } - r := map[float64]int64{} - for _, pairVal := range mulVal { - pair, ok := pairVal.([]interface{}) - if !ok { - panicErr("map: not an array") - } - if len(pair) != 2 { - panicErr("map: not a pair") - } - k := ensureReal(pair[0]) - v := ensureInteger(pair[1]) - r[k] = v - } - return r -} - -func ensureMapRealBoolean(val interface{}) map[float64]bool { - mulVal := ensureMultiples(val, "map") - if len(mulVal) == 0 { - return nil - } - r := map[float64]bool{} - for _, pairVal := range mulVal { - pair, ok := pairVal.([]interface{}) - if !ok { - panicErr("map: not an array") - } - if len(pair) != 2 { - panicErr("map: not a pair") - } - k := ensureReal(pair[0]) - v := ensureBoolean(pair[1]) - r[k] = v - } - return r -} - -func ensureMapRealReal(val interface{}) map[float64]float64 { - mulVal := ensureMultiples(val, "map") - if len(mulVal) == 0 { - return nil - } - r := map[float64]float64{} - for _, pairVal := range mulVal { - pair, ok := pairVal.([]interface{}) - if !ok { - panicErr("map: not an array") - } - if len(pair) != 2 { - panicErr("map: not a pair") - } - k := ensureReal(pair[0]) - v := ensureReal(pair[1]) - r[k] = v - } - return r -} - -func ensureMapRealUuid(val interface{}) map[float64]string { - mulVal := ensureMultiples(val, "map") - if len(mulVal) == 0 { - return nil - } - r := map[float64]string{} - for _, pairVal := range mulVal { - pair, ok := pairVal.([]interface{}) - if !ok { - panicErr("map: not an array") - } - if len(pair) != 2 { - panicErr("map: not a pair") - } - k := ensureReal(pair[0]) - v := ensureUuid(pair[1]) - r[k] = v - } - return r -} - -func ensureUuidOptional(val interface{}) *string { - if ok := probeEmpty(val); ok { - return nil - } - r := ensureUuid(val) - return &r -} - -func ensureMapUuidReal(val interface{}) map[string]float64 { - mulVal := ensureMultiples(val, "map") - if len(mulVal) == 0 { - return nil - } - r := map[string]float64{} - for _, pairVal := range mulVal { - pair, ok := pairVal.([]interface{}) - if !ok { - panicErr("map: not an array") - } - if len(pair) != 2 { - panicErr("map: not a pair") - } - k := ensureUuid(pair[0]) - v := ensureReal(pair[1]) - r[k] = v - } - return r -} - -func ensureMapUuidUuid(val interface{}) map[string]string { - mulVal := ensureMultiples(val, "map") - if len(mulVal) == 0 { - return nil - } - r := map[string]string{} - for _, pairVal := range mulVal { - pair, ok := pairVal.([]interface{}) - if !ok { - panicErr("map: not an array") - } - if len(pair) != 2 { - panicErr("map: not a pair") - } - k := ensureUuid(pair[0]) - v := ensureUuid(pair[1]) - r[k] = v - } - return r -} - -func ensureMapUuidString(val interface{}) map[string]string { - mulVal := ensureMultiples(val, "map") - if len(mulVal) == 0 { - return nil - } - r := map[string]string{} - for _, pairVal := range mulVal { - pair, ok := pairVal.([]interface{}) - if !ok { - panicErr("map: not an array") - } - if len(pair) != 2 { - panicErr("map: not a pair") - } - k := ensureUuid(pair[0]) - v := ensureString(pair[1]) - r[k] = v - } - return r -} - -func ensureMapUuidInteger(val interface{}) map[string]int64 { - mulVal := ensureMultiples(val, "map") - if len(mulVal) == 0 { - return nil - } - r := map[string]int64{} - for _, pairVal := range mulVal { - pair, ok := pairVal.([]interface{}) - if !ok { - panicErr("map: not an array") - } - if len(pair) != 2 { - panicErr("map: not a pair") - } - k := ensureUuid(pair[0]) - v := ensureInteger(pair[1]) - r[k] = v - } - return r -} - -func ensureMapUuidBoolean(val interface{}) map[string]bool { - mulVal := ensureMultiples(val, "map") - if len(mulVal) == 0 { - return nil - } - r := map[string]bool{} - for _, pairVal := range mulVal { - pair, ok := pairVal.([]interface{}) - if !ok { - panicErr("map: not an array") - } - if len(pair) != 2 { - panicErr("map: not a pair") - } - k := ensureUuid(pair[0]) - v := ensureBoolean(pair[1]) - r[k] = v - } - return r -} - -func ensureString(val interface{}) string { - if r, ok := val.(string); ok { - return r - } - panic(ErrBadType) -} - -func ensureStringMultiples(val interface{}) []string { - if ok := probeEmpty(val); ok { - return nil - } - if r, ok := val.(string); ok { - return []string{r} - } - mulVal := ensureMultiples(val, "set") - if len(mulVal) == 0 { - return nil - } - r := make([]string, len(mulVal)) - for i, val := range mulVal { - r[i] = ensureString(val) - } - return r -} - -func ensureStringOptional(val interface{}) *string { - if ok := probeEmpty(val); ok { - return nil - } - r := ensureString(val) - return &r -} - -func ensureMapStringUuid(val interface{}) map[string]string { - mulVal := ensureMultiples(val, "map") - if len(mulVal) == 0 { - return nil - } - r := map[string]string{} - for _, pairVal := range mulVal { - pair, ok := pairVal.([]interface{}) - if !ok { - panicErr("map: not an array") - } - if len(pair) != 2 { - panicErr("map: not a pair") - } - k := ensureString(pair[0]) - v := ensureUuid(pair[1]) - r[k] = v - } - return r -} - -func ensureMapStringString(val interface{}) map[string]string { - mulVal := ensureMultiples(val, "map") - if len(mulVal) == 0 { - return nil - } - r := map[string]string{} - for _, pairVal := range mulVal { - pair, ok := pairVal.([]interface{}) - if !ok { - panicErr("map: not an array") - } - if len(pair) != 2 { - panicErr("map: not a pair") - } - k := ensureString(pair[0]) - v := ensureString(pair[1]) - r[k] = v - } - return r -} - -func ensureMapStringInteger(val interface{}) map[string]int64 { - mulVal := ensureMultiples(val, "map") - if len(mulVal) == 0 { - return nil - } - r := map[string]int64{} - for _, pairVal := range mulVal { - pair, ok := pairVal.([]interface{}) - if !ok { - panicErr("map: not an array") - } - if len(pair) != 2 { - panicErr("map: not a pair") - } - k := ensureString(pair[0]) - v := ensureInteger(pair[1]) - r[k] = v - } - return r -} - -func ensureMapStringBoolean(val interface{}) map[string]bool { - mulVal := ensureMultiples(val, "map") - if len(mulVal) == 0 { - return nil - } - r := map[string]bool{} - for _, pairVal := range mulVal { - pair, ok := pairVal.([]interface{}) - if !ok { - panicErr("map: not an array") - } - if len(pair) != 2 { - panicErr("map: not a pair") - } - k := ensureString(pair[0]) - v := ensureBoolean(pair[1]) - r[k] = v - } - return r -} - -func ensureMapStringReal(val interface{}) map[string]float64 { - mulVal := ensureMultiples(val, "map") - if len(mulVal) == 0 { - return nil - } - r := map[string]float64{} - for _, pairVal := range mulVal { - pair, ok := pairVal.([]interface{}) - if !ok { - panicErr("map: not an array") - } - if len(pair) != 2 { - panicErr("map: not a pair") - } - k := ensureString(pair[0]) - v := ensureReal(pair[1]) - r[k] = v - } - return r -} - -func ensureInteger(val interface{}) int64 { - if r, ok := val.(int64); ok { - return r - } - panic(ErrBadType) -} - -func ensureIntegerMultiples(val interface{}) []int64 { - if ok := probeEmpty(val); ok { - return nil - } - if r, ok := val.(int64); ok { - return []int64{r} - } - mulVal := ensureMultiples(val, "set") - if len(mulVal) == 0 { - return nil - } - r := make([]int64, len(mulVal)) - for i, val := range mulVal { - r[i] = ensureInteger(val) - } - return r -} - -func ensureIntegerOptional(val interface{}) *int64 { - if ok := probeEmpty(val); ok { - return nil - } - r := ensureInteger(val) - return &r -} - -func ensureMapIntegerReal(val interface{}) map[int64]float64 { - mulVal := ensureMultiples(val, "map") - if len(mulVal) == 0 { - return nil - } - r := map[int64]float64{} - for _, pairVal := range mulVal { - pair, ok := pairVal.([]interface{}) - if !ok { - panicErr("map: not an array") - } - if len(pair) != 2 { - panicErr("map: not a pair") - } - k := ensureInteger(pair[0]) - v := ensureReal(pair[1]) - r[k] = v - } - return r -} - -func ensureMapIntegerUuid(val interface{}) map[int64]string { - mulVal := ensureMultiples(val, "map") - if len(mulVal) == 0 { - return nil - } - r := map[int64]string{} - for _, pairVal := range mulVal { - pair, ok := pairVal.([]interface{}) - if !ok { - panicErr("map: not an array") - } - if len(pair) != 2 { - panicErr("map: not a pair") - } - k := ensureInteger(pair[0]) - v := ensureUuid(pair[1]) - r[k] = v - } - return r -} - -func ensureMapIntegerString(val interface{}) map[int64]string { - mulVal := ensureMultiples(val, "map") - if len(mulVal) == 0 { - return nil - } - r := map[int64]string{} - for _, pairVal := range mulVal { - pair, ok := pairVal.([]interface{}) - if !ok { - panicErr("map: not an array") - } - if len(pair) != 2 { - panicErr("map: not a pair") - } - k := ensureInteger(pair[0]) - v := ensureString(pair[1]) - r[k] = v - } - return r -} - -func ensureMapIntegerInteger(val interface{}) map[int64]int64 { - mulVal := ensureMultiples(val, "map") - if len(mulVal) == 0 { - return nil - } - r := map[int64]int64{} - for _, pairVal := range mulVal { - pair, ok := pairVal.([]interface{}) - if !ok { - panicErr("map: not an array") - } - if len(pair) != 2 { - panicErr("map: not a pair") - } - k := ensureInteger(pair[0]) - v := ensureInteger(pair[1]) - r[k] = v - } - return r -} - -func ensureMapIntegerBoolean(val interface{}) map[int64]bool { - mulVal := ensureMultiples(val, "map") - if len(mulVal) == 0 { - return nil - } - r := map[int64]bool{} - for _, pairVal := range mulVal { - pair, ok := pairVal.([]interface{}) - if !ok { - panicErr("map: not an array") - } - if len(pair) != 2 { - panicErr("map: not a pair") - } - k := ensureInteger(pair[0]) - v := ensureBoolean(pair[1]) - r[k] = v - } - return r -} diff --git a/pkg/vpcagent/ovnutil/atomics_match.go b/pkg/vpcagent/ovnutil/atomics_match.go deleted file mode 100644 index 13b6530e2a..0000000000 --- a/pkg/vpcagent/ovnutil/atomics_match.go +++ /dev/null @@ -1,990 +0,0 @@ -// Copyright 2019 Yunion -// -// 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 ovnutil - -func matchIntegerIfNonZero(a, b int64) bool { - var z int64 - if b == z { - return true - } - return matchInteger(a, b) -} - -func matchInteger(a, b int64) bool { - return a == b -} - -func matchIntegerOptionalIfNonZero(a, b *int64) bool { - if b == nil { - return true - } - return matchIntegerOptional(a, b) -} - -func matchIntegerOptional(a, b *int64) bool { - if a == nil && b == nil { - return true - } else if a != nil && b != nil { - return *a == *b - } - return false -} - -func matchIntegerMultiplesIfNonZero(a, b []int64) bool { - if b == nil { - return true - } - return matchIntegerMultiples(a, b) -} - -func matchIntegerMultiples(a, b []int64) bool { - if len(a) != len(b) { - return false - } - bCopy := make([]int64, len(b)) - copy(bCopy, b) - for _, elA := range a { - for i := len(bCopy) - 1; i >= 0; i-- { - elB := bCopy[i] - if elA == elB { - bCopy = append(bCopy[:i], bCopy[i+1:]...) - } - } - } - if len(bCopy) == 0 { - return true - } - return false -} - -func matchMapIntegerUuidIfNonZero(a, b map[int64]string) bool { - if b == nil { - return true - } - return matchMapIntegerUuid(a, b) -} - -func matchMapIntegerUuid(a, b map[int64]string) bool { - if len(a) != len(b) { - return false - } - bCopy := map[int64]string{} - for k, v := range b { - bCopy[k] = v - } - for aK, aV := range a { - if bV, ok := bCopy[aK]; !ok || aV != bV { - return false - } else { - delete(bCopy, aK) - } - } - if len(bCopy) == 0 { - return true - } - return false -} - -func matchMapIntegerStringIfNonZero(a, b map[int64]string) bool { - if b == nil { - return true - } - return matchMapIntegerString(a, b) -} - -func matchMapIntegerString(a, b map[int64]string) bool { - if len(a) != len(b) { - return false - } - bCopy := map[int64]string{} - for k, v := range b { - bCopy[k] = v - } - for aK, aV := range a { - if bV, ok := bCopy[aK]; !ok || aV != bV { - return false - } else { - delete(bCopy, aK) - } - } - if len(bCopy) == 0 { - return true - } - return false -} - -func matchMapIntegerIntegerIfNonZero(a, b map[int64]int64) bool { - if b == nil { - return true - } - return matchMapIntegerInteger(a, b) -} - -func matchMapIntegerInteger(a, b map[int64]int64) bool { - if len(a) != len(b) { - return false - } - bCopy := map[int64]int64{} - for k, v := range b { - bCopy[k] = v - } - for aK, aV := range a { - if bV, ok := bCopy[aK]; !ok || aV != bV { - return false - } else { - delete(bCopy, aK) - } - } - if len(bCopy) == 0 { - return true - } - return false -} - -func matchMapIntegerBooleanIfNonZero(a, b map[int64]bool) bool { - if b == nil { - return true - } - return matchMapIntegerBoolean(a, b) -} - -func matchMapIntegerBoolean(a, b map[int64]bool) bool { - if len(a) != len(b) { - return false - } - bCopy := map[int64]bool{} - for k, v := range b { - bCopy[k] = v - } - for aK, aV := range a { - if bV, ok := bCopy[aK]; !ok || aV != bV { - return false - } else { - delete(bCopy, aK) - } - } - if len(bCopy) == 0 { - return true - } - return false -} - -func matchMapIntegerRealIfNonZero(a, b map[int64]float64) bool { - if b == nil { - return true - } - return matchMapIntegerReal(a, b) -} - -func matchMapIntegerReal(a, b map[int64]float64) bool { - if len(a) != len(b) { - return false - } - bCopy := map[int64]float64{} - for k, v := range b { - bCopy[k] = v - } - for aK, aV := range a { - if bV, ok := bCopy[aK]; !ok || aV != bV { - return false - } else { - delete(bCopy, aK) - } - } - if len(bCopy) == 0 { - return true - } - return false -} - -func matchBooleanIfNonZero(a, b bool) bool { - var z bool - if b == z { - return true - } - return matchBoolean(a, b) -} - -func matchBoolean(a, b bool) bool { - return a == b -} - -func matchBooleanOptionalIfNonZero(a, b *bool) bool { - if b == nil { - return true - } - return matchBooleanOptional(a, b) -} - -func matchBooleanOptional(a, b *bool) bool { - if a == nil && b == nil { - return true - } else if a != nil && b != nil { - return *a == *b - } - return false -} - -func matchBooleanMultiplesIfNonZero(a, b []bool) bool { - if b == nil { - return true - } - return matchBooleanMultiples(a, b) -} - -func matchBooleanMultiples(a, b []bool) bool { - if len(a) != len(b) { - return false - } - bCopy := make([]bool, len(b)) - copy(bCopy, b) - for _, elA := range a { - for i := len(bCopy) - 1; i >= 0; i-- { - elB := bCopy[i] - if elA == elB { - bCopy = append(bCopy[:i], bCopy[i+1:]...) - } - } - } - if len(bCopy) == 0 { - return true - } - return false -} - -func matchMapBooleanBooleanIfNonZero(a, b map[bool]bool) bool { - if b == nil { - return true - } - return matchMapBooleanBoolean(a, b) -} - -func matchMapBooleanBoolean(a, b map[bool]bool) bool { - if len(a) != len(b) { - return false - } - bCopy := map[bool]bool{} - for k, v := range b { - bCopy[k] = v - } - for aK, aV := range a { - if bV, ok := bCopy[aK]; !ok || aV != bV { - return false - } else { - delete(bCopy, aK) - } - } - if len(bCopy) == 0 { - return true - } - return false -} - -func matchMapBooleanRealIfNonZero(a, b map[bool]float64) bool { - if b == nil { - return true - } - return matchMapBooleanReal(a, b) -} - -func matchMapBooleanReal(a, b map[bool]float64) bool { - if len(a) != len(b) { - return false - } - bCopy := map[bool]float64{} - for k, v := range b { - bCopy[k] = v - } - for aK, aV := range a { - if bV, ok := bCopy[aK]; !ok || aV != bV { - return false - } else { - delete(bCopy, aK) - } - } - if len(bCopy) == 0 { - return true - } - return false -} - -func matchMapBooleanUuidIfNonZero(a, b map[bool]string) bool { - if b == nil { - return true - } - return matchMapBooleanUuid(a, b) -} - -func matchMapBooleanUuid(a, b map[bool]string) bool { - if len(a) != len(b) { - return false - } - bCopy := map[bool]string{} - for k, v := range b { - bCopy[k] = v - } - for aK, aV := range a { - if bV, ok := bCopy[aK]; !ok || aV != bV { - return false - } else { - delete(bCopy, aK) - } - } - if len(bCopy) == 0 { - return true - } - return false -} - -func matchMapBooleanStringIfNonZero(a, b map[bool]string) bool { - if b == nil { - return true - } - return matchMapBooleanString(a, b) -} - -func matchMapBooleanString(a, b map[bool]string) bool { - if len(a) != len(b) { - return false - } - bCopy := map[bool]string{} - for k, v := range b { - bCopy[k] = v - } - for aK, aV := range a { - if bV, ok := bCopy[aK]; !ok || aV != bV { - return false - } else { - delete(bCopy, aK) - } - } - if len(bCopy) == 0 { - return true - } - return false -} - -func matchMapBooleanIntegerIfNonZero(a, b map[bool]int64) bool { - if b == nil { - return true - } - return matchMapBooleanInteger(a, b) -} - -func matchMapBooleanInteger(a, b map[bool]int64) bool { - if len(a) != len(b) { - return false - } - bCopy := map[bool]int64{} - for k, v := range b { - bCopy[k] = v - } - for aK, aV := range a { - if bV, ok := bCopy[aK]; !ok || aV != bV { - return false - } else { - delete(bCopy, aK) - } - } - if len(bCopy) == 0 { - return true - } - return false -} - -func matchRealIfNonZero(a, b float64) bool { - var z float64 - if b == z { - return true - } - return matchReal(a, b) -} - -func matchReal(a, b float64) bool { - return a == b -} - -func matchRealOptionalIfNonZero(a, b *float64) bool { - if b == nil { - return true - } - return matchRealOptional(a, b) -} - -func matchRealOptional(a, b *float64) bool { - if a == nil && b == nil { - return true - } else if a != nil && b != nil { - return *a == *b - } - return false -} - -func matchRealMultiplesIfNonZero(a, b []float64) bool { - if b == nil { - return true - } - return matchRealMultiples(a, b) -} - -func matchRealMultiples(a, b []float64) bool { - if len(a) != len(b) { - return false - } - bCopy := make([]float64, len(b)) - copy(bCopy, b) - for _, elA := range a { - for i := len(bCopy) - 1; i >= 0; i-- { - elB := bCopy[i] - if elA == elB { - bCopy = append(bCopy[:i], bCopy[i+1:]...) - } - } - } - if len(bCopy) == 0 { - return true - } - return false -} - -func matchMapRealUuidIfNonZero(a, b map[float64]string) bool { - if b == nil { - return true - } - return matchMapRealUuid(a, b) -} - -func matchMapRealUuid(a, b map[float64]string) bool { - if len(a) != len(b) { - return false - } - bCopy := map[float64]string{} - for k, v := range b { - bCopy[k] = v - } - for aK, aV := range a { - if bV, ok := bCopy[aK]; !ok || aV != bV { - return false - } else { - delete(bCopy, aK) - } - } - if len(bCopy) == 0 { - return true - } - return false -} - -func matchMapRealStringIfNonZero(a, b map[float64]string) bool { - if b == nil { - return true - } - return matchMapRealString(a, b) -} - -func matchMapRealString(a, b map[float64]string) bool { - if len(a) != len(b) { - return false - } - bCopy := map[float64]string{} - for k, v := range b { - bCopy[k] = v - } - for aK, aV := range a { - if bV, ok := bCopy[aK]; !ok || aV != bV { - return false - } else { - delete(bCopy, aK) - } - } - if len(bCopy) == 0 { - return true - } - return false -} - -func matchMapRealIntegerIfNonZero(a, b map[float64]int64) bool { - if b == nil { - return true - } - return matchMapRealInteger(a, b) -} - -func matchMapRealInteger(a, b map[float64]int64) bool { - if len(a) != len(b) { - return false - } - bCopy := map[float64]int64{} - for k, v := range b { - bCopy[k] = v - } - for aK, aV := range a { - if bV, ok := bCopy[aK]; !ok || aV != bV { - return false - } else { - delete(bCopy, aK) - } - } - if len(bCopy) == 0 { - return true - } - return false -} - -func matchMapRealBooleanIfNonZero(a, b map[float64]bool) bool { - if b == nil { - return true - } - return matchMapRealBoolean(a, b) -} - -func matchMapRealBoolean(a, b map[float64]bool) bool { - if len(a) != len(b) { - return false - } - bCopy := map[float64]bool{} - for k, v := range b { - bCopy[k] = v - } - for aK, aV := range a { - if bV, ok := bCopy[aK]; !ok || aV != bV { - return false - } else { - delete(bCopy, aK) - } - } - if len(bCopy) == 0 { - return true - } - return false -} - -func matchMapRealRealIfNonZero(a, b map[float64]float64) bool { - if b == nil { - return true - } - return matchMapRealReal(a, b) -} - -func matchMapRealReal(a, b map[float64]float64) bool { - if len(a) != len(b) { - return false - } - bCopy := map[float64]float64{} - for k, v := range b { - bCopy[k] = v - } - for aK, aV := range a { - if bV, ok := bCopy[aK]; !ok || aV != bV { - return false - } else { - delete(bCopy, aK) - } - } - if len(bCopy) == 0 { - return true - } - return false -} - -func matchUuidIfNonZero(a, b string) bool { - var z string - if b == z { - return true - } - return matchUuid(a, b) -} - -func matchUuid(a, b string) bool { - return a == b -} - -func matchUuidOptionalIfNonZero(a, b *string) bool { - if b == nil { - return true - } - return matchUuidOptional(a, b) -} - -func matchUuidOptional(a, b *string) bool { - if a == nil && b == nil { - return true - } else if a != nil && b != nil { - return *a == *b - } - return false -} - -func matchUuidMultiplesIfNonZero(a, b []string) bool { - if b == nil { - return true - } - return matchUuidMultiples(a, b) -} - -func matchUuidMultiples(a, b []string) bool { - if len(a) != len(b) { - return false - } - bCopy := make([]string, len(b)) - copy(bCopy, b) - for _, elA := range a { - for i := len(bCopy) - 1; i >= 0; i-- { - elB := bCopy[i] - if elA == elB { - bCopy = append(bCopy[:i], bCopy[i+1:]...) - } - } - } - if len(bCopy) == 0 { - return true - } - return false -} - -func matchMapUuidBooleanIfNonZero(a, b map[string]bool) bool { - if b == nil { - return true - } - return matchMapUuidBoolean(a, b) -} - -func matchMapUuidBoolean(a, b map[string]bool) bool { - if len(a) != len(b) { - return false - } - bCopy := map[string]bool{} - for k, v := range b { - bCopy[k] = v - } - for aK, aV := range a { - if bV, ok := bCopy[aK]; !ok || aV != bV { - return false - } else { - delete(bCopy, aK) - } - } - if len(bCopy) == 0 { - return true - } - return false -} - -func matchMapUuidRealIfNonZero(a, b map[string]float64) bool { - if b == nil { - return true - } - return matchMapUuidReal(a, b) -} - -func matchMapUuidReal(a, b map[string]float64) bool { - if len(a) != len(b) { - return false - } - bCopy := map[string]float64{} - for k, v := range b { - bCopy[k] = v - } - for aK, aV := range a { - if bV, ok := bCopy[aK]; !ok || aV != bV { - return false - } else { - delete(bCopy, aK) - } - } - if len(bCopy) == 0 { - return true - } - return false -} - -func matchMapUuidUuidIfNonZero(a, b map[string]string) bool { - if b == nil { - return true - } - return matchMapUuidUuid(a, b) -} - -func matchMapUuidUuid(a, b map[string]string) bool { - if len(a) != len(b) { - return false - } - bCopy := map[string]string{} - for k, v := range b { - bCopy[k] = v - } - for aK, aV := range a { - if bV, ok := bCopy[aK]; !ok || aV != bV { - return false - } else { - delete(bCopy, aK) - } - } - if len(bCopy) == 0 { - return true - } - return false -} - -func matchMapUuidStringIfNonZero(a, b map[string]string) bool { - if b == nil { - return true - } - return matchMapUuidString(a, b) -} - -func matchMapUuidString(a, b map[string]string) bool { - if len(a) != len(b) { - return false - } - bCopy := map[string]string{} - for k, v := range b { - bCopy[k] = v - } - for aK, aV := range a { - if bV, ok := bCopy[aK]; !ok || aV != bV { - return false - } else { - delete(bCopy, aK) - } - } - if len(bCopy) == 0 { - return true - } - return false -} - -func matchMapUuidIntegerIfNonZero(a, b map[string]int64) bool { - if b == nil { - return true - } - return matchMapUuidInteger(a, b) -} - -func matchMapUuidInteger(a, b map[string]int64) bool { - if len(a) != len(b) { - return false - } - bCopy := map[string]int64{} - for k, v := range b { - bCopy[k] = v - } - for aK, aV := range a { - if bV, ok := bCopy[aK]; !ok || aV != bV { - return false - } else { - delete(bCopy, aK) - } - } - if len(bCopy) == 0 { - return true - } - return false -} - -func matchStringIfNonZero(a, b string) bool { - var z string - if b == z { - return true - } - return matchString(a, b) -} - -func matchString(a, b string) bool { - return a == b -} - -func matchStringOptionalIfNonZero(a, b *string) bool { - if b == nil { - return true - } - return matchStringOptional(a, b) -} - -func matchStringOptional(a, b *string) bool { - if a == nil && b == nil { - return true - } else if a != nil && b != nil { - return *a == *b - } - return false -} - -func matchStringMultiplesIfNonZero(a, b []string) bool { - if b == nil { - return true - } - return matchStringMultiples(a, b) -} - -func matchStringMultiples(a, b []string) bool { - if len(a) != len(b) { - return false - } - bCopy := make([]string, len(b)) - copy(bCopy, b) - for _, elA := range a { - for i := len(bCopy) - 1; i >= 0; i-- { - elB := bCopy[i] - if elA == elB { - bCopy = append(bCopy[:i], bCopy[i+1:]...) - } - } - } - if len(bCopy) == 0 { - return true - } - return false -} - -func matchMapStringStringIfNonZero(a, b map[string]string) bool { - if b == nil { - return true - } - return matchMapStringString(a, b) -} - -func matchMapStringString(a, b map[string]string) bool { - if len(a) != len(b) { - return false - } - bCopy := map[string]string{} - for k, v := range b { - bCopy[k] = v - } - for aK, aV := range a { - if bV, ok := bCopy[aK]; !ok || aV != bV { - return false - } else { - delete(bCopy, aK) - } - } - if len(bCopy) == 0 { - return true - } - return false -} - -func matchMapStringIntegerIfNonZero(a, b map[string]int64) bool { - if b == nil { - return true - } - return matchMapStringInteger(a, b) -} - -func matchMapStringInteger(a, b map[string]int64) bool { - if len(a) != len(b) { - return false - } - bCopy := map[string]int64{} - for k, v := range b { - bCopy[k] = v - } - for aK, aV := range a { - if bV, ok := bCopy[aK]; !ok || aV != bV { - return false - } else { - delete(bCopy, aK) - } - } - if len(bCopy) == 0 { - return true - } - return false -} - -func matchMapStringBooleanIfNonZero(a, b map[string]bool) bool { - if b == nil { - return true - } - return matchMapStringBoolean(a, b) -} - -func matchMapStringBoolean(a, b map[string]bool) bool { - if len(a) != len(b) { - return false - } - bCopy := map[string]bool{} - for k, v := range b { - bCopy[k] = v - } - for aK, aV := range a { - if bV, ok := bCopy[aK]; !ok || aV != bV { - return false - } else { - delete(bCopy, aK) - } - } - if len(bCopy) == 0 { - return true - } - return false -} - -func matchMapStringRealIfNonZero(a, b map[string]float64) bool { - if b == nil { - return true - } - return matchMapStringReal(a, b) -} - -func matchMapStringReal(a, b map[string]float64) bool { - if len(a) != len(b) { - return false - } - bCopy := map[string]float64{} - for k, v := range b { - bCopy[k] = v - } - for aK, aV := range a { - if bV, ok := bCopy[aK]; !ok || aV != bV { - return false - } else { - delete(bCopy, aK) - } - } - if len(bCopy) == 0 { - return true - } - return false -} - -func matchMapStringUuidIfNonZero(a, b map[string]string) bool { - if b == nil { - return true - } - return matchMapStringUuid(a, b) -} - -func matchMapStringUuid(a, b map[string]string) bool { - if len(a) != len(b) { - return false - } - bCopy := map[string]string{} - for k, v := range b { - bCopy[k] = v - } - for aK, aV := range a { - if bV, ok := bCopy[aK]; !ok || aV != bV { - return false - } else { - delete(bCopy, aK) - } - } - if len(bCopy) == 0 { - return true - } - return false -} diff --git a/pkg/vpcagent/ovnutil/atomics_ovn_args.go b/pkg/vpcagent/ovnutil/atomics_ovn_args.go deleted file mode 100644 index d5f17221a5..0000000000 --- a/pkg/vpcagent/ovnutil/atomics_ovn_args.go +++ /dev/null @@ -1,425 +0,0 @@ -// Copyright 2019 Yunion -// -// 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 ovnutil - -import ( - "fmt" - "strings" -) - -func OvnArgUuid(a string) string { - return fmt.Sprintf("%s", a) -} -func OvnArgsUuid(field string, a string) []string { - return []string{fmt.Sprintf("%s=%s", field, OvnArgUuid(a))} -} - -func OvnArgsUuidOptional(field string, a *string) []string { - if a == nil { - return nil - } - return OvnArgsUuid(field, *a) -} - -func OvnArgsUuidMultiples(field string, a []string) []string { - if len(a) == 0 { - return nil - } - elArgs := make([]string, len(a)) - for i, el := range a { - elArgs[i] = OvnArgUuid(el) - } - arg := fmt.Sprintf("%s=[%s]", field, strings.Join(elArgs, ",")) - return []string{arg} -} - -func OvnArgsMapUuidReal(field string, a map[string]float64) []string { - if len(a) == 0 { - return nil - } - r := make([]string, 0, len(a)) - for aK, aV := range a { - r = append(r, fmt.Sprintf("%s:%s=%s", field, OvnArgUuid(aK), OvnArgReal(aV))) - } - return r -} - -func OvnArgsMapUuidUuid(field string, a map[string]string) []string { - if len(a) == 0 { - return nil - } - r := make([]string, 0, len(a)) - for aK, aV := range a { - r = append(r, fmt.Sprintf("%s:%s=%s", field, OvnArgUuid(aK), OvnArgUuid(aV))) - } - return r -} - -func OvnArgsMapUuidString(field string, a map[string]string) []string { - if len(a) == 0 { - return nil - } - r := make([]string, 0, len(a)) - for aK, aV := range a { - r = append(r, fmt.Sprintf("%s:%s=%s", field, OvnArgUuid(aK), OvnArgString(aV))) - } - return r -} - -func OvnArgsMapUuidInteger(field string, a map[string]int64) []string { - if len(a) == 0 { - return nil - } - r := make([]string, 0, len(a)) - for aK, aV := range a { - r = append(r, fmt.Sprintf("%s:%s=%s", field, OvnArgUuid(aK), OvnArgInteger(aV))) - } - return r -} - -func OvnArgsMapUuidBoolean(field string, a map[string]bool) []string { - if len(a) == 0 { - return nil - } - r := make([]string, 0, len(a)) - for aK, aV := range a { - r = append(r, fmt.Sprintf("%s:%s=%s", field, OvnArgUuid(aK), OvnArgBoolean(aV))) - } - return r -} - -func OvnArgString(a string) string { - return fmt.Sprintf("%q", a) -} -func OvnArgsString(field string, a string) []string { - return []string{fmt.Sprintf("%s=%s", field, OvnArgString(a))} -} - -func OvnArgsStringOptional(field string, a *string) []string { - if a == nil { - return nil - } - return OvnArgsString(field, *a) -} - -func OvnArgsStringMultiples(field string, a []string) []string { - if len(a) == 0 { - return nil - } - elArgs := make([]string, len(a)) - for i, el := range a { - elArgs[i] = OvnArgString(el) - } - arg := fmt.Sprintf("%s=[%s]", field, strings.Join(elArgs, ",")) - return []string{arg} -} - -func OvnArgsMapStringUuid(field string, a map[string]string) []string { - if len(a) == 0 { - return nil - } - r := make([]string, 0, len(a)) - for aK, aV := range a { - r = append(r, fmt.Sprintf("%s:%s=%s", field, OvnArgString(aK), OvnArgUuid(aV))) - } - return r -} - -func OvnArgsMapStringString(field string, a map[string]string) []string { - if len(a) == 0 { - return nil - } - r := make([]string, 0, len(a)) - for aK, aV := range a { - r = append(r, fmt.Sprintf("%s:%s=%s", field, OvnArgString(aK), OvnArgString(aV))) - } - return r -} - -func OvnArgsMapStringInteger(field string, a map[string]int64) []string { - if len(a) == 0 { - return nil - } - r := make([]string, 0, len(a)) - for aK, aV := range a { - r = append(r, fmt.Sprintf("%s:%s=%s", field, OvnArgString(aK), OvnArgInteger(aV))) - } - return r -} - -func OvnArgsMapStringBoolean(field string, a map[string]bool) []string { - if len(a) == 0 { - return nil - } - r := make([]string, 0, len(a)) - for aK, aV := range a { - r = append(r, fmt.Sprintf("%s:%s=%s", field, OvnArgString(aK), OvnArgBoolean(aV))) - } - return r -} - -func OvnArgsMapStringReal(field string, a map[string]float64) []string { - if len(a) == 0 { - return nil - } - r := make([]string, 0, len(a)) - for aK, aV := range a { - r = append(r, fmt.Sprintf("%s:%s=%s", field, OvnArgString(aK), OvnArgReal(aV))) - } - return r -} - -func OvnArgInteger(a int64) string { - return fmt.Sprintf("%d", a) -} -func OvnArgsInteger(field string, a int64) []string { - return []string{fmt.Sprintf("%s=%s", field, OvnArgInteger(a))} -} - -func OvnArgsIntegerOptional(field string, a *int64) []string { - if a == nil { - return nil - } - return OvnArgsInteger(field, *a) -} - -func OvnArgsIntegerMultiples(field string, a []int64) []string { - if len(a) == 0 { - return nil - } - elArgs := make([]string, len(a)) - for i, el := range a { - elArgs[i] = OvnArgInteger(el) - } - arg := fmt.Sprintf("%s=[%s]", field, strings.Join(elArgs, ",")) - return []string{arg} -} - -func OvnArgsMapIntegerUuid(field string, a map[int64]string) []string { - if len(a) == 0 { - return nil - } - r := make([]string, 0, len(a)) - for aK, aV := range a { - r = append(r, fmt.Sprintf("%s:%s=%s", field, OvnArgInteger(aK), OvnArgUuid(aV))) - } - return r -} - -func OvnArgsMapIntegerString(field string, a map[int64]string) []string { - if len(a) == 0 { - return nil - } - r := make([]string, 0, len(a)) - for aK, aV := range a { - r = append(r, fmt.Sprintf("%s:%s=%s", field, OvnArgInteger(aK), OvnArgString(aV))) - } - return r -} - -func OvnArgsMapIntegerInteger(field string, a map[int64]int64) []string { - if len(a) == 0 { - return nil - } - r := make([]string, 0, len(a)) - for aK, aV := range a { - r = append(r, fmt.Sprintf("%s:%s=%s", field, OvnArgInteger(aK), OvnArgInteger(aV))) - } - return r -} - -func OvnArgsMapIntegerBoolean(field string, a map[int64]bool) []string { - if len(a) == 0 { - return nil - } - r := make([]string, 0, len(a)) - for aK, aV := range a { - r = append(r, fmt.Sprintf("%s:%s=%s", field, OvnArgInteger(aK), OvnArgBoolean(aV))) - } - return r -} - -func OvnArgsMapIntegerReal(field string, a map[int64]float64) []string { - if len(a) == 0 { - return nil - } - r := make([]string, 0, len(a)) - for aK, aV := range a { - r = append(r, fmt.Sprintf("%s:%s=%s", field, OvnArgInteger(aK), OvnArgReal(aV))) - } - return r -} - -func OvnArgBoolean(a bool) string { - return fmt.Sprintf("%v", a) -} -func OvnArgsBoolean(field string, a bool) []string { - return []string{fmt.Sprintf("%s=%s", field, OvnArgBoolean(a))} -} - -func OvnArgsBooleanOptional(field string, a *bool) []string { - if a == nil { - return nil - } - return OvnArgsBoolean(field, *a) -} - -func OvnArgsBooleanMultiples(field string, a []bool) []string { - if len(a) == 0 { - return nil - } - elArgs := make([]string, len(a)) - for i, el := range a { - elArgs[i] = OvnArgBoolean(el) - } - arg := fmt.Sprintf("%s=[%s]", field, strings.Join(elArgs, ",")) - return []string{arg} -} - -func OvnArgsMapBooleanUuid(field string, a map[bool]string) []string { - if len(a) == 0 { - return nil - } - r := make([]string, 0, len(a)) - for aK, aV := range a { - r = append(r, fmt.Sprintf("%s:%s=%s", field, OvnArgBoolean(aK), OvnArgUuid(aV))) - } - return r -} - -func OvnArgsMapBooleanString(field string, a map[bool]string) []string { - if len(a) == 0 { - return nil - } - r := make([]string, 0, len(a)) - for aK, aV := range a { - r = append(r, fmt.Sprintf("%s:%s=%s", field, OvnArgBoolean(aK), OvnArgString(aV))) - } - return r -} - -func OvnArgsMapBooleanInteger(field string, a map[bool]int64) []string { - if len(a) == 0 { - return nil - } - r := make([]string, 0, len(a)) - for aK, aV := range a { - r = append(r, fmt.Sprintf("%s:%s=%s", field, OvnArgBoolean(aK), OvnArgInteger(aV))) - } - return r -} - -func OvnArgsMapBooleanBoolean(field string, a map[bool]bool) []string { - if len(a) == 0 { - return nil - } - r := make([]string, 0, len(a)) - for aK, aV := range a { - r = append(r, fmt.Sprintf("%s:%s=%s", field, OvnArgBoolean(aK), OvnArgBoolean(aV))) - } - return r -} - -func OvnArgsMapBooleanReal(field string, a map[bool]float64) []string { - if len(a) == 0 { - return nil - } - r := make([]string, 0, len(a)) - for aK, aV := range a { - r = append(r, fmt.Sprintf("%s:%s=%s", field, OvnArgBoolean(aK), OvnArgReal(aV))) - } - return r -} - -func OvnArgReal(a float64) string { - return fmt.Sprintf("%f", a) -} -func OvnArgsReal(field string, a float64) []string { - return []string{fmt.Sprintf("%s=%s", field, OvnArgReal(a))} -} - -func OvnArgsRealOptional(field string, a *float64) []string { - if a == nil { - return nil - } - return OvnArgsReal(field, *a) -} - -func OvnArgsRealMultiples(field string, a []float64) []string { - if len(a) == 0 { - return nil - } - elArgs := make([]string, len(a)) - for i, el := range a { - elArgs[i] = OvnArgReal(el) - } - arg := fmt.Sprintf("%s=[%s]", field, strings.Join(elArgs, ",")) - return []string{arg} -} - -func OvnArgsMapRealReal(field string, a map[float64]float64) []string { - if len(a) == 0 { - return nil - } - r := make([]string, 0, len(a)) - for aK, aV := range a { - r = append(r, fmt.Sprintf("%s:%s=%s", field, OvnArgReal(aK), OvnArgReal(aV))) - } - return r -} - -func OvnArgsMapRealUuid(field string, a map[float64]string) []string { - if len(a) == 0 { - return nil - } - r := make([]string, 0, len(a)) - for aK, aV := range a { - r = append(r, fmt.Sprintf("%s:%s=%s", field, OvnArgReal(aK), OvnArgUuid(aV))) - } - return r -} - -func OvnArgsMapRealString(field string, a map[float64]string) []string { - if len(a) == 0 { - return nil - } - r := make([]string, 0, len(a)) - for aK, aV := range a { - r = append(r, fmt.Sprintf("%s:%s=%s", field, OvnArgReal(aK), OvnArgString(aV))) - } - return r -} - -func OvnArgsMapRealInteger(field string, a map[float64]int64) []string { - if len(a) == 0 { - return nil - } - r := make([]string, 0, len(a)) - for aK, aV := range a { - r = append(r, fmt.Sprintf("%s:%s=%s", field, OvnArgReal(aK), OvnArgInteger(aV))) - } - return r -} - -func OvnArgsMapRealBoolean(field string, a map[float64]bool) []string { - if len(a) == 0 { - return nil - } - r := make([]string, 0, len(a)) - for aK, aV := range a { - r = append(r, fmt.Sprintf("%s:%s=%s", field, OvnArgReal(aK), OvnArgBoolean(aV))) - } - return r -} diff --git a/pkg/vpcagent/ovnutil/schema.go b/pkg/vpcagent/ovnutil/schema.go deleted file mode 100644 index f9f97a0f1d..0000000000 --- a/pkg/vpcagent/ovnutil/schema.go +++ /dev/null @@ -1,2440 +0,0 @@ -// Copyright 2019 Yunion -// -// 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 ovnutil - -import ( - "fmt" - - "yunion.io/x/pkg/errors" -) - -const ( - ErrUnknownColumn = errors.Error("unknown column") - ErrUnknownTable = errors.Error("unknown table") -) - -type IRow interface { - SetColumn(name string, val interface{}) error - OvnTableName() string - OvnIsRoot() bool - OvnUuid() string - OvnArgs() []string - OvnSetExternalIds(k, v string) - OvnGetExternalIds(k string) (string, bool) - OvnRemoveExternalIds(k string) (string, bool) -} - -type ITable interface { - NewRow() IRow - Rows() []IRow - OvnTableName() string - OvnIsRoot() bool -} - -type OVNNorthbound struct { - SSL SSLTable - NBGlobal NBGlobalTable - LogicalRouterStaticRoute LogicalRouterStaticRouteTable - LoadBalancer LoadBalancerTable - Connection ConnectionTable - DNS DNSTable - QoS QoSTable - LogicalRouter LogicalRouterTable - LogicalSwitchPort LogicalSwitchPortTable - GatewayChassis GatewayChassisTable - LogicalRouterPort LogicalRouterPortTable - LogicalSwitch LogicalSwitchTable - NAT NATTable - DHCPOptions DHCPOptionsTable - ACL ACLTable - AddressSet AddressSetTable -} - -func (db *OVNNorthbound) FindOneMatchNonZeros(irow IRow) (r IRow) { - switch row := irow.(type) { - case *GatewayChassis: - if r := db.GatewayChassis.FindOneMatchNonZeros(row); r != nil { - return r - } - return nil - case *LogicalRouterPort: - if r := db.LogicalRouterPort.FindOneMatchNonZeros(row); r != nil { - return r - } - return nil - case *LogicalSwitch: - if r := db.LogicalSwitch.FindOneMatchNonZeros(row); r != nil { - return r - } - return nil - case *NAT: - if r := db.NAT.FindOneMatchNonZeros(row); r != nil { - return r - } - return nil - case *DHCPOptions: - if r := db.DHCPOptions.FindOneMatchNonZeros(row); r != nil { - return r - } - return nil - case *ACL: - if r := db.ACL.FindOneMatchNonZeros(row); r != nil { - return r - } - return nil - case *AddressSet: - if r := db.AddressSet.FindOneMatchNonZeros(row); r != nil { - return r - } - return nil - case *SSL: - if r := db.SSL.FindOneMatchNonZeros(row); r != nil { - return r - } - return nil - case *NBGlobal: - if r := db.NBGlobal.FindOneMatchNonZeros(row); r != nil { - return r - } - return nil - case *LogicalRouterStaticRoute: - if r := db.LogicalRouterStaticRoute.FindOneMatchNonZeros(row); r != nil { - return r - } - return nil - case *LoadBalancer: - if r := db.LoadBalancer.FindOneMatchNonZeros(row); r != nil { - return r - } - return nil - case *Connection: - if r := db.Connection.FindOneMatchNonZeros(row); r != nil { - return r - } - return nil - case *DNS: - if r := db.DNS.FindOneMatchNonZeros(row); r != nil { - return r - } - return nil - case *QoS: - if r := db.QoS.FindOneMatchNonZeros(row); r != nil { - return r - } - return nil - case *LogicalRouter: - if r := db.LogicalRouter.FindOneMatchNonZeros(row); r != nil { - return r - } - return nil - case *LogicalSwitchPort: - if r := db.LogicalSwitchPort.FindOneMatchNonZeros(row); r != nil { - return r - } - return nil - } - panic(ErrUnknownTable) -} - -type LogicalRouter struct { - Uuid string `json:"-"` - Enabled *bool `json:"enabled"` - Nat []string `json:"nat"` - LoadBalancer []string `json:"load_balancer"` - Options map[string]string `json:"options"` - ExternalIds map[string]string `json:"external_ids"` - Name string `json:"name"` - Ports []string `json:"ports"` - StaticRoutes []string `json:"static_routes"` -} - -func (row *LogicalRouter) OvnTableName() string { - return "Logical_Router" -} - -func (row *LogicalRouter) OvnIsRoot() bool { - return true -} - -func (row *LogicalRouter) OvnUuid() string { - return row.Uuid -} - -func (row *LogicalRouter) OvnSetExternalIds(k, v string) { - if row.ExternalIds == nil { - row.ExternalIds = map[string]string{} - } - row.ExternalIds[k] = v -} - -func (row *LogicalRouter) OvnGetExternalIds(k string) (string, bool) { - if row.ExternalIds == nil { - return "", false - } - r, ok := row.ExternalIds[k] - return r, ok -} - -func (row *LogicalRouter) OvnRemoveExternalIds(k string) (string, bool) { - if row.ExternalIds == nil { - return "", false - } - r, ok := row.ExternalIds[k] - if ok { - delete(row.ExternalIds, k) - } - return r, ok -} - -func (row *LogicalRouter) SetColumn(name string, val interface{}) (err error) { - defer func() { - if panicErr := recover(); panicErr != nil { - err = errors.Wrapf(panicErr.(error), "%s: %#v", name, fmt.Sprintf("%#v", val)) - } - }() - switch name { - case "_uuid": - row.Uuid = ensureUuid(val) - case "nat": - row.Nat = ensureUuidMultiples(val) - case "load_balancer": - row.LoadBalancer = ensureUuidMultiples(val) - case "options": - row.Options = ensureMapStringString(val) - case "external_ids": - row.ExternalIds = ensureMapStringString(val) - case "name": - row.Name = ensureString(val) - case "ports": - row.Ports = ensureUuidMultiples(val) - case "static_routes": - row.StaticRoutes = ensureUuidMultiples(val) - case "enabled": - row.Enabled = ensureBooleanOptional(val) - default: - panic(ErrUnknownColumn) - } - return -} - -func (row *LogicalRouter) MatchNonZeros(row1 *LogicalRouter) bool { - if !matchBooleanOptionalIfNonZero(row.Enabled, row1.Enabled) { - return false - } - if !matchUuidMultiplesIfNonZero(row.Nat, row1.Nat) { - return false - } - if !matchUuidMultiplesIfNonZero(row.LoadBalancer, row1.LoadBalancer) { - return false - } - if !matchMapStringStringIfNonZero(row.Options, row1.Options) { - return false - } - if !matchMapStringStringIfNonZero(row.ExternalIds, row1.ExternalIds) { - return false - } - if !matchStringIfNonZero(row.Name, row1.Name) { - return false - } - if !matchUuidMultiplesIfNonZero(row.Ports, row1.Ports) { - return false - } - if !matchUuidMultiplesIfNonZero(row.StaticRoutes, row1.StaticRoutes) { - return false - } - return true -} - -func (row *LogicalRouter) OvnArgs() []string { - r := []string{} - r = append(r, OvnArgsUuidMultiples("nat", row.Nat)...) - r = append(r, OvnArgsUuidMultiples("load_balancer", row.LoadBalancer)...) - r = append(r, OvnArgsMapStringString("options", row.Options)...) - r = append(r, OvnArgsMapStringString("external_ids", row.ExternalIds)...) - r = append(r, OvnArgsString("name", row.Name)...) - r = append(r, OvnArgsUuidMultiples("ports", row.Ports)...) - r = append(r, OvnArgsUuidMultiples("static_routes", row.StaticRoutes)...) - r = append(r, OvnArgsBooleanOptional("enabled", row.Enabled)...) - return r -} - -type LogicalRouterTable []LogicalRouter - -func (tbl *LogicalRouterTable) NewRow() IRow { - *tbl = append(*tbl, LogicalRouter{}) - return &(*tbl)[len(*tbl)-1] -} - -func (tbl LogicalRouterTable) OvnTableName() string { - return "Logical_Router" -} - -func (tbl LogicalRouterTable) OvnIsRoot() bool { - return true -} - -func (tbl LogicalRouterTable) Rows() []IRow { - r := make([]IRow, len(tbl)) - for i := range tbl { - r[i] = &tbl[i] - } - return r -} - -func (tbl LogicalRouterTable) FindOneMatchNonZeros(row1 *LogicalRouter) *LogicalRouter { - for i := range tbl { - row := &tbl[i] - if row.MatchNonZeros(row1) { - return row - } - } - return nil -} - -type LogicalSwitchPort struct { - Uuid string `json:"-"` - PortSecurity []string `json:"port_security"` - Type string `json:"type"` - Dhcpv4Options *string `json:"dhcpv4_options"` - Options map[string]string `json:"options"` - Dhcpv6Options *string `json:"dhcpv6_options"` - ParentName *string `json:"parent_name"` - Enabled *bool `json:"enabled"` - ExternalIds map[string]string `json:"external_ids"` - TagRequest *int64 `json:"tag_request"` - Addresses []string `json:"addresses"` - DynamicAddresses *string `json:"dynamic_addresses"` - Name string `json:"name"` - Tag *int64 `json:"tag"` - Up *bool `json:"up"` -} - -func (row *LogicalSwitchPort) OvnTableName() string { - return "Logical_Switch_Port" -} - -func (row *LogicalSwitchPort) OvnIsRoot() bool { - return false -} - -func (row *LogicalSwitchPort) OvnUuid() string { - return row.Uuid -} - -func (row *LogicalSwitchPort) OvnSetExternalIds(k, v string) { - if row.ExternalIds == nil { - row.ExternalIds = map[string]string{} - } - row.ExternalIds[k] = v -} - -func (row *LogicalSwitchPort) OvnGetExternalIds(k string) (string, bool) { - if row.ExternalIds == nil { - return "", false - } - r, ok := row.ExternalIds[k] - return r, ok -} - -func (row *LogicalSwitchPort) OvnRemoveExternalIds(k string) (string, bool) { - if row.ExternalIds == nil { - return "", false - } - r, ok := row.ExternalIds[k] - if ok { - delete(row.ExternalIds, k) - } - return r, ok -} - -func (row *LogicalSwitchPort) SetColumn(name string, val interface{}) (err error) { - defer func() { - if panicErr := recover(); panicErr != nil { - err = errors.Wrapf(panicErr.(error), "%s: %#v", name, fmt.Sprintf("%#v", val)) - } - }() - switch name { - case "_uuid": - row.Uuid = ensureUuid(val) - case "port_security": - row.PortSecurity = ensureStringMultiples(val) - case "type": - row.Type = ensureString(val) - case "dhcpv4_options": - row.Dhcpv4Options = ensureUuidOptional(val) - case "options": - row.Options = ensureMapStringString(val) - case "dhcpv6_options": - row.Dhcpv6Options = ensureUuidOptional(val) - case "parent_name": - row.ParentName = ensureStringOptional(val) - case "enabled": - row.Enabled = ensureBooleanOptional(val) - case "name": - row.Name = ensureString(val) - case "tag": - row.Tag = ensureIntegerOptional(val) - case "up": - row.Up = ensureBooleanOptional(val) - case "external_ids": - row.ExternalIds = ensureMapStringString(val) - case "tag_request": - row.TagRequest = ensureIntegerOptional(val) - case "addresses": - row.Addresses = ensureStringMultiples(val) - case "dynamic_addresses": - row.DynamicAddresses = ensureStringOptional(val) - default: - panic(ErrUnknownColumn) - } - return -} - -func (row *LogicalSwitchPort) MatchNonZeros(row1 *LogicalSwitchPort) bool { - if !matchStringMultiplesIfNonZero(row.Addresses, row1.Addresses) { - return false - } - if !matchStringOptionalIfNonZero(row.DynamicAddresses, row1.DynamicAddresses) { - return false - } - if !matchStringIfNonZero(row.Name, row1.Name) { - return false - } - if !matchIntegerOptionalIfNonZero(row.Tag, row1.Tag) { - return false - } - if !matchBooleanOptionalIfNonZero(row.Up, row1.Up) { - return false - } - if !matchMapStringStringIfNonZero(row.ExternalIds, row1.ExternalIds) { - return false - } - if !matchIntegerOptionalIfNonZero(row.TagRequest, row1.TagRequest) { - return false - } - if !matchUuidOptionalIfNonZero(row.Dhcpv4Options, row1.Dhcpv4Options) { - return false - } - if !matchStringMultiplesIfNonZero(row.PortSecurity, row1.PortSecurity) { - return false - } - if !matchStringIfNonZero(row.Type, row1.Type) { - return false - } - if !matchStringOptionalIfNonZero(row.ParentName, row1.ParentName) { - return false - } - if !matchBooleanOptionalIfNonZero(row.Enabled, row1.Enabled) { - return false - } - if !matchMapStringStringIfNonZero(row.Options, row1.Options) { - return false - } - if !matchUuidOptionalIfNonZero(row.Dhcpv6Options, row1.Dhcpv6Options) { - return false - } - return true -} - -func (row *LogicalSwitchPort) OvnArgs() []string { - r := []string{} - r = append(r, OvnArgsStringMultiples("port_security", row.PortSecurity)...) - r = append(r, OvnArgsString("type", row.Type)...) - r = append(r, OvnArgsUuidOptional("dhcpv4_options", row.Dhcpv4Options)...) - r = append(r, OvnArgsMapStringString("options", row.Options)...) - r = append(r, OvnArgsUuidOptional("dhcpv6_options", row.Dhcpv6Options)...) - r = append(r, OvnArgsStringOptional("parent_name", row.ParentName)...) - r = append(r, OvnArgsBooleanOptional("enabled", row.Enabled)...) - r = append(r, OvnArgsIntegerOptional("tag", row.Tag)...) - r = append(r, OvnArgsBooleanOptional("up", row.Up)...) - r = append(r, OvnArgsMapStringString("external_ids", row.ExternalIds)...) - r = append(r, OvnArgsIntegerOptional("tag_request", row.TagRequest)...) - r = append(r, OvnArgsStringMultiples("addresses", row.Addresses)...) - r = append(r, OvnArgsStringOptional("dynamic_addresses", row.DynamicAddresses)...) - r = append(r, OvnArgsString("name", row.Name)...) - return r -} - -type LogicalSwitchPortTable []LogicalSwitchPort - -func (tbl *LogicalSwitchPortTable) NewRow() IRow { - *tbl = append(*tbl, LogicalSwitchPort{}) - return &(*tbl)[len(*tbl)-1] -} - -func (tbl LogicalSwitchPortTable) OvnTableName() string { - return "Logical_Switch_Port" -} - -func (tbl LogicalSwitchPortTable) OvnIsRoot() bool { - return false -} - -func (tbl LogicalSwitchPortTable) Rows() []IRow { - r := make([]IRow, len(tbl)) - for i := range tbl { - r[i] = &tbl[i] - } - return r -} - -func (tbl LogicalSwitchPortTable) FindOneMatchNonZeros(row1 *LogicalSwitchPort) *LogicalSwitchPort { - for i := range tbl { - row := &tbl[i] - if row.MatchNonZeros(row1) { - return row - } - } - return nil -} - -type Connection struct { - Uuid string `json:"-"` - Status map[string]string `json:"status"` - Target string `json:"target"` - MaxBackoff *int64 `json:"max_backoff"` - InactivityProbe *int64 `json:"inactivity_probe"` - OtherConfig map[string]string `json:"other_config"` - ExternalIds map[string]string `json:"external_ids"` - IsConnected bool `json:"is_connected"` -} - -func (row *Connection) OvnTableName() string { - return "Connection" -} - -func (row *Connection) OvnIsRoot() bool { - return false -} - -func (row *Connection) OvnUuid() string { - return row.Uuid -} - -func (row *Connection) OvnSetExternalIds(k, v string) { - if row.ExternalIds == nil { - row.ExternalIds = map[string]string{} - } - row.ExternalIds[k] = v -} - -func (row *Connection) OvnGetExternalIds(k string) (string, bool) { - if row.ExternalIds == nil { - return "", false - } - r, ok := row.ExternalIds[k] - return r, ok -} - -func (row *Connection) OvnRemoveExternalIds(k string) (string, bool) { - if row.ExternalIds == nil { - return "", false - } - r, ok := row.ExternalIds[k] - if ok { - delete(row.ExternalIds, k) - } - return r, ok -} - -func (row *Connection) SetColumn(name string, val interface{}) (err error) { - defer func() { - if panicErr := recover(); panicErr != nil { - err = errors.Wrapf(panicErr.(error), "%s: %#v", name, fmt.Sprintf("%#v", val)) - } - }() - switch name { - case "_uuid": - row.Uuid = ensureUuid(val) - case "target": - row.Target = ensureString(val) - case "max_backoff": - row.MaxBackoff = ensureIntegerOptional(val) - case "inactivity_probe": - row.InactivityProbe = ensureIntegerOptional(val) - case "other_config": - row.OtherConfig = ensureMapStringString(val) - case "external_ids": - row.ExternalIds = ensureMapStringString(val) - case "is_connected": - row.IsConnected = ensureBoolean(val) - case "status": - row.Status = ensureMapStringString(val) - default: - panic(ErrUnknownColumn) - } - return -} - -func (row *Connection) MatchNonZeros(row1 *Connection) bool { - if !matchMapStringStringIfNonZero(row.ExternalIds, row1.ExternalIds) { - return false - } - if !matchBooleanIfNonZero(row.IsConnected, row1.IsConnected) { - return false - } - if !matchMapStringStringIfNonZero(row.Status, row1.Status) { - return false - } - if !matchStringIfNonZero(row.Target, row1.Target) { - return false - } - if !matchIntegerOptionalIfNonZero(row.MaxBackoff, row1.MaxBackoff) { - return false - } - if !matchIntegerOptionalIfNonZero(row.InactivityProbe, row1.InactivityProbe) { - return false - } - if !matchMapStringStringIfNonZero(row.OtherConfig, row1.OtherConfig) { - return false - } - return true -} - -func (row *Connection) OvnArgs() []string { - r := []string{} - r = append(r, OvnArgsBoolean("is_connected", row.IsConnected)...) - r = append(r, OvnArgsMapStringString("status", row.Status)...) - r = append(r, OvnArgsString("target", row.Target)...) - r = append(r, OvnArgsIntegerOptional("max_backoff", row.MaxBackoff)...) - r = append(r, OvnArgsIntegerOptional("inactivity_probe", row.InactivityProbe)...) - r = append(r, OvnArgsMapStringString("other_config", row.OtherConfig)...) - r = append(r, OvnArgsMapStringString("external_ids", row.ExternalIds)...) - return r -} - -type ConnectionTable []Connection - -func (tbl *ConnectionTable) NewRow() IRow { - *tbl = append(*tbl, Connection{}) - return &(*tbl)[len(*tbl)-1] -} - -func (tbl ConnectionTable) OvnTableName() string { - return "Connection" -} - -func (tbl ConnectionTable) OvnIsRoot() bool { - return false -} - -func (tbl ConnectionTable) Rows() []IRow { - r := make([]IRow, len(tbl)) - for i := range tbl { - r[i] = &tbl[i] - } - return r -} - -func (tbl ConnectionTable) FindOneMatchNonZeros(row1 *Connection) *Connection { - for i := range tbl { - row := &tbl[i] - if row.MatchNonZeros(row1) { - return row - } - } - return nil -} - -type DNS struct { - Uuid string `json:"-"` - Records map[string]string `json:"records"` - ExternalIds map[string]string `json:"external_ids"` -} - -func (row *DNS) OvnTableName() string { - return "DNS" -} - -func (row *DNS) OvnIsRoot() bool { - return true -} - -func (row *DNS) OvnUuid() string { - return row.Uuid -} - -func (row *DNS) OvnSetExternalIds(k, v string) { - if row.ExternalIds == nil { - row.ExternalIds = map[string]string{} - } - row.ExternalIds[k] = v -} - -func (row *DNS) OvnGetExternalIds(k string) (string, bool) { - if row.ExternalIds == nil { - return "", false - } - r, ok := row.ExternalIds[k] - return r, ok -} - -func (row *DNS) OvnRemoveExternalIds(k string) (string, bool) { - if row.ExternalIds == nil { - return "", false - } - r, ok := row.ExternalIds[k] - if ok { - delete(row.ExternalIds, k) - } - return r, ok -} - -func (row *DNS) SetColumn(name string, val interface{}) (err error) { - defer func() { - if panicErr := recover(); panicErr != nil { - err = errors.Wrapf(panicErr.(error), "%s: %#v", name, fmt.Sprintf("%#v", val)) - } - }() - switch name { - case "_uuid": - row.Uuid = ensureUuid(val) - case "records": - row.Records = ensureMapStringString(val) - case "external_ids": - row.ExternalIds = ensureMapStringString(val) - default: - panic(ErrUnknownColumn) - } - return -} - -func (row *DNS) MatchNonZeros(row1 *DNS) bool { - if !matchMapStringStringIfNonZero(row.Records, row1.Records) { - return false - } - if !matchMapStringStringIfNonZero(row.ExternalIds, row1.ExternalIds) { - return false - } - return true -} - -func (row *DNS) OvnArgs() []string { - r := []string{} - r = append(r, OvnArgsMapStringString("records", row.Records)...) - r = append(r, OvnArgsMapStringString("external_ids", row.ExternalIds)...) - return r -} - -type DNSTable []DNS - -func (tbl *DNSTable) NewRow() IRow { - *tbl = append(*tbl, DNS{}) - return &(*tbl)[len(*tbl)-1] -} - -func (tbl DNSTable) OvnTableName() string { - return "DNS" -} - -func (tbl DNSTable) OvnIsRoot() bool { - return true -} - -func (tbl DNSTable) Rows() []IRow { - r := make([]IRow, len(tbl)) - for i := range tbl { - r[i] = &tbl[i] - } - return r -} - -func (tbl DNSTable) FindOneMatchNonZeros(row1 *DNS) *DNS { - for i := range tbl { - row := &tbl[i] - if row.MatchNonZeros(row1) { - return row - } - } - return nil -} - -type QoS struct { - Uuid string `json:"-"` - Match string `json:"match"` - Action map[string]int64 `json:"action"` - Bandwidth map[string]int64 `json:"bandwidth"` - ExternalIds map[string]string `json:"external_ids"` - Priority int64 `json:"priority"` - Direction string `json:"direction"` -} - -func (row *QoS) OvnTableName() string { - return "QoS" -} - -func (row *QoS) OvnIsRoot() bool { - return false -} - -func (row *QoS) OvnUuid() string { - return row.Uuid -} - -func (row *QoS) OvnSetExternalIds(k, v string) { - if row.ExternalIds == nil { - row.ExternalIds = map[string]string{} - } - row.ExternalIds[k] = v -} - -func (row *QoS) OvnGetExternalIds(k string) (string, bool) { - if row.ExternalIds == nil { - return "", false - } - r, ok := row.ExternalIds[k] - return r, ok -} - -func (row *QoS) OvnRemoveExternalIds(k string) (string, bool) { - if row.ExternalIds == nil { - return "", false - } - r, ok := row.ExternalIds[k] - if ok { - delete(row.ExternalIds, k) - } - return r, ok -} - -func (row *QoS) SetColumn(name string, val interface{}) (err error) { - defer func() { - if panicErr := recover(); panicErr != nil { - err = errors.Wrapf(panicErr.(error), "%s: %#v", name, fmt.Sprintf("%#v", val)) - } - }() - switch name { - case "_uuid": - row.Uuid = ensureUuid(val) - case "priority": - row.Priority = ensureInteger(val) - case "direction": - row.Direction = ensureString(val) - case "match": - row.Match = ensureString(val) - case "action": - row.Action = ensureMapStringInteger(val) - case "bandwidth": - row.Bandwidth = ensureMapStringInteger(val) - case "external_ids": - row.ExternalIds = ensureMapStringString(val) - default: - panic(ErrUnknownColumn) - } - return -} - -func (row *QoS) MatchNonZeros(row1 *QoS) bool { - if !matchStringIfNonZero(row.Match, row1.Match) { - return false - } - if !matchMapStringIntegerIfNonZero(row.Action, row1.Action) { - return false - } - if !matchMapStringIntegerIfNonZero(row.Bandwidth, row1.Bandwidth) { - return false - } - if !matchMapStringStringIfNonZero(row.ExternalIds, row1.ExternalIds) { - return false - } - if !matchIntegerIfNonZero(row.Priority, row1.Priority) { - return false - } - if !matchStringIfNonZero(row.Direction, row1.Direction) { - return false - } - return true -} - -func (row *QoS) OvnArgs() []string { - r := []string{} - r = append(r, OvnArgsInteger("priority", row.Priority)...) - r = append(r, OvnArgsString("direction", row.Direction)...) - r = append(r, OvnArgsString("match", row.Match)...) - r = append(r, OvnArgsMapStringInteger("action", row.Action)...) - r = append(r, OvnArgsMapStringInteger("bandwidth", row.Bandwidth)...) - r = append(r, OvnArgsMapStringString("external_ids", row.ExternalIds)...) - return r -} - -type QoSTable []QoS - -func (tbl *QoSTable) NewRow() IRow { - *tbl = append(*tbl, QoS{}) - return &(*tbl)[len(*tbl)-1] -} - -func (tbl QoSTable) OvnTableName() string { - return "QoS" -} - -func (tbl QoSTable) OvnIsRoot() bool { - return false -} - -func (tbl QoSTable) Rows() []IRow { - r := make([]IRow, len(tbl)) - for i := range tbl { - r[i] = &tbl[i] - } - return r -} - -func (tbl QoSTable) FindOneMatchNonZeros(row1 *QoS) *QoS { - for i := range tbl { - row := &tbl[i] - if row.MatchNonZeros(row1) { - return row - } - } - return nil -} - -type GatewayChassis struct { - Uuid string `json:"-"` - Name string `json:"name"` - ChassisName string `json:"chassis_name"` - Priority int64 `json:"priority"` - ExternalIds map[string]string `json:"external_ids"` - Options map[string]string `json:"options"` -} - -func (row *GatewayChassis) OvnTableName() string { - return "Gateway_Chassis" -} - -func (row *GatewayChassis) OvnIsRoot() bool { - return false -} - -func (row *GatewayChassis) OvnUuid() string { - return row.Uuid -} - -func (row *GatewayChassis) OvnSetExternalIds(k, v string) { - if row.ExternalIds == nil { - row.ExternalIds = map[string]string{} - } - row.ExternalIds[k] = v -} - -func (row *GatewayChassis) OvnGetExternalIds(k string) (string, bool) { - if row.ExternalIds == nil { - return "", false - } - r, ok := row.ExternalIds[k] - return r, ok -} - -func (row *GatewayChassis) OvnRemoveExternalIds(k string) (string, bool) { - if row.ExternalIds == nil { - return "", false - } - r, ok := row.ExternalIds[k] - if ok { - delete(row.ExternalIds, k) - } - return r, ok -} - -func (row *GatewayChassis) SetColumn(name string, val interface{}) (err error) { - defer func() { - if panicErr := recover(); panicErr != nil { - err = errors.Wrapf(panicErr.(error), "%s: %#v", name, fmt.Sprintf("%#v", val)) - } - }() - switch name { - case "_uuid": - row.Uuid = ensureUuid(val) - case "name": - row.Name = ensureString(val) - case "chassis_name": - row.ChassisName = ensureString(val) - case "priority": - row.Priority = ensureInteger(val) - case "external_ids": - row.ExternalIds = ensureMapStringString(val) - case "options": - row.Options = ensureMapStringString(val) - default: - panic(ErrUnknownColumn) - } - return -} - -func (row *GatewayChassis) MatchNonZeros(row1 *GatewayChassis) bool { - if !matchStringIfNonZero(row.ChassisName, row1.ChassisName) { - return false - } - if !matchIntegerIfNonZero(row.Priority, row1.Priority) { - return false - } - if !matchMapStringStringIfNonZero(row.ExternalIds, row1.ExternalIds) { - return false - } - if !matchMapStringStringIfNonZero(row.Options, row1.Options) { - return false - } - if !matchStringIfNonZero(row.Name, row1.Name) { - return false - } - return true -} - -func (row *GatewayChassis) OvnArgs() []string { - r := []string{} - r = append(r, OvnArgsString("name", row.Name)...) - r = append(r, OvnArgsString("chassis_name", row.ChassisName)...) - r = append(r, OvnArgsInteger("priority", row.Priority)...) - r = append(r, OvnArgsMapStringString("external_ids", row.ExternalIds)...) - r = append(r, OvnArgsMapStringString("options", row.Options)...) - return r -} - -type GatewayChassisTable []GatewayChassis - -func (tbl *GatewayChassisTable) NewRow() IRow { - *tbl = append(*tbl, GatewayChassis{}) - return &(*tbl)[len(*tbl)-1] -} - -func (tbl GatewayChassisTable) OvnTableName() string { - return "Gateway_Chassis" -} - -func (tbl GatewayChassisTable) OvnIsRoot() bool { - return false -} - -func (tbl GatewayChassisTable) Rows() []IRow { - r := make([]IRow, len(tbl)) - for i := range tbl { - r[i] = &tbl[i] - } - return r -} - -func (tbl GatewayChassisTable) FindOneMatchNonZeros(row1 *GatewayChassis) *GatewayChassis { - for i := range tbl { - row := &tbl[i] - if row.MatchNonZeros(row1) { - return row - } - } - return nil -} - -type LogicalRouterPort struct { - Uuid string `json:"-"` - Networks []string `json:"networks"` - ExternalIds map[string]string `json:"external_ids"` - Enabled *bool `json:"enabled"` - Peer *string `json:"peer"` - Ipv6RaConfigs map[string]string `json:"ipv6_ra_configs"` - GatewayChassis []string `json:"gateway_chassis"` - Mac string `json:"mac"` - Name string `json:"name"` - Options map[string]string `json:"options"` -} - -func (row *LogicalRouterPort) OvnTableName() string { - return "Logical_Router_Port" -} - -func (row *LogicalRouterPort) OvnIsRoot() bool { - return false -} - -func (row *LogicalRouterPort) OvnUuid() string { - return row.Uuid -} - -func (row *LogicalRouterPort) OvnSetExternalIds(k, v string) { - if row.ExternalIds == nil { - row.ExternalIds = map[string]string{} - } - row.ExternalIds[k] = v -} - -func (row *LogicalRouterPort) OvnGetExternalIds(k string) (string, bool) { - if row.ExternalIds == nil { - return "", false - } - r, ok := row.ExternalIds[k] - return r, ok -} - -func (row *LogicalRouterPort) OvnRemoveExternalIds(k string) (string, bool) { - if row.ExternalIds == nil { - return "", false - } - r, ok := row.ExternalIds[k] - if ok { - delete(row.ExternalIds, k) - } - return r, ok -} - -func (row *LogicalRouterPort) SetColumn(name string, val interface{}) (err error) { - defer func() { - if panicErr := recover(); panicErr != nil { - err = errors.Wrapf(panicErr.(error), "%s: %#v", name, fmt.Sprintf("%#v", val)) - } - }() - switch name { - case "_uuid": - row.Uuid = ensureUuid(val) - case "peer": - row.Peer = ensureStringOptional(val) - case "ipv6_ra_configs": - row.Ipv6RaConfigs = ensureMapStringString(val) - case "gateway_chassis": - row.GatewayChassis = ensureUuidMultiples(val) - case "mac": - row.Mac = ensureString(val) - case "name": - row.Name = ensureString(val) - case "options": - row.Options = ensureMapStringString(val) - case "networks": - row.Networks = ensureStringMultiples(val) - case "external_ids": - row.ExternalIds = ensureMapStringString(val) - case "enabled": - row.Enabled = ensureBooleanOptional(val) - default: - panic(ErrUnknownColumn) - } - return -} - -func (row *LogicalRouterPort) MatchNonZeros(row1 *LogicalRouterPort) bool { - if !matchMapStringStringIfNonZero(row.ExternalIds, row1.ExternalIds) { - return false - } - if !matchBooleanOptionalIfNonZero(row.Enabled, row1.Enabled) { - return false - } - if !matchStringMultiplesIfNonZero(row.Networks, row1.Networks) { - return false - } - if !matchMapStringStringIfNonZero(row.Ipv6RaConfigs, row1.Ipv6RaConfigs) { - return false - } - if !matchUuidMultiplesIfNonZero(row.GatewayChassis, row1.GatewayChassis) { - return false - } - if !matchStringIfNonZero(row.Mac, row1.Mac) { - return false - } - if !matchStringIfNonZero(row.Name, row1.Name) { - return false - } - if !matchMapStringStringIfNonZero(row.Options, row1.Options) { - return false - } - if !matchStringOptionalIfNonZero(row.Peer, row1.Peer) { - return false - } - return true -} - -func (row *LogicalRouterPort) OvnArgs() []string { - r := []string{} - r = append(r, OvnArgsString("mac", row.Mac)...) - r = append(r, OvnArgsString("name", row.Name)...) - r = append(r, OvnArgsMapStringString("options", row.Options)...) - r = append(r, OvnArgsStringOptional("peer", row.Peer)...) - r = append(r, OvnArgsMapStringString("ipv6_ra_configs", row.Ipv6RaConfigs)...) - r = append(r, OvnArgsUuidMultiples("gateway_chassis", row.GatewayChassis)...) - r = append(r, OvnArgsMapStringString("external_ids", row.ExternalIds)...) - r = append(r, OvnArgsBooleanOptional("enabled", row.Enabled)...) - r = append(r, OvnArgsStringMultiples("networks", row.Networks)...) - return r -} - -type LogicalRouterPortTable []LogicalRouterPort - -func (tbl *LogicalRouterPortTable) NewRow() IRow { - *tbl = append(*tbl, LogicalRouterPort{}) - return &(*tbl)[len(*tbl)-1] -} - -func (tbl LogicalRouterPortTable) OvnTableName() string { - return "Logical_Router_Port" -} - -func (tbl LogicalRouterPortTable) OvnIsRoot() bool { - return false -} - -func (tbl LogicalRouterPortTable) Rows() []IRow { - r := make([]IRow, len(tbl)) - for i := range tbl { - r[i] = &tbl[i] - } - return r -} - -func (tbl LogicalRouterPortTable) FindOneMatchNonZeros(row1 *LogicalRouterPort) *LogicalRouterPort { - for i := range tbl { - row := &tbl[i] - if row.MatchNonZeros(row1) { - return row - } - } - return nil -} - -type ACL struct { - Uuid string `json:"-"` - Direction string `json:"direction"` - Match string `json:"match"` - Action string `json:"action"` - Log bool `json:"log"` - Severity *string `json:"severity"` - ExternalIds map[string]string `json:"external_ids"` - Name *string `json:"name"` - Priority int64 `json:"priority"` -} - -func (row *ACL) OvnTableName() string { - return "ACL" -} - -func (row *ACL) OvnIsRoot() bool { - return false -} - -func (row *ACL) OvnUuid() string { - return row.Uuid -} - -func (row *ACL) OvnSetExternalIds(k, v string) { - if row.ExternalIds == nil { - row.ExternalIds = map[string]string{} - } - row.ExternalIds[k] = v -} - -func (row *ACL) OvnGetExternalIds(k string) (string, bool) { - if row.ExternalIds == nil { - return "", false - } - r, ok := row.ExternalIds[k] - return r, ok -} - -func (row *ACL) OvnRemoveExternalIds(k string) (string, bool) { - if row.ExternalIds == nil { - return "", false - } - r, ok := row.ExternalIds[k] - if ok { - delete(row.ExternalIds, k) - } - return r, ok -} - -func (row *ACL) SetColumn(name string, val interface{}) (err error) { - defer func() { - if panicErr := recover(); panicErr != nil { - err = errors.Wrapf(panicErr.(error), "%s: %#v", name, fmt.Sprintf("%#v", val)) - } - }() - switch name { - case "_uuid": - row.Uuid = ensureUuid(val) - case "match": - row.Match = ensureString(val) - case "action": - row.Action = ensureString(val) - case "log": - row.Log = ensureBoolean(val) - case "severity": - row.Severity = ensureStringOptional(val) - case "external_ids": - row.ExternalIds = ensureMapStringString(val) - case "name": - row.Name = ensureStringOptional(val) - case "priority": - row.Priority = ensureInteger(val) - case "direction": - row.Direction = ensureString(val) - default: - panic(ErrUnknownColumn) - } - return -} - -func (row *ACL) MatchNonZeros(row1 *ACL) bool { - if !matchStringIfNonZero(row.Action, row1.Action) { - return false - } - if !matchBooleanIfNonZero(row.Log, row1.Log) { - return false - } - if !matchStringOptionalIfNonZero(row.Severity, row1.Severity) { - return false - } - if !matchMapStringStringIfNonZero(row.ExternalIds, row1.ExternalIds) { - return false - } - if !matchStringOptionalIfNonZero(row.Name, row1.Name) { - return false - } - if !matchIntegerIfNonZero(row.Priority, row1.Priority) { - return false - } - if !matchStringIfNonZero(row.Direction, row1.Direction) { - return false - } - if !matchStringIfNonZero(row.Match, row1.Match) { - return false - } - return true -} - -func (row *ACL) OvnArgs() []string { - r := []string{} - r = append(r, OvnArgsStringOptional("name", row.Name)...) - r = append(r, OvnArgsInteger("priority", row.Priority)...) - r = append(r, OvnArgsString("direction", row.Direction)...) - r = append(r, OvnArgsString("match", row.Match)...) - r = append(r, OvnArgsString("action", row.Action)...) - r = append(r, OvnArgsBoolean("log", row.Log)...) - r = append(r, OvnArgsStringOptional("severity", row.Severity)...) - r = append(r, OvnArgsMapStringString("external_ids", row.ExternalIds)...) - return r -} - -type ACLTable []ACL - -func (tbl *ACLTable) NewRow() IRow { - *tbl = append(*tbl, ACL{}) - return &(*tbl)[len(*tbl)-1] -} - -func (tbl ACLTable) OvnTableName() string { - return "ACL" -} - -func (tbl ACLTable) OvnIsRoot() bool { - return false -} - -func (tbl ACLTable) Rows() []IRow { - r := make([]IRow, len(tbl)) - for i := range tbl { - r[i] = &tbl[i] - } - return r -} - -func (tbl ACLTable) FindOneMatchNonZeros(row1 *ACL) *ACL { - for i := range tbl { - row := &tbl[i] - if row.MatchNonZeros(row1) { - return row - } - } - return nil -} - -type AddressSet struct { - Uuid string `json:"-"` - Addresses []string `json:"addresses"` - ExternalIds map[string]string `json:"external_ids"` - Name string `json:"name"` -} - -func (row *AddressSet) OvnTableName() string { - return "Address_Set" -} - -func (row *AddressSet) OvnIsRoot() bool { - return true -} - -func (row *AddressSet) OvnUuid() string { - return row.Uuid -} - -func (row *AddressSet) OvnSetExternalIds(k, v string) { - if row.ExternalIds == nil { - row.ExternalIds = map[string]string{} - } - row.ExternalIds[k] = v -} - -func (row *AddressSet) OvnGetExternalIds(k string) (string, bool) { - if row.ExternalIds == nil { - return "", false - } - r, ok := row.ExternalIds[k] - return r, ok -} - -func (row *AddressSet) OvnRemoveExternalIds(k string) (string, bool) { - if row.ExternalIds == nil { - return "", false - } - r, ok := row.ExternalIds[k] - if ok { - delete(row.ExternalIds, k) - } - return r, ok -} - -func (row *AddressSet) SetColumn(name string, val interface{}) (err error) { - defer func() { - if panicErr := recover(); panicErr != nil { - err = errors.Wrapf(panicErr.(error), "%s: %#v", name, fmt.Sprintf("%#v", val)) - } - }() - switch name { - case "_uuid": - row.Uuid = ensureUuid(val) - case "external_ids": - row.ExternalIds = ensureMapStringString(val) - case "name": - row.Name = ensureString(val) - case "addresses": - row.Addresses = ensureStringMultiples(val) - default: - panic(ErrUnknownColumn) - } - return -} - -func (row *AddressSet) MatchNonZeros(row1 *AddressSet) bool { - if !matchMapStringStringIfNonZero(row.ExternalIds, row1.ExternalIds) { - return false - } - if !matchStringIfNonZero(row.Name, row1.Name) { - return false - } - if !matchStringMultiplesIfNonZero(row.Addresses, row1.Addresses) { - return false - } - return true -} - -func (row *AddressSet) OvnArgs() []string { - r := []string{} - r = append(r, OvnArgsString("name", row.Name)...) - r = append(r, OvnArgsStringMultiples("addresses", row.Addresses)...) - r = append(r, OvnArgsMapStringString("external_ids", row.ExternalIds)...) - return r -} - -type AddressSetTable []AddressSet - -func (tbl *AddressSetTable) NewRow() IRow { - *tbl = append(*tbl, AddressSet{}) - return &(*tbl)[len(*tbl)-1] -} - -func (tbl AddressSetTable) OvnTableName() string { - return "Address_Set" -} - -func (tbl AddressSetTable) OvnIsRoot() bool { - return true -} - -func (tbl AddressSetTable) Rows() []IRow { - r := make([]IRow, len(tbl)) - for i := range tbl { - r[i] = &tbl[i] - } - return r -} - -func (tbl AddressSetTable) FindOneMatchNonZeros(row1 *AddressSet) *AddressSet { - for i := range tbl { - row := &tbl[i] - if row.MatchNonZeros(row1) { - return row - } - } - return nil -} - -type LogicalSwitch struct { - Uuid string `json:"-"` - ExternalIds map[string]string `json:"external_ids"` - Name string `json:"name"` - Ports []string `json:"ports"` - Acls []string `json:"acls"` - QosRules []string `json:"qos_rules"` - LoadBalancer []string `json:"load_balancer"` - DnsRecords []string `json:"dns_records"` - OtherConfig map[string]string `json:"other_config"` -} - -func (row *LogicalSwitch) OvnTableName() string { - return "Logical_Switch" -} - -func (row *LogicalSwitch) OvnIsRoot() bool { - return true -} - -func (row *LogicalSwitch) OvnUuid() string { - return row.Uuid -} - -func (row *LogicalSwitch) OvnSetExternalIds(k, v string) { - if row.ExternalIds == nil { - row.ExternalIds = map[string]string{} - } - row.ExternalIds[k] = v -} - -func (row *LogicalSwitch) OvnGetExternalIds(k string) (string, bool) { - if row.ExternalIds == nil { - return "", false - } - r, ok := row.ExternalIds[k] - return r, ok -} - -func (row *LogicalSwitch) OvnRemoveExternalIds(k string) (string, bool) { - if row.ExternalIds == nil { - return "", false - } - r, ok := row.ExternalIds[k] - if ok { - delete(row.ExternalIds, k) - } - return r, ok -} - -func (row *LogicalSwitch) SetColumn(name string, val interface{}) (err error) { - defer func() { - if panicErr := recover(); panicErr != nil { - err = errors.Wrapf(panicErr.(error), "%s: %#v", name, fmt.Sprintf("%#v", val)) - } - }() - switch name { - case "_uuid": - row.Uuid = ensureUuid(val) - case "qos_rules": - row.QosRules = ensureUuidMultiples(val) - case "load_balancer": - row.LoadBalancer = ensureUuidMultiples(val) - case "dns_records": - row.DnsRecords = ensureUuidMultiples(val) - case "other_config": - row.OtherConfig = ensureMapStringString(val) - case "external_ids": - row.ExternalIds = ensureMapStringString(val) - case "name": - row.Name = ensureString(val) - case "ports": - row.Ports = ensureUuidMultiples(val) - case "acls": - row.Acls = ensureUuidMultiples(val) - default: - panic(ErrUnknownColumn) - } - return -} - -func (row *LogicalSwitch) MatchNonZeros(row1 *LogicalSwitch) bool { - if !matchUuidMultiplesIfNonZero(row.QosRules, row1.QosRules) { - return false - } - if !matchUuidMultiplesIfNonZero(row.LoadBalancer, row1.LoadBalancer) { - return false - } - if !matchUuidMultiplesIfNonZero(row.DnsRecords, row1.DnsRecords) { - return false - } - if !matchMapStringStringIfNonZero(row.OtherConfig, row1.OtherConfig) { - return false - } - if !matchMapStringStringIfNonZero(row.ExternalIds, row1.ExternalIds) { - return false - } - if !matchStringIfNonZero(row.Name, row1.Name) { - return false - } - if !matchUuidMultiplesIfNonZero(row.Ports, row1.Ports) { - return false - } - if !matchUuidMultiplesIfNonZero(row.Acls, row1.Acls) { - return false - } - return true -} - -func (row *LogicalSwitch) OvnArgs() []string { - r := []string{} - r = append(r, OvnArgsUuidMultiples("qos_rules", row.QosRules)...) - r = append(r, OvnArgsUuidMultiples("load_balancer", row.LoadBalancer)...) - r = append(r, OvnArgsUuidMultiples("dns_records", row.DnsRecords)...) - r = append(r, OvnArgsMapStringString("other_config", row.OtherConfig)...) - r = append(r, OvnArgsMapStringString("external_ids", row.ExternalIds)...) - r = append(r, OvnArgsString("name", row.Name)...) - r = append(r, OvnArgsUuidMultiples("ports", row.Ports)...) - r = append(r, OvnArgsUuidMultiples("acls", row.Acls)...) - return r -} - -type LogicalSwitchTable []LogicalSwitch - -func (tbl *LogicalSwitchTable) NewRow() IRow { - *tbl = append(*tbl, LogicalSwitch{}) - return &(*tbl)[len(*tbl)-1] -} - -func (tbl LogicalSwitchTable) OvnTableName() string { - return "Logical_Switch" -} - -func (tbl LogicalSwitchTable) OvnIsRoot() bool { - return true -} - -func (tbl LogicalSwitchTable) Rows() []IRow { - r := make([]IRow, len(tbl)) - for i := range tbl { - r[i] = &tbl[i] - } - return r -} - -func (tbl LogicalSwitchTable) FindOneMatchNonZeros(row1 *LogicalSwitch) *LogicalSwitch { - for i := range tbl { - row := &tbl[i] - if row.MatchNonZeros(row1) { - return row - } - } - return nil -} - -type NAT struct { - Uuid string `json:"-"` - Type string `json:"type"` - ExternalIds map[string]string `json:"external_ids"` - ExternalIp string `json:"external_ip"` - ExternalMac *string `json:"external_mac"` - LogicalIp string `json:"logical_ip"` - LogicalPort *string `json:"logical_port"` -} - -func (row *NAT) OvnTableName() string { - return "NAT" -} - -func (row *NAT) OvnIsRoot() bool { - return false -} - -func (row *NAT) OvnUuid() string { - return row.Uuid -} - -func (row *NAT) OvnSetExternalIds(k, v string) { - if row.ExternalIds == nil { - row.ExternalIds = map[string]string{} - } - row.ExternalIds[k] = v -} - -func (row *NAT) OvnGetExternalIds(k string) (string, bool) { - if row.ExternalIds == nil { - return "", false - } - r, ok := row.ExternalIds[k] - return r, ok -} - -func (row *NAT) OvnRemoveExternalIds(k string) (string, bool) { - if row.ExternalIds == nil { - return "", false - } - r, ok := row.ExternalIds[k] - if ok { - delete(row.ExternalIds, k) - } - return r, ok -} - -func (row *NAT) SetColumn(name string, val interface{}) (err error) { - defer func() { - if panicErr := recover(); panicErr != nil { - err = errors.Wrapf(panicErr.(error), "%s: %#v", name, fmt.Sprintf("%#v", val)) - } - }() - switch name { - case "_uuid": - row.Uuid = ensureUuid(val) - case "type": - row.Type = ensureString(val) - case "external_ids": - row.ExternalIds = ensureMapStringString(val) - case "external_ip": - row.ExternalIp = ensureString(val) - case "external_mac": - row.ExternalMac = ensureStringOptional(val) - case "logical_ip": - row.LogicalIp = ensureString(val) - case "logical_port": - row.LogicalPort = ensureStringOptional(val) - default: - panic(ErrUnknownColumn) - } - return -} - -func (row *NAT) MatchNonZeros(row1 *NAT) bool { - if !matchMapStringStringIfNonZero(row.ExternalIds, row1.ExternalIds) { - return false - } - if !matchStringIfNonZero(row.ExternalIp, row1.ExternalIp) { - return false - } - if !matchStringOptionalIfNonZero(row.ExternalMac, row1.ExternalMac) { - return false - } - if !matchStringIfNonZero(row.LogicalIp, row1.LogicalIp) { - return false - } - if !matchStringOptionalIfNonZero(row.LogicalPort, row1.LogicalPort) { - return false - } - if !matchStringIfNonZero(row.Type, row1.Type) { - return false - } - return true -} - -func (row *NAT) OvnArgs() []string { - r := []string{} - r = append(r, OvnArgsMapStringString("external_ids", row.ExternalIds)...) - r = append(r, OvnArgsString("external_ip", row.ExternalIp)...) - r = append(r, OvnArgsStringOptional("external_mac", row.ExternalMac)...) - r = append(r, OvnArgsString("logical_ip", row.LogicalIp)...) - r = append(r, OvnArgsStringOptional("logical_port", row.LogicalPort)...) - r = append(r, OvnArgsString("type", row.Type)...) - return r -} - -type NATTable []NAT - -func (tbl *NATTable) NewRow() IRow { - *tbl = append(*tbl, NAT{}) - return &(*tbl)[len(*tbl)-1] -} - -func (tbl NATTable) OvnTableName() string { - return "NAT" -} - -func (tbl NATTable) OvnIsRoot() bool { - return false -} - -func (tbl NATTable) Rows() []IRow { - r := make([]IRow, len(tbl)) - for i := range tbl { - r[i] = &tbl[i] - } - return r -} - -func (tbl NATTable) FindOneMatchNonZeros(row1 *NAT) *NAT { - for i := range tbl { - row := &tbl[i] - if row.MatchNonZeros(row1) { - return row - } - } - return nil -} - -type DHCPOptions struct { - Uuid string `json:"-"` - ExternalIds map[string]string `json:"external_ids"` - Cidr string `json:"cidr"` - Options map[string]string `json:"options"` -} - -func (row *DHCPOptions) OvnTableName() string { - return "DHCP_Options" -} - -func (row *DHCPOptions) OvnIsRoot() bool { - return true -} - -func (row *DHCPOptions) OvnUuid() string { - return row.Uuid -} - -func (row *DHCPOptions) OvnSetExternalIds(k, v string) { - if row.ExternalIds == nil { - row.ExternalIds = map[string]string{} - } - row.ExternalIds[k] = v -} - -func (row *DHCPOptions) OvnGetExternalIds(k string) (string, bool) { - if row.ExternalIds == nil { - return "", false - } - r, ok := row.ExternalIds[k] - return r, ok -} - -func (row *DHCPOptions) OvnRemoveExternalIds(k string) (string, bool) { - if row.ExternalIds == nil { - return "", false - } - r, ok := row.ExternalIds[k] - if ok { - delete(row.ExternalIds, k) - } - return r, ok -} - -func (row *DHCPOptions) SetColumn(name string, val interface{}) (err error) { - defer func() { - if panicErr := recover(); panicErr != nil { - err = errors.Wrapf(panicErr.(error), "%s: %#v", name, fmt.Sprintf("%#v", val)) - } - }() - switch name { - case "_uuid": - row.Uuid = ensureUuid(val) - case "cidr": - row.Cidr = ensureString(val) - case "options": - row.Options = ensureMapStringString(val) - case "external_ids": - row.ExternalIds = ensureMapStringString(val) - default: - panic(ErrUnknownColumn) - } - return -} - -func (row *DHCPOptions) MatchNonZeros(row1 *DHCPOptions) bool { - if !matchStringIfNonZero(row.Cidr, row1.Cidr) { - return false - } - if !matchMapStringStringIfNonZero(row.Options, row1.Options) { - return false - } - if !matchMapStringStringIfNonZero(row.ExternalIds, row1.ExternalIds) { - return false - } - return true -} - -func (row *DHCPOptions) OvnArgs() []string { - r := []string{} - r = append(r, OvnArgsString("cidr", row.Cidr)...) - r = append(r, OvnArgsMapStringString("options", row.Options)...) - r = append(r, OvnArgsMapStringString("external_ids", row.ExternalIds)...) - return r -} - -type DHCPOptionsTable []DHCPOptions - -func (tbl *DHCPOptionsTable) NewRow() IRow { - *tbl = append(*tbl, DHCPOptions{}) - return &(*tbl)[len(*tbl)-1] -} - -func (tbl DHCPOptionsTable) OvnTableName() string { - return "DHCP_Options" -} - -func (tbl DHCPOptionsTable) OvnIsRoot() bool { - return true -} - -func (tbl DHCPOptionsTable) Rows() []IRow { - r := make([]IRow, len(tbl)) - for i := range tbl { - r[i] = &tbl[i] - } - return r -} - -func (tbl DHCPOptionsTable) FindOneMatchNonZeros(row1 *DHCPOptions) *DHCPOptions { - for i := range tbl { - row := &tbl[i] - if row.MatchNonZeros(row1) { - return row - } - } - return nil -} - -type LoadBalancer struct { - Uuid string `json:"-"` - ExternalIds map[string]string `json:"external_ids"` - Name string `json:"name"` - Vips map[string]string `json:"vips"` - Protocol *string `json:"protocol"` -} - -func (row *LoadBalancer) OvnTableName() string { - return "Load_Balancer" -} - -func (row *LoadBalancer) OvnIsRoot() bool { - return true -} - -func (row *LoadBalancer) OvnUuid() string { - return row.Uuid -} - -func (row *LoadBalancer) OvnSetExternalIds(k, v string) { - if row.ExternalIds == nil { - row.ExternalIds = map[string]string{} - } - row.ExternalIds[k] = v -} - -func (row *LoadBalancer) OvnGetExternalIds(k string) (string, bool) { - if row.ExternalIds == nil { - return "", false - } - r, ok := row.ExternalIds[k] - return r, ok -} - -func (row *LoadBalancer) OvnRemoveExternalIds(k string) (string, bool) { - if row.ExternalIds == nil { - return "", false - } - r, ok := row.ExternalIds[k] - if ok { - delete(row.ExternalIds, k) - } - return r, ok -} - -func (row *LoadBalancer) SetColumn(name string, val interface{}) (err error) { - defer func() { - if panicErr := recover(); panicErr != nil { - err = errors.Wrapf(panicErr.(error), "%s: %#v", name, fmt.Sprintf("%#v", val)) - } - }() - switch name { - case "_uuid": - row.Uuid = ensureUuid(val) - case "name": - row.Name = ensureString(val) - case "vips": - row.Vips = ensureMapStringString(val) - case "protocol": - row.Protocol = ensureStringOptional(val) - case "external_ids": - row.ExternalIds = ensureMapStringString(val) - default: - panic(ErrUnknownColumn) - } - return -} - -func (row *LoadBalancer) MatchNonZeros(row1 *LoadBalancer) bool { - if !matchMapStringStringIfNonZero(row.Vips, row1.Vips) { - return false - } - if !matchStringOptionalIfNonZero(row.Protocol, row1.Protocol) { - return false - } - if !matchMapStringStringIfNonZero(row.ExternalIds, row1.ExternalIds) { - return false - } - if !matchStringIfNonZero(row.Name, row1.Name) { - return false - } - return true -} - -func (row *LoadBalancer) OvnArgs() []string { - r := []string{} - r = append(r, OvnArgsString("name", row.Name)...) - r = append(r, OvnArgsMapStringString("vips", row.Vips)...) - r = append(r, OvnArgsStringOptional("protocol", row.Protocol)...) - r = append(r, OvnArgsMapStringString("external_ids", row.ExternalIds)...) - return r -} - -type LoadBalancerTable []LoadBalancer - -func (tbl *LoadBalancerTable) NewRow() IRow { - *tbl = append(*tbl, LoadBalancer{}) - return &(*tbl)[len(*tbl)-1] -} - -func (tbl LoadBalancerTable) OvnTableName() string { - return "Load_Balancer" -} - -func (tbl LoadBalancerTable) OvnIsRoot() bool { - return true -} - -func (tbl LoadBalancerTable) Rows() []IRow { - r := make([]IRow, len(tbl)) - for i := range tbl { - r[i] = &tbl[i] - } - return r -} - -func (tbl LoadBalancerTable) FindOneMatchNonZeros(row1 *LoadBalancer) *LoadBalancer { - for i := range tbl { - row := &tbl[i] - if row.MatchNonZeros(row1) { - return row - } - } - return nil -} - -type SSL struct { - Uuid string `json:"-"` - SslCiphers string `json:"ssl_ciphers"` - ExternalIds map[string]string `json:"external_ids"` - PrivateKey string `json:"private_key"` - Certificate string `json:"certificate"` - CaCert string `json:"ca_cert"` - BootstrapCaCert bool `json:"bootstrap_ca_cert"` - SslProtocols string `json:"ssl_protocols"` -} - -func (row *SSL) OvnTableName() string { - return "SSL" -} - -func (row *SSL) OvnIsRoot() bool { - return false -} - -func (row *SSL) OvnUuid() string { - return row.Uuid -} - -func (row *SSL) OvnSetExternalIds(k, v string) { - if row.ExternalIds == nil { - row.ExternalIds = map[string]string{} - } - row.ExternalIds[k] = v -} - -func (row *SSL) OvnGetExternalIds(k string) (string, bool) { - if row.ExternalIds == nil { - return "", false - } - r, ok := row.ExternalIds[k] - return r, ok -} - -func (row *SSL) OvnRemoveExternalIds(k string) (string, bool) { - if row.ExternalIds == nil { - return "", false - } - r, ok := row.ExternalIds[k] - if ok { - delete(row.ExternalIds, k) - } - return r, ok -} - -func (row *SSL) SetColumn(name string, val interface{}) (err error) { - defer func() { - if panicErr := recover(); panicErr != nil { - err = errors.Wrapf(panicErr.(error), "%s: %#v", name, fmt.Sprintf("%#v", val)) - } - }() - switch name { - case "_uuid": - row.Uuid = ensureUuid(val) - case "ssl_protocols": - row.SslProtocols = ensureString(val) - case "ssl_ciphers": - row.SslCiphers = ensureString(val) - case "external_ids": - row.ExternalIds = ensureMapStringString(val) - case "private_key": - row.PrivateKey = ensureString(val) - case "certificate": - row.Certificate = ensureString(val) - case "ca_cert": - row.CaCert = ensureString(val) - case "bootstrap_ca_cert": - row.BootstrapCaCert = ensureBoolean(val) - default: - panic(ErrUnknownColumn) - } - return -} - -func (row *SSL) MatchNonZeros(row1 *SSL) bool { - if !matchMapStringStringIfNonZero(row.ExternalIds, row1.ExternalIds) { - return false - } - if !matchStringIfNonZero(row.PrivateKey, row1.PrivateKey) { - return false - } - if !matchStringIfNonZero(row.Certificate, row1.Certificate) { - return false - } - if !matchStringIfNonZero(row.CaCert, row1.CaCert) { - return false - } - if !matchBooleanIfNonZero(row.BootstrapCaCert, row1.BootstrapCaCert) { - return false - } - if !matchStringIfNonZero(row.SslProtocols, row1.SslProtocols) { - return false - } - if !matchStringIfNonZero(row.SslCiphers, row1.SslCiphers) { - return false - } - return true -} - -func (row *SSL) OvnArgs() []string { - r := []string{} - r = append(r, OvnArgsBoolean("bootstrap_ca_cert", row.BootstrapCaCert)...) - r = append(r, OvnArgsString("ssl_protocols", row.SslProtocols)...) - r = append(r, OvnArgsString("ssl_ciphers", row.SslCiphers)...) - r = append(r, OvnArgsMapStringString("external_ids", row.ExternalIds)...) - r = append(r, OvnArgsString("private_key", row.PrivateKey)...) - r = append(r, OvnArgsString("certificate", row.Certificate)...) - r = append(r, OvnArgsString("ca_cert", row.CaCert)...) - return r -} - -type SSLTable []SSL - -func (tbl *SSLTable) NewRow() IRow { - *tbl = append(*tbl, SSL{}) - return &(*tbl)[len(*tbl)-1] -} - -func (tbl SSLTable) OvnTableName() string { - return "SSL" -} - -func (tbl SSLTable) OvnIsRoot() bool { - return false -} - -func (tbl SSLTable) Rows() []IRow { - r := make([]IRow, len(tbl)) - for i := range tbl { - r[i] = &tbl[i] - } - return r -} - -func (tbl SSLTable) FindOneMatchNonZeros(row1 *SSL) *SSL { - for i := range tbl { - row := &tbl[i] - if row.MatchNonZeros(row1) { - return row - } - } - return nil -} - -type NBGlobal struct { - Uuid string `json:"-"` - Connections []string `json:"connections"` - Ssl *string `json:"ssl"` - NbCfg int64 `json:"nb_cfg"` - SbCfg int64 `json:"sb_cfg"` - HvCfg int64 `json:"hv_cfg"` - ExternalIds map[string]string `json:"external_ids"` -} - -func (row *NBGlobal) OvnTableName() string { - return "NB_Global" -} - -func (row *NBGlobal) OvnIsRoot() bool { - return true -} - -func (row *NBGlobal) OvnUuid() string { - return row.Uuid -} - -func (row *NBGlobal) OvnSetExternalIds(k, v string) { - if row.ExternalIds == nil { - row.ExternalIds = map[string]string{} - } - row.ExternalIds[k] = v -} - -func (row *NBGlobal) OvnGetExternalIds(k string) (string, bool) { - if row.ExternalIds == nil { - return "", false - } - r, ok := row.ExternalIds[k] - return r, ok -} - -func (row *NBGlobal) OvnRemoveExternalIds(k string) (string, bool) { - if row.ExternalIds == nil { - return "", false - } - r, ok := row.ExternalIds[k] - if ok { - delete(row.ExternalIds, k) - } - return r, ok -} - -func (row *NBGlobal) SetColumn(name string, val interface{}) (err error) { - defer func() { - if panicErr := recover(); panicErr != nil { - err = errors.Wrapf(panicErr.(error), "%s: %#v", name, fmt.Sprintf("%#v", val)) - } - }() - switch name { - case "_uuid": - row.Uuid = ensureUuid(val) - case "sb_cfg": - row.SbCfg = ensureInteger(val) - case "hv_cfg": - row.HvCfg = ensureInteger(val) - case "external_ids": - row.ExternalIds = ensureMapStringString(val) - case "connections": - row.Connections = ensureUuidMultiples(val) - case "ssl": - row.Ssl = ensureUuidOptional(val) - case "nb_cfg": - row.NbCfg = ensureInteger(val) - default: - panic(ErrUnknownColumn) - } - return -} - -func (row *NBGlobal) MatchNonZeros(row1 *NBGlobal) bool { - if !matchUuidOptionalIfNonZero(row.Ssl, row1.Ssl) { - return false - } - if !matchIntegerIfNonZero(row.NbCfg, row1.NbCfg) { - return false - } - if !matchIntegerIfNonZero(row.SbCfg, row1.SbCfg) { - return false - } - if !matchIntegerIfNonZero(row.HvCfg, row1.HvCfg) { - return false - } - if !matchMapStringStringIfNonZero(row.ExternalIds, row1.ExternalIds) { - return false - } - if !matchUuidMultiplesIfNonZero(row.Connections, row1.Connections) { - return false - } - return true -} - -func (row *NBGlobal) OvnArgs() []string { - r := []string{} - r = append(r, OvnArgsInteger("sb_cfg", row.SbCfg)...) - r = append(r, OvnArgsInteger("hv_cfg", row.HvCfg)...) - r = append(r, OvnArgsMapStringString("external_ids", row.ExternalIds)...) - r = append(r, OvnArgsUuidMultiples("connections", row.Connections)...) - r = append(r, OvnArgsUuidOptional("ssl", row.Ssl)...) - r = append(r, OvnArgsInteger("nb_cfg", row.NbCfg)...) - return r -} - -type NBGlobalTable []NBGlobal - -func (tbl *NBGlobalTable) NewRow() IRow { - *tbl = append(*tbl, NBGlobal{}) - return &(*tbl)[len(*tbl)-1] -} - -func (tbl NBGlobalTable) OvnTableName() string { - return "NB_Global" -} - -func (tbl NBGlobalTable) OvnIsRoot() bool { - return true -} - -func (tbl NBGlobalTable) Rows() []IRow { - r := make([]IRow, len(tbl)) - for i := range tbl { - r[i] = &tbl[i] - } - return r -} - -func (tbl NBGlobalTable) FindOneMatchNonZeros(row1 *NBGlobal) *NBGlobal { - for i := range tbl { - row := &tbl[i] - if row.MatchNonZeros(row1) { - return row - } - } - return nil -} - -type LogicalRouterStaticRoute struct { - Uuid string `json:"-"` - IpPrefix string `json:"ip_prefix"` - Policy *string `json:"policy"` - Nexthop string `json:"nexthop"` - OutputPort *string `json:"output_port"` - ExternalIds map[string]string `json:"external_ids"` -} - -func (row *LogicalRouterStaticRoute) OvnTableName() string { - return "Logical_Router_Static_Route" -} - -func (row *LogicalRouterStaticRoute) OvnIsRoot() bool { - return false -} - -func (row *LogicalRouterStaticRoute) OvnUuid() string { - return row.Uuid -} - -func (row *LogicalRouterStaticRoute) OvnSetExternalIds(k, v string) { - if row.ExternalIds == nil { - row.ExternalIds = map[string]string{} - } - row.ExternalIds[k] = v -} - -func (row *LogicalRouterStaticRoute) OvnGetExternalIds(k string) (string, bool) { - if row.ExternalIds == nil { - return "", false - } - r, ok := row.ExternalIds[k] - return r, ok -} - -func (row *LogicalRouterStaticRoute) OvnRemoveExternalIds(k string) (string, bool) { - if row.ExternalIds == nil { - return "", false - } - r, ok := row.ExternalIds[k] - if ok { - delete(row.ExternalIds, k) - } - return r, ok -} - -func (row *LogicalRouterStaticRoute) SetColumn(name string, val interface{}) (err error) { - defer func() { - if panicErr := recover(); panicErr != nil { - err = errors.Wrapf(panicErr.(error), "%s: %#v", name, fmt.Sprintf("%#v", val)) - } - }() - switch name { - case "_uuid": - row.Uuid = ensureUuid(val) - case "external_ids": - row.ExternalIds = ensureMapStringString(val) - case "ip_prefix": - row.IpPrefix = ensureString(val) - case "policy": - row.Policy = ensureStringOptional(val) - case "nexthop": - row.Nexthop = ensureString(val) - case "output_port": - row.OutputPort = ensureStringOptional(val) - default: - panic(ErrUnknownColumn) - } - return -} - -func (row *LogicalRouterStaticRoute) MatchNonZeros(row1 *LogicalRouterStaticRoute) bool { - if !matchStringIfNonZero(row.IpPrefix, row1.IpPrefix) { - return false - } - if !matchStringOptionalIfNonZero(row.Policy, row1.Policy) { - return false - } - if !matchStringIfNonZero(row.Nexthop, row1.Nexthop) { - return false - } - if !matchStringOptionalIfNonZero(row.OutputPort, row1.OutputPort) { - return false - } - if !matchMapStringStringIfNonZero(row.ExternalIds, row1.ExternalIds) { - return false - } - return true -} - -func (row *LogicalRouterStaticRoute) OvnArgs() []string { - r := []string{} - r = append(r, OvnArgsString("ip_prefix", row.IpPrefix)...) - r = append(r, OvnArgsStringOptional("policy", row.Policy)...) - r = append(r, OvnArgsString("nexthop", row.Nexthop)...) - r = append(r, OvnArgsStringOptional("output_port", row.OutputPort)...) - r = append(r, OvnArgsMapStringString("external_ids", row.ExternalIds)...) - return r -} - -type LogicalRouterStaticRouteTable []LogicalRouterStaticRoute - -func (tbl *LogicalRouterStaticRouteTable) NewRow() IRow { - *tbl = append(*tbl, LogicalRouterStaticRoute{}) - return &(*tbl)[len(*tbl)-1] -} - -func (tbl LogicalRouterStaticRouteTable) OvnTableName() string { - return "Logical_Router_Static_Route" -} - -func (tbl LogicalRouterStaticRouteTable) OvnIsRoot() bool { - return false -} - -func (tbl LogicalRouterStaticRouteTable) Rows() []IRow { - r := make([]IRow, len(tbl)) - for i := range tbl { - r[i] = &tbl[i] - } - return r -} - -func (tbl LogicalRouterStaticRouteTable) FindOneMatchNonZeros(row1 *LogicalRouterStaticRoute) *LogicalRouterStaticRoute { - for i := range tbl { - row := &tbl[i] - if row.MatchNonZeros(row1) { - return row - } - } - return nil -} diff --git a/pkg/vpcagent/ovnutil/schema_test.go b/pkg/vpcagent/ovnutil/schema_test.go deleted file mode 100644 index 4c5118e7fe..0000000000 --- a/pkg/vpcagent/ovnutil/schema_test.go +++ /dev/null @@ -1,47 +0,0 @@ -// Copyright 2019 Yunion -// -// 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 ovnutil - -import ( - "reflect" - "testing" -) - -func TestUnmarshal(t *testing.T) { - d := `{"data":[[["uuid","281f3163-0430-4626-8b94-eb4e79e6d85a"],["set",[]],["set",[]],["map",[["oc-vpc-id","uuididid"]]],["set",[]],"ls0",["map",[["subnet","192.168.2.0/24"]]],["set",[]],["set",[]]]],"headings":["_uuid","acls","dns_records","external_ids","load_balancer","name","other_config","ports","qos_rules"]}` - got := &LogicalSwitchTable{} - if err := UnmarshalJSON([]byte(d), got); err != nil { - t.Fatalf("unmarshal: %v", err) - } - want := &LogicalSwitchTable{ - LogicalSwitch{ - Uuid: "281f3163-0430-4626-8b94-eb4e79e6d85a", - Name: "ls0", - ExternalIds: map[string]string{"oc-vpc-id": "uuididid"}, - OtherConfig: map[string]string{"subnet": "192.168.2.0/24"}, - }, - } - if !reflect.DeepEqual(got, want) { - t.Errorf("\n got %#v\nwant %#v", got, want) - } - - t.Run("logical switch", func(t *testing.T) { - d := `{"data":[[["uuid","d9dbe3cc-7efe-4cf2-91f0-f8f2143037f1"],"32:38:30:34:61:64 169.254.169.3",["set",[]],["set",[]],["set",[]],["set",[]],["map",[]],"subnet-lsmp-subnet3",["map",[]],["set",[]],["set",[]],["set",[]],["set",[]],"localport",false],[["uuid","90fd42c1-ca9c-4fb5-a37a-a950faef4d19"],"router",["set",[]],["set",[]],["set",[]],["set",[]],["map",[]],"subnet-lsp-subnet3",["map",[["router-port","subnet-lrp-subnet3"]]],["set",[]],["set",[]],["set",[]],["set",[]],"router",true],[["uuid","f8fefe76-083b-405c-ae1e-1e70eab9b903"],"00:33:00:00:00:09 192.168.3.9",["uuid","34466b0c-038d-44df-b444-f127d19ef188"],["set",[]],["set",[]],["set",[]],["map",[]],"iface-p39",["map",[]],["set",[]],"00:33:00:00:00:09 192.168.3.9/24",["set",[]],["set",[]],"",true],[["uuid","e514e6da-080b-46b8-9822-d62596c28918"],"router",["set",[]],["set",[]],["set",[]],["set",[]],["map",[]],"subnet-lsp-subnet2",["map",[["router-port","subnet-lrp-subnet2"]]],["set",[]],["set",[]],["set",[]],["set",[]],"router",true],[["uuid","804d671e-20d4-4ad3-82e8-735463dfed09"],"00:22:00:00:00:04 192.168.2.4",["uuid","2cd3dfeb-c521-4e88-9ffb-c89006f8f92b"],["set",[]],["set",[]],["set",[]],["map",[]],"iface-p24",["map",[]],["set",[]],"00:22:00:00:00:04 192.168.2.4/24",["set",[]],["set",[]],"",true],[["uuid","91742362-93b9-4d06-92df-d5e0e2c28dc3"],"00:22:00:00:00:03 192.168.2.3",["uuid","2cd3dfeb-c521-4e88-9ffb-c89006f8f92b"],["set",[]],["set",[]],["set",[]],["map",[]],"iface-p23",["map",[]],["set",[]],"00:22:00:00:00:03 192.168.2.3/24",["set",[]],["set",[]],"",true],[["uuid","91d9efcf-fba3-4b5b-adaa-4c64948f8824"],"32:31:36:37:62:38 169.254.169.2",["set",[]],["set",[]],["set",[]],["set",[]],["map",[]],"subnet-lsmp-subnet2",["map",[]],["set",[]],["set",[]],["set",[]],["set",[]],"localport",false]],"headings":["_uuid","addresses","dhcpv4_options","dhcpv6_options","dynamic_addresses","enabled","external_ids","name","options","parent_name","port_security","tag","tag_request","type","up"]}` - got := &LogicalSwitchPortTable{} - if err := UnmarshalJSON([]byte(d), got); err != nil { - t.Fatalf("unmarshal: %v", err) - } - }) -} diff --git a/pkg/vpcagent/ovnutil/unmarshal.go b/pkg/vpcagent/ovnutil/unmarshal.go deleted file mode 100644 index 426f9d878d..0000000000 --- a/pkg/vpcagent/ovnutil/unmarshal.go +++ /dev/null @@ -1,61 +0,0 @@ -// Copyright 2019 Yunion -// -// 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 ovnutil - -import ( - "encoding/json" - - "yunion.io/x/pkg/errors" -) - -type List struct { - Headings ListHeadings - Data []ListDataRow -} -type ListHeadings []string -type ListDataRow []ListDataColumn -type ListDataColumn = interface{} - -const ( - ErrColumnIndexOverrun = errors.Error("column index overrun") -) - -func (h ListHeadings) GetByIndex(i int) (string, error) { - if i < len(h) { - return h[i], nil - } - return "", ErrColumnIndexOverrun -} - -func UnmarshalJSON(data []byte, rows ITable) error { - list := &List{} - if err := json.Unmarshal(data, list); err != nil { - return err - } - for _, row := range list.Data { - r := rows.NewRow() - for ci := range row { - col := row[ci] - colName, err := list.Headings.GetByIndex(ci) - if err != nil { - return err - } - if err := r.SetColumn(colName, col); err != nil { - return err - } - } - } - return nil -} From e8cbaee90473291abe76c8d04bca0e99e651c290 Mon Sep 17 00:00:00 2001 From: Yousong Zhou Date: Mon, 11 May 2020 21:50:19 +0800 Subject: [PATCH 05/13] region: guests: include secgroup ids in listing --- pkg/compute/models/guests.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/compute/models/guests.go b/pkg/compute/models/guests.go index 63b609eb05..73a7c63251 100644 --- a/pkg/compute/models/guests.go +++ b/pkg/compute/models/guests.go @@ -136,9 +136,9 @@ type SGuest struct { // 安全组Id // example: default - SecgrpId string `width:"36" charset:"ascii" nullable:"true" get:"user" create:"optional"` + SecgrpId string `width:"36" charset:"ascii" nullable:"true" list:"user" get:"user" create:"optional"` // 管理员可见安全组Id - AdminSecgrpId string `width:"36" charset:"ascii" nullable:"true" get:"domain"` + AdminSecgrpId string `width:"36" charset:"ascii" nullable:"true" list:"admin" get:"domain"` SrcIpCheck tristate.TriState `nullable:"false" default:"true" create:"optional" list:"user" update:"user"` SrcMacCheck tristate.TriState `nullable:"false" default:"true" create:"optional" list:"user" update:"user"` From f33a2e1770cb13e30b4e6063da4f690e99231985 Mon Sep 17 00:00:00 2001 From: Yousong Zhou Date: Mon, 27 Apr 2020 19:48:39 +0800 Subject: [PATCH 06/13] vpcagent: apihelper: do not set details=true by default --- pkg/vpcagent/apihelper/interface.go | 11 ++++++----- pkg/vpcagent/apihelper/reflect.go | 7 ++++--- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/pkg/vpcagent/apihelper/interface.go b/pkg/vpcagent/apihelper/interface.go index 90959c4ff1..6017d497b0 100644 --- a/pkg/vpcagent/apihelper/interface.go +++ b/pkg/vpcagent/apihelper/interface.go @@ -45,11 +45,12 @@ func SyncModelSets(mssOld IModelSets, s *mcclient.ClientSession, batchSize int) for i, msNew := range mssNews.ModelSetList() { minUpdatedAt := ModelSetMaxUpdatedAt(mss[i]) err = GetModels(&GetModelsOptions{ - ClientSession: s, - ModelManager: msNew.ModelManager(), - MinUpdatedAt: minUpdatedAt, - ModelSet: msNew, - BatchListSize: batchSize, + ClientSession: s, + ModelManager: msNew.ModelManager(), + MinUpdatedAt: minUpdatedAt, + ModelSet: msNew, + BatchListSize: batchSize, + IncludeDetails: true, }) if err != nil { return diff --git a/pkg/vpcagent/apihelper/reflect.go b/pkg/vpcagent/apihelper/reflect.go index 86c1939396..8b3baff2d1 100644 --- a/pkg/vpcagent/apihelper/reflect.go +++ b/pkg/vpcagent/apihelper/reflect.go @@ -38,8 +38,9 @@ type GetModelsOptions struct { ModelManager mcclient_modulebase.IBaseManager ModelSet IModelSet - BatchListSize int - MinUpdatedAt time.Time + BatchListSize int + MinUpdatedAt time.Time + IncludeDetails bool } func GetModels(opts *GetModelsOptions) error { @@ -100,7 +101,7 @@ func GetModels(opts *GetModelsOptions) error { listOptions := options.BaseListOptions{ Admin: options.Bool(true), - Details: options.Bool(true), + Details: options.Bool(opts.IncludeDetails), Filter: []string{ minUpdatedAtFilter(minUpdatedAt), // order matters, filter.0 "manager_id.isnullorempty()", // len(manager_id) > 0 is for pubcloud objects From 7ba46e9289d566126531ca0fe43386b4ecba0eb0 Mon Sep 17 00:00:00 2001 From: Yousong Zhou Date: Mon, 27 Apr 2020 16:53:25 +0800 Subject: [PATCH 07/13] vpcagent: models: include secgroup and rules --- pkg/vpcagent/models/models.go | 45 +++++++- pkg/vpcagent/models/modelset.go | 176 ++++++++++++++++++++++++++++++- pkg/vpcagent/models/modelsets.go | 72 ++++++++----- 3 files changed, 262 insertions(+), 31 deletions(-) diff --git a/pkg/vpcagent/models/models.go b/pkg/vpcagent/models/models.go index 0fe8d8f8cc..a9dd7218b6 100644 --- a/pkg/vpcagent/models/models.go +++ b/pkg/vpcagent/models/models.go @@ -62,7 +62,9 @@ func (el *Guestnetwork) Copy() *Guestnetwork { type Guest struct { compute_models.SGuest - Host *Host `json:"-"` + Host *Host `json:"-"` + AdminSecurityGroup *SecurityGroup `json:"-"` + SecurityGroups SecurityGroups `json:"-"` } func (el *Guest) Copy() *Guest { @@ -80,3 +82,44 @@ func (el *Host) Copy() *Host { SHost: el.SHost, } } + +type Guestsecgroup struct { + compute_models.SGuestsecgroup + + Guest *Guest `json:"-"` + SecurityGroup *SecurityGroup `json:"-"` +} + +func (el *Guestsecgroup) ModelSetKey() string { + return el.GuestId + "/" + el.SecgroupId +} + +func (el *Guestsecgroup) Copy() *Guestsecgroup { + return &Guestsecgroup{ + SGuestsecgroup: el.SGuestsecgroup, + } +} + +type SecurityGroup struct { + compute_models.SSecurityGroup + + SecurityGroupRules SecurityGroupRules `json:"-"` +} + +func (el *SecurityGroup) Copy() *SecurityGroup { + return &SecurityGroup{ + SSecurityGroup: el.SSecurityGroup, + } +} + +type SecurityGroupRule struct { + compute_models.SSecurityGroupRule + + SecurityGroup *SecurityGroup `json:"-"` +} + +func (el *SecurityGroupRule) Copy() *SecurityGroupRule { + return &SecurityGroupRule{ + SSecurityGroupRule: el.SSecurityGroupRule, + } +} diff --git a/pkg/vpcagent/models/modelset.go b/pkg/vpcagent/models/modelset.go index 3e7671fb3c..bc1902b804 100644 --- a/pkg/vpcagent/models/modelset.go +++ b/pkg/vpcagent/models/modelset.go @@ -24,11 +24,17 @@ import ( "yunion.io/x/onecloud/pkg/vpcagent/apihelper" ) -type Vpcs map[string]*Vpc -type Networks map[string]*Network -type Guests map[string]*Guest -type Hosts map[string]*Host -type Guestnetworks map[string]*Guestnetwork // key: guestId/ifname +type ( + Vpcs map[string]*Vpc + Networks map[string]*Network + Guests map[string]*Guest + Hosts map[string]*Host + SecurityGroups map[string]*SecurityGroup + SecurityGroupRules map[string]*SecurityGroupRule + + Guestnetworks map[string]*Guestnetwork // key: guestId/ifname + Guestsecgroups map[string]*Guestsecgroup // key: guestId/secgroupId +) func (set Vpcs) ModelManager() mcclient_modulebase.IBaseManager { return &mcclient_modules.Vpcs @@ -106,6 +112,12 @@ func (set Guests) Copy() apihelper.IModelSet { return setCopy } +func (set Guests) initJoin() { + for _, el := range set { + el.SecurityGroups = SecurityGroups{} + } +} + func (set Guests) joinHosts(subEntries Hosts) bool { correct := true for gId, g := range set { @@ -132,6 +144,32 @@ func (set Guests) joinHosts(subEntries Hosts) bool { return correct } +func (set Guests) joinSecurityGroups(subEntries SecurityGroups) bool { + correct := true + j := func(guest *Guest, fname, secgroupId string) (*SecurityGroup, bool) { + if secgroupId == "" { + return nil, true + } + secgroup, ok := subEntries[secgroupId] + if !ok { + log.Warningf("cannot find %s %s of guest %s(%s)", + fname, secgroupId, guest.Name, guest.Id) + return nil, false + } + guest.SecurityGroups[secgroupId] = secgroup + return secgroup, true + } + for _, g := range set { + adminSecgroup, c0 := j(g, "admin_secgrp_id", g.AdminSecgrpId) + _, c1 := j(g, "secgrp_id", g.SecgrpId) + g.AdminSecurityGroup = adminSecgroup + if !(c0 && c1) { + correct = false + } + } + return correct +} + func (set Hosts) ModelManager() mcclient_modulebase.IBaseManager { return &mcclient_modules.Hosts } @@ -237,3 +275,131 @@ func (set Guestnetworks) joinGuests(subEntries Guests) bool { } return true } + +func (set SecurityGroups) ModelManager() mcclient_modulebase.IBaseManager { + return &mcclient_modules.SecGroups +} + +func (set SecurityGroups) NewModel() db.IModel { + return &SecurityGroup{} +} + +func (set SecurityGroups) AddModel(i db.IModel) { + m := i.(*SecurityGroup) + set[m.Id] = m +} + +func (set SecurityGroups) Copy() apihelper.IModelSet { + setCopy := SecurityGroups{} + for id, el := range set { + setCopy[id] = el.Copy() + } + return setCopy +} + +func (ms SecurityGroups) joinSecurityGroupRules(subEntries SecurityGroupRules) bool { + for _, m := range ms { + m.SecurityGroupRules = SecurityGroupRules{} + } + correct := true + for subId, subEntry := range subEntries { + id := subEntry.SecgroupId + m, ok := ms[id] + if !ok { + log.Warningf("secgrouprule %s: secgroup %s not found", + subEntry.Id, id) + correct = false + continue + } + if _, ok := m.SecurityGroupRules[subId]; ok { + log.Warningf("secgrouprule %s: already joined", subEntry.Id) + continue + } + subEntry.SecurityGroup = m + m.SecurityGroupRules[subId] = subEntry + } + return correct +} + +func (set SecurityGroupRules) ModelManager() mcclient_modulebase.IBaseManager { + return &mcclient_modules.SecGroupRules +} + +func (set SecurityGroupRules) NewModel() db.IModel { + return &SecurityGroupRule{} +} + +func (set SecurityGroupRules) AddModel(i db.IModel) { + m := i.(*SecurityGroupRule) + set[m.Id] = m +} + +func (set SecurityGroupRules) Copy() apihelper.IModelSet { + setCopy := SecurityGroupRules{} + for id, el := range set { + setCopy[id] = el.Copy() + } + return setCopy +} + +func (set Guestsecgroups) ModelManager() mcclient_modulebase.IBaseManager { + return &mcclient_modules.Serversecgroups +} + +func (set Guestsecgroups) NewModel() db.IModel { + return &Guestsecgroup{} +} + +func (set Guestsecgroups) AddModel(i db.IModel) { + m := i.(*Guestsecgroup) + set[m.ModelSetKey()] = m +} + +func (set Guestsecgroups) Copy() apihelper.IModelSet { + setCopy := Guestsecgroups{} + for id, el := range set { + setCopy[id] = el.Copy() + } + return setCopy +} + +func (set Guestsecgroups) joinSecurityGroups(subEntries SecurityGroups) bool { + for _, el := range set { + secgroupId := el.SecgroupId + guestId := el.GuestId + subEntry, ok := subEntries[secgroupId] + if !ok { + // This is possible if guestsecgroups is for external resources + log.Infof("guestsecgroups cannot find secgroup %s for guest %s", + secgroupId, guestId) + continue + } + el.SecurityGroup = subEntry + } + return true +} + +func (set Guestsecgroups) joinGuests(subEntries Guests) bool { + for _, el := range set { + secgroupId := el.SecgroupId + guestId := el.GuestId + subEntry, ok := subEntries[guestId] + if !ok { + // This is possible if guestsecgroups is for external resources + log.Infof("guestsecgroups cannot find guest %s for secgroup %s", + guestId, secgroupId) + continue + } + el.Guest = subEntry + subEntry.SecurityGroups[secgroupId] = el.SecurityGroup + } + return true +} + +func (set Guestsecgroups) join(secgroups SecurityGroups, guests Guests) bool { + // order matters as joinGuests() will need to refer to secgroup joined + // by joinSecurityGroups() + c0 := set.joinSecurityGroups(secgroups) + c1 := set.joinGuests(guests) + return c0 && c1 +} diff --git a/pkg/vpcagent/models/modelsets.go b/pkg/vpcagent/models/modelsets.go index af7dcc3821..4dc3b2c327 100644 --- a/pkg/vpcagent/models/modelsets.go +++ b/pkg/vpcagent/models/modelsets.go @@ -38,38 +38,50 @@ func init() { } type ModelSetsMaxUpdatedAt struct { - Vpcs time.Time - Networks time.Time - Guests time.Time - Hosts time.Time - Guestnetworks time.Time + Vpcs time.Time + Networks time.Time + Guests time.Time + Hosts time.Time + SecurityGroups time.Time + SecurityGroupRules time.Time + Guestnetworks time.Time + Guestsecgroups time.Time } func NewModelSetsMaxUpdatedAt() *ModelSetsMaxUpdatedAt { return &ModelSetsMaxUpdatedAt{ - Vpcs: apihelper.PseudoZeroTime, - Networks: apihelper.PseudoZeroTime, - Guests: apihelper.PseudoZeroTime, - Hosts: apihelper.PseudoZeroTime, - Guestnetworks: apihelper.PseudoZeroTime, + Vpcs: apihelper.PseudoZeroTime, + Networks: apihelper.PseudoZeroTime, + Guests: apihelper.PseudoZeroTime, + Hosts: apihelper.PseudoZeroTime, + SecurityGroups: apihelper.PseudoZeroTime, + SecurityGroupRules: apihelper.PseudoZeroTime, + Guestnetworks: apihelper.PseudoZeroTime, + Guestsecgroups: apihelper.PseudoZeroTime, } } type ModelSets struct { - Vpcs Vpcs - Networks Networks - Guests Guests - Hosts Hosts - Guestnetworks Guestnetworks + Vpcs Vpcs + Networks Networks + Guests Guests + Hosts Hosts + SecurityGroups SecurityGroups + SecurityGroupRules SecurityGroupRules + Guestnetworks Guestnetworks + Guestsecgroups Guestsecgroups } func NewModelSets() *ModelSets { return &ModelSets{ - Vpcs: Vpcs{}, - Networks: Networks{}, - Guests: Guests{}, - Hosts: Hosts{}, - Guestnetworks: Guestnetworks{}, + Vpcs: Vpcs{}, + Networks: Networks{}, + Guests: Guests{}, + Hosts: Hosts{}, + SecurityGroups: SecurityGroups{}, + SecurityGroupRules: SecurityGroupRules{}, + Guestnetworks: Guestnetworks{}, + Guestsecgroups: Guestsecgroups{}, } } @@ -80,7 +92,10 @@ func (mss *ModelSets) ModelSetList() []apihelper.IModelSet { mss.Networks, mss.Guests, mss.Hosts, + mss.SecurityGroups, + mss.SecurityGroupRules, mss.Guestnetworks, + mss.Guestsecgroups, } } @@ -90,11 +105,14 @@ func (mss *ModelSets) NewEmpty() apihelper.IModelSets { func (mss *ModelSets) Copy() apihelper.IModelSets { mssCopy := &ModelSets{ - Vpcs: mss.Vpcs.Copy().(Vpcs), - Networks: mss.Networks.Copy().(Networks), - Guests: mss.Guests.Copy().(Guests), - Hosts: mss.Hosts.Copy().(Hosts), - Guestnetworks: mss.Guestnetworks.Copy().(Guestnetworks), + Vpcs: mss.Vpcs.Copy().(Vpcs), + Networks: mss.Networks.Copy().(Networks), + Guests: mss.Guests.Copy().(Guests), + Hosts: mss.Hosts.Copy().(Hosts), + SecurityGroups: mss.SecurityGroups.Copy().(SecurityGroups), + SecurityGroupRules: mss.SecurityGroupRules.Copy().(SecurityGroupRules), + Guestnetworks: mss.Guestnetworks.Copy().(Guestnetworks), + Guestsecgroups: mss.Guestsecgroups.Copy().(Guestsecgroups), } mssCopy.join() return mssCopy @@ -121,10 +139,14 @@ func (mss *ModelSets) ApplyUpdates(mssNews apihelper.IModelSets) apihelper.Model } func (mss *ModelSets) join() bool { + mss.Guests.initJoin() var p []bool p = append(p, mss.Vpcs.joinNetworks(mss.Networks)) p = append(p, mss.Networks.joinGuestnetworks(mss.Guestnetworks)) p = append(p, mss.Guests.joinHosts(mss.Hosts)) + p = append(p, mss.Guests.joinSecurityGroups(mss.SecurityGroups)) + p = append(p, mss.SecurityGroups.joinSecurityGroupRules(mss.SecurityGroupRules)) + p = append(p, mss.Guestsecgroups.join(mss.SecurityGroups, mss.Guests)) p = append(p, mss.Guestnetworks.joinGuests(mss.Guests)) for _, b := range p { if !b { From 1abdb4f13629eb5fa69fd7995a3e97bc0a5cb006 Mon Sep 17 00:00:00 2001 From: Yousong Zhou Date: Tue, 28 Apr 2020 22:04:06 +0800 Subject: [PATCH 08/13] vpcagent: models: sort security group rules --- pkg/vpcagent/models/secgrouprules_sort.go | 37 +++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 pkg/vpcagent/models/secgrouprules_sort.go diff --git a/pkg/vpcagent/models/secgrouprules_sort.go b/pkg/vpcagent/models/secgrouprules_sort.go new file mode 100644 index 0000000000..26e628b1be --- /dev/null +++ b/pkg/vpcagent/models/secgrouprules_sort.go @@ -0,0 +1,37 @@ +package models + +import ( + "sort" +) + +func (el *Guest) OrderedSecurityGroupRules() []*SecurityGroupRule { + rs := []*SecurityGroupRule{} + for _, secgroup := range el.SecurityGroups { + rs = append(rs, secgroup.securityGroupRules()...) + } + sort.Slice(rs, SecurityGroupRuleLessFunc(rs)) + if el.AdminSecurityGroup != nil { + rs = append(rs, el.AdminSecurityGroup.OrderedSecurityGroupRules()...) + } + return rs +} + +func (el *SecurityGroup) securityGroupRules() []*SecurityGroupRule { + rs := make([]*SecurityGroupRule, 0, len(el.SecurityGroupRules)) + for _, r := range el.SecurityGroupRules { + rs = append(rs, r) + } + return rs +} + +func (el *SecurityGroup) OrderedSecurityGroupRules() []*SecurityGroupRule { + rs := el.securityGroupRules() + sort.Slice(rs, SecurityGroupRuleLessFunc(rs)) + return rs +} + +func SecurityGroupRuleLessFunc(rs []*SecurityGroupRule) func(i, j int) bool { + return func(i, j int) bool { + return rs[i].Priority < rs[i].Priority + } +} From 9f4daafee29ba6245df4e7531b2d548f67a60828 Mon Sep 17 00:00:00 2001 From: Yousong Zhou Date: Mon, 11 May 2020 09:28:37 +0800 Subject: [PATCH 09/13] vpcagent: ovn: secgrouprules_acl --- pkg/vpcagent/ovn/secgrouprules_acl.go | 151 ++++++++++++++++++++++++++ 1 file changed, 151 insertions(+) create mode 100644 pkg/vpcagent/ovn/secgrouprules_acl.go diff --git a/pkg/vpcagent/ovn/secgrouprules_acl.go b/pkg/vpcagent/ovn/secgrouprules_acl.go new file mode 100644 index 0000000000..626afab501 --- /dev/null +++ b/pkg/vpcagent/ovn/secgrouprules_acl.go @@ -0,0 +1,151 @@ +package ovn + +import ( + "fmt" + "strconv" + "strings" + + "yunion.io/x/ovsdb/schema/ovn_nb" + "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/secrules" + + agentmodels "yunion.io/x/onecloud/pkg/vpcagent/models" +) + +const ( + errBadSecgroupRule = errors.Error("bad security group rule") +) + +const ( + aclDirToLport = "to-lport" + aclDirFromLport = "from-lport" +) + +func ruleToAcl(lport string, rule *agentmodels.SecurityGroupRule) (*ovn_nb.ACL, error) { + var ( + dir string + action string + + match string + matches []string + subfn string + errs []error + ) + + switch secrules.TSecurityRuleDirection(rule.Direction) { + case secrules.SecurityRuleIngress: + dir = aclDirToLport + subfn = "src" + matches = append(matches, fmt.Sprintf("outport == %q", lport)) + case secrules.SecurityRuleEgress: + dir = aclDirFromLport + subfn = "dst" + matches = append(matches, fmt.Sprintf("inport == %q", lport)) + default: + return nil, errors.Wrapf(errBadSecgroupRule, "unknown direction %q", rule.Direction) + } + + switch secrules.TSecurityRuleAction(rule.Action) { + case secrules.SecurityRuleAllow: + action = "allow-related" + case secrules.SecurityRuleDeny: + action = "drop" + default: + return nil, errors.Wrapf(errBadSecgroupRule, "unknown action %q", rule.Action) + } + + addL3Match := func() { + matches = append(matches, "ip4") + if cidr := strings.TrimSpace(rule.CIDR); cidr != "" && cidr != "0.0.0.0/0" { + matches = append(matches, fmt.Sprintf("ip4.%s == %s", subfn, cidr)) + } + } + addL4Match := func(l4proto string) { + var ( + l4portfn = fmt.Sprintf("%s.%s", l4proto, subfn) + portMatches []string + ) + + parsePort := func(pstr string) (int, error) { + pn, err := strconv.ParseUint(pstr, 10, 16) + if err != nil { + return -1, err + } + return int(pn), nil + } + for _, pstr := range strings.Split(rule.Ports, ",") { + pstr = strings.TrimSpace(pstr) + if pstr == "" { + continue + } + + if i := strings.Index(pstr, "-"); i >= 0 { + spstr := strings.TrimSpace(pstr[:i]) + epstr := strings.TrimSpace(pstr[i+1:]) + if spstr == "" || epstr == "" { + continue + } + + spn, err := parsePort(spstr) + if err != nil { + errs = append(errs, errors.Wrap(err, "start port")) + } + epn, err := parsePort(epstr) + if err != nil { + errs = append(errs, errors.Wrap(err, "end port")) + } + + if spn > epn { + spn, epn = epn, spn + } + if spn < epn { + portMatches = append(portMatches, + fmt.Sprintf("( %s >= %d && %s <= %d )", + l4portfn, spn, l4portfn, epn)) + } else /* spn == epn */ { + portMatches = append(portMatches, + fmt.Sprintf("%s == %d", l4portfn, spn)) + } + } else { + if pn, err := parsePort(pstr); err != nil { + errs = append(errs, errors.Wrap(err, "port")) + } else { + portMatches = append(portMatches, + fmt.Sprintf("%s == %d", l4portfn, pn)) + } + } + } + + matches = append(matches, l4proto) + if len(portMatches) > 0 { + matches = append(matches, strings.Join(portMatches, " || ")) + } + } + switch rule.Protocol { + case secrules.PROTO_ANY: + addL3Match() + case secrules.PROTO_TCP: + addL3Match() + addL4Match("tcp") + case secrules.PROTO_UDP: + addL3Match() + addL4Match("udp") + case secrules.PROTO_ICMP: + addL3Match() + matches = append(matches, "icmp4") + default: + return nil, errors.Wrapf(errBadSecgroupRule, "unknown protocol %q", rule.Protocol) + } + if len(errs) > 0 { + return nil, errors.NewAggregate(errs) + } + match = strings.Join(matches, " && ") + + acl := &ovn_nb.ACL{ + Priority: rule.Priority, + Direction: dir, + Match: match, + Action: action, + } + return acl, nil +} From 53f35461252268788b7f0b0d14ee268de0e074e3 Mon Sep 17 00:00:00 2001 From: Yousong Zhou Date: Wed, 29 Apr 2020 21:12:03 +0800 Subject: [PATCH 10/13] vpcagent: ovnutil: OvnNbctlArgsDestroy: take into account ACL --- pkg/vpcagent/ovnutil/ovn_nbctl.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/vpcagent/ovnutil/ovn_nbctl.go b/pkg/vpcagent/ovnutil/ovn_nbctl.go index 0d34e8ce4c..b8dead9f2c 100644 --- a/pkg/vpcagent/ovnutil/ovn_nbctl.go +++ b/pkg/vpcagent/ovnutil/ovn_nbctl.go @@ -159,7 +159,7 @@ func OvnNbctlArgsDestroy(irows []types.IRow) []string { case *ovn_nb.LogicalRouterPort: args = append(args, "--", "--if-exists", "lrp-del", irow.OvsdbUuid()) case *ovn_nb.LogicalRouterStaticRoute: - // find out vpc id/logical router from external_ids + case *ovn_nb.ACL: default: if !irow.OvsdbIsRoot() { panic(irow.OvsdbTableName()) From 579641a26898c2040e4c5d9ba347c7d3adb17fa5 Mon Sep 17 00:00:00 2001 From: Yousong Zhou Date: Wed, 29 Apr 2020 17:59:21 +0800 Subject: [PATCH 11/13] vpcagent: ovn: configure acl for lport --- pkg/vpcagent/ovn/keeper.go | 58 ++++++++++++++++++++++++++++++++++---- 1 file changed, 53 insertions(+), 5 deletions(-) diff --git a/pkg/vpcagent/ovn/keeper.go b/pkg/vpcagent/ovn/keeper.go index 13a2b44bd9..6346bd384c 100644 --- a/pkg/vpcagent/ovn/keeper.go +++ b/pkg/vpcagent/ovn/keeper.go @@ -19,6 +19,7 @@ import ( "fmt" "strings" + "yunion.io/x/log" "yunion.io/x/ovsdb/cli_util" "yunion.io/x/ovsdb/schema/ovn_nb" "yunion.io/x/ovsdb/types" @@ -48,6 +49,7 @@ func DumpOVNNorthbound(ctx context.Context, cli *ovnutil.OvnNbCtl) (*OVNNorthbou &db.LogicalRouter, &db.LogicalRouterPort, &db.LogicalRouterStaticRoute, + &db.ACL, &db.DHCPOptions, } args := []string{"--format=json", "list", ""} @@ -227,8 +229,10 @@ func (keeper *OVNNorthboundKeeper) ClaimGuestnetwork(ctx context.Context, guestn vpc = network.Vpc host = guest.Host + lportName = gnpName(guestnetwork.NetworkId, guestnetwork.Ifname) ocVersion = fmt.Sprintf("%s.%d", guestnetwork.UpdatedAt, guestnetwork.UpdateVersion) ocGnrRef = fmt.Sprintf("gnr/%s/%s/%s", vpc.Id, guestnetwork.GuestId, guestnetwork.Ifname) + ocAclRef = fmt.Sprintf("acl/%s/%s/%s", network.Id, guestnetwork.GuestId, guestnetwork.Ifname) dhcpOpt string ) @@ -254,7 +258,7 @@ func (keeper *OVNNorthboundKeeper) ClaimGuestnetwork(ctx context.Context, guestn } gnp := &ovn_nb.LogicalSwitchPort{ - Name: gnpName(guestnetwork.NetworkId, guestnetwork.Ifname), + Name: lportName, Addresses: []string{fmt.Sprintf("%s %s", guestnetwork.MacAddr, guestnetwork.IpAddr)}, PortSecurity: []string{fmt.Sprintf("%s %s/%d", guestnetwork.MacAddr, guestnetwork.IpAddr, guestnetwork.Network.GuestIpMask)}, Dhcpv4Options: &dhcpOpt, @@ -270,10 +274,29 @@ func (keeper *OVNNorthboundKeeper) ClaimGuestnetwork(ctx context.Context, guestn }, } - allFound, args := cmp(&keeper.DB, ocVersion, - gnp, - gnr, - ) + var acls []*ovn_nb.ACL + { + sgrs := guest.OrderedSecurityGroupRules() + for _, sgr := range sgrs { + acl, err := ruleToAcl(lportName, sgr) + if err != nil { + log.Errorf("converting security group rule to acl: %v", err) + break + } + acl.ExternalIds = map[string]string{ + externalKeyOcRef: ocAclRef, + } + acls = append(acls, acl) + } + } + + irows := []types.IRow{ + gnp, gnr, + } + for _, acl := range acls { + irows = append(irows, acl) + } + allFound, args := cmp(&keeper.DB, ocVersion, irows...) if allFound { return nil } @@ -281,6 +304,11 @@ func (keeper *OVNNorthboundKeeper) ClaimGuestnetwork(ctx context.Context, guestn args = append(args, ovnCreateArgs(gnr, "gnr")...) args = append(args, "--", "add", "Logical_Switch", netLsName(guestnetwork.NetworkId), "ports", "@"+gnp.Name) args = append(args, "--", "add", "Logical_Router", vpcLrName(vpc.Id), "static_routes", "@gnr") + for i, acl := range acls { + ref := fmt.Sprintf("acl%d", i) + args = append(args, ovnCreateArgs(acl, ref)...) + args = append(args, "--", "add", "Logical_Switch", netLsName(guestnetwork.NetworkId), "acls", "@"+ref) + } return keeper.cli.Must(ctx, "ClaimGuestnetwork", args) } @@ -292,6 +320,7 @@ func (keeper *OVNNorthboundKeeper) Mark(ctx context.Context) { &db.LogicalRouter, &db.LogicalRouterPort, &db.LogicalRouterStaticRoute, + &db.ACL, &db.DHCPOptions, } for _, itbl := range itbls { @@ -344,5 +373,24 @@ func (keeper *OVNNorthboundKeeper) Sweep(ctx context.Context) error { keeper.cli.Must(ctx, "Sweep static routes", args) } } + { + var args []string + for _, irow := range db.ACL.Rows() { + _, ok := irow.GetExternalId(externalKeyOcVersion) + if !ok { + ref, ok := irow.GetExternalId(externalKeyOcRef) + if ok { + parts := strings.SplitN(ref, "/", 4) + if len(parts) == 4 { + networkId := parts[1] + args = append(args, "--", "remove", "Logical_Switch", netLsName(networkId), "acls", irow.OvsdbUuid()) + } + } + } + } + if len(args) > 0 { + keeper.cli.Must(ctx, "Sweep acls", args) + } + } return nil } From 4f68026b84d9ed5c125fd4245dfff96514034805 Mon Sep 17 00:00:00 2001 From: Yousong Zhou Date: Tue, 12 May 2020 19:26:11 +0800 Subject: [PATCH 12/13] vendor: update yunion.io/x/ovsdb --- go.mod | 2 +- go.sum | 2 + vendor/modules.txt | 2 +- .../yunion.io/x/ovsdb/schema/ovn_nb/schema.go | 361 ++++++++++++++++-- vendor/yunion.io/x/ovsdb/types/atomic.go | 12 + vendor/yunion.io/x/ovsdb/types/atomic_gen.go | 56 +++ .../types/atomic_gen_iszero_zz_generated.go | 268 +++++++++++++ vendor/yunion.io/x/ovsdb/types/interface.go | 7 + vendor/yunion.io/x/ovsdb/types/schema_gen.go | 93 ++++- 9 files changed, 767 insertions(+), 36 deletions(-) create mode 100644 vendor/yunion.io/x/ovsdb/types/atomic_gen_iszero_zz_generated.go diff --git a/go.mod b/go.mod index 39fdfa2d00..e89fae70e8 100644 --- a/go.mod +++ b/go.mod @@ -129,7 +129,7 @@ require ( yunion.io/x/executor v0.0.0-20200227030256-a18417815e74 yunion.io/x/jsonutils v0.0.0-20200415132054-2bf8a5e94501 yunion.io/x/log v0.0.0-20200313080802-57a4ce5966b3 - yunion.io/x/ovsdb v0.0.0-20200508142751-3e60f3fc7d18 + yunion.io/x/ovsdb v0.0.0-20200512112253-a3601d1ee987 yunion.io/x/pkg v0.0.0-20200416145704-22c189971435 yunion.io/x/s3cli v0.0.0-20190917004522-13ac36d8687e yunion.io/x/sqlchemy v0.0.0-20200312002602-1177cd8fbc57 diff --git a/go.sum b/go.sum index 1dfcf0c968..8df2f89ad5 100644 --- a/go.sum +++ b/go.sum @@ -1119,6 +1119,8 @@ yunion.io/x/ovsdb v0.0.0-20200508121407-498ee891147e h1:M6sOv52s2wqXECm9w9eMHfEn yunion.io/x/ovsdb v0.0.0-20200508121407-498ee891147e/go.mod h1:0vLkNEhlmA64HViPBAnSTUMrx5QP1CLsxXmxDKQ80tc= yunion.io/x/ovsdb v0.0.0-20200508142751-3e60f3fc7d18 h1:MTR7IYAR5oxAjmBIcnk8A6PIjHz7gLN69jUgnkgYgQ8= yunion.io/x/ovsdb v0.0.0-20200508142751-3e60f3fc7d18/go.mod h1:0vLkNEhlmA64HViPBAnSTUMrx5QP1CLsxXmxDKQ80tc= +yunion.io/x/ovsdb v0.0.0-20200512112253-a3601d1ee987 h1:BlHpXbNhqG1rZ57io0+XI4L9ckWunn7LHR2JQikGqQg= +yunion.io/x/ovsdb v0.0.0-20200512112253-a3601d1ee987/go.mod h1:0vLkNEhlmA64HViPBAnSTUMrx5QP1CLsxXmxDKQ80tc= yunion.io/x/pkg v0.0.0-20190620104149-945c25821dbf/go.mod h1:t6rEGG2sQ4J7DhFxSZVOTjNd0YO/KlfWQyK1W4tog+E= yunion.io/x/pkg v0.0.0-20190628082551-f4033ba2ea30/go.mod h1:t6rEGG2sQ4J7DhFxSZVOTjNd0YO/KlfWQyK1W4tog+E= yunion.io/x/pkg v0.0.0-20200302034534-fdf44d54b070/go.mod h1:t6rEGG2sQ4J7DhFxSZVOTjNd0YO/KlfWQyK1W4tog+E= diff --git a/vendor/modules.txt b/vendor/modules.txt index 166fc98a94..0fce66e848 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -996,7 +996,7 @@ yunion.io/x/jsonutils # yunion.io/x/log v0.0.0-20200313080802-57a4ce5966b3 yunion.io/x/log yunion.io/x/log/hooks -# yunion.io/x/ovsdb v0.0.0-20200508142751-3e60f3fc7d18 +# yunion.io/x/ovsdb v0.0.0-20200512112253-a3601d1ee987 yunion.io/x/ovsdb/cli_util yunion.io/x/ovsdb/schema/ovn_nb yunion.io/x/ovsdb/types diff --git a/vendor/yunion.io/x/ovsdb/schema/ovn_nb/schema.go b/vendor/yunion.io/x/ovsdb/schema/ovn_nb/schema.go index 08345e2793..afcb1711cd 100644 --- a/vendor/yunion.io/x/ovsdb/schema/ovn_nb/schema.go +++ b/vendor/yunion.io/x/ovsdb/schema/ovn_nb/schema.go @@ -29,6 +29,8 @@ type OVNNorthbound struct { SSL SSLTable } +var _ types.IDatabase = &OVNNorthbound{} + func (db OVNNorthbound) FindOneMatchNonZeros(irow types.IRow) types.IRow { switch row := irow.(type) { case *ACL: @@ -36,106 +38,76 @@ func (db OVNNorthbound) FindOneMatchNonZeros(irow types.IRow) types.IRow { return r } return nil - } - switch row := irow.(type) { case *AddressSet: if r := db.AddressSet.FindOneMatchNonZeros(row); r != nil { return r } return nil - } - switch row := irow.(type) { case *Connection: if r := db.Connection.FindOneMatchNonZeros(row); r != nil { return r } return nil - } - switch row := irow.(type) { case *DHCPOptions: if r := db.DHCPOptions.FindOneMatchNonZeros(row); r != nil { return r } return nil - } - switch row := irow.(type) { case *DNS: if r := db.DNS.FindOneMatchNonZeros(row); r != nil { return r } return nil - } - switch row := irow.(type) { case *GatewayChassis: if r := db.GatewayChassis.FindOneMatchNonZeros(row); r != nil { return r } return nil - } - switch row := irow.(type) { case *LoadBalancer: if r := db.LoadBalancer.FindOneMatchNonZeros(row); r != nil { return r } return nil - } - switch row := irow.(type) { case *LogicalRouter: if r := db.LogicalRouter.FindOneMatchNonZeros(row); r != nil { return r } return nil - } - switch row := irow.(type) { case *LogicalRouterPort: if r := db.LogicalRouterPort.FindOneMatchNonZeros(row); r != nil { return r } return nil - } - switch row := irow.(type) { case *LogicalRouterStaticRoute: if r := db.LogicalRouterStaticRoute.FindOneMatchNonZeros(row); r != nil { return r } return nil - } - switch row := irow.(type) { case *LogicalSwitch: if r := db.LogicalSwitch.FindOneMatchNonZeros(row); r != nil { return r } return nil - } - switch row := irow.(type) { case *LogicalSwitchPort: if r := db.LogicalSwitchPort.FindOneMatchNonZeros(row); r != nil { return r } return nil - } - switch row := irow.(type) { case *NAT: if r := db.NAT.FindOneMatchNonZeros(row); r != nil { return r } return nil - } - switch row := irow.(type) { case *NBGlobal: if r := db.NBGlobal.FindOneMatchNonZeros(row); r != nil { return r } return nil - } - switch row := irow.(type) { case *QoS: if r := db.QoS.FindOneMatchNonZeros(row); r != nil { return r } return nil - } - switch row := irow.(type) { case *SSL: if r := db.SSL.FindOneMatchNonZeros(row); r != nil { return r @@ -145,6 +117,92 @@ func (db OVNNorthbound) FindOneMatchNonZeros(irow types.IRow) types.IRow { panic(types.ErrBadType) } +func (db OVNNorthbound) FindOneMatchByAnyIndex(irow types.IRow) types.IRow { + switch row := irow.(type) { + case *ACL: + if r := db.ACL.OvsdbGetByAnyIndex(row); r != nil { + return r + } + return nil + case *AddressSet: + if r := db.AddressSet.OvsdbGetByAnyIndex(row); r != nil { + return r + } + return nil + case *Connection: + if r := db.Connection.OvsdbGetByAnyIndex(row); r != nil { + return r + } + return nil + case *DHCPOptions: + if r := db.DHCPOptions.OvsdbGetByAnyIndex(row); r != nil { + return r + } + return nil + case *DNS: + if r := db.DNS.OvsdbGetByAnyIndex(row); r != nil { + return r + } + return nil + case *GatewayChassis: + if r := db.GatewayChassis.OvsdbGetByAnyIndex(row); r != nil { + return r + } + return nil + case *LoadBalancer: + if r := db.LoadBalancer.OvsdbGetByAnyIndex(row); r != nil { + return r + } + return nil + case *LogicalRouter: + if r := db.LogicalRouter.OvsdbGetByAnyIndex(row); r != nil { + return r + } + return nil + case *LogicalRouterPort: + if r := db.LogicalRouterPort.OvsdbGetByAnyIndex(row); r != nil { + return r + } + return nil + case *LogicalRouterStaticRoute: + if r := db.LogicalRouterStaticRoute.OvsdbGetByAnyIndex(row); r != nil { + return r + } + return nil + case *LogicalSwitch: + if r := db.LogicalSwitch.OvsdbGetByAnyIndex(row); r != nil { + return r + } + return nil + case *LogicalSwitchPort: + if r := db.LogicalSwitchPort.OvsdbGetByAnyIndex(row); r != nil { + return r + } + return nil + case *NAT: + if r := db.NAT.OvsdbGetByAnyIndex(row); r != nil { + return r + } + return nil + case *NBGlobal: + if r := db.NBGlobal.OvsdbGetByAnyIndex(row); r != nil { + return r + } + return nil + case *QoS: + if r := db.QoS.OvsdbGetByAnyIndex(row); r != nil { + return r + } + return nil + case *SSL: + if r := db.SSL.OvsdbGetByAnyIndex(row); r != nil { + return r + } + return nil + } + panic(types.ErrBadType) +} + type ACLTable []ACL var _ types.ITable = &ACLTable{} @@ -174,6 +232,14 @@ func (tbl *ACLTable) AppendRow(irow types.IRow) { *tbl = append(*tbl, *row) } +func (tbl ACLTable) OvsdbHasIndex() bool { + return false +} + +func (tbl ACLTable) OvsdbGetByAnyIndex(irow1 types.IRow) types.IRow { + return nil +} + func (tbl ACLTable) FindOneMatchNonZeros(row1 *ACL) *ACL { for i := range tbl { row := &tbl[i] @@ -350,6 +416,37 @@ func (tbl *AddressSetTable) AppendRow(irow types.IRow) { *tbl = append(*tbl, *row) } +func (tbl AddressSetTable) OvsdbHasIndex() bool { + return true +} + +func (row *AddressSet) MatchByName(row1 *AddressSet) bool { + if !types.MatchString(row.Name, row1.Name) { + return false + } + return true +} + +func (tbl AddressSetTable) GetByName(row1 *AddressSet) *AddressSet { + for i := range tbl { + row := &tbl[i] + if row.MatchByName(row1) { + return row + } + } + return nil +} + +func (tbl AddressSetTable) OvsdbGetByAnyIndex(irow1 types.IRow) types.IRow { + row1 := irow1.(*AddressSet) + if !(types.IsZeroString(row1.Name)) { + if row := tbl.GetByName(row1); row != nil { + return row + } + } + return nil +} + func (tbl AddressSetTable) FindOneMatchNonZeros(row1 *AddressSet) *AddressSet { for i := range tbl { row := &tbl[i] @@ -491,6 +588,37 @@ func (tbl *ConnectionTable) AppendRow(irow types.IRow) { *tbl = append(*tbl, *row) } +func (tbl ConnectionTable) OvsdbHasIndex() bool { + return true +} + +func (row *Connection) MatchByTarget(row1 *Connection) bool { + if !types.MatchString(row.Target, row1.Target) { + return false + } + return true +} + +func (tbl ConnectionTable) GetByTarget(row1 *Connection) *Connection { + for i := range tbl { + row := &tbl[i] + if row.MatchByTarget(row1) { + return row + } + } + return nil +} + +func (tbl ConnectionTable) OvsdbGetByAnyIndex(irow1 types.IRow) types.IRow { + row1 := irow1.(*Connection) + if !(types.IsZeroString(row1.Target)) { + if row := tbl.GetByTarget(row1); row != nil { + return row + } + } + return nil +} + func (tbl ConnectionTable) FindOneMatchNonZeros(row1 *Connection) *Connection { for i := range tbl { row := &tbl[i] @@ -660,6 +788,14 @@ func (tbl *DHCPOptionsTable) AppendRow(irow types.IRow) { *tbl = append(*tbl, *row) } +func (tbl DHCPOptionsTable) OvsdbHasIndex() bool { + return false +} + +func (tbl DHCPOptionsTable) OvsdbGetByAnyIndex(irow1 types.IRow) types.IRow { + return nil +} + func (tbl DHCPOptionsTable) FindOneMatchNonZeros(row1 *DHCPOptions) *DHCPOptions { for i := range tbl { row := &tbl[i] @@ -801,6 +937,14 @@ func (tbl *DNSTable) AppendRow(irow types.IRow) { *tbl = append(*tbl, *row) } +func (tbl DNSTable) OvsdbHasIndex() bool { + return false +} + +func (tbl DNSTable) OvsdbGetByAnyIndex(irow1 types.IRow) types.IRow { + return nil +} + func (tbl DNSTable) FindOneMatchNonZeros(row1 *DNS) *DNS { for i := range tbl { row := &tbl[i] @@ -935,6 +1079,37 @@ func (tbl *GatewayChassisTable) AppendRow(irow types.IRow) { *tbl = append(*tbl, *row) } +func (tbl GatewayChassisTable) OvsdbHasIndex() bool { + return true +} + +func (row *GatewayChassis) MatchByName(row1 *GatewayChassis) bool { + if !types.MatchString(row.Name, row1.Name) { + return false + } + return true +} + +func (tbl GatewayChassisTable) GetByName(row1 *GatewayChassis) *GatewayChassis { + for i := range tbl { + row := &tbl[i] + if row.MatchByName(row1) { + return row + } + } + return nil +} + +func (tbl GatewayChassisTable) OvsdbGetByAnyIndex(irow1 types.IRow) types.IRow { + row1 := irow1.(*GatewayChassis) + if !(types.IsZeroString(row1.Name)) { + if row := tbl.GetByName(row1); row != nil { + return row + } + } + return nil +} + func (tbl GatewayChassisTable) FindOneMatchNonZeros(row1 *GatewayChassis) *GatewayChassis { for i := range tbl { row := &tbl[i] @@ -1090,6 +1265,14 @@ func (tbl *LoadBalancerTable) AppendRow(irow types.IRow) { *tbl = append(*tbl, *row) } +func (tbl LoadBalancerTable) OvsdbHasIndex() bool { + return false +} + +func (tbl LoadBalancerTable) OvsdbGetByAnyIndex(irow1 types.IRow) types.IRow { + return nil +} + func (tbl LoadBalancerTable) FindOneMatchNonZeros(row1 *LoadBalancer) *LoadBalancer { for i := range tbl { row := &tbl[i] @@ -1238,6 +1421,14 @@ func (tbl *LogicalRouterTable) AppendRow(irow types.IRow) { *tbl = append(*tbl, *row) } +func (tbl LogicalRouterTable) OvsdbHasIndex() bool { + return false +} + +func (tbl LogicalRouterTable) OvsdbGetByAnyIndex(irow1 types.IRow) types.IRow { + return nil +} + func (tbl LogicalRouterTable) FindOneMatchNonZeros(row1 *LogicalRouter) *LogicalRouter { for i := range tbl { row := &tbl[i] @@ -1414,6 +1605,37 @@ func (tbl *LogicalRouterPortTable) AppendRow(irow types.IRow) { *tbl = append(*tbl, *row) } +func (tbl LogicalRouterPortTable) OvsdbHasIndex() bool { + return true +} + +func (row *LogicalRouterPort) MatchByName(row1 *LogicalRouterPort) bool { + if !types.MatchString(row.Name, row1.Name) { + return false + } + return true +} + +func (tbl LogicalRouterPortTable) GetByName(row1 *LogicalRouterPort) *LogicalRouterPort { + for i := range tbl { + row := &tbl[i] + if row.MatchByName(row1) { + return row + } + } + return nil +} + +func (tbl LogicalRouterPortTable) OvsdbGetByAnyIndex(irow1 types.IRow) types.IRow { + row1 := irow1.(*LogicalRouterPort) + if !(types.IsZeroString(row1.Name)) { + if row := tbl.GetByName(row1); row != nil { + return row + } + } + return nil +} + func (tbl LogicalRouterPortTable) FindOneMatchNonZeros(row1 *LogicalRouterPort) *LogicalRouterPort { for i := range tbl { row := &tbl[i] @@ -1597,6 +1819,14 @@ func (tbl *LogicalRouterStaticRouteTable) AppendRow(irow types.IRow) { *tbl = append(*tbl, *row) } +func (tbl LogicalRouterStaticRouteTable) OvsdbHasIndex() bool { + return false +} + +func (tbl LogicalRouterStaticRouteTable) OvsdbGetByAnyIndex(irow1 types.IRow) types.IRow { + return nil +} + func (tbl LogicalRouterStaticRouteTable) FindOneMatchNonZeros(row1 *LogicalRouterStaticRoute) *LogicalRouterStaticRoute { for i := range tbl { row := &tbl[i] @@ -1752,6 +1982,14 @@ func (tbl *LogicalSwitchTable) AppendRow(irow types.IRow) { *tbl = append(*tbl, *row) } +func (tbl LogicalSwitchTable) OvsdbHasIndex() bool { + return false +} + +func (tbl LogicalSwitchTable) OvsdbGetByAnyIndex(irow1 types.IRow) types.IRow { + return nil +} + func (tbl LogicalSwitchTable) FindOneMatchNonZeros(row1 *LogicalSwitch) *LogicalSwitch { for i := range tbl { row := &tbl[i] @@ -1928,6 +2166,37 @@ func (tbl *LogicalSwitchPortTable) AppendRow(irow types.IRow) { *tbl = append(*tbl, *row) } +func (tbl LogicalSwitchPortTable) OvsdbHasIndex() bool { + return true +} + +func (row *LogicalSwitchPort) MatchByName(row1 *LogicalSwitchPort) bool { + if !types.MatchString(row.Name, row1.Name) { + return false + } + return true +} + +func (tbl LogicalSwitchPortTable) GetByName(row1 *LogicalSwitchPort) *LogicalSwitchPort { + for i := range tbl { + row := &tbl[i] + if row.MatchByName(row1) { + return row + } + } + return nil +} + +func (tbl LogicalSwitchPortTable) OvsdbGetByAnyIndex(irow1 types.IRow) types.IRow { + row1 := irow1.(*LogicalSwitchPort) + if !(types.IsZeroString(row1.Name)) { + if row := tbl.GetByName(row1); row != nil { + return row + } + } + return nil +} + func (tbl LogicalSwitchPortTable) FindOneMatchNonZeros(row1 *LogicalSwitchPort) *LogicalSwitchPort { for i := range tbl { row := &tbl[i] @@ -2146,6 +2415,14 @@ func (tbl *NATTable) AppendRow(irow types.IRow) { *tbl = append(*tbl, *row) } +func (tbl NATTable) OvsdbHasIndex() bool { + return false +} + +func (tbl NATTable) OvsdbGetByAnyIndex(irow1 types.IRow) types.IRow { + return nil +} + func (tbl NATTable) FindOneMatchNonZeros(row1 *NAT) *NAT { for i := range tbl { row := &tbl[i] @@ -2308,6 +2585,14 @@ func (tbl *NBGlobalTable) AppendRow(irow types.IRow) { *tbl = append(*tbl, *row) } +func (tbl NBGlobalTable) OvsdbHasIndex() bool { + return false +} + +func (tbl NBGlobalTable) OvsdbGetByAnyIndex(irow1 types.IRow) types.IRow { + return nil +} + func (tbl NBGlobalTable) FindOneMatchNonZeros(row1 *NBGlobal) *NBGlobal { for i := range tbl { row := &tbl[i] @@ -2470,6 +2755,14 @@ func (tbl *QoSTable) AppendRow(irow types.IRow) { *tbl = append(*tbl, *row) } +func (tbl QoSTable) OvsdbHasIndex() bool { + return false +} + +func (tbl QoSTable) OvsdbGetByAnyIndex(irow1 types.IRow) types.IRow { + return nil +} + func (tbl QoSTable) FindOneMatchNonZeros(row1 *QoS) *QoS { for i := range tbl { row := &tbl[i] @@ -2632,6 +2925,14 @@ func (tbl *SSLTable) AppendRow(irow types.IRow) { *tbl = append(*tbl, *row) } +func (tbl SSLTable) OvsdbHasIndex() bool { + return false +} + +func (tbl SSLTable) OvsdbGetByAnyIndex(irow1 types.IRow) types.IRow { + return nil +} + func (tbl SSLTable) FindOneMatchNonZeros(row1 *SSL) *SSL { for i := range tbl { row := &tbl[i] diff --git a/vendor/yunion.io/x/ovsdb/types/atomic.go b/vendor/yunion.io/x/ovsdb/types/atomic.go index 4dbe6aef0b..b98e703881 100644 --- a/vendor/yunion.io/x/ovsdb/types/atomic.go +++ b/vendor/yunion.io/x/ovsdb/types/atomic.go @@ -35,6 +35,14 @@ var ( Uuid: "string", } + atomicZeroVals = map[Atomic]string{ + String: `""`, + Integer: `0`, + Real: `0`, + Boolean: `false`, + Uuid: `""`, + } + atomics = []Atomic{ String, Integer, @@ -56,6 +64,10 @@ func (a Atomic) fmtStr() string { return atomicFmtStrs[a] } +func (a Atomic) zeroVal() string { + return atomicZeroVals[a] +} + func (a Atomic) isValid() bool { _, ok := atomicGoMap[a] return ok diff --git a/vendor/yunion.io/x/ovsdb/types/atomic_gen.go b/vendor/yunion.io/x/ovsdb/types/atomic_gen.go index 3c22338105..48c83e7e61 100644 --- a/vendor/yunion.io/x/ovsdb/types/atomic_gen.go +++ b/vendor/yunion.io/x/ovsdb/types/atomic_gen.go @@ -36,6 +36,9 @@ func (ag *AtomicGen) Gen() error { if err := ag.genMatches(); err != nil { return err } + if err := ag.genIsZero(); err != nil { + return err + } return nil } @@ -421,3 +424,56 @@ func (ag *AtomicGen) genMatches_(w writer) { } } } + +func (ag *AtomicGen) genIsZero() error { + w, err := ag.prepGen("atomic_gen_iszero_zz_generated.go") + if err != nil { + return err + } + ag.genIsZero_(w) + return nil +} + +func (ag *AtomicGen) genIsZero_(w writer) { + for _, atom0 := range atomics { + var ( + name0 = atom0.exportName() + zero0 = atom0.zeroVal() + gotyp0 = atomicGoMap[atom0] + ) + w.Writef(`func IsZero%s(a %s) bool {`, name0, gotyp0) + w.Writef(` return a == %s`, zero0) + w.Writeln(`}`) + w.Writeln(``) + + w.Writef(`func IsZero%sOptional(a *%s) bool {`, name0, gotyp0) + w.Writeln(` if a == nil {`) + w.Writeln(` return true`) + w.Writeln(` }`) + w.Writeln(` return false`) + w.Writeln(`}`) + w.Writeln(``) + + w.Writef(`func IsZero%sMultiples(a, b []%s) bool {`, name0, gotyp0) + w.Writeln(` if len(a) == 0 {`) + w.Writeln(` return true`) + w.Writeln(` }`) + w.Writeln(` return false`) + w.Writeln(`}`) + w.Writeln(``) + + for _, atom1 := range atomics { + var ( + name1 = atom1.exportName() + gotyp1 = atomicGoMap[atom1] + ) + w.Writef(`func IsZeroMap%s%s(a map[%s]%s) bool {`, name0, name1, gotyp0, gotyp1) + w.Writeln(` if len(a) == 0 {`) + w.Writeln(` return true`) + w.Writeln(` }`) + w.Writef(` return false`) + w.Writeln(`}`) + w.Writeln(``) + } + } +} diff --git a/vendor/yunion.io/x/ovsdb/types/atomic_gen_iszero_zz_generated.go b/vendor/yunion.io/x/ovsdb/types/atomic_gen_iszero_zz_generated.go new file mode 100644 index 0000000000..1142edd7bf --- /dev/null +++ b/vendor/yunion.io/x/ovsdb/types/atomic_gen_iszero_zz_generated.go @@ -0,0 +1,268 @@ +// DO NOT EDIT: automatically generated code + +package types + +func IsZeroString(a string) bool { + return a == "" +} + +func IsZeroStringOptional(a *string) bool { + if a == nil { + return true + } + return false +} + +func IsZeroStringMultiples(a, b []string) bool { + if len(a) == 0 { + return true + } + return false +} + +func IsZeroMapStringString(a map[string]string) bool { + if len(a) == 0 { + return true + } + return false +} + +func IsZeroMapStringInteger(a map[string]int64) bool { + if len(a) == 0 { + return true + } + return false +} + +func IsZeroMapStringReal(a map[string]float64) bool { + if len(a) == 0 { + return true + } + return false +} + +func IsZeroMapStringBoolean(a map[string]bool) bool { + if len(a) == 0 { + return true + } + return false +} + +func IsZeroMapStringUuid(a map[string]string) bool { + if len(a) == 0 { + return true + } + return false +} + +func IsZeroInteger(a int64) bool { + return a == 0 +} + +func IsZeroIntegerOptional(a *int64) bool { + if a == nil { + return true + } + return false +} + +func IsZeroIntegerMultiples(a, b []int64) bool { + if len(a) == 0 { + return true + } + return false +} + +func IsZeroMapIntegerString(a map[int64]string) bool { + if len(a) == 0 { + return true + } + return false +} + +func IsZeroMapIntegerInteger(a map[int64]int64) bool { + if len(a) == 0 { + return true + } + return false +} + +func IsZeroMapIntegerReal(a map[int64]float64) bool { + if len(a) == 0 { + return true + } + return false +} + +func IsZeroMapIntegerBoolean(a map[int64]bool) bool { + if len(a) == 0 { + return true + } + return false +} + +func IsZeroMapIntegerUuid(a map[int64]string) bool { + if len(a) == 0 { + return true + } + return false +} + +func IsZeroReal(a float64) bool { + return a == 0 +} + +func IsZeroRealOptional(a *float64) bool { + if a == nil { + return true + } + return false +} + +func IsZeroRealMultiples(a, b []float64) bool { + if len(a) == 0 { + return true + } + return false +} + +func IsZeroMapRealString(a map[float64]string) bool { + if len(a) == 0 { + return true + } + return false +} + +func IsZeroMapRealInteger(a map[float64]int64) bool { + if len(a) == 0 { + return true + } + return false +} + +func IsZeroMapRealReal(a map[float64]float64) bool { + if len(a) == 0 { + return true + } + return false +} + +func IsZeroMapRealBoolean(a map[float64]bool) bool { + if len(a) == 0 { + return true + } + return false +} + +func IsZeroMapRealUuid(a map[float64]string) bool { + if len(a) == 0 { + return true + } + return false +} + +func IsZeroBoolean(a bool) bool { + return a == false +} + +func IsZeroBooleanOptional(a *bool) bool { + if a == nil { + return true + } + return false +} + +func IsZeroBooleanMultiples(a, b []bool) bool { + if len(a) == 0 { + return true + } + return false +} + +func IsZeroMapBooleanString(a map[bool]string) bool { + if len(a) == 0 { + return true + } + return false +} + +func IsZeroMapBooleanInteger(a map[bool]int64) bool { + if len(a) == 0 { + return true + } + return false +} + +func IsZeroMapBooleanReal(a map[bool]float64) bool { + if len(a) == 0 { + return true + } + return false +} + +func IsZeroMapBooleanBoolean(a map[bool]bool) bool { + if len(a) == 0 { + return true + } + return false +} + +func IsZeroMapBooleanUuid(a map[bool]string) bool { + if len(a) == 0 { + return true + } + return false +} + +func IsZeroUuid(a string) bool { + return a == "" +} + +func IsZeroUuidOptional(a *string) bool { + if a == nil { + return true + } + return false +} + +func IsZeroUuidMultiples(a, b []string) bool { + if len(a) == 0 { + return true + } + return false +} + +func IsZeroMapUuidString(a map[string]string) bool { + if len(a) == 0 { + return true + } + return false +} + +func IsZeroMapUuidInteger(a map[string]int64) bool { + if len(a) == 0 { + return true + } + return false +} + +func IsZeroMapUuidReal(a map[string]float64) bool { + if len(a) == 0 { + return true + } + return false +} + +func IsZeroMapUuidBoolean(a map[string]bool) bool { + if len(a) == 0 { + return true + } + return false +} + +func IsZeroMapUuidUuid(a map[string]string) bool { + if len(a) == 0 { + return true + } + return false +} diff --git a/vendor/yunion.io/x/ovsdb/types/interface.go b/vendor/yunion.io/x/ovsdb/types/interface.go index 0e1edba183..82db24185a 100644 --- a/vendor/yunion.io/x/ovsdb/types/interface.go +++ b/vendor/yunion.io/x/ovsdb/types/interface.go @@ -18,8 +18,15 @@ type IRow interface { type ITable interface { OvsdbTableName() string OvsdbIsRoot() bool + OvsdbHasIndex() bool + OvsdbGetByAnyIndex(IRow) IRow Rows() []IRow NewRow() IRow AppendRow(IRow) } + +type IDatabase interface { + FindOneMatchNonZeros(IRow) IRow + FindOneMatchByAnyIndex(IRow) IRow +} diff --git a/vendor/yunion.io/x/ovsdb/types/schema_gen.go b/vendor/yunion.io/x/ovsdb/types/schema_gen.go index dc78439404..056a081d48 100644 --- a/vendor/yunion.io/x/ovsdb/types/schema_gen.go +++ b/vendor/yunion.io/x/ovsdb/types/schema_gen.go @@ -3,6 +3,7 @@ package types import ( "fmt" "sort" + "strings" ) func (sch *Schema) OrderedTableNames() []string { @@ -45,23 +46,43 @@ func (sch *Schema) gen(w writer) { w.Writef(`%s %s`, fieldName, tblTyp) } w.Writef(`}`) + w.Writef(`var _ types.IDatabase = &%s{}`, schTyp) w.Writef(``) w.Writef(`func (db %s) FindOneMatchNonZeros(irow types.IRow) types.IRow {`, schTyp) + w.Writef(` switch row := irow.(type) {`) for _, name := range sch.OrderedTableNames() { var ( tbl = sch.Tables[name] rowTyp = tbl.rowTypeName() fieldName = tbl.tblField() ) - w.Writef(`switch row := irow.(type) {`) w.Writef(`case *%s:`, rowTyp) w.Writef(` if r := db.%s.FindOneMatchNonZeros(row); r != nil {`, fieldName) w.Writef(` return r`) w.Writef(` }`) w.Writef(` return nil`) - w.Writef(`}`) } + w.Writef(` }`) + w.Writef(` panic(types.ErrBadType)`) + w.Writef(`}`) + w.Writef(``) + + w.Writef(`func (db %s) FindOneMatchByAnyIndex(irow types.IRow) types.IRow {`, schTyp) + w.Writef(` switch row := irow.(type) {`) + for _, name := range sch.OrderedTableNames() { + var ( + tbl = sch.Tables[name] + rowTyp = tbl.rowTypeName() + fieldName = tbl.tblField() + ) + w.Writef(`case *%s:`, rowTyp) + w.Writef(` if r := db.%s.OvsdbGetByAnyIndex(row); r != nil {`, fieldName) + w.Writef(` return r`) + w.Writef(` }`) + w.Writef(` return nil`) + } + w.Writef(` }`) w.Writef(` panic(types.ErrBadType)`) w.Writef(`}`) w.Writef(``) @@ -138,6 +159,62 @@ func (tbl *Table) gen(w writer) { w.Writef(`}`) w.Writef(``) + w.Writef(`func (tbl %s) OvsdbHasIndex() bool {`, tblTyp) + w.Writef(` return %v`, len(tbl.Indexes) > 0) + w.Writef(`}`) + w.Writef(``) + getByFuncNames := make([]string, len(tbl.Indexes)) + for i, index := range tbl.Indexes { + fields := make([]string, len(index)) + matchSufs := make([]string, len(index)) + for j, colName := range index { + col := tbl.Columns[colName] + fields[j] = col.goField() + matchSufs[j] = col.matchFuncName() + } + getByFuncNames[i] = strings.Join(fields, "") + + w.Writef(`func (row *%s) MatchBy%s(row1 *%s) bool {`, rowTyp, getByFuncNames[i], rowTyp) + for i, field := range fields { + w.Writef("if !types.%s(row.%s, row1.%s) {", matchSufs[i], field, field) + w.Writef(" return false") + w.Writef("}") + } + w.Writef(` return true`) + w.Writef(`}`) + w.Writef(``) + + w.Writef(`func (tbl %s) GetBy%s(row1 *%s) *%s {`, tblTyp, getByFuncNames[i], rowTyp, rowTyp) + w.Writef(` for i := range tbl {`) + w.Writef(` row := &tbl[i]`) + w.Writef(` if row.MatchBy%s(row1) {`, getByFuncNames[i]) + w.Writef(` return row`) + w.Writef(` }`) + w.Writef(` }`) + w.Writef(` return nil`) + w.Writef(`}`) + w.Writef(``) + } + w.Writef(`func (tbl %s) OvsdbGetByAnyIndex(irow1 types.IRow) types.IRow {`, tblTyp) + if len(tbl.Indexes) > 0 { + w.Writef(` row1 := irow1.(*%s)`, rowTyp) + } + for i, index := range tbl.Indexes { + zeroConds := make([]string, len(index)) + for j, colName := range index { + col := tbl.Columns[colName] + zeroConds[j] = fmt.Sprintf("types.%s(row1.%s)", col.isZeroFuncName(), col.goField()) + } + w.Writef("if !(%s) {", strings.Join(zeroConds, "||")) + w.Writef(" if row := tbl.GetBy%s(row1); row != nil {", getByFuncNames[i]) + w.Writef(" return row") + w.Writef(" }") + w.Writef("}") + } + w.Writef(` return nil`) + w.Writef(`}`) + w.Writef(``) + w.Writef(`func (tbl %s) FindOneMatchNonZeros(row1 *%s) *%s {`, tblTyp, rowTyp, rowTyp) w.Writef(` for i := range tbl {`) w.Writef(` row := &tbl[i]`) @@ -208,7 +285,7 @@ func (tbl *Table) gen(w writer) { w.Writef(`func (row *%s) MatchNonZeros(row1 *%s) bool {`, rowTyp, rowTyp) for _, colName := range tbl.OrderedColumnNames() { col := tbl.Columns[colName] - w.Writef(`if !types.%s(row.%s, row1.%s) {`, col.matchFuncName(), col.goField(), col.goField()) + w.Writef(`if !types.%s(row.%s, row1.%s) {`, col.matchNonZeroFuncName(), col.goField(), col.goField()) w.Writef(` return false`) w.Writef(`}`) } @@ -357,6 +434,14 @@ func (col *Column) cmdArgsFuncName() string { return "OvsdbCmdArgs" + col.funcNameSuffix() } -func (col *Column) matchFuncName() string { +func (col *Column) matchNonZeroFuncName() string { return "Match" + col.funcNameSuffix() + "IfNonZero" } + +func (col *Column) matchFuncName() string { + return "Match" + col.funcNameSuffix() +} + +func (col *Column) isZeroFuncName() string { + return "IsZero" + col.funcNameSuffix() +} From 4962bdc7e14d4f8deb95d2132a4f334ff7e3efb3 Mon Sep 17 00:00:00 2001 From: Yousong Zhou Date: Tue, 12 May 2020 20:17:43 +0800 Subject: [PATCH 13/13] vpcagent: ovn: use db.FindOneMatchByAnyIndex --- pkg/vpcagent/ovn/cmp.go | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/pkg/vpcagent/ovn/cmp.go b/pkg/vpcagent/ovn/cmp.go index f66ebff733..3ed26a68f8 100644 --- a/pkg/vpcagent/ovn/cmp.go +++ b/pkg/vpcagent/ovn/cmp.go @@ -19,15 +19,8 @@ func cmp(db *ovn_nb.OVNNorthbound, ocver string, irows ...types.IRow) (bool, []s if irowFound != nil { irowsFound = append(irowsFound, irowFound) } else { - // TODO db.FindByIndex() - switch row := irow.(type) { - case *ovn_nb.LogicalSwitchPort: - rowQ := &ovn_nb.LogicalSwitchPort{ - Name: row.Name, - } - if irow := db.FindOneMatchNonZeros(rowQ); irow != nil { - irowsDiff = append(irowsDiff, irow) - } + if irowDiff := db.FindOneMatchByAnyIndex(irow); irowDiff != nil { + irowsDiff = append(irowsDiff, irowDiff) } } }