Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dependency verification #23

Open
wants to merge 55 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 44 commits
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
efb456d
add basic support of references to POST/GET subjects
libretto Apr 19, 2022
843a1da
fixups
libretto Apr 19, 2022
44f853a
fixup
libretto Apr 19, 2022
3498962
fixup
libretto Apr 19, 2022
9e9b16d
fixup
libretto Apr 20, 2022
944cd39
fixup
libretto Apr 20, 2022
956b68e
fixup
libretto Apr 26, 2022
d677bd5
merge with master and fixup conflicts
libretto Apr 26, 2022
764facf
debugging
libretto May 1, 2022
c1c4c50
referencedby/delete workarounds
libretto May 11, 2022
732a9ed
referencedby/delete workarounds
libretto May 11, 2022
1f33b7d
Add basic support of references with basic tests
libretto May 16, 2022
ebe889f
Merge branch 'master' into deps
sujayinstaclustr May 23, 2022
93cd241
removed reference for ujson
sujayinstaclustr May 23, 2022
2e9a8c6
added comma at the end
sujayinstaclustr May 23, 2022
516d280
dependencies verification without known deps
libretto Jun 14, 2022
cc1a691
fixup cyclic dependencies
libretto Jun 17, 2022
7f2cf01
Update schema_models.py
libretto Jun 19, 2022
0f2fab6
Update schema_models.py
libretto Jun 19, 2022
bbbb5a3
Update schema_models.py
libretto Jun 19, 2022
1d2b7c4
Update schema_reader.py
libretto Jun 19, 2022
4634373
Update karapace/schema_registry_apis.py
libretto Jun 19, 2022
4b99fc8
fixup style
libretto Jun 19, 2022
efe29f4
update code by PR review
libretto Jun 19, 2022
0854296
add reference_key()
libretto Jun 21, 2022
8a1b129
Merge branch 'master' into deps
sujayinstaclustr Jun 23, 2022
46146dd
fixed undefined variable missing due to merge
sujayinstaclustr Jun 23, 2022
967c822
removed extra line feeds
sujayinstaclustr Jun 29, 2022
73ff0f3
implementation of protobuf dependency verifications beta
libretto Jul 7, 2022
c38c952
fixup
libretto Jul 12, 2022
1f198af
delete workaround file
libretto Jul 13, 2022
da4171a
merge with main branch
libretto Jul 18, 2022
98d15e9
merge with main branch
libretto Jul 18, 2022
b0d2532
fixup issue
libretto Jul 18, 2022
69c5293
add info about confluent known dependencies
libretto Jul 18, 2022
70e8077
Update karapace/schema_registry_apis.py
libretto Jul 26, 2022
ef05bd4
improve PR1 code
libretto Jul 29, 2022
144c5ec
merge with deps
libretto Aug 1, 2022
8e57eeb
resolve conflicts with aiven/main
libretto Aug 4, 2022
1d4be0b
fixup merge issues
libretto Aug 8, 2022
fad2c0e
merge with aiven/master
libretto Aug 8, 2022
45c6c54
lint
libretto Aug 8, 2022
b454e1a
Merge branch 'master' into branch pr2
libretto Aug 18, 2022
e3ace7d
Merge remote-tracking branch 'origin' into pr2
libretto Aug 24, 2022
4bd7ff7
move dependency classes into separate files
libretto Sep 6, 2022
d8c54e1
change dependencies class
libretto Sep 7, 2022
d1fa06e
fixup references issues
libretto Sep 20, 2022
f72f855
fixup issues in code
libretto Sep 26, 2022
4d14ff0
fixup lint
libretto Sep 26, 2022
e1f39b9
add dependency verifier unit test
libretto Sep 28, 2022
90ef33c
add dependency verifier unit test
libretto Sep 28, 2022
341d355
merge with master
libretto Oct 4, 2022
7bd1ab6
fixup test bug with protobuf
libretto Oct 4, 2022
d5fdf59
fixup bug2
libretto Oct 5, 2022
37e8adb
fixup bug2
libretto Oct 5, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ __pycache__/
/kafka_*/
venv
/karapace/version.py
.run
14 changes: 14 additions & 0 deletions karapace/errors.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
from typing import List, Union


class VersionNotFoundException(Exception):
pass

Expand All @@ -18,6 +21,10 @@ class InvalidSchemaType(Exception):
pass


class InvalidReferences(Exception):
pass


class SchemasNotFoundException(Exception):
pass

Expand All @@ -36,3 +43,10 @@ class SubjectNotFoundException(Exception):

class SubjectNotSoftDeletedException(Exception):
pass


class ReferenceExistsException(Exception):
def __init__(self, referenced_by: List, version: Union[int, str]):
super().__init__()
self.version = version
self.referenced_by = referenced_by
4 changes: 4 additions & 0 deletions karapace/protobuf/exception.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ class ProtobufTypeException(Error):
"""Generic Protobuf type error."""


class ProtobufUnresolvedDependencyException(ProtobufException):
"""a Protobuf schema has unresolved dependency"""


class SchemaParseException(ProtobufException):
"""Error while parsing a Protobuf schema descriptor."""

Expand Down
158 changes: 158 additions & 0 deletions karapace/protobuf/google/protobuf/any.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,158 @@
// Protocol Buffers - Google's data interchange format
// Copyright 2008 Google Inc. All rights reserved.
// https://developers.google.com/protocol-buffers/
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

syntax = "proto3";

package google.protobuf;

option csharp_namespace = "Google.Protobuf.WellKnownTypes";
option go_package = "google.golang.org/protobuf/types/known/anypb";
option java_package = "com.google.protobuf";
option java_outer_classname = "AnyProto";
option java_multiple_files = true;
option objc_class_prefix = "GPB";

// `Any` contains an arbitrary serialized protocol buffer message along with a
// URL that describes the type of the serialized message.
//
// Protobuf library provides support to pack/unpack Any values in the form
// of utility functions or additional generated methods of the Any type.
//
// Example 1: Pack and unpack a message in C++.
//
// Foo foo = ...;
// Any any;
// any.PackFrom(foo);
// ...
// if (any.UnpackTo(&foo)) {
// ...
// }
//
// Example 2: Pack and unpack a message in Java.
//
// Foo foo = ...;
// Any any = Any.pack(foo);
// ...
// if (any.is(Foo.class)) {
// foo = any.unpack(Foo.class);
// }
//
// Example 3: Pack and unpack a message in Python.
//
// foo = Foo(...)
// any = Any()
// any.Pack(foo)
// ...
// if any.Is(Foo.DESCRIPTOR):
// any.Unpack(foo)
// ...
//
// Example 4: Pack and unpack a message in Go
//
// foo := &pb.Foo{...}
// any, err := anypb.New(foo)
// if err != nil {
// ...
// }
// ...
// foo := &pb.Foo{}
// if err := any.UnmarshalTo(foo); err != nil {
// ...
// }
//
// The pack methods provided by protobuf library will by default use
// 'type.googleapis.com/full.type.name' as the type URL and the unpack
// methods only use the fully qualified type name after the last '/'
// in the type URL, for example "foo.bar.com/x/y.z" will yield type
// name "y.z".
//
//
// JSON
//
// The JSON representation of an `Any` value uses the regular
// representation of the deserialized, embedded message, with an
// additional field `@type` which contains the type URL. Example:
//
// package google.profile;
// message Person {
// string first_name = 1;
// string last_name = 2;
// }
//
// {
// "@type": "type.googleapis.com/google.profile.Person",
// "firstName": <string>,
// "lastName": <string>
// }
//
// If the embedded message type is well-known and has a custom JSON
// representation, that representation will be embedded adding a field
// `value` which holds the custom JSON in addition to the `@type`
// field. Example (for message [google.protobuf.Duration][]):
//
// {
// "@type": "type.googleapis.com/google.protobuf.Duration",
// "value": "1.212s"
// }
//
message Any {
// A URL/resource name that uniquely identifies the type of the serialized
// protocol buffer message. This string must contain at least
// one "/" character. The last segment of the URL's path must represent
// the fully qualified name of the type (as in
// `path/google.protobuf.Duration`). The name should be in a canonical form
// (e.g., leading "." is not accepted).
//
// In practice, teams usually precompile into the binary all types that they
// expect it to use in the context of Any. However, for URLs which use the
// scheme `http`, `https`, or no scheme, one can optionally set up a type
// server that maps type URLs to message definitions as follows:
//
// * If no scheme is provided, `https` is assumed.
// * An HTTP GET on the URL must yield a [google.protobuf.Type][]
// value in binary format, or produce an error.
// * Applications are allowed to cache lookup results based on the
// URL, or have them precompiled into a binary to avoid any
// lookup. Therefore, binary compatibility needs to be preserved
// on changes to types. (Use versioned type names to manage
// breaking changes.)
//
// Note: this functionality is not currently available in the official
// protobuf release, and it is not used for type URLs beginning with
// type.googleapis.com.
//
// Schemes other than `http`, `https` (or the empty scheme) might be
// used with implementation specific semantics.
//
string type_url = 1;

// Must be a valid serialized protocol buffer of the above specified type.
bytes value = 2;
}
44 changes: 44 additions & 0 deletions karapace/protobuf/google/protobuf/any_test.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
// Protocol Buffers - Google's data interchange format
// Copyright 2008 Google Inc. All rights reserved.
// https://developers.google.com/protocol-buffers/
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

syntax = "proto3";

package protobuf_unittest;

import "google/protobuf/any.proto";

option java_outer_classname = "TestAnyProto";

message TestAny {
int32 int32_value = 1;
google.protobuf.Any any_value = 2;
repeated google.protobuf.Any repeated_any_value = 3;
string text = 4;
}
Loading