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

Improve tilt args command with an update function #6137

Open
guyWeinberg opened this issue Jun 6, 2023 · 0 comments
Open

Improve tilt args command with an update function #6137

guyWeinberg opened this issue Jun 6, 2023 · 0 comments
Labels
enhancement New feature or request

Comments

@guyWeinberg
Copy link

guyWeinberg commented Jun 6, 2023

Describe the Feature You Want

I would like to improve the tilt args management system with an update function

Current Behavior

Today's api currently only have either full set with tilt args <ARGUMENTS> or full edit with vim with tilt args

Why Do You Want This?

I'm currently working on implementing tilt local environment for our developers. As part of the experience there are two extra features we wanted to accomplish:

  • An image type selector for each service
    • Each service can be run with either a Remote image based on our develop branch or an image built locally
    • Benefits mainly setup efforts - because by default we use our Remote images so no source code is needed on the first run
  • Java Composite build selector
    • Our backend is Java so another request was to enable composite build with a button similarly to IntelliJ

Our solution was to leverage tilt args and the extension UIButton. To accomplish that we added the following custom code to help us update the args dynamically:

 def get_config_args():
    return cfg.get("args") or []

def get_tilt_args_dict():
    args = get_config_args()
    argsDict = {}
    for arg in args:
        argParts = arg.split("=")
        name = argParts[0]
        value = argParts[1]
        argsDict[name] = value
    return argsDict

def convert_args_dict_to_args_command(argsDict):
    command = "tilt args"
    for argName, value in argsDict.items():
        command += " " + argName + "=" + value
    return command

def get_replace_tilt_arg_value_command(argName, value):
    argsDict = get_tilt_args_dict()
    argsDict[argName] = value
    return convert_args_dict_to_args_command(argsDict)

service_core_enabled_arg_name = self["name"] + '-CoreComposite'
command = get_replace_tilt_arg_value_command(service_core_enabled_arg_name, "$COMPOSITE")
cmd_button(
    self["name"] + "-core-composite",
    argv=["sh", "-c", command],
    resource=self["auto_compile_resource_name"],
    icon_name='developer_board',
    text='Composite Build Selector - Press to apply changes',
    inputs=[
        bool_input(name='COMPOSITE', true_string='true', false_string='false', label='Composite Build With Core'),
    ],
)

As you can see the custom code could have been shorten if tilt args had an update function.
After updating the args we can use the argument to change the way we build our service.

Providing an image of the final button
image

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

No branches or pull requests

1 participant