Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

snippet-service: Extend plgd/snippet-service #1309

Draft
wants to merge 15 commits into
base: main
Choose a base branch
from

Conversation

Danielius1922
Copy link
Member

No description provided.

Copy link

coderabbitai bot commented May 16, 2024

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Walkthrough

The recent changes introduce a new snippet-service to the project, including its integration into various configurations and build scripts. Several linters were removed from the .golangci.yml file, and the Makefile was updated to include the new service. Additionally, modifications were made to the bundle setup, nginx configuration, and test scripts to accommodate the new service.

Changes

File/Directory Summary of Changes
.github/workflows/build-publish.yaml Added a new job for snippet-service with specific directory and Dockerfile configurations.
.golangci.yml Removed execinquery, exhaustivestruct, ifshort, and maligned linters.
Makefile Added snippet-service to the SUBDIRS list.
bundle/Dockerfile Added a new build step for snippet-service and defined new environment variables.
bundle/nginx/nginx.conf.template Added a new location block for /api/v1/snippets with proxy settings and CORS headers configuration.
bundle/run.sh Exported new environment variables and updated configurations for snippet-service.
cloud2cloud-gateway/service/subscribeToDevices_test.go Removed //nolint:testifylint comments from assert.NoError calls.
cloud2cloud-gateway/test/events.go Removed //nolint:testifylint comments from assert.NoError calls.
snippet-service/Makefile Defined targets for building Docker images, pushing images, and generating protocol buffers.
snippet-service/cmd/service/main.go Added main function and service setup for snippet-service.
snippet-service/pb/README.md Added protocol documentation for various entities and methods related to device configurations.
snippet-service/store/configuration.go Introduced structures and functions for handling configurations and versions.
snippet-service/store/cqldb/store.go Added functionality for creating and managing a store using a cqldb client.
snippet-service/store/mongodb/configuration.go Added functions for handling configurations in a MongoDB store.
snippet-service/store/mongodb/configuration_internal_test.go Added test function TestConfigurationNormalizeQuery.
snippet-service/store/mongodb/configuration_test.go Added test functions for managing configurations in a MongoDB store.
snippet-service/store/mongodb/store.go Introduced Store struct and functions for managing configurations in MongoDB.
snippet-service/store/store.go Added functionality for managing configurations in a store using MongoDB.
snippet-service/test/configuration.go Introduced functions for managing configurations and generating configuration-related data.
snippet-service/test/service.go Added functions for setting up and managing a test environment for snippet-service.
snippet-service/test/test.go Introduced functions for comparing JSON data and configuration resources.
test/config/config.go Added constants for SNIPPET_SERVICE_HOST and SNIPPET_SERVICE_HTTP_HOST.
test/http/request.go Added method ID(id string) *RequestBuilder to RequestBuilder struct.
test/http/uri.go Added constants IDKey and ConfigurationIDKey.
test/iotivity-lite/service/offboard_test.go Replaced require.Greater with require.Positive for checking counts.
test/iotivity-lite/service/republish_test.go Changed assertion for refreshCount to require.Positive.

In the world of code, a service new,
Snippets now have a place to brew.
With Docker builds and tests so fine,
Configurations align, sublime.
Through Mongo's depths and HTTP's call,
Our snippets stand tall, serving all.
🐇✨


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?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@Danielius1922 Danielius1922 force-pushed the adam/feature/snapshot-service branch from 6a85258 to 3cc79fb Compare May 16, 2024 08:34
@Danielius1922 Danielius1922 changed the title snapshot-service: Introduce plgd/snapshot-service snapshot-service: Extend plgd/snapshot-service May 16, 2024
@Danielius1922 Danielius1922 force-pushed the adam/feature/snapshot-service branch 4 times, most recently from 835a887 to 02a9ec7 Compare May 17, 2024 18:01
@Danielius1922 Danielius1922 force-pushed the adam/feature/snapshot-service branch from e24ed0e to 5341f2c Compare May 24, 2024 08:52
@Danielius1922 Danielius1922 changed the title snapshot-service: Extend plgd/snapshot-service snippet-service: Extend plgd/snippet-service May 24, 2024
@Danielius1922 Danielius1922 force-pushed the adam/feature/snapshot-service branch 5 times, most recently from 96722e8 to e438968 Compare May 27, 2024 15:21
@Danielius1922
Copy link
Member Author

@coderabbitai review

Copy link

coderabbitai bot commented May 27, 2024

Actions Performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Copy link

@coderabbitai coderabbitai bot left a 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, using slices.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: Add MinVersion: 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.VersionTLS13

Also applies to: 222-224, 285-287, 350-352, 421-423, 486-488

snippet-service/pb/doc.html (3)

276-276: Consider finalizing the naming for AppliedDeviceConfiguration.

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 in IDFilter.

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 the InvokeConfiguration method in SnippetService.

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

Commits Files that changed from the base of the PR and between 3d487bf and e438968.
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> use apk 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> use apt-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> use apt-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 of IDKey and ConfigurationIDKey aligns well with existing URI constants and supports the new functionality in snippet-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 normalizing Configuration 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 return ErrNotSupported. 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! The ConfigurationVersion struct is well-defined with appropriate BSON tags.


18-23: LGTM! The Configuration struct is well-defined with appropriate BSON tags.


25-31: LGTM! The MakeConfiguration function correctly initializes a Configuration instance from a protobuf message.

snippet-service/test/test.go (2)

13-19: LGTM! The CmpJSON function correctly compares JSON representations of objects.


35-42: LGTM! The CmpConfiguration function correctly compares configurations, handling resources separately.

snippet-service/store/mongodb/store.go (3)

19-21: The Store struct is correctly defined to embed the pkgMongo.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 from require.Greater to require.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: The Store struct is correctly defined to embed the cqldb.Store. This allows leveraging existing CQLDB functionalities.

snippet-service/store/store.go (2)

29-32: The Iterator interface is well-defined, providing a clear contract for iteration over collections.


69-79: The methods added to the Store 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: The build-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: The proto/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 the service.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 at dependency/googleapis/.
  • The service.proto file exists at snippet-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.proto

Length 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.proto

Length 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.proto

Length of output: 162

snippet-service/test/service.go (4)

22-24: The HTTPURI function correctly constructs URIs for HTTP requests. This is a useful utility for tests that need to make network requests.


26-44: The MakeConfig function is well-implemented, setting up necessary configurations for testing. It's important to validate the configuration to catch any misconfigurations early.


46-73: The SetUp and New functions provide a clean way to set up and tear down the snippet-service for tests. The use of a sync.WaitGroup ensures that the service is properly shut down before the test exits.


75-97: The MakeStorageConfig 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 the snippet-service image is correctly configured with appropriate directory and Dockerfile paths.

test/http/request.go (1)

105-111: The method ID in RequestBuilder is correctly implemented to add ID parameters to the URI. Consider enhancing the security of the TLS configuration.

- InsecureSkipVerify: true,
+ InsecureSkipVerify: true, MinVersion: tls.VersionTLS13

Likely 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 in snippet-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 10

Length 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 20

Length 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 20

Length of output: 60097

snippet-service/store/mongodb/configuration_test.go (3)

34-141: The function TestStoreCreateConfiguration is well-structured and covers a comprehensive set of test cases for configuration creation.


143-232: The function TestUpdateConfiguration effectively tests various scenarios for updating configurations, ensuring robust error handling and validation.


234-519: The function TestStoreGetConfigurations 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 from require.Greater to require.Positive are appropriate and make the assertions clearer.

Also applies to: 58-58


340-340: Change from require.Greater to require.Positive is appropriate and makes the assertion clearer.

bundle/run.sh (5)

27-28: Added environment variables for SNIPPET_SERVICE_ADDRESS and HTTP_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
+ fi

Likely invalid or redundant comment.


457-457: Ensure the HTTP_SNIPPET_SERVICE_PORT is defined and correctly replaced in the nginx configuration.


18-18: Ensure the environment variable HTTP_CERTIFICATE_AUTHORITY_PORT is defined.

Verification successful

The environment variable HTTP_CERTIFICATE_AUTHORITY_PORT is defined in the bundle/Dockerfile as ENV 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 for snippet-service is correctly implemented. Ensure that the configuration file /data/snippet-service.yaml is properly formatted and contains all necessary settings.

<tr>
<td>DONE</td>
<td>2</td>
<td><p>If done look to resource_updated even update resource failed for resource aggregate.</p></td>
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Enhance the description for the DONE status in AppliedDeviceConfiguration.Resource.Status.

The current description for the DONE status is somewhat unclear: "If done look to resource_updated even update resource failed for resource aggregate." Consider rephrasing for better clarity and completeness, possibly explaining the conditions under which this status is assigned.

<td>condition_id</td>
<td><a href="#snippetservice.pb.AppliedDeviceConfiguration.RelationTo">AppliedDeviceConfiguration.RelationTo</a></td>
<td></td>
<td><p>TODO Naming </p></td>
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Address incomplete documentation and TODO comments.

There are several places in the document where "TODO" comments are left, indicating incomplete sections. These should either be completed or removed if they are no longer relevant. This includes:

  • Naming for fields in AppliedDeviceConfiguration and AppliedDeviceConfiguration.RelationTo.
  • Description for the resource_id in AppliedDeviceConfiguration.Resource.
  • Naming for GetAppliedDeviceConfigurationsRequest.

Also applies to: 324-324, 351-351, 395-395, 787-787

snippet-service/test/configuration.go Outdated Show resolved Hide resolved
Comment on lines +41 to +43
return s, nil
}
return nil, fmt.Errorf("invalid store use('%v')", config.Use)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ensure TLS configurations use secure protocols.

The TLS configuration should specify a minimum version to enhance security. Currently, it defaults to TLS 1.2, which might not be secure enough for all environments.

- credentials.NewTLS(&tls.Config{ RootCAs: test.GetRootCertificatePool(t) })
+ credentials.NewTLS(&tls.Config{ RootCAs: test.GetRootCertificatePool(t), MinVersion: tls.VersionTLS13 })

Committable suggestion was skipped due low confidence.

Comment on lines 46 to 85
func newStore(ctx context.Context, config StorageConfig, fileWatcher *fsnotify.Watcher, logger log.Logger, tracerProvider trace.TracerProvider) (store.Store, func(), error) {
var fl fn.FuncList
db, err := createStore(ctx, config.Embedded, fileWatcher, logger, tracerProvider)
if err != nil {
fl.Execute()
return nil, nil, err
}
fl.AddFunc(func() {
if errC := db.Close(ctx); errC != nil {
log.Errorf("failed to close mongodb store: %w", errC)
}
})
if config.CleanUpRecords == "" {
return db, fl.ToFunction(), nil
}
s, err := gocron.NewScheduler(gocron.WithLocation(time.Local)) //nolint:gosmopolitan
if err != nil {
fl.Execute()
return nil, nil, fmt.Errorf("cannot create cron job: %w", err)
}
_, err = s.NewJob(gocron.CronJob(config.CleanUpRecords, config.ExtendCronParserBySeconds), gocron.NewTask(func() {
/*
_, errDel := db.DeleteNonDeviceExpiredRecords(ctx, time.Now())
if errDel != nil && !errors.Is(errDel, store.ErrNotSupported) {
log.Errorf("failed to delete expired signing records: %w", errDel)
}
*/
}))
if err != nil {
fl.Execute()
return nil, nil, fmt.Errorf("cannot create cron job: %w", err)
}
fl.AddFunc(func() {
if errS := s.Shutdown(); errS != nil {
log.Errorf("failed to shutdown cron job: %w", errS)
}
})
s.Start()
return db, fl.ToFunction(), nil
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Optimize error handling and resource management.

The function newStore could be optimized by handling errors and resources more efficiently. Consider using defer for cleanup actions to ensure they are always executed.

- fl.Execute()
+ defer fl.Execute()

Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
func newStore(ctx context.Context, config StorageConfig, fileWatcher *fsnotify.Watcher, logger log.Logger, tracerProvider trace.TracerProvider) (store.Store, func(), error) {
var fl fn.FuncList
db, err := createStore(ctx, config.Embedded, fileWatcher, logger, tracerProvider)
if err != nil {
fl.Execute()
return nil, nil, err
}
fl.AddFunc(func() {
if errC := db.Close(ctx); errC != nil {
log.Errorf("failed to close mongodb store: %w", errC)
}
})
if config.CleanUpRecords == "" {
return db, fl.ToFunction(), nil
}
s, err := gocron.NewScheduler(gocron.WithLocation(time.Local)) //nolint:gosmopolitan
if err != nil {
fl.Execute()
return nil, nil, fmt.Errorf("cannot create cron job: %w", err)
}
_, err = s.NewJob(gocron.CronJob(config.CleanUpRecords, config.ExtendCronParserBySeconds), gocron.NewTask(func() {
/*
_, errDel := db.DeleteNonDeviceExpiredRecords(ctx, time.Now())
if errDel != nil && !errors.Is(errDel, store.ErrNotSupported) {
log.Errorf("failed to delete expired signing records: %w", errDel)
}
*/
}))
if err != nil {
fl.Execute()
return nil, nil, fmt.Errorf("cannot create cron job: %w", err)
}
fl.AddFunc(func() {
if errS := s.Shutdown(); errS != nil {
log.Errorf("failed to shutdown cron job: %w", errS)
}
})
s.Start()
return db, fl.ToFunction(), nil
}
func newStore(ctx context.Context, config StorageConfig, fileWatcher *fsnotify.Watcher, logger log.Logger, tracerProvider trace.TracerProvider) (store.Store, func(), error) {
var fl fn.FuncList
defer fl.Execute()
db, err := createStore(ctx, config.Embedded, fileWatcher, logger, tracerProvider)
if err != nil {
return nil, nil, err
}
fl.AddFunc(func() {
if errC := db.Close(ctx); errC != nil {
log.Errorf("failed to close mongodb store: %w", errC)
}
})
if config.CleanUpRecords == "" {
return db, fl.ToFunction(), nil
}
s, err := gocron.NewScheduler(gocron.WithLocation(time.Local)) //nolint:gosmopolitan
if err != nil {
return nil, nil, fmt.Errorf("cannot create cron job: %w", err)
}
_, err = s.NewJob(gocron.CronJob(config.CleanUpRecords, config.ExtendCronParserBySeconds), gocron.NewTask(func() {
/*
_, errDel := db.DeleteNonDeviceExpiredRecords(ctx, time.Now())
if errDel != nil && !errors.Is(errDel, store.ErrNotSupported) {
log.Errorf("failed to delete expired signing records: %w", errDel)
}
*/
}))
if err != nil {
return nil, nil, fmt.Errorf("cannot create cron job: %w", err)
}
fl.AddFunc(func() {
if errS := s.Shutdown(); errS != nil {
log.Errorf("failed to shutdown cron job: %w", errS)
}
})
s.Start()
return db, fl.ToFunction(), nil
}

Comment on lines +21 to +72
func cmpConfigurationResources(t *testing.T, want, got []*pb.Configuration_Resource) {
require.Len(t, got, len(want))
for i := range want {
wantData, ok := test.DecodeCbor(t, want[i].GetContent().GetData()).(map[interface{}]interface{})
require.True(t, ok)
gotData, ok := test.DecodeCbor(t, got[i].GetContent().GetData()).(map[interface{}]interface{})
require.True(t, ok)
require.Equal(t, wantData, gotData)
want[i].Content.Data = nil
got[i].Content.Data = nil
}
CmpJSON(t, want, got)
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Refactor to simplify data comparison.

The cmpConfigurationResources function compares configuration resources. Consider refactoring to simplify the data comparison logic, possibly by abstracting some of the repeated code into helper functions or using more direct comparison methods if available.

snippet-service/store/cqldb/store.go Show resolved Hide resolved
snippet-service/store/mongodb/configuration.go Outdated Show resolved Hide resolved
snippet-service/store/mongodb/configuration.go Outdated Show resolved Hide resolved
snippet-service/store/mongodb/configuration.go Outdated Show resolved Hide resolved
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO: remove values which are not used

@Danielius1922 Danielius1922 force-pushed the adam/feature/snapshot-service branch 3 times, most recently from f965fe1 to 3030d53 Compare May 28, 2024 20:28
{{- tpl .Values.snippetservice.initContainersTpl . | nindent 8 }}
{{- end }}
containers:
- name: {{ .Values.snippetservice.name }}

Check warning

Code scanning / SonarCloud

Memory limits should be enforced

<!--SONAR_ISSUE_KEY:AY_BEuFUfcPD8TZC2iSd-->Specify a memory limit for this container. <p>See more on <a href="https://sonarcloud.io/project/issues?id=plgd-dev_cloud&issues=AY_BEuFUfcPD8TZC2iSd&open=AY_BEuFUfcPD8TZC2iSd&pullRequest=1309">SonarCloud</a></p>
{{- end }}
labels:
{{- include "plgd-hub.snippetservice.selectorLabels" . | nindent 8 }}
spec:

Check warning

Code scanning / SonarCloud

Service account tokens should not be mounted in pods

<!--SONAR_ISSUE_KEY:AY_BEuFUfcPD8TZC2iSe-->Set automountServiceAccountToken to false for this specification of kind Deployment. <p>See more on <a href="https://sonarcloud.io/project/issues?id=plgd-dev_cloud&issues=AY_BEuFUfcPD8TZC2iSe&open=AY_BEuFUfcPD8TZC2iSe&pullRequest=1309">SonarCloud</a></p>
{{- tpl .Values.snippetservice.initContainersTpl . | nindent 8 }}
{{- end }}
containers:
- name: {{ .Values.snippetservice.name }}

Check warning

Code scanning / SonarCloud

Storage limits should be enforced

<!--SONAR_ISSUE_KEY:AY_BEuFUfcPD8TZC2iSf-->Specify a storage limit for this container. <p>See more on <a href="https://sonarcloud.io/project/issues?id=plgd-dev_cloud&issues=AY_BEuFUfcPD8TZC2iSf&open=AY_BEuFUfcPD8TZC2iSf&pullRequest=1309">SonarCloud</a></p>
@Danielius1922 Danielius1922 force-pushed the adam/feature/snapshot-service branch from 6333e1a to 87b13df Compare May 30, 2024 15:20
@Danielius1922 Danielius1922 force-pushed the adam/feature/snapshot-service branch from 87b13df to e59d4fd Compare June 4, 2024 11:59
@Danielius1922 Danielius1922 force-pushed the adam/feature/snapshot-service branch from e59d4fd to c7abb14 Compare June 4, 2024 13:08
@Danielius1922 Danielius1922 force-pushed the adam/feature/snapshot-service branch from 9a88892 to a809956 Compare June 6, 2024 12:04
@Danielius1922 Danielius1922 force-pushed the adam/feature/snapshot-service branch from 7fda49b to c9e0ed3 Compare June 7, 2024 08:17
@Danielius1922 Danielius1922 force-pushed the adam/feature/snapshot-service branch from 7d38c7f to 272ea6a Compare June 8, 2024 11:01
Copy link

sonarcloud bot commented Jun 11, 2024

Quality Gate Failed Quality Gate failed

Failed conditions
C Security Rating on New Code (required ≥ A)

See analysis details on SonarCloud

Catch issues before they fail your Quality Gate with our IDE extension SonarLint

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants