-
-
Notifications
You must be signed in to change notification settings - Fork 17
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
Automated Device Configuration with Event-Driven Filters #1309
Conversation
Important Review skippedMore than 25% of the files skipped due to max files limit. The review is being skipped to prevent a low-quality review. 149 files out of 258 files are above the max files limit of 50. Please upgrade to Pro plan to get higher limits. You can disable this status message by setting the WalkthroughThe update introduces a new service called Changes
Poem
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configration File (
|
6a85258
to
3cc79fb
Compare
835a887
to
02a9ec7
Compare
e24ed0e
to
5341f2c
Compare
96722e8
to
e438968
Compare
@coderabbitai review |
Actions PerformedReview triggered.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 21
Outside diff range and nitpick comments (9)
snippet-service/store/configuration.go (1)
34-41
: Consider using a more efficient cloning method if available.While the
Clone
method is correct, usingslices.Clone
might not be the most efficient way to clone complex nested structures if the library does not handle deep copies well. If performance becomes a concern, consider implementing a more tailored deep copy method.snippet-service/cmd/service/main.go (1)
35-48
: Review configuration loading and logging setup.The
main
function handles configuration loading and logging setup. It's generally well-implemented, but consider adding more detailed error messages and possibly a recovery mechanism if the configuration fails to load, to enhance the robustness of the service startup process.test/iotivity-lite/service/republish_test.go (1)
Line range hint
59-61
: The TLS configuration is missing a minimum version specification. This is a security best practice to ensure the use of up-to-date and secure TLS protocols.- RootCAs: test.GetRootCertificatePool(t), + RootCAs: test.GetRootCertificatePool(t), MinVersion: tls.VersionTLS13,cloud2cloud-gateway/service/subscribeToDevices_test.go (1)
Line range hint
57-59
: Update TLS configuration to use TLS 1.3.The TLS configuration used in the test setup does not specify a minimum version, which could lead to the use of less secure protocols. Update this to use TLS 1.3.
- credentials.NewTLS(&tls.Config{ RootCAs: test.GetRootCertificatePool(t) }) + credentials.NewTLS(&tls.Config{ RootCAs: test.GetRootCertificatePool(t), MinVersion: tls.VersionTLS13 })snippet-service/pb/README.md (1)
Line range hint
1-416
: The protocol documentation is comprehensive but contains several TODO comments which should be addressed to complete the documentation. Additionally, consider fixing the formatting inconsistencies in the unordered list indentation and the excessive blank lines throughout the document.- TODO naming + Provide specific names for the fields and entities marked with TODO.test/iotivity-lite/service/offboard_test.go (1)
Line range hint
66-68
: AddMinVersion: tls.VersionTLS13
to the TLS configurations to ensure the use of a secure protocol version.- RootCAs: test.GetRootCertificatePool(t), + RootCAs: test.GetRootCertificatePool(t), MinVersion: tls.VersionTLS13Also applies to: 222-224, 285-287, 350-352, 421-423, 486-488
snippet-service/pb/doc.html (3)
276-276
: Consider finalizing the naming forAppliedDeviceConfiguration
.It appears there is a placeholder comment "TODO naming" which suggests that the naming for
AppliedDeviceConfiguration
is not yet finalized. It would be beneficial to resolve this to ensure clarity in the documentation.
880-880
: Clarify the humorous comment inIDFilter
.The comment "configuration/123?version=latest :) Jozko spravi :)" in the
IDFilter
section seems to be informal and possibly a placeholder. It would be appropriate to replace it with a more formal and informative description.
1078-1078
: Clarify the description for theInvokeConfiguration
method inSnippetService
.The description "streaming process of update configuration to invoker" could be expanded to provide more details about what the method does, how it should be used, and what the expected outcomes are.
Review Details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files ignored due to path filters (5)
snippet-service/config.yaml
is excluded by!**/*.yaml
snippet-service/pb/service.pb.go
is excluded by!**/*.pb.go
,!**/*.pb.go
snippet-service/pb/service.pb.gw.go
is excluded by!**/*.pb.gw.go
,!**/*.pb.gw.go
snippet-service/pb/service.swagger.json
is excluded by!**/*.json
snippet-service/pb/service_grpc.pb.go
is excluded by!**/*.pb.go
,!**/*.pb.go
Files selected for processing (47)
- .github/workflows/build-publish.yaml (1 hunks)
- .golangci.yml (2 hunks)
- Makefile (1 hunks)
- bundle/Dockerfile (3 hunks)
- bundle/nginx/nginx.conf.template (1 hunks)
- bundle/run.sh (6 hunks)
- cloud2cloud-gateway/service/subscribeToDevices_test.go (2 hunks)
- cloud2cloud-gateway/test/events.go (1 hunks)
- snippet-service/Makefile (1 hunks)
- snippet-service/cmd/service/main.go (1 hunks)
- snippet-service/pb/README.md (1 hunks)
- snippet-service/pb/configuration.go (1 hunks)
- snippet-service/pb/doc.html (1 hunks)
- snippet-service/pb/service.proto (1 hunks)
- snippet-service/service/config.go (1 hunks)
- snippet-service/service/grpc/config.go (1 hunks)
- snippet-service/service/grpc/server.go (1 hunks)
- snippet-service/service/grpc/service.go (1 hunks)
- snippet-service/service/http/config.go (1 hunks)
- snippet-service/service/http/createConfiguration_test.go (1 hunks)
- snippet-service/service/http/getConfigurations_test.go (1 hunks)
- snippet-service/service/http/requestHandler.go (1 hunks)
- snippet-service/service/http/service.go (1 hunks)
- snippet-service/service/http/updateConfiguration_test.go (1 hunks)
- snippet-service/service/http/uri.go (1 hunks)
- snippet-service/service/service.go (1 hunks)
- snippet-service/service/service_test.go (1 hunks)
- snippet-service/store/condition.go (1 hunks)
- snippet-service/store/config/config.go (1 hunks)
- snippet-service/store/configuration.go (1 hunks)
- snippet-service/store/cqldb/config.go (1 hunks)
- snippet-service/store/cqldb/configuration.go (1 hunks)
- snippet-service/store/cqldb/store.go (1 hunks)
- snippet-service/store/mongodb/config.go (1 hunks)
- snippet-service/store/mongodb/configuration.go (1 hunks)
- snippet-service/store/mongodb/configuration_internal_test.go (1 hunks)
- snippet-service/store/mongodb/configuration_test.go (1 hunks)
- snippet-service/store/mongodb/store.go (1 hunks)
- snippet-service/store/store.go (1 hunks)
- snippet-service/test/configuration.go (1 hunks)
- snippet-service/test/service.go (1 hunks)
- snippet-service/test/test.go (1 hunks)
- test/config/config.go (1 hunks)
- test/http/request.go (1 hunks)
- test/http/uri.go (1 hunks)
- test/iotivity-lite/service/offboard_test.go (2 hunks)
- test/iotivity-lite/service/republish_test.go (1 hunks)
Files not reviewed due to errors (2)
- snippet-service/pb/service.proto (no review received)
- bundle/Dockerfile (no review received)
Files skipped from review due to trivial changes (9)
- .golangci.yml
- Makefile
- cloud2cloud-gateway/test/events.go
- snippet-service/service/grpc/config.go
- snippet-service/service/http/uri.go
- snippet-service/service/service_test.go
- snippet-service/store/condition.go
- snippet-service/store/mongodb/config.go
- test/config/config.go
Additional Context Used
LanguageTool (4)
snippet-service/pb/README.md (4)
Near line 7: Possible typo: you repeated a word
Context: ...nippet-service_pb_service-proto) - AppliedDeviceConfiguration - [AppliedDeviceConfiguration.RelationTo](#snippetservice-pb-AppliedD...
Rule ID: ENGLISH_WORD_REPEAT_RULE
Near line 11: Possible typo: you repeated a word
Context: ...n](#snippetservice-pb-Condition) - Configuration - [Configuration.Resource](#snippetservice-pb-Configurat...
Rule ID: ENGLISH_WORD_REPEAT_RULE
Near line 89: To form a complete sentence, be sure to include a subject.
Context: ...eused from invoke command or generated. Can be used to retrieve corresponding pendi...
Rule ID: MISSING_IT_THERE
Near line 89: Possible missing article found.
Context: ...d or generated. Can be used to retrieve corresponding pending command. | | status | [AppliedD...
Rule ID: AI_HYDRA_LEO_MISSING_THE
ShellCheck (263)
bundle/run.sh (263)
[info] 53-53: Possible misspelling: SCYLLA_PORT may not be assigned. Did you mean SCYLLA_HOST?
[info] 56-56: Possible misspelling: NATS_PORT may not be assigned. Did you mean NATS_HOST?
[info] 108-108: Double quote to prevent globbing and word splitting.
[info] 132-132: Double quote to prevent globbing and word splitting.
[info] 141-141: Double quote to prevent globbing and word splitting.
[info] 141-141: Double quote to prevent globbing and word splitting.
[info] 147-147: Double quote to prevent globbing and word splitting.
[info] 148-148: Double quote to prevent globbing and word splitting.
[info] 148-148: Double quote to prevent globbing and word splitting.
[info] 152-152: Double quote to prevent globbing and word splitting.
[info] 153-153: Double quote to prevent globbing and word splitting.
[info] 154-154: Double quote to prevent globbing and word splitting.
[info] 155-155: Double quote to prevent globbing and word splitting.
[info] 161-161: Double quote to prevent globbing and word splitting.
[info] 162-162: Double quote to prevent globbing and word splitting.
[info] 162-162: Double quote to prevent globbing and word splitting.
[style] 177-177: Use $(...) notation instead of legacy backticks
...
.
[info] 177-177: Double quote to prevent globbing and word splitting.
[warning] 178-178: Quote this to prevent word splitting.
[style] 178-178: Use $(...) notation instead of legacy backticks
...
.
[info] 178-178: Double quote to prevent globbing and word splitting.
[info] 180-180: Double quote to prevent globbing and word splitting.
[style] 185-185: Use $(...) notation instead of legacy backticks
...
.
[info] 185-185: Double quote to prevent globbing and word splitting.
[warning] 186-186: Quote this to prevent word splitting.
[style] 186-186: Use $(...) notation instead of legacy backticks
...
.
[info] 186-186: Double quote to prevent globbing and word splitting.
[info] 188-188: Double quote to prevent globbing and word splitting.
[style] 193-193: Use $(...) notation instead of legacy backticks
...
.
[info] 193-193: Double quote to prevent globbing and word splitting.
[warning] 194-194: Quote this to prevent word splitting.
[style] 194-194: Use $(...) notation instead of legacy backticks
...
.
[info] 194-194: Double quote to prevent globbing and word splitting.
[info] 196-196: Double quote to prevent globbing and word splitting.
[style] 202-202: Use $(...) notation instead of legacy backticks
...
.
[info] 202-202: Double quote to prevent globbing and word splitting.
[warning] 203-203: Quote this to prevent word splitting.
[style] 203-203: Use $(...) notation instead of legacy backticks
...
.
[info] 203-203: Double quote to prevent globbing and word splitting.
[info] 205-205: Double quote to prevent globbing and word splitting.
[style] 210-210: Use $(...) notation instead of legacy backticks
...
.
[info] 210-210: Double quote to prevent globbing and word splitting.
[warning] 211-211: Quote this to prevent word splitting.
[style] 211-211: Use $(...) notation instead of legacy backticks
...
.
[info] 211-211: Double quote to prevent globbing and word splitting.
[info] 213-213: Double quote to prevent globbing and word splitting.
[style] 218-218: Use $(...) notation instead of legacy backticks
...
.
[info] 218-218: Double quote to prevent globbing and word splitting.
[warning] 219-219: Quote this to prevent word splitting.
[style] 219-219: Use $(...) notation instead of legacy backticks
...
.
[info] 219-219: Double quote to prevent globbing and word splitting.
[info] 221-221: Double quote to prevent globbing and word splitting.
[style] 228-228: Use $(...) notation instead of legacy backticks
...
.
[info] 228-228: Double quote to prevent globbing and word splitting.
[warning] 229-229: Quote this to prevent word splitting.
[style] 229-229: Use $(...) notation instead of legacy backticks
...
.
[info] 229-229: Double quote to prevent globbing and word splitting.
[info] 231-231: Double quote to prevent globbing and word splitting.
[style] 236-236: Use $(...) notation instead of legacy backticks
...
.
[info] 236-236: Double quote to prevent globbing and word splitting.
[warning] 237-237: Quote this to prevent word splitting.
[style] 237-237: Use $(...) notation instead of legacy backticks
...
.
[info] 237-237: Double quote to prevent globbing and word splitting.
[info] 239-239: Double quote to prevent globbing and word splitting.
[style] 244-244: Use $(...) notation instead of legacy backticks
...
.
[info] 244-244: Double quote to prevent globbing and word splitting.
[warning] 245-245: Quote this to prevent word splitting.
[style] 245-245: Use $(...) notation instead of legacy backticks
...
.
[info] 245-245: Double quote to prevent globbing and word splitting.
[info] 247-247: Double quote to prevent globbing and word splitting.
[style] 254-254: Use $(...) notation instead of legacy backticks
...
.
[info] 254-254: Double quote to prevent globbing and word splitting.
[warning] 255-255: Quote this to prevent word splitting.
[style] 255-255: Use $(...) notation instead of legacy backticks
...
.
[info] 255-255: Double quote to prevent globbing and word splitting.
[info] 257-257: Double quote to prevent globbing and word splitting.
[style] 262-262: Use $(...) notation instead of legacy backticks
...
.
[info] 262-262: Double quote to prevent globbing and word splitting.
[warning] 263-263: Quote this to prevent word splitting.
[style] 263-263: Use $(...) notation instead of legacy backticks
...
.
[info] 263-263: Double quote to prevent globbing and word splitting.
[info] 265-265: Double quote to prevent globbing and word splitting.
[style] 270-270: Use $(...) notation instead of legacy backticks
...
.
[info] 270-270: Double quote to prevent globbing and word splitting.
[warning] 271-271: Quote this to prevent word splitting.
[style] 271-271: Use $(...) notation instead of legacy backticks
...
.
[info] 271-271: Double quote to prevent globbing and word splitting.
[info] 273-273: Double quote to prevent globbing and word splitting.
[style] 280-280: Use $(...) notation instead of legacy backticks
...
.
[info] 280-280: Double quote to prevent globbing and word splitting.
[warning] 281-281: Quote this to prevent word splitting.
[style] 281-281: Use $(...) notation instead of legacy backticks
...
.
[info] 281-281: Double quote to prevent globbing and word splitting.
[info] 283-283: Double quote to prevent globbing and word splitting.
[style] 288-288: Use $(...) notation instead of legacy backticks
...
.
[info] 288-288: Double quote to prevent globbing and word splitting.
[warning] 289-289: Quote this to prevent word splitting.
[style] 289-289: Use $(...) notation instead of legacy backticks
...
.
[info] 289-289: Double quote to prevent globbing and word splitting.
[info] 291-291: Double quote to prevent globbing and word splitting.
[style] 296-296: Use $(...) notation instead of legacy backticks
...
.
[info] 296-296: Double quote to prevent globbing and word splitting.
[warning] 297-297: Quote this to prevent word splitting.
[style] 297-297: Use $(...) notation instead of legacy backticks
...
.
[info] 297-297: Double quote to prevent globbing and word splitting.
[info] 299-299: Double quote to prevent globbing and word splitting.
[style] 306-306: Use $(...) notation instead of legacy backticks
...
.
[info] 306-306: Double quote to prevent globbing and word splitting.
[warning] 307-307: Quote this to prevent word splitting.
[style] 307-307: Use $(...) notation instead of legacy backticks
...
.
[info] 307-307: Double quote to prevent globbing and word splitting.
[info] 309-309: Double quote to prevent globbing and word splitting.
[style] 314-314: Use $(...) notation instead of legacy backticks
...
.
[info] 314-314: Double quote to prevent globbing and word splitting.
[warning] 315-315: Quote this to prevent word splitting.
[style] 315-315: Use $(...) notation instead of legacy backticks
...
.
[info] 315-315: Double quote to prevent globbing and word splitting.
[info] 317-317: Double quote to prevent globbing and word splitting.
[style] 322-322: Use $(...) notation instead of legacy backticks
...
.
[info] 322-322: Double quote to prevent globbing and word splitting.
[warning] 323-323: Quote this to prevent word splitting.
[style] 323-323: Use $(...) notation instead of legacy backticks
...
.
[info] 323-323: Double quote to prevent globbing and word splitting.
[info] 325-325: Double quote to prevent globbing and word splitting.
[style] 332-332: Use $(...) notation instead of legacy backticks
...
.
[info] 332-332: Double quote to prevent globbing and word splitting.
[warning] 333-333: Quote this to prevent word splitting.
[style] 333-333: Use $(...) notation instead of legacy backticks
...
.
[info] 333-333: Double quote to prevent globbing and word splitting.
[info] 335-335: Double quote to prevent globbing and word splitting.
[style] 340-340: Use $(...) notation instead of legacy backticks
...
.
[info] 340-340: Double quote to prevent globbing and word splitting.
[warning] 341-341: Quote this to prevent word splitting.
[style] 341-341: Use $(...) notation instead of legacy backticks
...
.
[info] 341-341: Double quote to prevent globbing and word splitting.
[info] 343-343: Double quote to prevent globbing and word splitting.
[style] 348-348: Use $(...) notation instead of legacy backticks
...
.
[info] 348-348: Double quote to prevent globbing and word splitting.
[warning] 349-349: Quote this to prevent word splitting.
[style] 349-349: Use $(...) notation instead of legacy backticks
...
.
[info] 349-349: Double quote to prevent globbing and word splitting.
[info] 351-351: Double quote to prevent globbing and word splitting.
[style] 358-358: Use $(...) notation instead of legacy backticks
...
.
[info] 358-358: Double quote to prevent globbing and word splitting.
[warning] 359-359: Quote this to prevent word splitting.
[style] 359-359: Use $(...) notation instead of legacy backticks
...
.
[info] 359-359: Double quote to prevent globbing and word splitting.
[info] 361-361: Double quote to prevent globbing and word splitting.
[style] 366-366: Use $(...) notation instead of legacy backticks
...
.
[info] 366-366: Double quote to prevent globbing and word splitting.
[warning] 367-367: Quote this to prevent word splitting.
[style] 367-367: Use $(...) notation instead of legacy backticks
...
.
[info] 367-367: Double quote to prevent globbing and word splitting.
[info] 369-369: Double quote to prevent globbing and word splitting.
[style] 374-374: Use $(...) notation instead of legacy backticks
...
.
[info] 374-374: Double quote to prevent globbing and word splitting.
[warning] 375-375: Quote this to prevent word splitting.
[style] 375-375: Use $(...) notation instead of legacy backticks
...
.
[info] 375-375: Double quote to prevent globbing and word splitting.
[info] 377-377: Double quote to prevent globbing and word splitting.
[style] 384-384: Use $(...) notation instead of legacy backticks
...
.
[info] 384-384: Double quote to prevent globbing and word splitting.
[warning] 385-385: Quote this to prevent word splitting.
[style] 385-385: Use $(...) notation instead of legacy backticks
...
.
[info] 385-385: Double quote to prevent globbing and word splitting.
[info] 387-387: Double quote to prevent globbing and word splitting.
[style] 392-392: Use $(...) notation instead of legacy backticks
...
.
[info] 392-392: Double quote to prevent globbing and word splitting.
[warning] 393-393: Quote this to prevent word splitting.
[style] 393-393: Use $(...) notation instead of legacy backticks
...
.
[info] 393-393: Double quote to prevent globbing and word splitting.
[info] 395-395: Double quote to prevent globbing and word splitting.
[style] 400-400: Use $(...) notation instead of legacy backticks
...
.
[info] 400-400: Double quote to prevent globbing and word splitting.
[warning] 401-401: Quote this to prevent word splitting.
[style] 401-401: Use $(...) notation instead of legacy backticks
...
.
[info] 401-401: Double quote to prevent globbing and word splitting.
[info] 403-403: Double quote to prevent globbing and word splitting.
[style] 410-410: Use $(...) notation instead of legacy backticks
...
.
[info] 410-410: Double quote to prevent globbing and word splitting.
[warning] 411-411: Quote this to prevent word splitting.
[style] 411-411: Use $(...) notation instead of legacy backticks
...
.
[info] 411-411: Double quote to prevent globbing and word splitting.
[info] 413-413: Double quote to prevent globbing and word splitting.
[style] 418-418: Use $(...) notation instead of legacy backticks
...
.
[info] 418-418: Double quote to prevent globbing and word splitting.
[warning] 419-419: Quote this to prevent word splitting.
[style] 419-419: Use $(...) notation instead of legacy backticks
...
.
[info] 419-419: Double quote to prevent globbing and word splitting.
[info] 421-421: Double quote to prevent globbing and word splitting.
[style] 426-426: Use $(...) notation instead of legacy backticks
...
.
[info] 426-426: Double quote to prevent globbing and word splitting.
[warning] 427-427: Quote this to prevent word splitting.
[style] 427-427: Use $(...) notation instead of legacy backticks
...
.
[info] 427-427: Double quote to prevent globbing and word splitting.
[info] 429-429: Double quote to prevent globbing and word splitting.
[info] 504-504: Double quote to prevent globbing and word splitting.
[style] 521-521: Useless cat. Consider 'cmd < file | ..' or 'cmd file | ..' instead.
[info] 537-537: Double quote to prevent globbing and word splitting.
[info] 549-549: Double quote to prevent globbing and word splitting.
[info] 552-552: Consider using pgrep instead of grepping ps output.
[style] 553-553: Check exit code directly with e.g. 'if ! mycmd;', not indirectly with $?.
[info] 571-571: Double quote to prevent globbing and word splitting.
[info] 585-585: Double quote to prevent globbing and word splitting.
[info] 607-607: Double quote to prevent globbing and word splitting.
[style] 619-619: Useless cat. Consider 'cmd < file | ..' or 'cmd file | ..' instead.
[info] 649-649: Double quote to prevent globbing and word splitting.
[style] 659-659: Useless cat. Consider 'cmd < file | ..' or 'cmd file | ..' instead.
[info] 696-696: Double quote to prevent globbing and word splitting.
[style] 708-708: Useless cat. Consider 'cmd < file | ..' or 'cmd file | ..' instead.
[info] 747-747: Double quote to prevent globbing and word splitting.
[style] 757-757: Useless cat. Consider 'cmd < file | ..' or 'cmd file | ..' instead.
[info] 799-799: Double quote to prevent globbing and word splitting.
[style] 810-810: Useless cat. Consider 'cmd < file | ..' or 'cmd file | ..' instead.
[style] 863-863: Useless cat. Consider 'cmd < file | ..' or 'cmd file | ..' instead.
[style] 916-916: Useless cat. Consider 'cmd < file | ..' or 'cmd file | ..' instead.
[info] 953-953: Double quote to prevent globbing and word splitting.
[style] 964-964: Useless cat. Consider 'cmd < file | ..' or 'cmd file | ..' instead.
[info] 997-997: Double quote to prevent globbing and word splitting.
[style] 1008-1008: Useless cat. Consider 'cmd < file | ..' or 'cmd file | ..' instead.
[info] 1048-1048: Double quote to prevent globbing and word splitting.
[style] 1058-1058: Useless cat. Consider 'cmd < file | ..' or 'cmd file | ..' instead.
[info] 1093-1093: Double quote to prevent globbing and word splitting.
[style] 1103-1103: Useless cat. Consider 'cmd < file | ..' or 'cmd file | ..' instead.
[info] 1145-1145: Double quote to prevent globbing and word splitting.
[style] 1156-1156: Useless cat. Consider 'cmd < file | ..' or 'cmd file | ..' instead.
[info] 1191-1191: Double quote to prevent globbing and word splitting.
[info] 1206-1206: Consider using pgrep instead of grepping ps output.
[style] 1207-1207: Check exit code directly with e.g. 'if ! mycmd;', not indirectly with $?.
[info] 1213-1213: Consider using pgrep instead of grepping ps output.
[style] 1214-1214: Check exit code directly with e.g. 'if ! mycmd;', not indirectly with $?.
[info] 1220-1220: Consider using pgrep instead of grepping ps output.
[style] 1221-1221: Check exit code directly with e.g. 'if ! mycmd;', not indirectly with $?.
[info] 1227-1227: Consider using pgrep instead of grepping ps output.
[style] 1228-1228: Check exit code directly with e.g. 'if ! mycmd;', not indirectly with $?.
[info] 1234-1234: Consider using pgrep instead of grepping ps output.
[style] 1235-1235: Check exit code directly with e.g. 'if ! mycmd;', not indirectly with $?.
[style] 1241-1241: Use -n instead of ! -z.
[info] 1242-1242: Consider using pgrep instead of grepping ps output.
[info] 1242-1242: Double quote to prevent globbing and word splitting.
[style] 1243-1243: Check exit code directly with e.g. 'if ! mycmd;', not indirectly with $?.
[info] 1250-1250: Consider using pgrep instead of grepping ps output.
[style] 1251-1251: Check exit code directly with e.g. 'if ! mycmd;', not indirectly with $?.
[info] 1257-1257: Consider using pgrep instead of grepping ps output.
[style] 1258-1258: Check exit code directly with e.g. 'if ! mycmd;', not indirectly with $?.
[info] 1264-1264: Consider using pgrep instead of grepping ps output.
[style] 1265-1265: Check exit code directly with e.g. 'if ! mycmd;', not indirectly with $?.
[info] 1271-1271: Consider using pgrep instead of grepping ps output.
[style] 1272-1272: Check exit code directly with e.g. 'if ! mycmd;', not indirectly with $?.
[info] 1278-1278: Consider using pgrep instead of grepping ps output.
[style] 1279-1279: Check exit code directly with e.g. 'if ! mycmd;', not indirectly with $?.
[info] 1285-1285: Consider using pgrep instead of grepping ps output.
[style] 1286-1286: Check exit code directly with e.g. 'if ! mycmd;', not indirectly with $?.
[info] 1292-1292: Consider using pgrep instead of grepping ps output.
[style] 1293-1293: Check exit code directly with e.g. 'if ! mycmd;', not indirectly with $?.
[info] 1299-1299: Consider using pgrep instead of grepping ps output.
[style] 1300-1300: Check exit code directly with e.g. 'if ! mycmd;', not indirectly with $?.
[style] 1306-1306: Use -n instead of ! -z.
[info] 1307-1307: Consider using pgrep instead of grepping ps output.
[info] 1307-1307: Double quote to prevent globbing and word splitting.
[style] 1308-1308: Check exit code directly with e.g. 'if ! mycmd;', not indirectly with $?.
[info] 1315-1315: Consider using pgrep instead of grepping ps output.
[style] 1316-1316: Check exit code directly with e.g. 'if ! mycmd;', not indirectly with $?.
Markdownlint (168)
snippet-service/pb/README.md (168)
7: Expected: 2; Actual: 4
Unordered list indentation
8: Expected: 2; Actual: 4
Unordered list indentation
9: Expected: 2; Actual: 4
Unordered list indentation
10: Expected: 2; Actual: 4
Unordered list indentation
11: Expected: 2; Actual: 4
Unordered list indentation
12: Expected: 2; Actual: 4
Unordered list indentation
13: Expected: 2; Actual: 4
Unordered list indentation
14: Expected: 2; Actual: 4
Unordered list indentation
15: Expected: 2; Actual: 4
Unordered list indentation
16: Expected: 2; Actual: 4
Unordered list indentation
17: Expected: 2; Actual: 4
Unordered list indentation
18: Expected: 2; Actual: 4
Unordered list indentation
19: Expected: 2; Actual: 4
Unordered list indentation
20: Expected: 2; Actual: 4
Unordered list indentation
21: Expected: 2; Actual: 4
Unordered list indentation
22: Expected: 2; Actual: 4
Unordered list indentation
23: Expected: 2; Actual: 4
Unordered list indentation
25: Expected: 2; Actual: 4
Unordered list indentation
27: Expected: 2; Actual: 4
Unordered list indentation
352: Expected: 0 or 2; Actual: 1
Trailing spaces
368: Expected: 0 or 2; Actual: 1
Trailing spaces
370: Expected: 0 or 2; Actual: 1
Trailing spaces
392: Expected: 0 or 2; Actual: 1
Trailing spaces
31: Expected: 1; Actual: 2
Multiple consecutive blank lines
32: Expected: 1; Actual: 3
Multiple consecutive blank lines
38: Expected: 1; Actual: 2
Multiple consecutive blank lines
39: Expected: 1; Actual: 3
Multiple consecutive blank lines
45: Expected: 1; Actual: 2
Multiple consecutive blank lines
59: Expected: 1; Actual: 2
Multiple consecutive blank lines
60: Expected: 1; Actual: 3
Multiple consecutive blank lines
61: Expected: 1; Actual: 4
Multiple consecutive blank lines
62: Expected: 1; Actual: 5
Multiple consecutive blank lines
63: Expected: 1; Actual: 6
Multiple consecutive blank lines
69: Expected: 1; Actual: 2
Multiple consecutive blank lines
75: Expected: 1; Actual: 2
Multiple consecutive blank lines
76: Expected: 1; Actual: 3
Multiple consecutive blank lines
77: Expected: 1; Actual: 4
Multiple consecutive blank lines
78: Expected: 1; Actual: 5
Multiple consecutive blank lines
79: Expected: 1; Actual: 6
Multiple consecutive blank lines
84: Expected: 1; Actual: 2
Multiple consecutive blank lines
85: Expected: 1; Actual: 3
Multiple consecutive blank lines
93: Expected: 1; Actual: 2
Multiple consecutive blank lines
94: Expected: 1; Actual: 3
Multiple consecutive blank lines
95: Expected: 1; Actual: 4
Multiple consecutive blank lines
96: Expected: 1; Actual: 5
Multiple consecutive blank lines
97: Expected: 1; Actual: 6
Multiple consecutive blank lines
103: Expected: 1; Actual: 2
Multiple consecutive blank lines
133: Expected: 1; Actual: 2
Multiple consecutive blank lines
134: Expected: 1; Actual: 3
Multiple consecutive blank lines
135: Expected: 1; Actual: 4
Multiple consecutive blank lines
136: Expected: 1; Actual: 5
Multiple consecutive blank lines
137: Expected: 1; Actual: 6
Multiple consecutive blank lines
142: Expected: 1; Actual: 2
Multiple consecutive blank lines
143: Expected: 1; Actual: 3
Multiple consecutive blank lines
157: Expected: 1; Actual: 2
Multiple consecutive blank lines
158: Expected: 1; Actual: 3
Multiple consecutive blank lines
159: Expected: 1; Actual: 4
Multiple consecutive blank lines
160: Expected: 1; Actual: 5
Multiple consecutive blank lines
161: Expected: 1; Actual: 6
Multiple consecutive blank lines
166: Expected: 1; Actual: 2
Multiple consecutive blank lines
167: Expected: 1; Actual: 3
Multiple consecutive blank lines
174: Expected: 1; Actual: 2
Multiple consecutive blank lines
175: Expected: 1; Actual: 3
Multiple consecutive blank lines
176: Expected: 1; Actual: 4
Multiple consecutive blank lines
177: Expected: 1; Actual: 5
Multiple consecutive blank lines
178: Expected: 1; Actual: 6
Multiple consecutive blank lines
183: Expected: 1; Actual: 2
Multiple consecutive blank lines
184: Expected: 1; Actual: 3
Multiple consecutive blank lines
189: Expected: 1; Actual: 2
Multiple consecutive blank lines
190: Expected: 1; Actual: 3
Multiple consecutive blank lines
191: Expected: 1; Actual: 4
Multiple consecutive blank lines
192: Expected: 1; Actual: 5
Multiple consecutive blank lines
193: Expected: 1; Actual: 6
Multiple consecutive blank lines
198: Expected: 1; Actual: 2
Multiple consecutive blank lines
199: Expected: 1; Actual: 3
Multiple consecutive blank lines
204: Expected: 1; Actual: 2
Multiple consecutive blank lines
205: Expected: 1; Actual: 3
Multiple consecutive blank lines
206: Expected: 1; Actual: 4
Multiple consecutive blank lines
207: Expected: 1; Actual: 5
Multiple consecutive blank lines
208: Expected: 1; Actual: 6
Multiple consecutive blank lines
213: Expected: 1; Actual: 2
Multiple consecutive blank lines
214: Expected: 1; Actual: 3
Multiple consecutive blank lines
219: Expected: 1; Actual: 2
Multiple consecutive blank lines
220: Expected: 1; Actual: 3
Multiple consecutive blank lines
221: Expected: 1; Actual: 4
Multiple consecutive blank lines
222: Expected: 1; Actual: 5
Multiple consecutive blank lines
223: Expected: 1; Actual: 6
Multiple consecutive blank lines
228: Expected: 1; Actual: 2
Multiple consecutive blank lines
229: Expected: 1; Actual: 3
Multiple consecutive blank lines
234: Expected: 1; Actual: 2
Multiple consecutive blank lines
235: Expected: 1; Actual: 3
Multiple consecutive blank lines
236: Expected: 1; Actual: 4
Multiple consecutive blank lines
237: Expected: 1; Actual: 5
Multiple consecutive blank lines
238: Expected: 1; Actual: 6
Multiple consecutive blank lines
243: Expected: 1; Actual: 2
Multiple consecutive blank lines
244: Expected: 1; Actual: 3
Multiple consecutive blank lines
249: Expected: 1; Actual: 2
Multiple consecutive blank lines
250: Expected: 1; Actual: 3
Multiple consecutive blank lines
251: Expected: 1; Actual: 4
Multiple consecutive blank lines
252: Expected: 1; Actual: 5
Multiple consecutive blank lines
253: Expected: 1; Actual: 6
Multiple consecutive blank lines
258: Expected: 1; Actual: 2
Multiple consecutive blank lines
259: Expected: 1; Actual: 3
Multiple consecutive blank lines
264: Expected: 1; Actual: 2
Multiple consecutive blank lines
265: Expected: 1; Actual: 3
Multiple consecutive blank lines
266: Expected: 1; Actual: 4
Multiple consecutive blank lines
267: Expected: 1; Actual: 5
Multiple consecutive blank lines
268: Expected: 1; Actual: 6
Multiple consecutive blank lines
274: Expected: 1; Actual: 2
Multiple consecutive blank lines
282: Expected: 1; Actual: 2
Multiple consecutive blank lines
283: Expected: 1; Actual: 3
Multiple consecutive blank lines
284: Expected: 1; Actual: 4
Multiple consecutive blank lines
285: Expected: 1; Actual: 5
Multiple consecutive blank lines
286: Expected: 1; Actual: 6
Multiple consecutive blank lines
291: Expected: 1; Actual: 2
Multiple consecutive blank lines
292: Expected: 1; Actual: 3
Multiple consecutive blank lines
297: Expected: 1; Actual: 2
Multiple consecutive blank lines
298: Expected: 1; Actual: 3
Multiple consecutive blank lines
299: Expected: 1; Actual: 4
Multiple consecutive blank lines
300: Expected: 1; Actual: 5
Multiple consecutive blank lines
301: Expected: 1; Actual: 6
Multiple consecutive blank lines
306: Expected: 1; Actual: 2
Multiple consecutive blank lines
307: Expected: 1; Actual: 3
Multiple consecutive blank lines
312: Expected: 1; Actual: 2
Multiple consecutive blank lines
313: Expected: 1; Actual: 3
Multiple consecutive blank lines
314: Expected: 1; Actual: 4
Multiple consecutive blank lines
315: Expected: 1; Actual: 5
Multiple consecutive blank lines
316: Expected: 1; Actual: 6
Multiple consecutive blank lines
322: Expected: 1; Actual: 2
Multiple consecutive blank lines
330: Expected: 1; Actual: 2
Multiple consecutive blank lines
331: Expected: 1; Actual: 3
Multiple consecutive blank lines
332: Expected: 1; Actual: 4
Multiple consecutive blank lines
333: Expected: 1; Actual: 5
Multiple consecutive blank lines
334: Expected: 1; Actual: 6
Multiple consecutive blank lines
339: Expected: 1; Actual: 2
Multiple consecutive blank lines
340: Expected: 1; Actual: 3
Multiple consecutive blank lines
348: Expected: 1; Actual: 2
Multiple consecutive blank lines
349: Expected: 1; Actual: 3
Multiple consecutive blank lines
350: Expected: 1; Actual: 4
Multiple consecutive blank lines
351: Expected: 1; Actual: 5
Multiple consecutive blank lines
352: Expected: 1; Actual: 6
Multiple consecutive blank lines
353: Expected: 1; Actual: 7
Multiple consecutive blank lines
354: Expected: 1; Actual: 8
Multiple consecutive blank lines
359: Expected: 1; Actual: 2
Multiple consecutive blank lines
367: Expected: 1; Actual: 2
Multiple consecutive blank lines
368: Expected: 1; Actual: 3
Multiple consecutive blank lines
369: Expected: 1; Actual: 4
Multiple consecutive blank lines
370: Expected: 1; Actual: 5
Multiple consecutive blank lines
371: Expected: 1; Actual: 6
Multiple consecutive blank lines
372: Expected: 1; Actual: 7
Multiple consecutive blank lines
377: Expected: 1; Actual: 2
Multiple consecutive blank lines
392: Expected: 1; Actual: 2
Multiple consecutive blank lines
393: Expected: 1; Actual: 3
Multiple consecutive blank lines
394: Expected: 1; Actual: 4
Multiple consecutive blank lines
395: Expected: 1; Actual: 5
Multiple consecutive blank lines
416: Expected: 1; Actual: 2
Multiple consecutive blank lines
1: Expected: 1; Actual: 0; Below
Headings should be surrounded by blank lines
42: Expected: 1; Actual: 0; Below
Headings should be surrounded by blank lines
66: Expected: 1; Actual: 0; Below
Headings should be surrounded by blank lines
100: Expected: 1; Actual: 0; Below
Headings should be surrounded by blank lines
271: Expected: 1; Actual: 0; Below
Headings should be surrounded by blank lines
319: Expected: 1; Actual: 0; Below
Headings should be surrounded by blank lines
88: null
Link fragments should be valid
91: null
Link fragments should be valid
171: null
Link fragments should be valid
55: Expected: leading_and_trailing; Actual: leading_only; Missing trailing pipe
Table pipe style
106: Expected: leading_and_trailing; Actual: leading_only; Missing trailing pipe
Table pipe style
148: Expected: leading_and_trailing; Actual: leading_only; Missing trailing pipe
Table pipe style
Hadolint (17)
bundle/Dockerfile (17)
3: Pin versions in apk add. Instead of
apk add <package>
useapk add <package>=<version>
128: Multiple consecutive
RUN
instructions. Consider consolidation.
129: Multiple consecutive
RUN
instructions. Consider consolidation.
131: Multiple consecutive
RUN
instructions. Consider consolidation.
132: Multiple consecutive
RUN
instructions. Consider consolidation.
133: Multiple consecutive
RUN
instructions. Consider consolidation.
140: Pin versions in apt get install. Instead of
apt-get install <package>
useapt-get install <package>=<version>
140: Do not use apt as it is meant to be a end-user tool, use apt-get or apt-cache instead
144: Quote this to prevent word splitting.
144: Avoid use of wget without progress bar. Use
wget --progress=dot:giga <url>
. Or consider using-q
or-nv
(shorthands for--quiet
or--no-verbose
).
145: Set the SHELL option -o pipefail before RUN with a pipe in it. If you are using /bin/sh in an alpine image or if your shell is symlinked to busybox then consider explicitly setting your SHELL to /bin/ash, or disable this check
146: Set the SHELL option -o pipefail before RUN with a pipe in it. If you are using /bin/sh in an alpine image or if your shell is symlinked to busybox then consider explicitly setting your SHELL to /bin/ash, or disable this check
147: Do not use apt as it is meant to be a end-user tool, use apt-get or apt-cache instead
147: Pin versions in apt get install. Instead of
apt-get install <package>
useapt-get install <package>=<version>
182: Either use Wget or Curl but not both
182: Do not use sudo as it leads to unpredictable behavior. Use a tool like gosu to enforce root
182: Set the SHELL option -o pipefail before RUN with a pipe in it. If you are using /bin/sh in an alpine image or if your shell is symlinked to busybox then consider explicitly setting your SHELL to /bin/ash, or disable this check
Additional comments not posted (51)
test/http/uri.go (1)
6-10
: The addition ofIDKey
andConfigurationIDKey
aligns well with existing URI constants and supports the new functionality insnippet-service
.snippet-service/store/config/config.go (1)
1-9
: The configuration type definition for integrating MongoDB and CQLDB is clear and follows good practices for structuring configurations in Go.snippet-service/store/cqldb/config.go (1)
7-15
: The configuration struct for CQLDB is well-defined, and the validation method is appropriately implemented.snippet-service/service/http/config.go (1)
11-22
: The HTTP configuration struct is robustly defined, and the validation method ensures all components are correctly configured.snippet-service/pb/configuration.go (1)
12-25
: The method for validating and normalizingConfiguration
objects is comprehensive, ensuring data integrity and consistency.snippet-service/store/cqldb/configuration.go (1)
10-24
: All CRUD operation methods in the CQLDB store returnErrNotSupported
. Please verify if this is intentional and consider documenting the reason for these limitations to improve code clarity.Would you like me to document these limitations in the code or open a GitHub issue to track this task?
snippet-service/store/configuration.go (3)
13-16
: LGTM! TheConfigurationVersion
struct is well-defined with appropriate BSON tags.
18-23
: LGTM! TheConfiguration
struct is well-defined with appropriate BSON tags.
25-31
: LGTM! TheMakeConfiguration
function correctly initializes aConfiguration
instance from a protobuf message.snippet-service/test/test.go (2)
13-19
: LGTM! TheCmpJSON
function correctly compares JSON representations of objects.
35-42
: LGTM! TheCmpConfiguration
function correctly compares configurations, handling resources separately.snippet-service/store/mongodb/store.go (3)
19-21
: TheStore
struct is correctly defined to embed thepkgMongo.Store
. This allows leveraging existing MongoDB functionalities.
28-34
: The creation of a unique index on_id
and version is crucial for ensuring data integrity. This prevents duplicate configurations with the same version.
66-68
: Simple and effective closure of the MongoDB store. It ensures that all resources are properly released.test/iotivity-lite/service/republish_test.go (1)
48-48
: The change fromrequire.Greater
torequire.Positive
is appropriate as it simplifies the assertion while ensuring that the count is above zero.snippet-service/store/cqldb/store.go (1)
37-39
: TheStore
struct is correctly defined to embed thecqldb.Store
. This allows leveraging existing CQLDB functionalities.snippet-service/store/store.go (2)
29-32
: TheIterator
interface is well-defined, providing a clear contract for iteration over collections.
69-79
: The methods added to theStore
interface for managing configurations are clear and concise. Ensure that the implementations of these methods handle errors appropriately and log significant events.snippet-service/Makefile (2)
19-35
: Thebuild-docker-image
definition is robust, incorporating dynamic tags and build arguments. Ensure that the Docker build context is correctly set to include all necessary files.
49-63
: Theproto/generate
target is comprehensive, covering all necessary steps for generating protocol buffers, gRPC, and documentation. Ensure that all paths and dependencies are correctly configured to avoid build failures.Verification successful
The paths for the
googleapis
directory and theservice.proto
file have been identified:
dependency/googleapis/
snippet-service/pb/service.proto
Let's verify the existence of these paths and files using the correct paths.
The necessary directories and files for the
proto/generate
target have been verified:
- The
googleapis
directory exists atdependency/googleapis/
.- The
service.proto
file exists atsnippet-service/pb/service.proto
.This confirms that the paths and dependencies in the
proto/generate
target are correctly configured.Scripts Executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify that all paths and dependencies in the proto/generate target are correctly configured. # Test: Check for the existence of necessary directories and files. ls -l $(REPOSITORY_DIRECTORY)/dependency/googleapis $(REPOSITORY_DIRECTORY)/pb/service.protoLength of output: 407
Script:
#!/bin/bash # Description: Locate the necessary directories and files for the proto/generate target. # Locate the googleapis directory fd -t d googleapis # Locate the service.proto file fd -t f service.protoLength of output: 273
Script:
#!/bin/bash # Description: Verify the existence of necessary directories and files for the proto/generate target. # Check for the existence of the googleapis directory ls -l dependency/googleapis/ # Check for the existence of the service.proto file ls -l snippet-service/pb/service.protoLength of output: 162
snippet-service/test/service.go (4)
22-24
: TheHTTPURI
function correctly constructs URIs for HTTP requests. This is a useful utility for tests that need to make network requests.
26-44
: TheMakeConfig
function is well-implemented, setting up necessary configurations for testing. It's important to validate the configuration to catch any misconfigurations early.
46-73
: TheSetUp
andNew
functions provide a clean way to set up and tear down the snippet-service for tests. The use of async.WaitGroup
ensures that the service is properly shut down before the test exits.
75-97
: TheMakeStorageConfig
function sets up storage configurations with options for MongoDB and CQLDB. Ensure that the configurations are tested to handle different storage scenarios effectively.snippet-service/service/grpc/server.go (6)
25-33
: Constructor implementation looks good and correctly initializes all fields.
36-44
: Owner verification logic is correctly implemented to ensure security.
47-58
: Method for creating configurations is well-implemented with appropriate error handling.
61-72
: Update configuration method is correctly implemented with necessary owner checks and error handling.
75-102
: Method for retrieving configurations is implemented correctly with streaming support and robust error handling.
105-107
: Close method is simple and effective for cleaning up resources.snippet-service/service/config.go (5)
18-39
: Configuration struct and its validation method are correctly implemented, ensuring all fields are properly validated.
43-55
: APIs configuration and validation are well-defined, ensuring both gRPC and HTTP configurations are validated.
58-67
: HTTP configuration and its validation are properly implemented, ensuring the address is in a valid TCP format.
70-99
: Storage configuration includes comprehensive validation, ensuring both embedded config and cleanup records are correctly formatted.
102-114
: Clients configuration is well-structured with thorough validation for each client configuration.snippet-service/store/mongodb/configuration_internal_test.go (1)
10-111
: The test function for normalizing ID filters is well-implemented, covering various scenarios to ensure correct behavior..github/workflows/build-publish.yaml (1)
112-115
: The GitHub Actions job for building and publishing thesnippet-service
image is correctly configured with appropriate directory and Dockerfile paths.test/http/request.go (1)
105-111
: The methodID
inRequestBuilder
is correctly implemented to add ID parameters to the URI. Consider enhancing the security of the TLS configuration.- InsecureSkipVerify: true, + InsecureSkipVerify: true, MinVersion: tls.VersionTLS13Likely invalid or redundant comment.
snippet-service/test/configuration.go (1)
22-29
: Ensure consistent ID generation for configurations.The function
ConfigurationID
ensures that each configuration ID is generated once and reused, which is crucial for consistency in tests that may rely on the ID being the same across different calls.bundle/nginx/nginx.conf.template (1)
110-123
: Ensure proper configuration for the new snippet service endpoint.The configuration for the new
/api/v1/snippets
endpoint in the NGINX template is correctly set up to route traffic to the snippet service. This includes proper SSL configuration and CORS headers.snippet-service/store/mongodb/configuration.go (1)
16-26
: Ensure proper error handling for MongoDB operations.Verification successful
The
CreateConfiguration
function insnippet-service/store/mongodb/configuration.go
does handle errors returned by MongoDB operations. Specifically, it checks for errors after attempting to insert a document into the MongoDB collection and returns the error if one occurs.
snippet-service/store/mongodb/configuration.go:16-26
The function includes proper error handling for the MongoDB
InsertOne
operation, returning any errors encountered during the insertion process.Scripts Executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify MongoDB error handling in the `CreateConfiguration` function. # Test: Search for MongoDB error handling patterns. Expect: Proper error handling. rg --type python $'CreateConfiguration'Length of output: 69
Script:
#!/bin/bash # Description: Verify MongoDB error handling in the `CreateConfiguration` function. # Test: Search for the `CreateConfiguration` function in Go files and check for proper error handling. rg --type go 'func (s \*Store) CreateConfiguration' -A 10Length of output: 59
Script:
#!/bin/bash # Description: Verify MongoDB error handling in the `CreateConfiguration` function. # Test: Search for the `CreateConfiguration` function in Go files and check for proper error handling. rg 'func (s \*Store) CreateConfiguration' -t go -A 20Length of output: 55
Script:
#!/bin/bash # Description: Verify MongoDB error handling in the `CreateConfiguration` function. # Test: Search for the `CreateConfiguration` function across the entire repository and check for proper error handling. rg 'CreateConfiguration' -A 20Length of output: 60097
snippet-service/store/mongodb/configuration_test.go (3)
34-141
: The functionTestStoreCreateConfiguration
is well-structured and covers a comprehensive set of test cases for configuration creation.
143-232
: The functionTestUpdateConfiguration
effectively tests various scenarios for updating configurations, ensuring robust error handling and validation.
234-519
: The functionTestStoreGetConfigurations
is well-implemented, testing a variety of retrieval scenarios and ensuring the correct configurations are fetched based on different filters.test/iotivity-lite/service/offboard_test.go (2)
52-52
: Changes fromrequire.Greater
torequire.Positive
are appropriate and make the assertions clearer.Also applies to: 58-58
340-340
: Change fromrequire.Greater
torequire.Positive
is appropriate and makes the assertion clearer.bundle/run.sh (5)
27-28
: Added environment variables forSNIPPET_SERVICE_ADDRESS
andHTTP_SNIPPET_SERVICE_PORT
are correctly set.
1315-1321
: Monitor the snippet-service process to ensure it does not exit unexpectedly. Consider enhancing the monitoring logic to provide more detailed diagnostics in case of failure.- ps aux |grep $snippet_service_pid |grep -q -v grep - if [ $? -ne 0 ]; then - echo "snippet-service has already exited." - sync - cat $LOGS_PATH/snippet-service.log - exit 1 - fi + if ! ps -p $snippet_service_pid > /dev/null; then + echo "snippet-service has already exited." + sync + cat $LOGS_PATH/snippet-service.log + exit 1 + fiLikely invalid or redundant comment.
457-457
: Ensure theHTTP_SNIPPET_SERVICE_PORT
is defined and correctly replaced in the nginx configuration.
18-18
: Ensure the environment variableHTTP_CERTIFICATE_AUTHORITY_PORT
is defined.Verification successful
The environment variable
HTTP_CERTIFICATE_AUTHORITY_PORT
is defined in thebundle/Dockerfile
asENV HTTP_CERTIFICATE_AUTHORITY_PORT=9090
.
bundle/Dockerfile: ENV HTTP_CERTIFICATE_AUTHORITY_PORT=9090
Scripts Executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify if HTTP_CERTIFICATE_AUTHORITY_PORT is defined in the environment or configuration files. # Test: Search for the definition of HTTP_CERTIFICATE_AUTHORITY_PORT. Expect: At least one occurrence. rg --type bash 'HTTP_CERTIFICATE_AUTHORITY_PORT'Length of output: 77
Script:
#!/bin/bash # Description: Verify if HTTP_CERTIFICATE_AUTHORITY_PORT is defined in the environment or configuration files. # Test: Search for the definition of HTTP_CERTIFICATE_AUTHORITY_PORT. Expect: At least one occurrence. rg --type sh 'HTTP_CERTIFICATE_AUTHORITY_PORT'Length of output: 276
Script:
#!/bin/bash # Description: Verify if HTTP_CERTIFICATE_AUTHORITY_PORT is defined in common configuration files or environment setup scripts. # Test: Search for the definition of HTTP_CERTIFICATE_AUTHORITY_PORT in .env, .bashrc, .bash_profile, and other shell scripts. rg 'HTTP_CERTIFICATE_AUTHORITY_PORT' .env .bashrc .bash_profile rg --type sh 'HTTP_CERTIFICATE_AUTHORITY_PORT'Length of output: 487
Script:
#!/bin/bash # Description: Verify if HTTP_CERTIFICATE_AUTHORITY_PORT is defined in any shell scripts or configuration files in the repository. # Test: Search for the definition of HTTP_CERTIFICATE_AUTHORITY_PORT in all shell scripts and configuration files. rg 'HTTP_CERTIFICATE_AUTHORITY_PORT'Length of output: 459
1153-1185
: The configuration and startup sequence forsnippet-service
is correctly implemented. Ensure that the configuration file/data/snippet-service.yaml
is properly formatted and contains all necessary settings.
f965fe1
to
3030d53
Compare
{{- end }} | ||
labels: | ||
{{- include "plgd-hub.snippetservice.selectorLabels" . | nindent 8 }} | ||
spec: |
Check warning
Code scanning / SonarCloud
Service account tokens should not be mounted in pods Medium
{{- tpl .Values.snippetservice.initContainersTpl . | nindent 8 }} | ||
{{- end }} | ||
containers: | ||
- name: {{ .Values.snippetservice.name }} |
Check warning
Code scanning / SonarCloud
Storage limits should be enforced Medium
9a88892
to
a809956
Compare
e8bfe80
to
df593f4
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 6
Outside diff range and nitpick comments (2)
grpc-gateway/client/observeResource_test.go (1)
29-29
: Suggest additional assertions to verify correctness of observed resource.Add assertions to verify the correctness of the observed resource, such as checking the resource's state or properties.
grpc-gateway/client/createResource_test.go (1)
71-71
: Suggest additional test cases to cover more scenarios.Add test cases to cover more scenarios, such as creating resources with different data or handling different error conditions.
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files ignored due to path filters (19)
charts/plgd-hub/templates/http-gateway/config.yaml
is excluded by!**/*.yaml
charts/plgd-hub/templates/snippet-service/config.yaml
is excluded by!**/*.yaml
charts/plgd-hub/templates/snippet-service/deployment.yaml
is excluded by!**/*.yaml
charts/plgd-hub/templates/snippet-service/domain-crt.yaml
is excluded by!**/*.yaml
charts/plgd-hub/templates/snippet-service/grpc-ingress.yaml
is excluded by!**/*.yaml
charts/plgd-hub/templates/snippet-service/grpc-service.yaml
is excluded by!**/*.yaml
charts/plgd-hub/templates/snippet-service/http-ingress.yaml
is excluded by!**/*.yaml
charts/plgd-hub/templates/snippet-service/http-service.yaml
is excluded by!**/*.yaml
charts/plgd-hub/templates/snippet-service/role.yaml
is excluded by!**/*.yaml
charts/plgd-hub/templates/snippet-service/service-account.yaml
is excluded by!**/*.yaml
charts/plgd-hub/templates/snippet-service/service-crt.yaml
is excluded by!**/*.yaml
charts/plgd-hub/values.yaml
is excluded by!**/*.yaml
go.mod
is excluded by!**/*.mod
go.sum
is excluded by!**/*.sum
,!**/*.sum
grpc-gateway/pb/devices.pb.go
is excluded by!**/*.pb.go
,!**/*.pb.go
grpc-gateway/pb/getPendingCommands.pb.go
is excluded by!**/*.pb.go
,!**/*.pb.go
grpc-gateway/pb/hubConfiguration.pb.go
is excluded by!**/*.pb.go
,!**/*.pb.go
grpc-gateway/pb/service.swagger.json
is excluded by!**/*.json
http-gateway/config.yaml
is excluded by!**/*.yaml
Files selected for processing (54)
- .github/workflows/build-publish.yaml (1 hunks)
- .github/workflows/test.yml (5 hunks)
- .vscode/settings.json (1 hunks)
- Makefile (7 hunks)
- bundle/Dockerfile (3 hunks)
- bundle/nginx/nginx.conf.template (1 hunks)
- bundle/run.sh (6 hunks)
- charts/plgd-hub/templates/http-gateway/_helpers.tpl (1 hunks)
- charts/plgd-hub/templates/snippet-service/_helpers.tpl (1 hunks)
- cloud2cloud-gateway/service/retrieveDevice.go (2 hunks)
- cloud2cloud-gateway/test/test.go (4 hunks)
- coap-gateway/service/clientObserveHandler.go (3 hunks)
- coap-gateway/service/clientSubscriber.go (1 hunks)
- coap-gateway/service/observation/deviceObserver.go (3 hunks)
- coap-gateway/service/resourceDirectory.go (1 hunks)
- coap-gateway/service/signIn.go (3 hunks)
- coap-gateway/test/test.go (1 hunks)
- grpc-gateway/client/client_test.go (2 hunks)
- grpc-gateway/client/createResource_test.go (2 hunks)
- grpc-gateway/client/deleteResource_test.go (3 hunks)
- grpc-gateway/client/deviceSubscriber.go (1 hunks)
- grpc-gateway/client/deviceSubscriptions_test.go (4 hunks)
- grpc-gateway/client/getDevice_test.go (2 hunks)
- grpc-gateway/client/getDevices_test.go (2 hunks)
- grpc-gateway/client/getResource_test.go (2 hunks)
- grpc-gateway/client/maintenance.go (2 hunks)
- grpc-gateway/client/maintenance_test.go (3 hunks)
- grpc-gateway/client/observeDeviceResources_test.go (2 hunks)
- grpc-gateway/client/observeDevices_test.go (2 hunks)
- grpc-gateway/client/observeResource_test.go (2 hunks)
- grpc-gateway/client/updateResource_test.go (3 hunks)
- grpc-gateway/pb/README.md (5 hunks)
- grpc-gateway/pb/createResource.go (2 hunks)
- grpc-gateway/pb/deleteResource.go (2 hunks)
- grpc-gateway/pb/devices.proto (3 hunks)
- grpc-gateway/pb/doc.html (5 hunks)
- grpc-gateway/pb/getPendingCommands.proto (1 hunks)
- grpc-gateway/pb/hubConfiguration.proto (1 hunks)
- grpc-gateway/pb/updateResource.go (2 hunks)
- grpc-gateway/service/createResource.go (1 hunks)
- grpc-gateway/service/deleteResource.go (1 hunks)
- grpc-gateway/service/subscribeToEvents_test.go (4 hunks)
- grpc-gateway/service/updateResource.go (1 hunks)
- grpc-gateway/service/updateResource_test.go (2 hunks)
- grpc-gateway/test/test.go (1 hunks)
- http-gateway/service/config.go (1 hunks)
- http-gateway/service/getDevicePendingCommands_test.go (2 hunks)
- http-gateway/service/getDeviceResourceLinks_test.go (3 hunks)
- http-gateway/service/getHubConfiguration.go (1 hunks)
- http-gateway/service/getHubConfiguration_test.go (2 hunks)
- http-gateway/service/getPendingCommands_test.go (2 hunks)
- http-gateway/service/getResourcePendingCommands_test.go (2 hunks)
- http-gateway/test/test.go (2 hunks)
- http-gateway/uri/uri.go (2 hunks)
Files skipped from review due to trivial changes (1)
- .vscode/settings.json
Additional context used
Hadolint
bundle/Dockerfile
[error] 192-192: Do not use sudo as it leads to unpredictable behavior. Use a tool like gosu to enforce root
(DL3004)
LanguageTool
grpc-gateway/pb/README.md
[uncategorized] ~225-~225: Use a comma before “and” if it connects two independent clauses (unless they are closely connected and short).
Context: ...validity in nanoseconds. 0 means forever and minimal value is 100000000 (100ms). | |...(COMMA_COMPOUND_SENTENCE_2)
[uncategorized] ~225-~225: Possible missing comma found.
Context: ...onds. 0 means forever and minimal value is 100000000 (100ms). | | force | [bool](#...(AI_HYDRA_LEO_MISSING_COMMA)
[uncategorized] ~288-~288: Use a comma before “and” if it connects two independent clauses (unless they are closely connected and short).
Context: ...validity in nanoseconds. 0 means forever and minimal value is 100000000 (100ms). | |...(COMMA_COMPOUND_SENTENCE_2)
[uncategorized] ~288-~288: Possible missing comma found.
Context: ...onds. 0 means forever and minimal value is 100000000 (100ms). | | resource_interfa...(AI_HYDRA_LEO_MISSING_COMMA)
[uncategorized] ~700-~700: Use a comma before “and” if it connects two independent clauses (unless they are closely connected and short).
Context: ...validity in nanoseconds. 0 means forever and minimal value is 100000000 (100ms). | |...(COMMA_COMPOUND_SENTENCE_2)
[uncategorized] ~700-~700: Possible missing comma found.
Context: ...onds. 0 means forever and minimal value is 100000000 (100ms). | | content | [Conte...(AI_HYDRA_LEO_MISSING_COMMA)
[uncategorized] ~913-~913: Possible missing comma found.
Context: ...uests, use it multiple times as a query parameter like "resourceIdFilter={deviceID}{h...(AI_HYDRA_LEO_MISSING_COMMA)
[formatting] ~913-~913: These punctuation marks differ from each other. Use only one if you are ending a sentence.
Context: ...34;resourceIdFilter={deviceID}{href}". | | include_hidden_resources | [bool](#...(DOUBLE_PUNCTUATION_PREMIUM)
Markdownlint
grpc-gateway/pb/README.md
229-229: Expected: 1; Actual: 2
Multiple consecutive blank lines(MD012, no-multiple-blanks)
230-230: Expected: 1; Actual: 3
Multiple consecutive blank lines(MD012, no-multiple-blanks)
293-293: Expected: 1; Actual: 2
Multiple consecutive blank lines(MD012, no-multiple-blanks)
294-294: Expected: 1; Actual: 3
Multiple consecutive blank lines(MD012, no-multiple-blanks)
705-705: Expected: 1; Actual: 2
Multiple consecutive blank lines(MD012, no-multiple-blanks)
706-706: Expected: 1; Actual: 3
Multiple consecutive blank lines(MD012, no-multiple-blanks)
916-916: Expected: 1; Actual: 2
Multiple consecutive blank lines(MD012, no-multiple-blanks)
917-917: Expected: 1; Actual: 3
Multiple consecutive blank lines(MD012, no-multiple-blanks)
1062-1062: Expected: 1; Actual: 2
Multiple consecutive blank lines(MD012, no-multiple-blanks)
1063-1063: Expected: 1; Actual: 3
Multiple consecutive blank lines(MD012, no-multiple-blanks)
1059-1059: null
Bare URL used(MD034, no-bare-urls)
1060-1060: null
Bare URL used(MD034, no-bare-urls)
Additional comments not posted (117)
grpc-gateway/service/deleteResource.go (1)
10-18
: Verify correctness ofhandleResourceRequest
parameters.Ensure that the parameters passed to
handleResourceRequest
are correct and match the expected types and values.grpc-gateway/service/updateResource.go (1)
10-18
: Verify correctness ofhandleResourceRequest
parameters.Ensure that the parameters passed to
handleResourceRequest
are correct and match the expected types and values.Verification successful
The parameters passed to
handleResourceRequest
in theUpdateResource
function are correct.
- The parameters align with the expected types and values of the
handleResourceRequest
function.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the parameters passed to `handleResourceRequest` in `UpdateResource`. # Test: Search for the `handleResourceRequest` function definition. Expect: Correct parameter types and values. rg --type go 'func handleResourceRequest'Length of output: 173
Script:
#!/bin/bash # Description: Extract the `UpdateResource` function definition and check parameters passed to `handleResourceRequest`. # Find the `UpdateResource` function in `grpc-gateway/service/updateResource.go`. rg --type go --pcre2 'func UpdateResource' -A 20 grpc-gateway/service/updateResource.goLength of output: 89
Script:
#!/bin/bash # Description: Search for the `UpdateResource` function definition in the entire codebase and check parameters passed to `handleResourceRequest`. # Find the `UpdateResource` function in the entire codebase. rg --type go --pcre2 'func UpdateResource' -A 20Length of output: 50
Script:
#!/bin/bash # Description: Search for all `handleResourceRequest` calls in the codebase to identify where it is being used. # Find all calls to `handleResourceRequest` in the codebase. rg --type go 'handleResourceRequest'Length of output: 397
Script:
#!/bin/bash # Description: Extract more lines around the `handleResourceRequest` call in `grpc-gateway/service/updateResource.go` to identify the `UpdateResource` function and its parameters. # Extract lines around the `handleResourceRequest` call in `grpc-gateway/service/updateResource.go`. rg --type go 'handleResourceRequest' -A 10 -B 10 grpc-gateway/service/updateResource.goLength of output: 510
coap-gateway/service/clientSubscriber.go (3)
14-18
: LGTM!The function is correctly structured and thread-safe.
20-25
: LGTM!The function is correctly structured and ensures that the
deviceSubscriber
is not nil before calling the method.
Line range hint
26-34
:
LGTM!The function is correctly structured and ensures proper cleanup of the
deviceSubscriber
.grpc-gateway/pb/deleteResource.go (2)
Line range hint
8-34
:
LGTM!The function is correctly structured and includes the new
Force
field.
38-43
: LGTM!The function is correctly structured and ensures that the response object is not nil before setting the
Data
field.grpc-gateway/pb/createResource.go (2)
39-39
: LGTM!The addition of the
Force
field is consistent with the rest of the function.
43-48
: LGTM!The
SetData
function correctly sets theData
field and handles the case where the receiver isnil
.grpc-gateway/pb/updateResource.go (2)
40-40
: LGTM!The addition of the
Force
field is consistent with the rest of the function.
44-49
: LGTM!The
SetData
function correctly sets theData
field and handles the case where the receiver isnil
.grpc-gateway/pb/getPendingCommands.proto (1)
23-23
: LGTM!The addition of the
include_hidden_resources
field to theGetPendingCommandsRequest
message is consistent with the rest of the message structure.charts/plgd-hub/templates/snippet-service/_helpers.tpl (7)
1-12
: LGTM!The template
plgd-hub.snippetservice.fullname
correctly handles the full name based on various conditions.
14-17
: LGTM!The template
plgd-hub.snippetservice.configName
correctly generates the configuration name based on the full name.
19-26
: LGTM!The template
plgd-hub.snippetservice.createServiceCertByCm
correctly handles the creation of the service certificate based on the presence of thetls.certFile
.
28-34
: LGTM!The template
plgd-hub.snippetservice.domain
correctly generates the domain based on the presence of thesnippetservice.domain
value.
36-39
: LGTM!The template
plgd-hub.snippetservice.serviceCertName
correctly generates the service certificate name based on the full name.
41-48
: LGTM!The template
plgd-hub.snippetservice.domainCertName
correctly generates the domain certificate name based on the presence of theingress.secretName
.
50-53
: LGTM!The template
plgd-hub.snippetservice.selectorLabels
correctly generates the selector labels based on thesnippetservice.name
andRelease.Name
.grpc-gateway/service/createResource.go (6)
13-14
: LGTM!The
resourceError
function is correctly implemented.
17-19
: LGTM!The
reqRACommand
type constraint is correctly defined.
21-23
: LGTM!The
respCommand
type constraint is correctly defined.
25-28
: LGTM!The
reqCommand
type constraint is correctly defined.
35-69
: Verify the use of*
as the owner in the synchronous call.The use of
*
as the owner in the synchronous call tosyncFunc
might need verification to ensure it is intended and correct.
71-80
: LGTM!The
CreateResource
function is correctly implemented.grpc-gateway/test/test.go (2)
20-34
: LGTM!The
NewTestClient
function is correctly implemented.
Line range hint
35-58
: LGTM!The
MakeConfig
function is correctly implemented.grpc-gateway/client/observeDeviceResources_test.go (4)
29-31
: Ensure the client is properly closed.The client is properly closed using
defer
and error handling is done usingrequire.NoError
.
Line range hint
32-32
:
Ensure the test logic remains intact.The test logic remains intact, ensuring that device resources are observed correctly.
9-9
: Verify the new import.The new import
grpcgwTest
should be verified for correctness and consistency with the rest of the codebase.Verification successful
The new import is verified and consistent.
The import
grpcgwTest "github.com/plgd-dev/hub/v2/grpc-gateway/test"
is consistently used across multiple test files in the codebase, indicating it is correct and properly integrated.
snippet-service/service/service_test.go
snippet-service/service/http/invokeConfiguration_test.go
snippet-service/updater/resourceUpdater_test.go
test/service/service.go
grpc-gateway/client/observeResource_test.go
grpc-gateway/client/createResource_test.go
grpc-gateway/client/observeDevices_test.go
grpc-gateway/client/updateResource_test.go
grpc-gateway/client/getDevices_test.go
grpc-gateway/client/getDevice_test.go
grpc-gateway/client/deleteResource_test.go
grpc-gateway/client/getResource_test.go
grpc-gateway/client/maintenance_test.go
grpc-gateway/client/observeDeviceResources_test.go
grpc-gateway/client/deviceSubscriptions_test.go
Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the import `grpcgwTest` is consistent with the codebase. # Test: Search for the import usage. Expect: Consistent usage across the codebase. rg --type go 'grpcgwTest "github.com/plgd-dev/hub/v2/grpc-gateway/test"'Length of output: 1600
28-28
: Verify the usage ofgrpcgwTest.NewTestClient
.Ensure that the usage of
grpcgwTest.NewTestClient
is correct and efficient.Verification successful
The implementation of
grpcgwTest.NewTestClient
ingrpc-gateway/test/test.go
appears to be correct and efficient. The function sets up a test client with proper TLS configuration and error handling.
- Correctness: The function correctly configures the TLS settings and creates a new client from the configuration. It ensures that there are no errors during the client creation process.
- Efficiency: The function does not contain any redundant or inefficient operations.
No changes are necessary.
Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the usage of `grpcgwTest.NewTestClient`. # Test: Search for the usage of `grpcgwTest.NewTestClient`. Expect: Correct and efficient usage. rg --type go 'grpcgwTest.NewTestClient'Length of output: 1651
Script:
#!/bin/bash # Searching for the implementation of `NewTestClient` in the `grpcgwTest` package. ast-grep --lang go --pattern 'func NewTestClient($_) $_'Length of output: 900
grpc-gateway/client/maintenance.go (3)
69-69
: Ensure the logic for updating maintenance resources remains intact.The logic for updating maintenance resources remains intact, ensuring that the correct resource is updated based on the device ID and resource type.
6-6
: Verify the new import.The new import
slices
should be verified for correctness and consistency with the rest of the codebase.Verification successful
The new import
slices
is correctly and consistently used across the codebase.
grpc-gateway/client/maintenance.go
: Verified usage ofslices
.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the import `slices` is consistent with the codebase. # Test: Search for the import usage. Expect: Consistent usage across the codebase. rg --type go 'slices'Length of output: 5685
68-68
: Verify the usage ofslices.Contains
.Ensure that the usage of
slices.Contains
is correct and efficient for checking resource types.Verification successful
The usage of
slices.Contains
is correct.The method
r.GetResourceTypes()
returns a slice of strings ([]string
), andmaintenance.ResourceType
is a string. Therefore, usingslices.Contains
to check ifmaintenance.ResourceType
is in the slice returned byr.GetResourceTypes()
is both correct and efficient.
grpc-gateway/client/maintenance.go:68
Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the usage of `slices.Contains`. # Test: Search for the usage of `slices.Contains`. Expect: Correct and efficient usage. rg --type go 'slices.Contains'Length of output: 1267
Script:
#!/bin/bash # Verify the implementation of `r.GetResourceTypes()` and the definition of `maintenance.ResourceType`. # Find all Go files and search for the implementation of `GetResourceTypes` method. rg --type go 'func (.*) GetResourceTypes' # Find the definition of `maintenance.ResourceType`. rg --type go 'ResourceType'Length of output: 72267
grpc-gateway/client/getDevices_test.go (4)
74-76
: Ensure the client is properly closed.The client is properly closed using
defer
and error handling is done usingrequire.NoError
.
Line range hint
77-77
:
Ensure the test logic remains intact.The test logic remains intact, ensuring that devices are retrieved correctly.
9-9
: Verify the new import.The new import
grpcgwTest
should be verified for correctness and consistency with the rest of the codebase.Verification successful
Verified the new import.
The import statement
grpcgwTest "github.com/plgd-dev/hub/v2/grpc-gateway/test"
is consistently used across multiple test files in the codebase, indicating correctness.
- Files with the same import:
snippet-service/service/service_test.go
snippet-service/updater/resourceUpdater_test.go
snippet-service/service/http/invokeConfiguration_test.go
test/service/service.go
grpc-gateway/client/deviceSubscriptions_test.go
grpc-gateway/client/maintenance_test.go
grpc-gateway/client/observeDevices_test.go
grpc-gateway/client/observeResource_test.go
grpc-gateway/client/getDevices_test.go
grpc-gateway/client/getDevice_test.go
grpc-gateway/client/observeDeviceResources_test.go
grpc-gateway/client/deleteResource_test.go
grpc-gateway/client/createResource_test.go
grpc-gateway/client/getResource_test.go
grpc-gateway/client/updateResource_test.go
Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the import `grpcgwTest` is consistent with the codebase. # Test: Search for the import usage. Expect: Consistent usage across the codebase. rg --type go 'grpcgwTest "github.com/plgd-dev/hub/v2/grpc-gateway/test"'Length of output: 1600
73-73
: Verify the usage ofgrpcgwTest.NewTestClient
.Ensure that the usage of
grpcgwTest.NewTestClient
is correct and efficient.Verification successful
Verified the usage of
grpcgwTest.NewTestClient
.The usage of
grpcgwTest.NewTestClient
in the test files is correct and efficient. The client is created, used appropriately, and closed with error handling, ensuring proper resource management.
- No changes needed.
Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the usage of `grpcgwTest.NewTestClient`. # Test: Search for the usage of `grpcgwTest.NewTestClient`. Expect: Correct and efficient usage. rg --type go 'grpcgwTest.NewTestClient'Length of output: 1651
Script:
#!/bin/bash # Locate the definition of `grpcgwTest.NewTestClient` to understand its implementation. ast-grep --lang go --pattern 'func NewTestClient($_) $_' --jsonLength of output: 1169
Script:
#!/bin/bash # Check the context of `grpcgwTest.NewTestClient` usage in the test files to ensure correct and efficient usage. rg --type go -A 5 'grpcgwTest.NewTestClient'Length of output: 10094
grpc-gateway/client/observeDevices_test.go (4)
28-30
: Ensure the client is properly closed.The client is properly closed using
defer
and error handling is done usingrequire.NoError
.
Line range hint
31-31
:
Ensure the test logic remains intact.The test logic remains intact, ensuring that devices are observed correctly.
10-10
: Verify the new import.The new import
grpcgwTest
should be verified for correctness and consistency with the rest of the codebase.Verification successful
The new import is verified for correctness and consistency.
The import
grpcgwTest "github.com/plgd-dev/hub/v2/grpc-gateway/test"
is consistently used across various test files in the codebase, primarily to create test clients and configure GRPC gateway settings.
snippet-service/updater/resourceUpdater_test.go
snippet-service/service/service_test.go
snippet-service/service/http/invokeConfiguration_test.go
test/service/service.go
grpc-gateway/client/getDevices_test.go
grpc-gateway/client/deleteResource_test.go
grpc-gateway/client/observeDevices_test.go
grpc-gateway/client/observeResource_test.go
grpc-gateway/client/getResource_test.go
grpc-gateway/client/getDevice_test.go
grpc-gateway/client/maintenance_test.go
grpc-gateway/client/deviceSubscriptions_test.go
grpc-gateway/client/observeDeviceResources_test.go
grpc-gateway/client/createResource_test.go
grpc-gateway/client/updateResource_test.go
Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the import `grpcgwTest` is consistent with the codebase. # Test: Search for the import usage. Expect: Consistent usage across the codebase. rg --type go 'grpcgwTest "github.com/plgd-dev/hub/v2/grpc-gateway/test"'Length of output: 1600
Script:
#!/bin/bash # Description: Verify the usage of the imported `grpcgwTest` in the files where it is imported. # Test: Search for `grpcgwTest` usage in the relevant test files. files=( "snippet-service/updater/resourceUpdater_test.go" "snippet-service/service/service_test.go" "snippet-service/service/http/invokeConfiguration_test.go" "test/service/service.go" "grpc-gateway/client/getDevices_test.go" "grpc-gateway/client/deleteResource_test.go" "grpc-gateway/client/observeDevices_test.go" "grpc-gateway/client/observeResource_test.go" "grpc-gateway/client/getResource_test.go" "grpc-gateway/client/getDevice_test.go" "grpc-gateway/client/maintenance_test.go" "grpc-gateway/client/deviceSubscriptions_test.go" "grpc-gateway/client/observeDeviceResources_test.go" "grpc-gateway/client/createResource_test.go" "grpc-gateway/client/updateResource_test.go" ) for file in "${files[@]}"; do echo "Checking usage in $file" rg 'grpcgwTest' "$file" doneLength of output: 5715
27-27
: Verify the usage ofgrpcgwTest.NewTestClient
.Ensure that the usage of
grpcgwTest.NewTestClient
is correct and efficient.Verification successful
The usage of
grpcgwTest.NewTestClient
is correct and efficient.
- The function
NewTestClient
is correctly implemented ingrpc-gateway/test/test.go
.- The import statement for
grpcgwTest
ingrpc-gateway/client/observeDevices_test.go
is correct.- The client is properly initialized and closed in the test file.
Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the usage of `grpcgwTest.NewTestClient`. # Test: Search for the usage of `grpcgwTest.NewTestClient`. Expect: Correct and efficient usage. rg --type go 'grpcgwTest.NewTestClient'Length of output: 1651
Script:
#!/bin/bash # Locate the implementation of `NewTestClient` to understand its functionality. ast-grep --lang go --pattern 'func NewTestClient($_) $_' # Check the imports in the test files to ensure `grpcgwTest` is properly imported. rg --type go 'import' -A 5 -B 5 grpc-gateway/client/observeDevices_test.goLength of output: 1045
Script:
#!/bin/bash # Check the imports in the test files to ensure `grpcgwTest` is properly imported. rg --type go 'grpcgwTest' -A 5 -B 5 grpc-gateway/client/observeDevices_test.goLength of output: 882
grpc-gateway/pb/hubConfiguration.proto (1)
61-62
: LGTM!The addition of the
snippet_service
field to theUIConfiguration
message is well-documented and follows the existing pattern.grpc-gateway/client/maintenance_test.go (2)
54-56
: LGTM!The usage of
grpcgwTest.NewTestClient
inTestClientFactoryReset
is correct and follows the existing pattern in the file.
108-110
: LGTM!The usage of
grpcgwTest.NewTestClient
inTestClientReboot
is correct and follows the existing pattern in the file.http-gateway/test/test.go (2)
24-24
: LGTM!The addition of the
SnippetService
field to theMakeWebConfigurationConfig
function is well-documented and follows the existing pattern.
55-55
: LGTM!The modification of the
MakeConfig
function to useconfig.MakeValidatorConfig
for theAuthorization
field is correct and follows the existing pattern.cloud2cloud-gateway/test/test.go (1)
7-7
: LGTM!The usage of the
slices
package in theGetUniqueSubscriptionID
function is correct and follows the existing pattern.grpc-gateway/client/getResource_test.go (2)
11-11
: Import statement approved.The import statement for
grpcgwTest
is correctly added.
Line range hint
104-108
: Test client instantiation approved.The new test client is correctly instantiated using
grpcgwTest.NewTestClient(t)
and properly closed after use.http-gateway/service/getHubConfiguration.go (1)
78-78
: Addition ofSnippetService
field approved.The new field
SnippetService
is correctly added to theUIConfiguration
and assigned from therequestHandler.config.UI.WebConfiguration.SnippetService
.charts/plgd-hub/templates/http-gateway/_helpers.tpl (1)
86-98
: Addition ofsnippetServiceApiDomain
template definition approved.The new template definition for
snippetServiceApiDomain
is correctly added and follows the existing structure of the file.coap-gateway/test/test.go (1)
55-55
: Verify the new assignment forAuthority
.Ensure that
config.MakeValidatorConfig()
is the correct function to use for theAuthority
field and that it matches the expected configuration.grpc-gateway/client/getDevice_test.go (1)
96-96
: Verify the new test client instantiation.Ensure that
grpcgwTest.NewTestClient(t)
correctly initializes the test client and integrates well with the existing test logic.http-gateway/service/getDeviceResourceLinks_test.go (1)
103-104
: Verify the newtypeFilter
logic.Ensure that the new
typeFilter
logic usingslices.Contains
correctly filters the resource links and integrates well with the existing test logic.http-gateway/service/getHubConfiguration_test.go (2)
33-33
: Verify the newSnippetService
field addition.Ensure that the new
SnippetService
field is correctly added to the expected configuration and integrates well with the existing test logic.
89-89
: Verify the newSnippetService
field addition.Ensure that the new
SnippetService
field is correctly added to the expected configuration and integrates well with the existing test logic.grpc-gateway/client/updateResource_test.go (3)
11-11
: Review the new test client instantiation.The new test client instantiation method
grpcgwTest.NewTestClient(t)
is introduced. Ensure that this updated method is correctly used and integrates well with the existing tests.
98-98
: Ensure proper cleanup of the test client.The test client
c
is instantiated usinggrpcgwTest.NewTestClient(t)
. Ensure that the client is properly closed to avoid resource leaks.
135-135
: Ensure proper cleanup of the test client.The test client
c
is instantiated usinggrpcgwTest.NewTestClient(t)
. Ensure that the client is properly closed to avoid resource leaks..github/workflows/build-publish.yaml (1)
112-115
: Review the new job forsnippet-service
.The new job for
snippet-service
is added with the directorysnippet-service
, Dockerfile.tmp/docker/snippet-service/Dockerfile
, and template filetools/docker/Dockerfile.in
. Ensure that the configurations are correct and the job integrates well within the CI/CD pipeline.grpc-gateway/client/deleteResource_test.go (3)
13-13
: Review the new test client instantiation.The new test client instantiation method
grpcgwTest.NewTestClient(t)
is introduced. Ensure that this updated method is correctly used and integrates well with the existing tests.
87-87
: Ensure proper cleanup of the test client.The test client
c
is instantiated usinggrpcgwTest.NewTestClient(t)
. Ensure that the client is properly closed to avoid resource leaks.
176-176
: Ensure proper cleanup of the test client.The test client
c
is instantiated usinggrpcgwTest.NewTestClient(t)
. Ensure that the client is properly closed to avoid resource leaks..github/workflows/test.yml (2)
87-90
: Review the new logging configurations forsnippet-service
.The new logging configurations for
snippet-service
are added. Ensure that the configurations are correct and integrate well within the CI/CD pipeline.
119-119
: Review the new logging configurations forsnippet-service
.The new logging configurations for
snippet-service
are added. Ensure that the configurations are correct and integrate well within the CI/CD pipeline.cloud2cloud-gateway/service/retrieveDevice.go (1)
77-80
: LGTM!The update to use
commands.DecodeContent
enhances maintainability and consistency.http-gateway/service/getResourcePendingCommands_test.go (3)
168-178
: LGTM!The addition of new test cases and helper functions improves test coverage and robustness.
191-201
: LGTM!The addition of new test cases and helper functions improves test coverage and robustness.
205-209
: LGTM!The addition of new test cases and helper functions improves test coverage and robustness.
http-gateway/uri/uri.go (1)
25-26
: LGTM!The additions of
IncludeHiddenResourcesQueryKey
andForceQueryKey
are consistent with existing constants.http-gateway/service/config.go (1)
196-196
: LGTM!The addition of the
SnippetService
field toWebConfiguration
is consistent with existing fields.bundle/nginx/nginx.conf.template (1)
124-137
: Ensure theREPLACE_HTTP_SNIPPET_SERVICE_PORT
is properly set.The new location block for
snippet-service
appears correct, but it is crucial to ensure thatREPLACE_HTTP_SNIPPET_SERVICE_PORT
is properly set during deployment to avoid runtime issues.coap-gateway/service/resourceDirectory.go (1)
176-177
: Verify thetriggerDeviceSubscriber
method implementation.The addition of
client.triggerDeviceSubscriber()
seems to trigger pending commands for published resources. Ensure that this method is correctly implemented and does not introduce side effects.grpc-gateway/pb/devices.proto (3)
70-71
: Fieldsforce
andasync
added toUpdateResourceRequest
.The fields
force
andasync
have been added toUpdateResourceRequest
. Ensure that these fields are properly handled in the service logic.
225-226
: Fieldsforce
andasync
added toDeleteResourceRequest
.The fields
force
andasync
have been added toDeleteResourceRequest
. Ensure that these fields are properly handled in the service logic.
237-238
: Fieldsforce
andasync
added toCreateResourceRequest
.The fields
force
andasync
have been added toCreateResourceRequest
. Ensure that these fields are properly handled in the service logic.coap-gateway/service/clientObserveHandler.go (2)
9-9
: Ensure compatibility withslices
package.The
slices
package has been imported. Ensure that the Go version and environment support this package.
122-122
: Usage ofslices.Contains
inisDuplicateEvent
method.The
slices.Contains
method is used to check if the event's href is in the list of unpublished resources. This is a correct and efficient usage.http-gateway/service/getDevicePendingCommands_test.go (3)
256-266
: Ensure correct error assertion.In the
createFn
function, the error assertion is correct. However, ensure that theerrC
variable is properly checked for context-specific error messages if needed.
279-289
: Ensure correct error assertion.In the
updateFn
function, the error assertion is correct. However, ensure that theerrU
variable is properly checked for context-specific error messages if needed.
293-297
: Ensure correct error assertion.In the
deleteFn
function, the error assertion is correct. However, ensure that theerrD
variable is properly checked for context-specific error messages if needed.http-gateway/service/getPendingCommands_test.go (3)
303-313
: Ensure correct error assertion.In the
createFn
function, the error assertion is correct. However, ensure that theerrC
variable is properly checked for context-specific error messages if needed.
326-336
: Ensure correct error assertion.In the
updateFn
function, the error assertion is correct. However, ensure that theerrU
variable is properly checked for context-specific error messages if needed.
340-344
: Ensure correct error assertion.In the
deleteFn
function, the error assertion is correct. However, ensure that theerrD
variable is properly checked for context-specific error messages if needed.coap-gateway/service/signIn.go (2)
7-7
: Ensure theslices
import is necessary.The
slices
package is imported, but ensure that it is used appropriately in the code.
176-176
: Ensure efficient usage ofslices.Contains
.The
slices.Contains
function is used to check if the device ID is in the list of device IDs. Ensure that this function is used correctly and efficiently.bundle/Dockerfile (3)
116-122
: Ensure correct build steps forsnippet-service
.The build steps for the
snippet-service
are added. Ensure that the build steps are correct and follow best practices.
188-189
: Ensure correct steps for copyingsnippet-service
binaries and configuration.The steps for copying the
snippet-service
binaries and configuration are added. Ensure that the steps are correct and follow best practices.
244-245
: Ensure correct environment variable definitions forsnippet-service
.The environment variables for the
snippet-service
are added. Ensure that the environment variables are correctly defined and used.grpc-gateway/client/deviceSubscriptions_test.go (4)
12-12
: Import statement approved.The import statement adds a new alias
grpcgwTest
for thegrpc-gateway/test
package, which is used to instantiate a new test client.
86-88
: Test client instance usage approved.The new test client instance is created and closed properly in
TestObserveDeviceResourcesRetrieve
.
181-183
: Test client instance usage approved.The new test client instance is created and closed properly in
TestObserveDeviceResourcesUpdate
.
310-312
: Test client instance usage approved.The new test client instance is created and closed properly in
TestObserveDeviceResourcesCreateAndDelete
.grpc-gateway/client/deviceSubscriber.go (1)
269-275
: New methodTriggerGetPendingCommands
approved.The new method triggers a reconnect by sending to the
reconnectChan
channel, which is implemented correctly.coap-gateway/service/observation/deviceObserver.go (2)
9-9
: Usage ofslices
package approved.The
slices
package is used to check if a slice contains a specific element, which is implemented correctly.
311-311
: MethodIsDiscoveryResourceObservable
approved.The method uses
slices.Contains
to check if theInterfaces
slice containsobserveInterface
, which is implemented correctly.Makefile (7)
34-35
: New logging configurations forsnippet-service
approved.The new logging configurations
TEST_SNIPPET_SERVICE_LOG_LEVEL
andTEST_SNIPPET_SERVICE_LOG_DUMP_BODY
are added correctly.
47-47
: Addition ofsnippet-service
toSUBDIRS
list approved.The
snippet-service
is added to theSUBDIRS
list correctly.
332-334
: Modification ofRUN-TESTS-IN-DIRECTORY
macro approved.The macro is modified to run tests with additional shell command, which is implemented correctly.
377-377
: Modification ofRUN-TESTS-UDP
macro approved.The macro is modified to include new logging configurations for
snippet-service
, which is implemented correctly.Also applies to: 385-385
398-398
: Modification oftest
target approved.The
test
target is modified to include new logging configurations forsnippet-service
, which is implemented correctly.
419-419
: Modification oftest/mem
target approved.The
test/mem
target is modified to include new logging configurations forsnippet-service
, which is implemented correctly.
437-444
: Modification ofRUN-TESTS-IN-DIRECTORY
macro approved.The macro is modified to include new logging configurations for
snippet-service
, which is implemented correctly.grpc-gateway/service/updateResource_test.go (1)
418-652
: LGTM!The new test method
TestUpdateCreateOnNotExistingResource
is well-structured and follows the pattern of other test methods in the file. It correctly handles the context and connection setup and teardown. The test cases cover various scenarios for updating and creating resources.grpc-gateway/service/subscribeToEvents_test.go (1)
Line range hint
670-721
:
LGTM!The new test method
TestRequestHandlerSubscribeForPendingCommands
is well-structured and follows the pattern of other test methods in the file. It correctly handles the context and connection setup and teardown. The test cases cover various scenarios for subscribing to pending commands.bundle/run.sh (5)
27-28
: Ensure the new environment variables are used correctly.The new environment variables
SNIPPET_SERVICE_ADDRESS
andSNIPPET_SERVICE_HTTP_ADDRESS
are exported correctly. Verify their usage in the codebase to ensure they're being utilized as expected.Verification successful
The new environment variables
SNIPPET_SERVICE_ADDRESS
andSNIPPET_SERVICE_HTTP_ADDRESS
are used correctly in the codebase.The variables are utilized appropriately within
bundle/run.sh
:
SNIPPET_SERVICE_ADDRESS
is used for gRPC address configuration and connection checks.
SNIPPET_SERVICE_HTTP_ADDRESS
is used for HTTP address configuration.
bundle/run.sh
:
- Line 27:
export SNIPPET_SERVICE_ADDRESS="localhost:${SNIPPET_SERVICE_PORT}"
- Line 28:
export SNIPPET_SERVICE_HTTP_ADDRESS="localhost:${HTTP_SNIPPET_SERVICE_PORT}"
- Usage in gRPC and HTTP address settings and connection checks.
Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the usage of `SNIPPET_SERVICE_ADDRESS` and `SNIPPET_SERVICE_HTTP_ADDRESS` in the codebase. # Test: Search for the environment variables usage. Expect: Proper usage in the codebase. rg --type sh $'SNIPPET_SERVICE_ADDRESS' rg --type sh $'SNIPPET_SERVICE_HTTP_ADDRESS'Length of output: 720
18-18
: Ensure the new environment variable is used correctly.The new environment variable
CERTIFICATE_AUTHORITY_HTTP_ADDRESS
is exported correctly. Verify its usage in the codebase to ensure it's being utilized as expected.Verification successful
The new environment variable is used correctly.
The
CERTIFICATE_AUTHORITY_HTTP_ADDRESS
is correctly exported and utilized within the codebase, particularly in thecertificate-authority/config.yaml
file.
bundle/run.sh
: Line 18 - Export statement.charts/plgd-hub/templates/certificate-authority/config.yaml
: Usage in configuration.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the usage of `CERTIFICATE_AUTHORITY_HTTP_ADDRESS` in the codebase. # Test: Search for the environment variable usage. Expect: Proper usage in the codebase. rg --type sh $'CERTIFICATE_AUTHORITY_HTTP_ADDRESS'Length of output: 233
Script:
#!/bin/bash # Description: Verify the usage of `.apis.http.address` in the codebase. # Test: Search for the usage of `.apis.http.address`. Expect: Proper usage in the codebase. rg --type sh $'.apis.http.address'Length of output: 549
Script:
#!/bin/bash # Description: Verify the usage of `.apis.http.address` in the codebase beyond assignments. # Test: Search for the usage of `.apis.http.address` in the codebase. Expect: Proper usage in the codebase. rg '.apis.http.address'Length of output: 1268
1250-1293
: Ensure the snippet-service configuration and startup commands are correct.The configuration and startup commands for the
snippet-service
are consistent with other services. Verify that the configuration file is correctly generated and the service starts as expected.
1419-1425
: Ensure the process check for snippet-service is correct.The process check for
snippet-service
is consistent with other similar checks. Verify that the process ID is correctly monitored and the service status is logged as expected.
490-490
: Ensure the sed command correctly replaces the placeholder.The sed command to replace
REPLACE_HTTP_SNIPPET_SERVICE_PORT
is consistent with other similar commands. Verify that the placeholder is correctly replaced in the nginx configuration.grpc-gateway/pb/README.md (1)
914-914
: Add missing commas and fix double punctuation.Add a comma before "and" to connect independent clauses and remove the double punctuation at the end of the sentence.
- | resource_id_filter | [ResourceIdFilter](#grpcgateway-pb-ResourceIdFilter) | repeated | New resource ID filter. For HTTP requests, use it multiple times as a query parameter like "resourceIdFilter={deviceID}{href}". | + | resource_id_filter | [ResourceIdFilter](#grpcgateway-pb-ResourceIdFilter) | repeated | New resource ID filter. For HTTP requests, use it multiple times as a query parameter like "resourceIdFilter={deviceID}{href}." | - | include_hidden_resources | [bool](#bool) | | Get all pending commands for all resources, even if the resource is not published. | + | include_hidden_resources | [bool](#bool) | | Get all pending commands for all resources, even if the resource is not published. |Likely invalid or redundant comment.
grpc-gateway/pb/doc.html (5)
844-857
: New fields added toCreateResourceRequest
.The fields
force
andasync
enhance the functionality of theCreateResourceRequest
. These additions look good.
968-981
: New fields added toDeleteResourceRequest
.The fields
force
andasync
enhance the functionality of theDeleteResourceRequest
. These additions look good.
1982-1995
: New fields added toUpdateResourceRequest
.The fields
force
andasync
enhance the functionality of theUpdateResourceRequest
. These additions look good.
2528-2533
: New field added toGetPendingCommandsRequest
.The field
include_hidden_resources
enhances the functionality of theGetPendingCommandsRequest
by allowing the retrieval of all pending commands for all resources, even if the resource is not published. This addition looks good.
2941-2946
: New field added toUIConfiguration
.The field
snippet_service
enhances theUIConfiguration
by providing the address to the snippet service HTTP API. This addition looks good.
@coderabbitai write summary for the PR, focus on the new snippet-service, you can ignore the rest |
@Danielius1922 Here's a summary of the PR focusing on the new Summary of Changes for
|
@coderabbitai thanks for the summary, now write a description focusing on the snippet-service, that can be used as a commit message |
Tip For best results, initiate chat on the files or code changes. @Danielius1922 Here's a description focusing on the snippet-service that can be used as a commit message: Commit MessageExtend
Feel free to adjust the message as needed. |
d8a58ff
to
0dfa3f3
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 12
Outside diff range and nitpick comments (1)
snippet-service/service/http/getAppliedConfigurations_test.go (1)
23-179
: Use table-driven tests for better readability.The function uses a table-driven test approach which is good. Ensure that the test cases are clear and maintainable. Consider adding comments to explain each test case scenario.
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files ignored due to path filters (2)
charts/plgd-hub/values.yaml
is excluded by!**/*.yaml
snippet-service/config.yaml
is excluded by!**/*.yaml
Files selected for processing (7)
- snippet-service/service/grpc/server.go (1 hunks)
- snippet-service/service/http/deleteAppliedConfigurations_test.go (1 hunks)
- snippet-service/service/http/getAppliedConfigurations_test.go (1 hunks)
- snippet-service/service/service.go (1 hunks)
- snippet-service/service/service_test.go (1 hunks)
- snippet-service/store/condition.go (1 hunks)
- snippet-service/store/configuration.go (1 hunks)
Additional comments not posted (30)
snippet-service/store/configuration.go (11)
9-16
: LGTM!The function correctly validates and normalizes the configuration object.
18-23
: LGTM!The
ConfigurationVersion
type is well-defined.
25-35
: LGTM!The
Copy
method correctly creates a deep copy of aConfigurationVersion
object.
37-44
: LGTM!The function correctly maps fields from
pb.Configuration
toConfigurationVersion
.
46-51
: LGTM!The
Configuration
type is well-defined.
53-61
: LGTM!The method correctly initializes the first
Configuration
object.
63-75
: LGTM!The method correctly retrieves and maps the latest
pb.Configuration
object.
77-91
: LGTM!The method correctly iterates over all versions and invokes the callback.
93-107
: LGTM!The method correctly creates a deep copy of a
Configuration
object.
109-109
: LGTM!The type alias is correctly defined.
111-116
: LGTM!The function correctly validates the
InvokeConfigurationRequest
object.snippet-service/store/condition.go (10)
11-18
: LGTM!The function correctly validates and normalizes the condition object.
20-30
: LGTM!The
ConditionVersion
type is well-defined.
32-44
: LGTM!The
Copy
method correctly creates a deep copy of aConditionVersion
object.
46-58
: LGTM!The function correctly maps fields from
pb.Condition
toConditionVersion
.
60-66
: LGTM!The
Condition
type is well-defined.
68-77
: LGTM!The method correctly initializes the first
Condition
object.
79-97
: LGTM!The method correctly retrieves and maps the latest
pb.Condition
object.
99-119
: LGTM!The method correctly iterates over all versions and invokes the callback.
121-135
: LGTM!The method correctly creates a deep copy of a
Condition
object.
138-144
: LGTM!The function correctly validates and normalizes the conditions query.
snippet-service/service/http/deleteAppliedConfigurations_test.go (1)
27-152
: LGTM!The test comprehensively covers various scenarios for the
DeleteAppliedConfigurations
endpoint.snippet-service/service/service.go (5)
35-44
: LGTM!The function correctly creates a store based on the provided configuration.
46-64
: LGTM!The function correctly creates a new HTTP service.
66-77
: LGTM!The function correctly creates a new gRPC service.
79-150
: LGTM!The function correctly initializes and sets up the entire snippet service.
152-154
: LGTM!The function correctly returns the store associated with the service.
snippet-service/service/grpc/server.go (1)
49-54
: LGTM!The method correctly maps store errors to gRPC error codes.
snippet-service/service/service_test.go (2)
41-173
: Ensure comprehensive test coverage.The function uses table-driven tests to cover different configurations. Ensure that the test cases cover edge cases and invalid configurations.
200-496
: Ensure comprehensive test coverage.The function covers various scenarios for creating, updating, and deleting configurations and conditions. Ensure that the tests cover edge cases and invalid configurations.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (1)
- snippet-service/service/grpc/server.go (1 hunks)
Files skipped from review as they are similar to previous changes (1)
- snippet-service/service/grpc/server.go
ac944ce
to
96edc2a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files ignored due to path filters (3)
charts/plgd-hub/templates/m2m-oauth-server/config.yaml
is excluded by!**/*.yaml
charts/plgd-hub/values.yaml
is excluded by!**/*.yaml
m2m-oauth-server/swagger.yaml
is excluded by!**/*.yaml
Files selected for processing (11)
- certificate-authority/service/grpc/signCertificate_test.go (1 hunks)
- m2m-oauth-server/service/config.go (4 hunks)
- m2m-oauth-server/service/token.go (9 hunks)
- m2m-oauth-server/service/token_test.go (6 hunks)
- m2m-oauth-server/test/test.go (4 hunks)
- m2m-oauth-server/uri/uri.go (1 hunks)
- snippet-service/service/grpc/server.go (1 hunks)
- snippet-service/service/http/invokeConfiguration_test.go (1 hunks)
- snippet-service/service/service.go (1 hunks)
- snippet-service/service/service_test.go (1 hunks)
- snippet-service/store/cqldb/appliedConfiguration.go (1 hunks)
Files skipped from review as they are similar to previous changes (3)
- snippet-service/service/grpc/server.go
- snippet-service/service/service.go
- snippet-service/service/service_test.go
Additional context used
golangci-lint
snippet-service/service/http/invokeConfiguration_test.go
25-25: ST1019: package "github.com/plgd-dev/hub/v2/snippet-service/test" is being imported more than once
(stylecheck)
26-26: ST1019(related information): other import of "github.com/plgd-dev/hub/v2/snippet-service/test"
(stylecheck)
GitHub Check: lint
snippet-service/service/http/invokeConfiguration_test.go
[failure] 25-25:
ST1019: package "github.com/plgd-dev/hub/v2/snippet-service/test" is being imported more than once (stylecheck)
[failure] 26-26:
ST1019(related information): other import of "github.com/plgd-dev/hub/v2/snippet-service/test" (stylecheck)
Additional comments not posted (25)
m2m-oauth-server/uri/uri.go (1)
16-17
: LGTM! Added constantOriginalTokenClaims
.The addition of the constant
OriginalTokenClaims
looks good.snippet-service/store/cqldb/appliedConfiguration.go (6)
10-12
: LGTM! Added methodGetAppliedConfigurations
.The addition of the method
GetAppliedConfigurations
looks good.
14-16
: LGTM! Added methodDeleteAppliedConfigurations
.The addition of the method
DeleteAppliedConfigurations
looks good.
18-20
: LGTM! Added methodCreateAppliedConfiguration
.The addition of the method
CreateAppliedConfiguration
looks good.
22-24
: LGTM! Added methodInsertAppliedConfigurations
.The addition of the method
InsertAppliedConfigurations
looks good.
26-28
: LGTM! Added methodUpdateAppliedConfigurationResource
.The addition of the method
UpdateAppliedConfigurationResource
looks good.
30-32
: LGTM! Added methodGetPendingAppliedConfigurationResourceUpdates
.The addition of the method
GetPendingAppliedConfigurationResourceUpdates
looks good.m2m-oauth-server/service/token_test.go (1)
20-21
: LGTM! Added test caseTestGetToken
.The addition of the test case
TestGetToken
looks good. It covers various scenarios, including valid and invalid tokens, and the newsnippetServiceToken
.Also applies to: 41-52, 74-75, 118-120
certificate-authority/service/grpc/signCertificate_test.go (1)
123-130
: LGTM! Added test caseTestCertificateAuthorityServerSignCSRWithDifferentPublicKeys
.The addition of the test case
TestCertificateAuthorityServerSignCSRWithDifferentPublicKeys
looks good. It validates the signing of certificates with different public keys and includes configurations for OAuth and CA services.Also applies to: 133-133
m2m-oauth-server/service/config.go (3)
47-54
: LGTM!The new fields added to the
Client
struct look good.
176-176
: LGTM!The validation logic for the OAuthSignerConfig struct looks good.
Line range hint
60-75
:
Verify the validation logic.The validation logic looks correct, but ensure that all necessary fields are being validated appropriately.
m2m-oauth-server/test/test.go (2)
42-42
: LGTM!The new field
InsertTokenClaims
added to theServiceOAuthClient
looks good.
54-54
: LGTM!The new field
Authorization
added to theJWTPrivateKeyOAuthClient
looks good.m2m-oauth-server/service/token.go (7)
25-27
: LGTM!The new function
setKeyErrorExt
looks good.
62-64
: LGTM!The updates to the
makeAccessToken
function look good.
89-101
: LGTM!The new function
setDeviceIDClaim
looks good.
102-104
: LGTM!The new function
setOwnerClaim
looks good.
150-164
: LGTM!The updates to the
tokenRequest
struct look good.
Line range hint
176-186
:
LGTM!The updates to the
postToken
function look good.
243-243
: LGTM!The updates to the
validateClient
function look good.snippet-service/service/http/invokeConfiguration_test.go (4)
40-59
: LGTM!The new function
invokeConfiguration
looks good.
61-95
: LGTM!The new function
getPendingCommands
looks good.
97-322
: LGTM!The new function
TestRequestHandlerInvokeConfiguration
looks good.
324-415
: LGTM!The new function
TestParallelRequestHandlerInvokeConfiguration
looks good.
96edc2a
to
76210c3
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 5
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files ignored due to path filters (1)
charts/plgd-hub/values.yaml
is excluded by!**/*.yaml
Files selected for processing (6)
- m2m-oauth-server/test/test.go (1 hunks)
- snippet-service/service/http/invokeConfiguration_test.go (1 hunks)
- snippet-service/service/service.go (1 hunks)
- snippet-service/service/service_test.go (1 hunks)
- snippet-service/store/cqldb/appliedConfiguration.go (1 hunks)
- snippet-service/store/mongodb/appliedConfiguration.go (1 hunks)
Files skipped from review as they are similar to previous changes (5)
- m2m-oauth-server/test/test.go
- snippet-service/service/http/invokeConfiguration_test.go
- snippet-service/service/service.go
- snippet-service/service/service_test.go
- snippet-service/store/cqldb/appliedConfiguration.go
Additional comments not posted (3)
snippet-service/store/mongodb/appliedConfiguration.go (3)
71-98
: LGTM!The function constructs the MongoDB filter correctly.
100-119
: LGTM!The function constructs the MongoDB filter correctly.
121-131
: LGTM!The function constructs the MongoDB query correctly.
76210c3
to
b1b617c
Compare
@coderabbitai the code review was skipped due to file limit, but can you do code review if you examine only files in the snippet-service folder? or at least write description for the code in the snippet-service folder? |
Tip For best results, initiate chat on the files or code changes. @Danielius1922 Here's a description of the code within the
|
@coderabbitai that's too long for a commit message, can you write something better? an overview of the code in the snippet-service folder that can be used as a commit message. |
Tip For best results, initiate chat on the files or code changes. @Danielius1922 Here's a more concise overview of the code in the Commit MessageExtend
Feel free to adjust the message as needed. |
@coderabbitai write a description of the code in the snippet-service folder, focusing on the overview of functionality of the added snippet-service |
Tip For best results, initiate chat on the files or code changes. @Danielius1922 Here's a description of the code in the Overview of
|
* SnippetService - templates init ( backup ) * Resources configuration * Conditions update * Versions columns * snippet service url from wellknown config * Applied configuration detail * Configurations Tab3 * Conditions Add page default value for deviceIdFilter * Table autosize * Resource statuses * ResourceToggleCreator canceled type * use form types * ResourceToggleCreator disabled content button od canceled status * Conditions visual improvements * dep fix * Conditions & AppliedConfiguration menu -> Tabs * Conditions add Configuration name * Tabs routes * Link fix * Conditions tab name fix * Conditions list link fix * Canceling pending commands from applied configuration * Pending commands multiple cancel * Invoking * Invoke update * snippet-service playwright testing * snippet-service playwright testing * DPS mock server * Generate token * m2mOauthClientType update * Generate Token for Conditions Add page * update condition wizard texts * fix text in selectConfigurationDescription * Storybook examples + tests * version Selector fix * Conditions - resources filters trim * Conditions - resources filters trim --------- Co-authored-by: Patrik Matiaško <[email protected]> Co-authored-by: Daniel Adam <[email protected]>
Quality Gate failedFailed conditions See analysis details on SonarCloud Catch issues before they fail your Quality Gate with our IDE extension SonarLint |
Description
This feature allows users to pre-configure devices by specifying desired configurations that are automatically applied when a ResourceChanged event occur. The newly introduced
snippet service
is responsible for managing this process.Key Features:
Device Configuration:
Event-Driven Configuration:
ResourceChanged
event.Filter Conditions:
Optional JQ Expression:
ResourceChanged
event.User Interface:
APIs:
Benefits:
This new feature enhances the capability of the system to manage and configure devices efficiently, ensuring they are always set up as required for optimal operation.