cloudwash icon indicating copy to clipboard operation
cloudwash copied to clipboard

Add option to set the settings.yaml path

Open adrianriobo opened this issue 3 years ago • 8 comments

According to documentation currently the settings.yaml file should be filled and placed at ~/cloudwash/settings.yaml. I was expecting that would be the path where cloudwash looks for the file. Instead it is looking for the file at current path where the tool is been executed.

Using the image on a different context like Tekton the execution will end on error:

<<<<<<< Running the cleanup script in DRY RUN mode >>>>>>> 
Traceback (most recent call last):
  File "/opt/app-root/bin/swach", line 8, in <module>
    sys.exit(cleanup_providers())
  File "/opt/app-root/lib64/python3.8/site-packages/click/core.py", line 1130, in __call__
    return self.main(*args, **kwargs)
  File "/opt/app-root/lib64/python3.8/site-packages/click/core.py", line 1055, in main
    rv = self.invoke(ctx)
  File "/opt/app-root/lib64/python3.8/site-packages/click/core.py", line 1657, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/opt/app-root/lib64/python3.8/site-packages/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/opt/app-root/lib64/python3.8/site-packages/click/core.py", line 760, in invoke
    return __callback(*args, **kwargs)
  File "/opt/app-root/lib64/python3.8/site-packages/click/decorators.py", line 26, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/opt/app-root/lib64/python3.8/site-packages/cloudwash/cli.py", line 87, in ec2
    validate_provider([ctx.command.name](http://ctx.command.name/))
  File "/opt/app-root/lib64/python3.8/site-packages/cloudwash/config.py", line 13, in validate_provider
    f"{provider}.{setting_key}" for setting_key in settings.to_dict()["PROVIDERS"].get(provider)

This is because the working dir (from where swach will be executed) for the tekton task is /tekton/home and the file is at /tekton/home/cloudwash/settings.yaml

So it would be great if a new option for passing the settings file path would be added:

swach --settings-file /custom_path/settings.yaml

adrianriobo avatar Jul 27 '22 08:07 adrianriobo

Would be great to have .config/cloudwatch/ in the search path as well, it is where most of us expect config files these days :)

lzap avatar Aug 25 '22 08:08 lzap

Hi @adrianriobo Can I work on this issue?

bovem avatar Oct 09 '22 07:10 bovem

Yeah I guess you can ask @jyejare , I just reported it but can not work on it...I think it would be great if you add this feature

adrianriobo avatar Oct 10 '22 07:10 adrianriobo

Hey @bovem you are more than welcome for contribution :)

jyejare avatar Oct 10 '22 07:10 jyejare

Thanks, I'll raise a PR.

bovem avatar Oct 10 '22 07:10 bovem

@bovem Where are you upto on this? Are you still interested ?

jyejare avatar Nov 04 '22 15:11 jyejare

@jyejare Yes, I am working on it. I will create a WIP PR for progress tracking.

I have added the flag but I think I have to make changes to individual provider's cleanup code to add settings path param.

bovem avatar Nov 07 '22 07:11 bovem

@bovem I would love to see what great stuffs your PR brings up :)

jyejare avatar Nov 07 '22 14:11 jyejare