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

feat: proxy component #1444

Open
wants to merge 42 commits into
base: develop
Choose a base branch
from
Open

feat: proxy component #1444

wants to merge 42 commits into from

Conversation

hetangmodi-crest
Copy link
Contributor

Issue number: ADDON-72372

Summary

Similar to logging component, we now have a proxy component, also introduced a new argument --need-proxy which includes default proxy configuration during init method

Changes

  • Just like logging component we now have a new type proxyTab which gives default proxy configuration, so that user doesn't have to mention default configuration themselves they just have to mention their custom configurations.

  • Introduced a new argument in init method that is --need-proxy, which includes default proxy configuration in globalConfig.json during creation of new add-on.

  • Changed the approach of fetching proxy_details inoauth template file. For that created a function in solnlib which fetches proxy_details and validates proxy_host and proxy_port.

User experience

Changes according to UX point of view :

  • If user have to use our default configuration of proxy they just need to define type=proxyTab in their globalConfig.
  • They can add their custom validations for any field, but they would have to use some specific keys for that
    for ex. If a user wants to customize the label of port they would just have to write
    { "type": "proxyTab", "port": { "label": "Proxy port", } }
  • Now users can validate their port and hostnames of proxy through get_proxy_dict function of solnlib.
  • While initializing an add-on user will have extra parameter --need-proxy which includes default proxy configuration in globalConfig.json.

Checklist

If your change doesn't seem to apply, please leave them unchecked.

@hetangmodi-crest hetangmodi-crest added the enhancement New feature or request label Nov 11, 2024
@hetangmodi-crest hetangmodi-crest self-assigned this Nov 11, 2024
@hetangmodi-crest hetangmodi-crest requested review from a team as code owners November 11, 2024 12:30
@artemrys
Copy link
Member

@hetangmodi-crest please fix pre-commit.

@hetangmodi-crest hetangmodi-crest requested a review from a team as a code owner November 15, 2024 12:44
Comment on lines +67 to +68
"username": true,
"password": true,
Copy link
Member

Choose a reason for hiding this comment

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

Does it make sense to move proxy_type, username and password to a default configuration? I feel that more TAs would benefit from having it already there.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

With respect to proxy server setup, username, password and proxy_type are not required configurations. I am inclined not keeping by default so that developers have awareness of the new features UCC rolls out. Yet, giving these fields by default would easy for the developers.

Copy link
Member

Choose a reason for hiding this comment

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

Thanks for remembering about this file as well!

Do we know how much is it used by folks in their TAs?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I am unsure about how much oauth.template file is used overall, but add-ons like Box and ServiceNow use it.

Copy link
Member

@artemrys artemrys left a comment

Choose a reason for hiding this comment

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

There is some groundbreaking work that was done to bring support of proxy components into UCC in this PR! Great work @hetangmodi-crest!

Comment on lines 52 to 56
{%- if need_proxy %}
{
"type": "proxyTab"
},
{%- endif %}
Copy link
Member

Choose a reason for hiding this comment

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

Let's move it after loggingTab definition.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated the template file.

@@ -12,6 +12,7 @@
import splunk.admin as admin
from solnlib import log
from solnlib import conf_manager
from solnlib.conf_manager import InvalidHostnameError,InvalidPortError
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
from solnlib.conf_manager import InvalidHostnameError,InvalidPortError
from solnlib.conf_manager import InvalidHostnameError, InvalidPortError

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Made the changes, also updated oauth.template


def updating_dictionaries(key_name: str, const: Any) -> None:
for key, value in const.items():
nonlocal definition
Copy link
Member

Choose a reason for hiding this comment

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

This looks hacky to me, how we can avoid having this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This was a result of another complex logic there due to one older scenario (which actually is invalid), I have simplified the logic.

{
"type": "loggingTab"
}
{%- endif %}
Copy link
Member

Choose a reason for hiding this comment

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

Can we move {%- if need_proxy %} after loggingTab? We have loggingTab by default and it is being referenced in 2 places with this approach.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Made the changes.

@@ -29,6 +29,7 @@


LIBS_REQUIRED_FOR_UI = {"splunktaucclib": "6.4.0"}
LIBS_REQUIRED_FOR_OAUTH = {"solnlib": "5.5.0"}
Copy link
Member

Choose a reason for hiding this comment

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

Let's leave the OAuth code updates for the next PRs, it's quite hard to review this one and I am not totally sure we need to require a specific version of solnlib for updating OAuth-related handlers.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

For the OAuth helper that we are generating, the solnlib.conf_manager's get_proxy_dict is being used, hence I've fixed the solnlib version and OAuth template file with this Proxy related PR.

> **_NOTE:_**
There are 2 ways to exclude optional entities in your add-on, either omit them from the proxy tab, or set the entities to false.

### Keys
Copy link
Contributor

Choose a reason for hiding this comment

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

Now I think: wouldn't it be good to put this table above ### Available configurations? Plus add "name" and "title" to the table and indicate required and optional fields.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think moving this table above Available configuration will break the flow of the document, as first we should mention what is being generated by default and then steps on how to customize it, which we are following here.
I have added name and title keys in the Keys table.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ok. So maybe would it be good to indicate what the ### Available configurations is about? To mention something about those values.

E.g.:

- Enable proxy :

```json
{
    "type": "checkbox", 
    "label": "Enable",
    "field": "proxy_enabled"
}
```

Because when I had a first look at that, I wasn't sure whether this is a parameter to set, or does it say that it is the default value for the minimal definition.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I had made the changes in documentation, can you please look into it?

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

Successfully merging this pull request may close these issues.

5 participants