private static RemoteTemplatesSourceConfig GetConfigFromCdn(EnvEnum env) { Fs.SafeDeleteFile(Path.Combine(Path.GetTempPath(), "config.json")); string configFile = RemoteSource.DownloadCdnElement(Environments.CdnUrls[env], "config.json", Path.GetTempPath()); RemoteTemplatesSourceConfig config = RemoteTemplatesSourceConfig.LoadFromFile(configFile); return(config); }
public static void DownloadConfig(RemoteSourceDownloadOptions options, TextWriter output, TextWriter error) { try { output.WriteCommandHeader($"Downloading template source config file from environment {options.Env.ToString()} ({options.StorageAccount})"); output.WriteLine(); var result = RemoteSource.DownloadCdnElement(Environments.CdnUrls[options.Env], "config.json", options.Destination); output.WriteCommandText($"Successfully downloaded '{result}'"); output.WriteLine(); } catch (Exception ex) { error.WriteException(ex, $"Unable to download the config file from the specified environment."); } }
public static void DownloadContent(RemoteSourceDownloadOptions options, TextWriter output, TextWriter error) { try { output.WriteCommandHeader($"Downloading templates content from environment {options.Env.ToString()} ({options.StorageAccount})"); RemoteTemplatesSourceConfig config = GetConfigFromCdn(options.Env); RemoteTemplatesPackage package = null; if (options.Version != null) { package = ResolvePackageForVersion(config, options.Version, output); } else { package = config.Latest; } if (package != null) { Fs.EnsureFolder(options.Destination); var result = RemoteSource.DownloadCdnElement(Environments.CdnUrls[options.Env], package.Name, options.Destination); output.WriteLine(); output.WriteCommandText($"Successfully downloaded '{result}'"); output.WriteLine(); } else { output.WriteLine(); output.WriteCommandText($"Package not found for the version '{options.Version}'"); output.WriteLine(); } } catch (Exception ex) { error.WriteException(ex, $"Unable to download the file content from the specified environment."); } }