Skip to content

Commit

Permalink
Merge pull request #193 from OctopusDeploy/bug-moveintorollingdeploym…
Browse files Browse the repository at this point in the history
…ent3449

Generate unique deployment names for Azure Resource Group deployments
  • Loading branch information
Rob Pearson committed May 30, 2017
2 parents b658826 + b458d61 commit cc0d190
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
Expand Up @@ -88,7 +88,7 @@ static string GenerateDeploymentNameFromStepName(string stepName)
new string(deploymentName.Select(x => (char.IsLetterOrDigit(x) || x == '-') ? x : '-').ToArray());
deploymentName = Regex.Replace(deploymentName, "-+", "-");
deploymentName = deploymentName.Trim('-', '/');
deploymentName = deploymentName + "-" + AesEncryption.RandomString(6);
deploymentName = deploymentName + "-" + Guid.NewGuid().ToString();
return deploymentName;
}

Expand Down
5 changes: 3 additions & 2 deletions source/Calamari/Util/AesEncryption.cs
Expand Up @@ -12,6 +12,8 @@ public class AesEncryption
static readonly byte[] PasswordPaddingSalt = Encoding.UTF8.GetBytes("Octopuss");
static readonly byte[] IvPrefix = Encoding.UTF8.GetBytes("IV__");

static readonly Random RandomGenerator = new Random();

readonly byte[] key;
public AesEncryption(string password)
{
Expand Down Expand Up @@ -98,10 +100,9 @@ public static byte[] GetEncryptionKey(string encryptionPassword)
public static string RandomString(int length)
{
const string chars = "abcdefghijklmnopqrstuvwxyz0123456789";
var random = new Random();
return new string(
Enumerable.Repeat(chars, length)
.Select(s => s[random.Next(s.Length)])
.Select(s => s[RandomGenerator.Next(s.Length)])
.ToArray());
}
}
Expand Down

0 comments on commit cc0d190

Please sign in to comment.