Inheritance: NamedModelComponentBase
Exemplo n.º 1
0
 public static object Resolve(SecretStore secrets, Service service, Resource resource)
 {
     Func<ResourceResolutionContext, object> resolver;
     if (!Resolvers.TryGetValue(resource.Type, out resolver))
     {
         return String.Empty;
     }
     return resolver(new ResourceResolutionContext(secrets, service, resource)) ?? String.Empty;
 }
 public override string ReadConfigTemplate(Service service)
 {
     // Generate file name
     string fileName = Path.Combine(
         RootDirectory,
         service.FullName + ".cscfg.template");
     if (File.Exists(fileName))
     {
         return File.ReadAllText(fileName);
     }
     else
     {
         return null;
     }
 }
Exemplo n.º 3
0
 public ConfigTemplateModel(SecretStore secrets, Service service)
 {
     Resources = new ConfigObject(
         service
             .Datacenter
             .Resources
             .GroupBy(r => r.Type)
             .ToDictionary(g => g.Key, g => (object)g.ToDictionary(r => r.Name, r => ResolveValue(secrets, service, r))));
     Service = service;
     Services = new ConfigObject(
         service
             .Datacenter
             .Services
             .ToDictionary(s => s.Name, s => (object)new ServiceModel(s, secrets)));
 }
        protected async Task<IDictionary<string, string>> LoadServiceConfig(Datacenter dc, Service service)
        {
            await Console.WriteInfoLine(Strings.AzureCommandBase_FetchingServiceConfig, service.Value);

            // Get creds
            var creds = await GetAzureCredentials();
            var ns = XNamespace.Get("http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceConfiguration");

            // Connect to the Compute Management Client
            using (var client = CloudContext.Clients.CreateComputeManagementClient(creds))
            {
                // Download config for the deployment
                var result = await client.Deployments.GetBySlotAsync(service.Value, DeploymentSlot.Production);

                var parsed = XDocument.Parse(result.Configuration);
                return parsed.Descendants(ns + "Setting").ToDictionary(
                    x => x.Attribute("name").Value,
                    x => x.Attribute("value").Value,
                    StringComparer.OrdinalIgnoreCase);
            }
        }
Exemplo n.º 5
0
 public ServiceModel(Service service, SecretStore secrets)
 {
     _service = service;
     _secrets = secrets;
     _attributes = new ConfigObject(service.Attributes.ToDictionary(p => p.Key, p => (object)p.Value));
 }
Exemplo n.º 6
0
 public ResourceResolutionContext(SecretStore secrets, Service service, Resource resource)
 {
     Secrets = secrets;
     Service = service;
     Resource = resource;
 }
Exemplo n.º 7
0
 private object ResolveValue(SecretStore secrets, Service service, Resource r)
 {
     // Simpler to just to sync here.
     return ResourceResolver.Resolve(secrets, service, r);
 }
 public abstract string ReadConfigTemplate(Service service);