atmos icon indicating copy to clipboard operation
atmos copied to clipboard

Added support for remote schemas

Open haitham911 opened this issue 1 year ago β€’ 6 comments

What

  • Added support for remote schemas in atmos for manifest validation.
  • Updated schemas configuration to allow referencing remote schema files, e.g.:
    schemas:
      atmos:
        manifest: "https://atmos.tools/schemas/atmos/atmos-manifest/1.0/atmos-manifest.json"
    

Why

  • This reduces redundancy as, in previous demos, the manifest file had to be copied multiple times. Now, it can be referenced remotely .

References


Summary by CodeRabbit

Summary by CodeRabbit

  • New Features

    • Users can now specify remote schema URLs for validation in the atmos.yaml configuration file.
    • Enhanced stack validation to support downloading schema files directly from a URL.
    • Introduced utility functions to validate URLs and extract file names from URLs.
  • Documentation

    • Updated the "JSON Schema Validation" document to include instructions for specifying remote schemas, along with an example configuration.
  • Bug Fixes

    • Improved error messages to inform users about the option to download schema files from URLs if they do not exist locally.

haitham911 avatar Oct 20 '24 00:10 haitham911

[!WARNING]

Rate limit exceeded

@aknysh has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 11 minutes and 52 seconds before requesting another review.

βŒ› How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

πŸ“₯ Commits

Files that changed from the base of the PR and between eebb3ee453cdb1dd106af588491a144d3840b3a6 and 493579de18465dddcdf93bf7e93845cef354fcf3.

πŸ“ Walkthrough
πŸ“ Walkthrough
πŸ“ Walkthrough
πŸ“ Walkthrough
πŸ“ Walkthrough

Walkthrough

The changes in this pull request involve updates to the atmos.yaml configuration file and enhancements to the ValidateStacks function in validate_stacks.go. The atmos.yaml file's manifest URL was changed from a local path to an absolute URL. Additionally, the ValidateStacks function was modified to support downloading the Atmos manifest JSON Schema from a URL, with new error handling and utility functions added to facilitate URL validation and file name extraction.

Changes

File Change Summary
examples/demo-context/atmos.yaml Updated manifest URL from local path to absolute URL.
internal/exec/validate_stacks.go Enhanced ValidateStacks function to support downloading manifest from a URL; added error handling.
pkg/utils/file_utils.go Added IsURL and GetFileNameFromURL functions for URL handling; included import for net/url.
website/docs/core-concepts/validate/json-schema.mdx Added new section on specifying remote schemas in validation; included example configuration.

Possibly related PRs

  • #736: This PR enhances the Atmos configuration by allowing retrieval of configuration files from both .yaml and .yml, which is directly related to the changes made in the main PR that updates the atmos.yaml configuration file's manifest URL.
  • #741: This PR documents the helmfile configuration options in Atmos, which includes updates to the atmos.yaml file structure. The changes in the main PR regarding the manifest URL in atmos.yaml are relevant to the broader context of configuring components like helmfile.

Suggested labels

minor

Suggested reviewers

  • osterman

Poem

In the meadow, where rabbits play,
A new URL leads the way.
With stacks validated, oh what a treat,
Downloading schemas, oh so neat!
Hops of joy, we celebrate,
Changes made, oh isn’t it great! πŸ‡βœ¨


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>, please review it.
    • 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 gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @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 using 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.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration 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.

coderabbitai[bot] avatar Oct 20 '24 00:10 coderabbitai[bot]

@aknysh what do you think about making this the default location for the schema? That way atmos validate always works, even if no schema installed locally.

osterman avatar Oct 21 '24 01:10 osterman

@aknysh what do you think about making this the default location for the schema? That way atmos validate always works, even if no schema installed locally.

I think yes, we can do it We need to think if we always use the remote location and always validate. In which case we need to allow the user to opt-out

aknysh avatar Oct 21 '24 01:10 aknysh

In which case we need to allow the user to opt-out

I think they can set the path to /dev/null to "opt out" =)

But at a very least, we should document how to disable it. And also update the documentation to indicate what is the default behavior.

osterman avatar Oct 21 '24 01:10 osterman

@haitham911 also please update docs here: https://atmos.tools/core-concepts/validate/json-schema

with how to specify remote schemas

osterman avatar Oct 21 '24 02:10 osterman

@haitham911 please post screenshot of this in action. Please confirm that using files as well as remote URLs both work. Also, this PR is conflicted.

osterman avatar Oct 21 '24 17:10 osterman

These changes were released in v1.97.0.

github-actions[bot] avatar Oct 30 '24 12:10 github-actions[bot]

@haitham911 we haven't set a default schema.

If you run: atmos describe config, you'll see JSON schema is not set:

  "schemas": {
    "jsonschema": {},
    "cue": {},
    "opa": {},
    "atmos": {}
  },

Full output

atmos describe config   
{
  "base_path": "./",
  "components": {
    "terraform": {
      "base_path": "components/terraform",
      "apply_auto_approve": false,
      "append_user_agent": "Atmos/1.99.0 (Cloud Posse; +https://atmos.tools)",
      "deploy_run_init": true,
      "init_run_reconfigure": true,
      "auto_generate_backend_file": false,
      "command": ""
    },
    "helmfile": {
      "base_path": "",
      "use_eks": true,
      "kubeconfig_path": "",
      "helm_aws_profile_pattern": "",
      "cluster_name_pattern": "",
      "command": ""
    }
  },
  "stacks": {
    "base_path": "stacks",
    "included_paths": [
      "deploy/**/*"
    ],
    "excluded_paths": [
      "**/_defaults.yaml"
    ],
    "name_pattern": "{stage}",
    "name_template": ""
  },
  "workflows": {
    "base_path": ""
  },
  "logs": {
    "file": "/dev/stderr",
    "level": "Info"
  },
  "integrations": {
    "atlantis": {}
  },
  "schemas": {
    "jsonschema": {},
    "cue": {},
    "opa": {},
    "atmos": {}
  },
  "templates": {
    "settings": {
      "enabled": false,
      "sprig": {
        "enabled": false
      },
      "gomplate": {
        "enabled": false,
        "timeout": 0,
        "datasources": null
      }
    }
  },
  "settings": {
    "list_merge_strategy": ""
  },
  "initialized": true,
  "stacksBaseAbsolutePath": "/Users/erik/Dev/cloudposse/tools/atmos/examples/quick-start-simple/stacks",
  "includeStackAbsolutePaths": [
    "/Users/erik/Dev/cloudposse/tools/atmos/examples/quick-start-simple/stacks/deploy/**/*"
  ],
  "excludeStackAbsolutePaths": [
    "/Users/erik/Dev/cloudposse/tools/atmos/examples/quick-start-simple/stacks/**/_defaults.yaml"
  ],
  "terraformDirAbsolutePath": "/Users/erik/Dev/cloudposse/tools/atmos/examples/quick-start-simple/components/terraform",
  "helmfileDirAbsolutePath": "/Users/erik/Dev/cloudposse/tools/atmos/examples/quick-start-simple",
  "default": false
}

osterman avatar Nov 01 '24 18:11 osterman