Skip to content

147788 - Uninstall app cmd in portal-sdk#135

Open
ritanorinho wants to merge 1 commit intomainfrom
main-147788-uninstallAppCmd
Open

147788 - Uninstall app cmd in portal-sdk#135
ritanorinho wants to merge 1 commit intomainfrom
main-147788-uninstallAppCmd

Conversation

@ritanorinho
Copy link
Contributor

Changes

  • Implement logic to support appl uninstallation in the portal sdk.
  • Add unit tests.
  • Update lbos.

@github-actions
Copy link
Contributor

github-actions bot commented Mar 5, 2026

Code Coverage

Package Line Rate Branch Rate Health
Cmf.CustomerPortal.Sdk.Common 23% 25%
Summary 23% (360 / 1548) 25% (136 / 550)

{
class UninstallAppCommand : BaseCommand
{
public UninstallAppCommand() : this("uninstallApp", "[Preview] Uninstalls an app from a customer environment version")
Copy link
Collaborator

Choose a reason for hiding this comment

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

the command name should be uninstall-app

Copy link
Collaborator

Choose a reason for hiding this comment

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

Preview is not needed for this one. Actually, please take the time to remove the preview from the undeploy, its already GA.


public UninstallAppCommand(string name, string description = null) : base(name, description)
{
Add(new Option<string>(new[] { "--appName", }, Resources.CUSTOMER_ENVIRONMENT_APPLICATION_PACKAGE_NAME_HELP)
Copy link
Collaborator

Choose a reason for hiding this comment

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

The app name option should be:

  • -n
  • --name

{
IsRequired = true
});
Add(new Option<string>(new[] { "--customerEnvironmentName", }, Resources.CUSTOMER_ENVIRONMENT_NAME_HELP)
Copy link
Collaborator

Choose a reason for hiding this comment

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

The customer env name should be:

  • -ce
  • --customer-environment

},
"Uninstall App": {
"commandName": "Project",
"commandLineArgs": "uninstallApp --customerEnvironmentName \"env-name\" --appName \"Dummy\""
Copy link
Collaborator

@vitorpmoreira vitorpmoreira Mar 6, 2026

Choose a reason for hiding this comment

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

This needs to be updated after the command options are updated

Copy link
Collaborator

Choose a reason for hiding this comment

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

Additionally, the README needs update to include the new cmd

public const string REPLACETOKENS_HELP = "Replace the tokens specified in the input files using the proper syntax (e.g. #{MyToken}#) with the specified values. E.g. MyToken=value MyToken2=value2.";

public const string CUSTOMER_ENVIRONMENT_NAME_HELP = "Name of the Customer Environment to be used.";
public const string CUSTOMER_ENVIRONMENT_APPLICATION_PACKAGE_NAME_HELP = "Name of the App to be uninstalled.";
Copy link
Collaborator

@vitorpmoreira vitorpmoreira Mar 6, 2026

Choose a reason for hiding this comment

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

Const name should be scoped to uninstall

try
{
customerEnvironment = await customerPortalClient.GetObjectByName<CustomerEnvironment>(customerEnvironmentName);
customerEnvironment = await customerPortalClient.GetCustomerEnvironmentById(customerEnvironment.Id, 1);
Copy link
Collaborator

Choose a reason for hiding this comment

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

why a second call?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

the first one doesn't load the relations.

Session.LogError($"Customer environment '{customerEnvironmentName}' is terminated; uninstall cannot proceed.");
return;
}
if (customerEnvironment.Status == DeploymentStatus.NotDeployed)
Copy link
Collaborator

Choose a reason for hiding this comment

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

We actually defined that we should get the last non-NotDeployed version.

return;
}

await customerPortalClient.StartAppUninstall(customerEnvironmentApplicationPackage.Id, terminateOtherVersionsRemove, terminateOtherVersionsRemoveVolumes);
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is missing the logic to get the logs/feedback and wait until the process is over.

await customerPortalClient.StartAppUninstall(customerEnvironmentApplicationPackage.Id, terminateOtherVersionsRemove, terminateOtherVersionsRemoveVolumes);
Session.LogInformation($"Uninstall request submitted for application '{appName}' (relation id: {customerEnvironmentApplicationPackage.Id}) in environment '{customerEnvironmentName}'.");
}
else
Copy link
Collaborator

@vitorpmoreira vitorpmoreira Mar 6, 2026

Choose a reason for hiding this comment

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

suggestion: For readability purposes, you can just add an if condition before and return right away if no installed app was found.

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.

3 participants