From 8d952b64f3ddddbbd24d5d5eb1aeb07184de47e5 Mon Sep 17 00:00:00 2001 From: Alexander Morogov Date: Thu, 3 Oct 2024 12:09:35 +0200 Subject: [PATCH] VCI-920: Use Organization parameter in CloudDown target --- docs/targets.md | 24 +++++++++++---------- src/VirtoCommerce.Build/Cloud/Build.SaaS.cs | 16 ++++++++------ 2 files changed, 22 insertions(+), 18 deletions(-) diff --git a/docs/targets.md b/docs/targets.md index 510c323..c556626 100644 --- a/docs/targets.md +++ b/docs/targets.md @@ -232,7 +232,7 @@ vc-build CloudEnvUpdate -CloudToken -Manifest -EnvironmentName -EnvironmentName @@ -265,21 +265,21 @@ vc-build CloudInit -EnvironmentName -ServicePlan F1 ``` ::: ::: -## CloudEnvList +## CloudEnvList List Environments with Statuses ```console vc-build CloudEnvList ``` ::: ::: -## CloudEnvRestart +## CloudEnvRestart Restart Environment ```console vc-build CloudEnvRestart -EnvironmentName ``` ::: ::: -## CloudEnvStatus +## CloudEnvStatus Waits for health and/or sync statuses of the Environment Gets parameters: CloudToken, EnvironmentName, HealthStatus, SyncStatus ```console @@ -287,28 +287,30 @@ vc-build CloudEnvStatus -CloudToken -EnvironmentName ``` ::: ::: -## CloudDown +## CloudDown Delete Environment +Parameters: Organization (optional), EnvironmentName (required) ```console vc-build CloudDown -EnvironmentName +vc-build CloudDown -Organization -EnvironmentName ``` ::: ::: -## CloudDeploy +## CloudDeploy Deploy Custom Image to the Existing Environment ```console vc-build CloudDeploy -EnvironmentName -DockerUsername ``` ::: ::: -## CloudUp +## CloudUp Deploy Custom Image to the New Environment ```console vc-build CloudUp -EnvironmentName -DockerUsername diff --git a/src/VirtoCommerce.Build/Cloud/Build.SaaS.cs b/src/VirtoCommerce.Build/Cloud/Build.SaaS.cs index a38c9f6..47bd07d 100644 --- a/src/VirtoCommerce.Build/Cloud/Build.SaaS.cs +++ b/src/VirtoCommerce.Build/Cloud/Build.SaaS.cs @@ -66,9 +66,10 @@ public string CloudAuthProvider } [Parameter("Use Azure AD as SaaS Auth Provider")] public bool AzureAD = false; private string cloudAuthProvider = "GitHub"; + private string environmentName; - [Parameter("App Project Name")] public string AppProject { get; set; } - [Parameter("Cloud Environment Name")] public string EnvironmentName { get; set; } + [Parameter("App Project Name")] public string AppProject { get => SaaSOrganizationName; set => SaaSOrganizationName = value?.ToLowerInvariant(); } + [Parameter("Cloud Environment Name")] public string EnvironmentName { get => environmentName; set => environmentName = value?.ToLowerInvariant(); } [Parameter("Cloud Environment Service Plan")] public string ServicePlan { get; set; } = "F1"; [Parameter("Cloud Environment Cluster Name")] public string ClusterName { get; set; } [Parameter("Cloud Environment Db Provider")] public string DbProvider { get; set; } @@ -300,7 +301,8 @@ private static void CopyPlatformDirectory(AbsolutePath platformDirectory, Absolu var port = "60123"; var listenerPrefix = $"http://localhost:{port}/"; - var listener = new HttpListener() { + var listener = new HttpListener() + { Prefixes = { listenerPrefix } }; listener.Start(); @@ -368,7 +370,7 @@ private void SaveCloudToken(string token) var cloudClient = CreateVirtocloudClient(CloudUrl, await GetCloudTokenAsync()); var envList = await cloudClient.EnvironmentsListAsync(); Log.Information("There are {0} environments.", envList.Count); - foreach ( var env in envList) + foreach (var env in envList) { Log.Information("{0} - {1}", env.MetadataName, env.Status); } @@ -401,15 +403,15 @@ private void SaveCloudToken(string token) Cluster = ClusterName, DbProvider = DbProvider, DbName = DbName, - Helm = new HelmObject(new Dictionary ()) + Helm = new HelmObject(new Dictionary()) }; - if(!string.IsNullOrEmpty(DockerImageName)) + if (!string.IsNullOrEmpty(DockerImageName)) { model.Helm.Parameters["platform.image.repository"] = DockerImageName; } - if(!DockerImageTag.IsNullOrEmpty()) + if (!DockerImageTag.IsNullOrEmpty()) { model.Helm.Parameters["platform.image.tag"] = DockerImageTag[0]; }