caprover / caprover-cli

Command Line Interface for https://github.com/caprover/caprover
72 stars 40 forks source link

API - Required fields for app definitions? #81

Closed thepandaguitar closed 3 years ago

thepandaguitar commented 3 years ago

Hi @githubsaturn

I would like to confirm with you if there are required fields when updating the app definitions using /user/apps/appDefinitions/update

In my case, I was able update the HTTP Container Port just by posting the following data, and everything seems to work: {"appName":"myapp","instanceCount":1, "containerHttpPort":80}

Do you have any defaults set somewhere? I want to make sure this is ok to continue.

Thank you as always @githubsaturn 🙌

(At first I added this question as a comment to my other issue but it seemed it would be more helpful for others to add it in a separate discussion)

githubsaturn commented 3 years ago

There are a bunch of items that will be set when updating app definition:

    serviceManager
        .updateAppDefinition(
            appName,
            description,
            Number(instanceCount),
            captainDefinitionRelativeFilePath,
            envVars,
            volumes,
            nodeId,
            notExposeAsWebApp,
            containerHttpPort,
            httpAuth,
            forceSsl,
            ports,
            repoInfo,
            customNginxConfig,
            preDeployFunction,
            serviceUpdateOverride,
            websocketSupport
        )

Seems like in your case, your app is simple and does not require any of these. So it should be fine to go with what you have now.

thepandaguitar commented 3 years ago

Thank you so much for your quick replies @githubsaturn! 🙏

Correct me if I'm wrong. That means as long as I have { "appName": "myApp" } in my POST request, all my previous settings are kept and optional in the call?

For example, let's say my app with some settings (eg 2 instances or forceSSL set to true). If I update the app definitions with POST { "appName": "myApp", "description": "blahblah" }

githubsaturn commented 3 years ago

Everything get overwritten (set to defaults), and only the new settings are set.

githubsaturn commented 3 years ago

That's why you first need to get the current app definition, then edit it, then update it with the entire content.

thepandaguitar commented 3 years ago

Got it, thank you!