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

Feature/SK-1229 | Project resource for CLI extension #784

Open
wants to merge 25 commits into
base: master
Choose a base branch
from

Conversation

KatHellg
Copy link
Contributor

@KatHellg KatHellg commented Jan 8, 2025

Features:

  • create project
  • delete project
  • activate project
  • list projects
  • get project

@github-actions github-actions bot added feature New feature or request minor labels Jan 8, 2025
@KatHellg KatHellg changed the title feature/SK-1229 | Project resource for CLI extension Feature/SK-1229 | Project resource for CLI extension Jan 8, 2025
@Wrede Wrede added the HOLD label Jan 8, 2025
Copy link
Member

@Wrede Wrede left a comment

Choose a reason for hiding this comment

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

mycket bra! Har några kommentarer

@click.option("-H", "--host", required=False, default="fedn.scaleoutsystems.com", help="Hostname of controller (api)")
@click.option("-p", "--protocol", required=False, default=CONTROLLER_DEFAULTS["protocol"], help="Communication protocol of controller (api)")
@click.option("-H", "--host", required=False, default=CONTROLLER_DEFAULTS["host"], help="Hostname of controller (api)")
@click.option("-P", "--port", required=False, default=CONTROLLER_DEFAULTS["port"], help="Port of controller (api)")
Copy link
Member

Choose a reason for hiding this comment

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

skulle även vilja ha alternativet att kunna ange --user --password istället för promt

else:
click.secho(f"Unexpected error: {response.text}", fg="red")


def get_context(response, protocol, host, port):
Copy link
Member

Choose a reason for hiding this comment

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

add doc string explaning what the function do, and in particular explain what context_data is.

if not os.path.exists(context_path):
os.makedirs(context_path)
try:
with open(f"{context_path}/context.yaml", "w") as yaml_file:
Copy link
Member

Choose a reason for hiding this comment

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

vad händer om det redan finns en context.yaml med innehåll?

headers_projects["Authorization"] = _token

try:
response_projects = requests.get(url_projects, headers=headers_projects)
Copy link
Member

Choose a reason for hiding this comment

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

om det returnerar status_code != 200 vad händer då?

except requests.exceptions.ConnectionError:
click.echo(f"Error: Could not connect to {url_project_token}")

controller_url = f"{protocol}://{host}/{slug}-fedn-reducer"
Copy link
Member

Choose a reason for hiding this comment

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

istället för att hårdkoda url med "-fedn-reducer" bör den fullstädiga url till controller returneras av studio

def list_projects(ctx, protocol: str = None, host: str = None, port: str = None, token: str = None):
"""Return:
------
- result: list of packages
Copy link
Member

Choose a reason for hiding this comment

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

list of packages?

for i in response_json:
project_name = i.get("slug")
if project_name == active_project:
click.secho(project_name, fg="green")
Copy link
Member

Choose a reason for hiding this comment

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

skulle nog tom ha project_name + "(active)" för att vara ännu mer tydlig

@click.option("-p", "--protocol", required=False, default=CONTROLLER_DEFAULTS["protocol"], help="Communication protocol of controller (api)")
@click.option("-H", "--host", required=False, default=CONTROLLER_DEFAULTS["host"], help="Hostname of controller (api)")
@click.option("-P", "--port", required=False, default=CONTROLLER_DEFAULTS["port"], help="Port of controller (api)")
@project_cmd.command("activate")
Copy link
Member

Choose a reason for hiding this comment

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

hmm "activate", kanske "fedn project set-context"? Bara en tanke

context_data["Active project url"] = controller_url

try:
with open(f"{context_path}/context.yaml", "w") as yaml_file:
Copy link
Member

Choose a reason for hiding this comment

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

code redudancy, gör till utility metod

@@ -16,6 +18,8 @@

API_VERSION = "v1"
Copy link
Member

Choose a reason for hiding this comment

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

detta måste funka för windows också, gör det det?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request HOLD minor
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants