public void VariablesInAdditionalVariablesPathAreContributed() { try { using (var varFile = new TemporaryFile(Path.GetTempFileName())) { new CalamariVariables { { "new.key", "new.value" } }.Save(varFile.FilePath); Environment.SetEnvironmentVariable(VariablesFactory.AdditionalVariablesPathVariable, varFile.FilePath); var variables = new VariablesFactory(CalamariPhysicalFileSystem.GetPhysicalFileSystem()) .Create(new CommonOptions("test")); variables.Get("new.key").Should().Be("new.value"); } } finally { Environment.SetEnvironmentVariable(VariablesFactory.AdditionalVariablesPathVariable, null); } }
public void ShouldCheckVariableIsSet() { var variables = new VariablesFactory(fileSystem).Create(options); Assert.That(variables.IsSet("thisIsBogus"), Is.False); Assert.That(variables.IsSet("firstSensitiveVariableName"), Is.True); }
protected IVariables GenerateVariables() { var variables = new VariablesFactory(fileSystem).Create(new CommonOptions("test")); variables.Set(TentacleVariables.Agent.ApplicationDirectoryPath, applicationDirectory); return(variables); }
public void ShouldIncludeEncryptedSensitiveVariables() { var result = new VariablesFactory(fileSystem).Create(options); Assert.AreEqual("firstSensitiveVariableValue", result.Get("firstSensitiveVariableName")); Assert.AreEqual("secondSensitiveVariableValue", result.Get("secondSensitiveVariableName")); Assert.AreEqual("firstInsensitiveVariableValue", result.Get("firstInsensitiveVariableName")); }
private IVariables AddEnvironmentVariables() { var variables = new VariablesFactory(CalamariPhysicalFileSystem.GetPhysicalFileSystem()).Create(new CommonOptions("test")); Assert.That(variables.GetNames().Count, Is.GreaterThan(3)); Assert.That(variables.GetRaw(TentacleVariables.Agent.InstanceName), Is.EqualTo("#{env:TentacleInstanceName}")); return(variables); }
public void ShouldIncludeCleartextSensitiveVariables() { options.InputVariables.SensitiveVariablesPassword = null; var sensitiveVariables = new Dictionary <string, string> { { "firstSensitiveVariableName", "firstSensitiveVariableValue" } }; File.WriteAllText(firstSensitiveVariablesFileName, JsonConvert.SerializeObject(sensitiveVariables)); File.WriteAllText(secondSensitiveVariablesFileName, "{}"); var result = new VariablesFactory(fileSystem).Create(options); Assert.AreEqual("firstSensitiveVariableValue", result.Get("firstSensitiveVariableName")); Assert.AreEqual("firstInsensitiveVariableValue", result.Get("firstInsensitiveVariableName")); }
public virtual void SetUp() { FileSystem = CalamariPhysicalFileSystem.GetPhysicalFileSystem(); // Ensure staging directory exists and is empty StagingDirectory = Path.Combine(Path.GetTempPath(), "CalamariTestStaging"); CustomDirectory = Path.Combine(Path.GetTempPath(), "CalamariTestCustom"); FileSystem.EnsureDirectoryExists(StagingDirectory); FileSystem.PurgeDirectory(StagingDirectory, FailureOptions.ThrowOnFailure); Environment.SetEnvironmentVariable("TentacleJournal", Path.Combine(StagingDirectory, "DeploymentJournal.xml")); Variables = new VariablesFactory(FileSystem).Create(new CommonOptions("test")); Variables.Set(TentacleVariables.Agent.ApplicationDirectoryPath, StagingDirectory); Variables.Set("PreDeployGreeting", "Bonjour"); }
public virtual void SetUp() { FileSystem = CalamariPhysicalFileSystem.GetPhysicalFileSystem(); // Ensure staging directory exists and is empty StagingDirectory = Path.Combine(Path.GetTempPath(), "CalamariTestStaging"); FileSystem.EnsureDirectoryExists(StagingDirectory); FileSystem.PurgeDirectory(StagingDirectory, FailureOptions.ThrowOnFailure); Environment.SetEnvironmentVariable("TentacleJournal", Path.Combine(StagingDirectory, "DeploymentJournal.xml")); Variables = new VariablesFactory(FileSystem).Create(new CommonOptions("test")); Variables.Set(TentacleVariables.Agent.ApplicationDirectoryPath, StagingDirectory); //Chart Pckage Variables.Set(PackageVariables.PackageId, "mychart"); Variables.Set(PackageVariables.PackageVersion, "0.3.7"); Variables.Set(PackageVariables.IndexedPackageId(""), $"#{{{PackageVariables.PackageId}}}"); Variables.Set(PackageVariables.IndexedPackageVersion(""), $"#{{{PackageVariables.PackageVersion}}}"); //Helm Options Variables.Set(Kubernetes.SpecialVariables.Helm.ReleaseName, ReleaseName); Variables.Set(Kubernetes.SpecialVariables.Helm.ClientVersion, helmVersion.ToString()); //K8S Auth Variables.Set(Kubernetes.SpecialVariables.ClusterUrl, ServerUrl); Variables.Set(Kubernetes.SpecialVariables.SkipTlsVerification, "True"); Variables.Set(Kubernetes.SpecialVariables.Namespace, Namespace); Variables.Set(SpecialVariables.Account.AccountType, "Token"); Variables.Set(SpecialVariables.Account.Token, ClusterToken); if (ExplicitExeVersion != null) { Variables.Set(Kubernetes.SpecialVariables.Helm.CustomHelmExecutable, HelmExePath); } AddPostDeployMessageCheckAndCleanup(); }