-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit c2db079
Showing
60 changed files
with
3,014 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
if ! has nix_direnv_version || ! nix_direnv_version 2.3.0; then | ||
source_url "https://raw.githubusercontent.com/nix-community/nix-direnv/2.3.0/direnvrc" "sha256-Dmd+j63L84wuzgyjITIfSxSD57Tx7v51DMxVZOsiUD8=" | ||
fi | ||
|
||
nix_direnv_watch_file devenv.nix | ||
nix_direnv_watch_file devenv.lock | ||
nix_direnv_watch_file devenv.yaml | ||
if ! use flake . --impure | ||
then | ||
echo "devenv could not be built. The devenv environment was not loaded. Make the necessary changes to devenv.nix and hit enter to try again." >&2 | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
name: Release | ||
|
||
on: | ||
push: | ||
tags: | ||
- 'v[0-9]+.[0-9]+.[0-9]+' | ||
- 'v[0-9]+.[0-9]+.[0-9]+-dev.[0-9]+' | ||
- 'v[0-9]+.[0-9]+.[0-9]+-beta.[0-9]+' | ||
|
||
jobs: | ||
artifacts: | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: write | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
- name: Setup pnpm | ||
uses: pnpm/action-setup@v2 | ||
with: | ||
version: 8 | ||
- name: Install Node.js | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: '20' | ||
cache: 'pnpm' | ||
cache-dependency-path: './pnpm-lock.yaml' | ||
- name: Install dependencies | ||
run: pnpm install --frozen-lockfile | ||
- name: Generate bundled schemas | ||
run: pnpm run bundle | ||
- name: Release | ||
uses: ncipollo/release-action@v1 | ||
with: | ||
allowUpdates: true | ||
artifacts: 'schemas/bundled/*.schema.{json,yaml}' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# logs | ||
logs | ||
*.log | ||
npm-debug.log* | ||
|
||
# dependency directory | ||
# https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git | ||
node_modules | ||
|
||
# editor | ||
.vscode/* | ||
!.vscode/settings.json | ||
!.vscode/tasks.json | ||
!.vscode/launch.json | ||
!.vscode/extensions.json | ||
!.vscode/*.code-snippets | ||
|
||
# build | ||
tsconfig.tsbuildinfo | ||
dist/ | ||
|
||
# nix | ||
.devenv | ||
.direnv | ||
.pre-commit-config.yaml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# dot-files (.env, .git, ...) | ||
.* | ||
|
||
# logs | ||
logs | ||
*.log | ||
npm-debug.log* | ||
|
||
# dependency directory | ||
# https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git | ||
node_modules | ||
|
||
# editor | ||
.vscode/* | ||
!.vscode/settings.json | ||
!.vscode/tasks.json | ||
!.vscode/launch.json | ||
!.vscode/extensions.json | ||
!.vscode/*.code-snippets | ||
|
||
# source | ||
scripts/ | ||
test/ | ||
tsconfig.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
save-exact=true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
pnpm-lock.yaml | ||
flake.lock |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"trailingComma": "es5", | ||
"semi": false, | ||
"singleQuote": true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2023 Tailfin Cloud, Inc. | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
# FinOps FOCUS JSON Schemas | ||
|
||
This repository contains JSON schemas and tools for the [FinOps Foundation's Open Cost and Usage Specification (FOCUS)](https://focus.finops.org/). | ||
|
||
## Getting Started | ||
|
||
To use the schema, clone this repository or download the schema directly and reference the JSON schema file in your data validation tools or scripts. Bundled schemas can be found in the `schemas/bundled` folder: | ||
|
||
- [`v1.0-Preview Candidate Release`](./schemas/bundled/1.0-rc.1.schema.json) | ||
|
||
## Roadmap | ||
|
||
- [ ] Conditional rules, for example: | ||
|
||
```json | ||
"$defs": { | ||
"rules": { | ||
"allOf": [ | ||
{ | ||
"$description": "When ChargeCategory is 'Purchase', ChargeFrequency MUST NOT be 'Usage-Based'.", | ||
"if": { | ||
"properties": { | ||
"ChargeCategory": { "const": "Purchase" } | ||
} | ||
}, | ||
"then": { | ||
"properties": { | ||
"ChargeFrequency": { "not": { "const": "Usage-Based" } } | ||
} | ||
} | ||
} | ||
] | ||
} | ||
} | ||
``` | ||
|
||
- [ ] Validation CLI command | ||
- [ ] Sample data generation command | ||
|
||
## Contributing | ||
|
||
Contributions to the schema are welcome, particularly in the following areas: | ||
|
||
- Enhancements to reflect updates in the FinOps FOCUS specification. | ||
- Additional examples and use cases. | ||
|
||
## Development | ||
|
||
**For an optimal developer experience, it is recommended to install [Nix](https://nixos.org/download.html) and [direnv](https://direnv.net/docs/installation.html).** | ||
|
||
<details><summary><i>Installing Nix and direnv</i></summary><br> | ||
|
||
**Note: These are instructions that _SHOULD_ work in most cases. Consult the links above for the official instructions for your OS.** | ||
|
||
Install Nix: | ||
|
||
```sh | ||
sh <(curl -L https://nixos.org/nix/install) --daemon | ||
``` | ||
|
||
Consult the [installation instructions](https://direnv.net/docs/installation.html) to install direnv using your package manager. | ||
|
||
On MacOS: | ||
|
||
```sh | ||
brew install direnv | ||
``` | ||
|
||
Install from binary builds: | ||
|
||
```sh | ||
curl -sfL https://direnv.net/install.sh | bash | ||
``` | ||
|
||
The last step is to configure your shell to use direnv. For example for bash, add the following lines at the end of your `~/.bashrc`: | ||
|
||
eval "\$(direnv hook bash)" | ||
|
||
**Then restart the shell.** | ||
|
||
For other shells, see [https://direnv.net/docs/hook.html](https://direnv.net/docs/hook.html). | ||
|
||
**MacOS specific instructions** | ||
|
||
Nix may stop working after a MacOS upgrade. If it does, follow [these instructions](https://github.com/NixOS/nix/issues/3616#issuecomment-662858874). | ||
|
||
<hr> | ||
</details> | ||
|
||
## License | ||
|
||
This project is licensed under the MIT License - see the LICENSE file for details. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
{ | ||
inputs = { | ||
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; | ||
flake-parts.url = "github:hercules-ci/flake-parts"; | ||
devenv.url = "github:cachix/devenv"; | ||
}; | ||
|
||
nixConfig = { | ||
extra-trusted-public-keys = "devenv.cachix.org-1:w1cLUi8dv3hnoSPGAuibQv+f9TZLr6cv/Hm9XgU50cw="; | ||
extra-substituters = "https://devenv.cachix.org"; | ||
}; | ||
|
||
outputs = inputs@{ flake-parts, ... }: | ||
flake-parts.lib.mkFlake { inherit inputs; } { | ||
imports = [ | ||
inputs.devenv.flakeModule | ||
]; | ||
|
||
systems = [ "x86_64-linux" "x86_64-darwin" "aarch64-darwin" ]; | ||
|
||
perSystem = { config, self', inputs', pkgs, system, ... }: rec { | ||
devenv.shells = { | ||
default = { | ||
languages = { | ||
javascript = { | ||
enable = true; | ||
package = pkgs.nodejs_20; | ||
}; | ||
}; | ||
|
||
pre-commit.hooks = { | ||
nixpkgs-fmt.enable = true; | ||
commitizen.enable = true; | ||
|
||
commitizen-branch = { | ||
enable = true; | ||
name = "commitizen-branch check"; | ||
description = '' | ||
Check whether commit messages on the current HEAD follows committing rules. | ||
''; | ||
entry = "${pkgs.commitizen}/bin/cz check --allow-abort --rev-range origin/HEAD..HEAD"; | ||
pass_filenames = false; | ||
stages = [ "manual" ]; | ||
}; | ||
}; | ||
|
||
packages = with pkgs; [ | ||
# node | ||
nodePackages.pnpm | ||
]; | ||
|
||
# https://github.com/cachix/devenv/issues/528#issuecomment-1556108767 | ||
containers = pkgs.lib.mkForce { }; | ||
}; | ||
|
||
ci = devenv.shells.default; | ||
}; | ||
}; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
import fs from 'fs' | ||
import { dirname, join } from 'path' | ||
import { fileURLToPath } from 'url' | ||
import { program, Option } from 'commander' | ||
import YAML from 'yaml' | ||
import { addSchema } from '@hyperjump/json-schema/draft-2020-12' | ||
import { bundle } from '@hyperjump/json-schema/bundle' | ||
|
||
const dir = dirname(fileURLToPath(import.meta.url)) | ||
const schemaFolders = ['./schemas/formats', './schemas/columns'] | ||
|
||
program.name('focus').description('FinOps FOCUS schema CLI') | ||
|
||
program | ||
.command('bundle') | ||
.argument('[schema]', 'specification schema URL') | ||
.addOption( | ||
new Option('-d, --destination <path>', 'destination path').default( | ||
'./schemas/bundled' | ||
) | ||
) | ||
.description('Bundle schema') | ||
.action(async function (id) { | ||
for (const folder of schemaFolders) { | ||
loadSchemas(folder) | ||
} | ||
|
||
const bundledFiles = {} | ||
if (id) { | ||
bundledFiles[id.split('/').pop().replace('.schema.json', '')] = | ||
await bundle(id) | ||
} else { | ||
for (const f of fs.readdirSync(join(dir, './schemas'))) { | ||
if (f.endsWith('.schema.json')) { | ||
const s = await bundle(`file://${dir}/schemas/${f}`) | ||
bundledFiles[f.replace('.schema.json', '')] = s | ||
} | ||
} | ||
} | ||
|
||
// write bundled files | ||
const destinationDir = join(dir, this.opts().destination) | ||
for (const [name, s] of Object.entries(bundledFiles)) { | ||
const contentWithComment = { | ||
$comment: "This file is automatically generated. Don't edit it.", | ||
...s, | ||
} | ||
fs.writeFileSync( | ||
join(destinationDir, `${name}.schema.json`), | ||
JSON.stringify(contentWithComment, null, 2) | ||
) | ||
|
||
fs.writeFileSync( | ||
join(destinationDir, `${name}.schema.yaml`), | ||
YAML.stringify(contentWithComment) | ||
) | ||
} | ||
}) | ||
|
||
await program.parseAsync(process.argv) | ||
|
||
function loadSchemas(path) { | ||
for (const f of fs.readdirSync(path)) { | ||
if (f.endsWith('.schema.json')) { | ||
const s = JSON.parse(fs.readFileSync(join(dir, path, f), 'utf8')) | ||
addSchema(s) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
{ | ||
"name": "@openmeter/finops-focus", | ||
"version": "0.0.1", | ||
"description": "JSON schemas and tools for the FinOps Foundation's Open Cost and Usage Specification (FOCUS)", | ||
"license": "MIT", | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/openmeterio/finops-focus-schema.git" | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/openmeterio/finops-focus-schema/issues" | ||
}, | ||
"homepage": "https://github.com/openmeterio/finops-focus-schema#readme", | ||
"keywords": [ | ||
"FinOps", | ||
"FOCUS", | ||
"cost", | ||
"usage", | ||
"schema" | ||
], | ||
"type": "module", | ||
"main": "index.js", | ||
"scripts": { | ||
"bundle": "node . bundle && prettier --write ./schemas/bundled", | ||
"format": "prettier --write .", | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
}, | ||
"dependencies": { | ||
"@hyperjump/json-schema": "1.6.5", | ||
"commander": "11.1.0", | ||
"yaml": "2.3.4" | ||
}, | ||
"devDependencies": { | ||
"prettier": "3.1.0" | ||
} | ||
} |
Oops, something went wrong.