Skip to content
This repository has been archived by the owner on Jan 18, 2022. It is now read-only.

UTY 2088: Set external ip from cli #1409

Merged
merged 16 commits into from
Jul 2, 2020

Conversation

BryanJY-Wong
Copy link
Contributor

@BryanJY-Wong BryanJY-Wong commented Jun 29, 2020

Description

Allow the setting of UseExternalIp flag from the cli.

  • Added new bool field for UseExternalIp in ReceptionistFlow and LocatorFlow
  • Added appropriate name and defaults in the RuntimeConfig classes RuntimeConfigNames and RuntimeConfigDefaults
  • Added unit test to check if the UseExternalIp is set if the argument exists and set to default if it does not

Tests

  • Added and ran unit test in 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.

@BryanJY-Wong BryanJY-Wong self-assigned this Jun 29, 2020
@improbable-prow-robot
Copy link

Corresponding JIRA ticket: https://improbableio.atlassian.net/browse/UTY-2088

@improbable-prow-robot improbable-prow-robot added A: core Area: Core GDK size/M Denotes a PR that changes 40-149 lines, ignoring generated files. labels Jun 29, 2020
@BryanJY-Wong BryanJY-Wong requested a review from paulbalaji June 29, 2020 14:11
@improbable-prow-robot improbable-prow-robot added size/S Denotes a PR that changes 15-39 lines, ignoring generated files. and removed size/M Denotes a PR that changes 40-149 lines, ignoring generated files. labels Jun 29, 2020
CHANGELOG.md Outdated Show resolved Hide resolved
Copy link
Contributor

@jamiebrynes7 jamiebrynes7 left a 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.

CHANGELOG.md Outdated Show resolved Hide resolved
@improbable-prow-robot improbable-prow-robot added size/M Denotes a PR that changes 40-149 lines, ignoring generated files. and removed size/S Denotes a PR that changes 15-39 lines, ignoring generated files. labels Jun 29, 2020
@@ -30,7 +30,6 @@ public void Initialize_should_set_network_protocol(string protocolStr, NetworkCo

[TestCase("ranket")]
[TestCase("raknet")]
[TestCase("")]
Copy link
Contributor Author

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.

Copy link
Contributor

@jamiebrynes7 jamiebrynes7 left a 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))
Copy link
Contributor

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?

Copy link
Contributor Author

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?

Copy link
Contributor

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?

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 can just set it to null for flags.

Copy link
Contributor

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

@BryanJY-Wong BryanJY-Wong force-pushed the feature/UTY-2088-set-external-ip-from-cli branch from 41bee17 to 3fbed4f Compare July 1, 2020 08:45
Copy link
Contributor

@jamiebrynes7 jamiebrynes7 left a 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",
Copy link
Contributor

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

Copy link
Contributor

@paulbalaji paulbalaji left a 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

@sonarqubecloud
Copy link

sonarqubecloud bot commented Jul 1, 2020

Kudos, SonarCloud Quality Gate passed!

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities (and Security Hotspot 0 Security Hotspots to review)
Code Smell A 0 Code Smells

100.0% 100.0% Coverage
0.0% 0.0% Duplication

@BryanJY-Wong BryanJY-Wong merged commit 7400dd1 into develop Jul 2, 2020
@improbable-prow-robot improbable-prow-robot deleted the feature/UTY-2088-set-external-ip-from-cli branch July 2, 2020 12:54
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
A: core Area: Core GDK jira/UTY size/M Denotes a PR that changes 40-149 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants