/// <summary>
        /// Get the value of the HCL list or map
        /// </summary>
        /// <param name="propertyType">The property type (map, list, string)</param>
        /// <param name="property">The string representation of the property entered by the user</param>
        /// <returns>The raw JSON property</returns>
        static string GetHclVariableValue(string?propertyType, JProperty property)
        {
            if (propertyType != null && propertyType.StartsWith(TerraformDataTypes.RawPrefix))
            {
                return(HclParser.EscapeString(property.Name) + " = " + property.Value);
            }

            return(HclParser.EscapeString(property.Name) + " = \"" + HclParser.EscapeString(property.Value.ToString()) + "\"");
        }
Esempio n. 2
0
        static IList <HclElement> GetVariables(string template)
        {
            if (template == null)
            {
                return(new List <HclElement>());
            }

            return(HclParser.HclTemplate.Parse(HclParser.NormalizeLineEndings(template))
                   .Children
                   .Where(child => child.Name == "variable")
                   .ToList());
        }
Esempio n. 3
0
 public static bool IsHcl(string template)
 {
     return(!string.IsNullOrWhiteSpace(template) && HclParser.HclTemplate.TryParse(HclParser.NormalizeLineEndings(template)).WasSuccessful);
 }
Esempio n. 4
0
        protected string LoadFile(string fileName, string directory = "Cases")
        {
            var templatesPath = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) ?? string.Empty, directory);

            return(HclParser.NormalizeLineEndings(File.ReadAllText(Path.Combine(templatesPath, fileName))).Trim());
        }