Skip to content

Conversation

okurz
Copy link
Member

@okurz okurz commented Sep 24, 2025

@okurz okurz force-pushed the feature/multi_host_tokens branch from ba4225b to e7a6bb2 Compare September 24, 2025 17:31
@okurz okurz marked this pull request as draft September 24, 2025 17:31
@okurz
Copy link
Member Author

okurz commented Sep 25, 2025

@Martchus had the idea to put the env variables into the client so the deepest level. I think we can try to put the authentication token support into the client as well

$host => {key => $key, secret => $secret}
} split /,/, $ENV{OPENQA_WORKER_TOKEN} // $cli_options->{token} // '';
for (keys %tokens) {
$webui_host_specific_settings{$_} ||= {};
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
$webui_host_specific_settings{$_} ||= {};

Copy link
Member Author

Choose a reason for hiding this comment

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

so you think this line isn't necessary? Isn't that needed for auto-vivification so that we can write values into the inner hash?

Copy link
Contributor

Choose a reason for hiding this comment

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

Auto-vivifaction is exactly why it isn't needed, that's why it's called "auto" :)

sub new ($class, $webui_host, $args) {
$webui_host = $ENV{OPENQA_WORKER_WEBUI_HOST} // $webui_host;
my $url = $webui_host !~ '/' ? Mojo::URL->new->scheme('http')->host_port($webui_host) : Mojo::URL->new($webui_host);
my ($host, $key, $secret) = split /|/, $ENV{OPENQA_WORKER_TOKEN} if $ENV{OPENQA_WORKER_TOKEN};
Copy link
Contributor

@perlpunk perlpunk Sep 25, 2025

Choose a reason for hiding this comment

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

perl -wE'@a = split /|/, "abc|de"; say for @a'
a
b
c
|
d
e

You want split m/\|/

) or usage(1);

usage(0) if ($options{help});
exit !OpenQA::Worker::encode_token($options{encode-token}) if $options{encode-token};
Copy link
Contributor

Choose a reason for hiding this comment

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

Unquoted string "encode" may clash with future reserved word at -e line 1.
Argument "token" isn't numeric in subtraction (-) at -e line 1.
Argument "encode" isn't numeric in subtraction (-) at -e line 1.

Copy link
Member Author

Choose a reason for hiding this comment

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

sorry, I missed some local changes for that

sub new ($class, $webui_host, $args) {
$webui_host = $ENV{OPENQA_WORKER_WEBUI_HOST} // $webui_host;
my $url = $webui_host !~ '/' ? Mojo::URL->new->scheme('http')->host_port($webui_host) : Mojo::URL->new($webui_host);
my ($host, $key, $secret) = split /|/, $ENV{OPENQA_WORKER_TOKEN} if $ENV{OPENQA_WORKER_TOKEN};
Copy link
Contributor

Choose a reason for hiding this comment

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

Why not reuse the decode_token here?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants