metalbear-co / mirrord

Connect your local process and your cloud environment, and run local code in cloud conditions.
https://mirrord.dev
MIT License
3.81k stars 104 forks source link

Passing cli arguments from pod to local application #772

Open 1grzyb1 opened 1 year ago

1grzyb1 commented 1 year ago

We pass the configuration to our application inside pod containers through CLI arguments. So for example my container definition inside the pod will look like that:

containers:
  name: container-name
  args:
    '--properties.propa.propb=value'
    '--properties.propc=value'

So I would like those properties to be passed as cli arguments in the same order as in args to my local app just like env variables are passed

aviramha commented 10 months ago

Proposal: This needs to be implemented in the agent, cli (and operator to support the new message), extensions (to modify the command line actually). I think it should be under a new feature in the configuration file, that lets user provide a regex to match arguments to use. It should also accept an optional parameter that tells us at what position of the command line to push this argument, for example:

{
    "feature": {
        "cmdline": {
            "filter": "-D.+",
            "position": 2
        }
    },
}

Now when remote has the cmdline

/app/user/java -Dfun=true -Dfun2=true -XXfun -jar fun.jar mainClass

Local that has the following cmdline:

/app/user/java -Dotherthing=1 -jar fun.jar mainClass

would be modified to

/app/user/java -Dotherthing=1  -Dfun=true -Dfun2=true -jar fun.jar mainClass

where /app/user/java is arg number 1, -Dotherthing=1 is 2, then we extend there the additional arguments.

Notes: