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

Add support for SLE_PRODUCT specific regcodes #4088

Merged
merged 3 commits into from Dec 20, 2017
Merged

Add support for SLE_PRODUCT specific regcodes #4088

merged 3 commits into from Dec 20, 2017

Conversation

alvarocarvajald
Copy link
Contributor

Adds support for product specific registration codes using the SLE_PRODUCT variable.

The content of SCC_REGCODE will be treated as the default registration code, which in turn can be overwritten by the variable SCC_REGCODE_ . getvar('SLE_PRODUCT').

This helps to streamline test suites, helping to avoid the need to create product/architecture specific tests.

@@ -459,6 +459,11 @@ sub get_addon_fullname {


sub fill_in_reg_server {
# Set product specific SCC_REGCODE if it was provided. Defaults to SCC_REGCODE if set
my $scc_code = get_required_var('SCC_REGCODE') if get_var('SCC_REGCODE');
Copy link
Member

Choose a reason for hiding this comment

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

No point to call get_required_var just after you check it's existance, you can simplify by calling just get_var instead.

Copy link
Member

Choose a reason for hiding this comment

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

If I know perl correctly then it will only even define the variable if it is set, i.e. cause an ugly Perl warning otherwise.
I recommend to use just the second argument of get_var in both lines about the regcode setting, e.g.

my $regcode = get_var('SCC_REGCODE_' . uc(get_var('SLE_PRODUCT', '')), get_var ('SCC_REGCODE', ''));
...
type_string $regcode if $regcode;

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Should I also change this as well?

https://github.com/os-autoinst/os-autoinst-distri-opensuse/blob/master/lib/registration.pm#L471

get_required_var() if get_var() was already in the code, so I left it that way even though it seemed redundant to me.

Copy link
Member

Choose a reason for hiding this comment

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

sure, it's not about that you did something wrong . You can just improve code while modifying it

@okurz
Copy link
Member

okurz commented Dec 18, 2017

You added a nice description in the PR which would also be very helpful in the commit message itself. Could you also write it threw
there? I myself very seldomly interact with the webui of github when creating a PR. I am using the tool hub together with my wrapper script git-pr-last which you can find in https://github.com/okurz/scripts if you are interested

@@ -459,6 +459,11 @@ sub get_addon_fullname {


sub fill_in_reg_server {
# Set product specific SCC_REGCODE if it was provided. Defaults to SCC_REGCODE if set
my $scc_code = get_required_var('SCC_REGCODE') if get_var('SCC_REGCODE');
Copy link
Contributor

Choose a reason for hiding this comment

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

using get_required_var if you do not require the variable is strange. I think get_var('SCC_REGCODE', '') is more in line

@@ -459,6 +459,11 @@ sub get_addon_fullname {


sub fill_in_reg_server {
# Set product specific SCC_REGCODE if it was provided. Defaults to SCC_REGCODE if set
my $scc_code = get_var('SCC_REGCODE', '') if get_var('SCC_REGCODE');
Copy link
Contributor

Choose a reason for hiding this comment

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

this assignment needs to be unconditionally

@@ -459,6 +459,11 @@ sub get_addon_fullname {


sub fill_in_reg_server {
# Set product specific SCC_REGCODE if it was provided. Defaults to SCC_REGCODE if set
my $scc_code = get_var('SCC_REGCODE', '') if get_var('SCC_REGCODE');
$scc_code = get_var('SCC_REGCODE_' . uc(get_var('SLE_PRODUCT')), '')
Copy link
Contributor

Choose a reason for hiding this comment

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

please assign get_var('SCC_REGCODE_' . uc(get_var('SLE_PRODUCT')), '') to another variable and do not duplicate the construct.

Adds support for product specific registration codes using the
SLE_PRODUCT variable. The content of SCC_REGCODE will be treated as the
default registration code, which in turn can be overwritten by the
variable SCC_REGCODE_ . getvar('SLE_PRODUCT').

This helps to streamline test suites, helping to avoid the need to
create product/architecture specific tests.
In fill_in_reg_server(), get_required_var() was being used after
checking the existence of the variable, so this streamlines the code by
changing those calls to get_var() and also adding default empty strings
to the get_var() calls
Remove conditional assignments in fill_in_reg_server()
@asmorodskyi asmorodskyi merged commit 8777f7d into os-autoinst:master Dec 20, 2017
@alvarocarvajald alvarocarvajald deleted the product-specific-scc-regcode branch December 20, 2017 11:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants