-
Notifications
You must be signed in to change notification settings - Fork 77
UTY 2088: Set external ip from cli #1409
UTY 2088: Set external ip from cli #1409
Conversation
Corresponding JIRA ticket: https://improbableio.atlassian.net/browse/UTY-2088 |
workers/unity/Packages/io.improbable.gdk.core/Worker/ConnectionHandlers/ConnectionFlows.cs
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As it stands, I don't believe our command line parser supports flag style arguments (https://github.com/spatialos/gdk-for-unity/blob/master/workers/unity/Packages/io.improbable.gdk.core/Utility/CommandLineUtility.cs#L83). What will currently happen is the +useExternalIp
argument will consume the next argument if used as a flag.
I.e. - UnityClient.exe +workerType UnityClient +useExternalIp +receptionistHost localhost
Would parse as:
workerType -> UnityClient
useExternalIp -> +receptionistHost
That being said, I do agree that this should be a flag style argument.
workers/unity/Packages/io.improbable.gdk.core/Utility/CommandLineUtility.cs
Outdated
Show resolved
Hide resolved
workers/unity/Packages/io.improbable.gdk.core/Utility/CommandLineUtility.cs
Outdated
Show resolved
Hide resolved
workers/unity/Packages/io.improbable.gdk.core/Utility/CommandLineUtility.cs
Outdated
Show resolved
Hide resolved
workers/unity/Packages/io.improbable.gdk.core/Utility/CommandLineUtility.cs
Outdated
Show resolved
Hide resolved
workers/unity/Packages/io.improbable.gdk.core/Utility/CommandLineUtility.cs
Outdated
Show resolved
Hide resolved
@@ -30,7 +30,6 @@ public void Initialize_should_set_network_protocol(string protocolStr, NetworkCo | |||
|
|||
[TestCase("ranket")] | |||
[TestCase("raknet")] | |||
[TestCase("")] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Had to remove this. The initializer now assumes empty string is a result of parsing a flag argument and will throw InvalidOperationException
when you try to use TryGetCommandLineValue
on it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM - sorry about the current build flake, if you push an empty commit it will retrigger and should pass:
git commit --allow-empty -m 'force rebuild' && git push origin HEAD
There appears to be a bug where we don't truncate the commit message before using it as a parameter elsewhere
@@ -59,6 +59,11 @@ public bool TryGetCommandLineValue<T>(string key, ref T value) | |||
var desiredType = typeof(T); | |||
if (arguments.TryGetValue(key, out var strValue)) | |||
{ | |||
if (string.IsNullOrEmpty(strValue)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this will be hit when you do the following as well +someArgument ""
.
I don't think there is a difference currently between "no" argument and an "empty" argument?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@zeroZshadow Should I allow empty argument to pass or throw a different exception for empty argument?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think an empty string as a value is valid, so we'd need a different way to differentiate between a flag and an empty value. @jamiebrynes7 @paulbalaji @seanjparker Opinions?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can just set it to null
for flags.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
null
for flags and string.Empty
for truly empty arguments seems reasonable to me
Co-authored-by: Jamie Brynes <[email protected]>
Make exception message clearer by referring to flag argument
…yGetCommandLineValue, also fix some coding style issue
`CommanLineParser` -> `CommandLineParser` Co-authored-by: Jamie Brynes <[email protected]>
41bee17
to
3fbed4f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice job!
{ | ||
var args = CommandLineArgs.From(new List<string> | ||
{ | ||
"+key1", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This would be a better test by changing the keys around. An empty one first, and then one with a value.
This way you test that the parser doesn't skip the empty key
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM % Martijn's comment
Kudos, SonarCloud Quality Gate passed! 0 Bugs |
Description
Allow the setting of
UseExternalIp
flag from the cli.UseExternalIp
inReceptionistFlow
andLocatorFlow
RuntimeConfigNames
andRuntimeConfigDefaults
UseExternalIp
is set if the argument exists and set to default if it does notTests
CommandLineConnectionFlowInitializerTests
Documentation
https://documentation.improbable.io/gdk-for-unity/v0.3.8/suggested-edits
Primary reviewers
If your change will take a long time to review, you can name at most two primary reviewers who are ultimately responsible for reviewing this request. @ mention them.