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 Runtime API Endpoint Command Line Arg to Runtime Support #1989

Draft
wants to merge 1 commit into
base: dev
Choose a base branch
from

Conversation

philasmar
Copy link
Contributor

Issue #, if available:

Description of changes:

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@philasmar philasmar marked this pull request as draft February 21, 2025 19:49
@philasmar philasmar changed the title commit 1 Add Runtime API Endpoint Command Line Arg to Runtime Support Feb 21, 2025
Copy link
Member

@normj normj left a comment

Choose a reason for hiding this comment

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

I assume the Lambd1 project is just there for demonstration purposes as a draft PR.

{
public class LambdaBootstrapOptions
{
public string RuntimeApiEndpoint { get; set; }
Copy link
Member

Choose a reason for hiding this comment

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

Be sure to add documentation that this should only be set for testing environments. Not when deployed to Lambda.

var arguments = new Dictionary<string, string>();

string currentKey = null;
for (int i = 1; i < args.Length; i++)
Copy link
Member

Choose a reason for hiding this comment

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

Probably personal preference but I find this logic a bit confusing especially keeping state outside of the loop and waiting for value to get resolved next iteration of the look. What about this something like this which is untested.

private static LambdaBootstrapOptions ParseCommandLineArguments(string[] args)
{
    var option = new LambdaBootstrapOptions();

    if (args.Length > 1)
    {
        var arguments = new Dictionary<string, string>();
        for (int i = 1; i < args.Length; i++)
        {
            if (!string.IsNullOrEmpty(args[i]))
                throw new Exception();

            string key = args[i];
            int valuePos = i + 1;
            string value = null;
            if (args.Length < valuePos && !args[valuePos].StartsWith("-"))                
            {
                value = args[valuePos];
                i++;
            }

            arguments[key] = value;
        }

        if (arguments.TryGetValue("--runtime-api-endpoint", out var argument))
            option.RuntimeApiEndpoint = argument;

    }

    return option;
}

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.

2 participants