-
Notifications
You must be signed in to change notification settings - Fork 98
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
GH 1451 #1454
GH 1451 #1454
Changes from all commits
4577589
64f6c43
af41a52
79939e2
8e5c3e1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -323,3 +323,6 @@ local-test | |
.local-* | ||
|
||
/artifacts/ | ||
|
||
# Python Virtual Env | ||
**/venv |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
[DEFAULT] | ||
LICENSE = MIT | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
import typer | ||
import configparser | ||
import json | ||
import os | ||
import sys | ||
import shutil | ||
from rich import print | ||
|
||
app = typer.Typer() | ||
dirs = ["assets", "info", "samples", "schema", "test"] | ||
|
||
|
||
def createIntegrationDirs(directory, force): | ||
if os.path.isdir(directory): | ||
if force: | ||
force = typer.confirm( | ||
f"Are you sure you want to delete {directory}?") | ||
if force: | ||
shutil.rmtree(directory) | ||
os.makedirs(directory) | ||
for dir in dirs: | ||
os.makedirs(os.path.join(directory, dir)) | ||
else: | ||
print(f"[red]Directory {directory} already exists[/red]") | ||
sys.exit(1) | ||
else: | ||
os.makedirs(directory) | ||
for dir in dirs: | ||
os.makedirs(os.path.join(directory, dir)) | ||
|
||
|
||
def populateDefaultVars(var_name): | ||
config = configparser.ConfigParser() | ||
config.read('config.ini') | ||
return (config.get("DEFAULT", var_name)) | ||
|
||
|
||
def generateJson(directory, integration_name, integration_desc, schema, license): | ||
data = { | ||
"name": integration_name, | ||
"version": { | ||
"integ": "0.1.0", | ||
"schema": schema, | ||
"resource": "^1.23.0", | ||
"license": license | ||
}, | ||
"description": integration_desc, | ||
"identification": "instrumentationScope.attributes.identification", | ||
"categories": [], | ||
"collection": [{}], | ||
"repo": { | ||
"github": "https://github.com/opensearch-project/observability/tree/main/integrarions/"+integration_name | ||
}} | ||
|
||
with open(os.path.join(directory, "config.json"), 'w', encoding='utf-8') as f: | ||
json.dump(data, f, ensure_ascii=False, indent=4) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This would only be for local data dump - should we think about how can we add this globally, not just on this cluster? Automated way to create a PR, etc.? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @derek-ho There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. see design RFC |
||
|
||
|
||
def error(txt): | ||
print(txt) | ||
sys.exit(1) | ||
|
||
|
||
def main( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the general flow for this CLI would be as follows:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. From where can I source the list of collections and their respective schemas? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. see above comment ... |
||
integration_name: str = typer.Option( | ||
"", "--name", "-n", help="Your new integration name"), | ||
integration_desc: str = typer.Option( | ||
"", "--description", "-d", help="Your new integration description"), | ||
license: str = typer.Option(populateDefaultVars( | ||
"LICENSE"), "--license", "-l", help="Opensource license (e.g. Apache, MIT)"), | ||
data_source: str = typer.Option( | ||
"", "--data-source", "-s", help="The data source to ingest from, as well as which version(s) to support."), | ||
schema: str = typer.Option( | ||
"", "--schema", "-s", help="Which schema, and at which version, to use. The data will be ingested with this schema."), | ||
catalog: str = typer.Option( | ||
"", "--catalog", "-c", help="The specific catalog to target, such as `observability` or `security`."), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can we have an functionality that will scan the /schema folder and present the results for the customer to select from ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Which part to scan in particular? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do you need the option to provide a checkout tag? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the next PR has additional clarification on the catalog folder structure and information |
||
force: bool = typer.Option( | ||
False, "--force", "-f", help="Force integration directoy removal and recreation") | ||
): | ||
|
||
directory = integration_name.lower().replace("_", "-") | ||
|
||
createIntegrationDirs(directory, force) | ||
|
||
generateJson(directory, | ||
integration_name, | ||
integration_desc, | ||
schema, license) | ||
|
||
|
||
if __name__ == "__main__": | ||
if len(sys.argv) <= 1: | ||
typer.run( | ||
error("No options has been provided\nIf unsure, run again with --help\n")) | ||
else: | ||
typer.run(main) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
click==8.1.3 | ||
markdown-it-py==2.2.0 | ||
mdurl==0.1.2 | ||
Pygments==2.14.0 | ||
rich==13.3.2 | ||
typer==0.7.0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should this be apache 2.0?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe?
I'm less familiar with opensource licenses and regulations,
I've placed it just for default value concept and will change it to whatever needed :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Apache-2.0
for compatibility with SPDX, but I agree.