public override ComparisonResult Compare(PersistedConfiguration other) { var diffs = new List <Difference>(); var config = (ChocolateyPackageConfiguration)other; if (this.Template.Exists != config.Exists) { diffs.Add(new Difference(nameof(ChocolateyPackageConfiguration.Exists), this.Template.Exists, config.Exists)); } if (this.Template.Exists && config.Exists) { if (string.IsNullOrEmpty(this.Template.Version) && !config.IsLatestVersion) { diffs.Add(new Difference(nameof(ChocolateyPackageConfiguration.IsLatestVersion), true, false)); } if (!string.IsNullOrEmpty(this.Template.Version) && !string.Equals(this.Template.Version, config.Version, StringComparison.OrdinalIgnoreCase)) { diffs.Add(new Difference(nameof(ChocolateyPackageConfiguration.Version), this.Template.Version, config.Version)); } } return(new ComparisonResult(diffs)); }
public override ComparisonResult Compare(PersistedConfiguration other) { var actual = (ChocolateyInstalledConfiguration)other; if (string.IsNullOrEmpty(this.Template.Version)) { if (actual.Version == "not-installed") { return(new ComparisonResult(new[] { new Difference(nameof(this.Template.Version), "any", "not-installed") })); } } else if (string.Equals(this.Template.Version, "latest", StringComparison.OrdinalIgnoreCase)) { if (actual.Version != actual.LatestVersion) { return(new ComparisonResult(new[] { new Difference(nameof(this.Template.Version), actual.LatestVersion, actual.Version) })); } } else if (this.Template.Version != actual.Version) { return(new ComparisonResult(new[] { new Difference(nameof(this.Template.Version), this.Template.Version, actual.Version) })); } return(ComparisonResult.Identical); }
public override ComparisonResult Compare(PersistedConfiguration other) { if (!(other is RegistryValueConfiguration reg)) { throw new InvalidOperationException("Cannot compare configurations of different types"); } var differences = new List <Difference>(); if (!this.Exists || !reg.Exists) { if (this.Exists || reg.Exists) { differences.Add(new Difference(nameof(Exists), this.Exists, reg.Exists)); } return(new ComparisonResult(differences)); } if (this.ValueKind != reg.ValueKind) { differences.Add(new Difference(nameof(ValueKind), this.ValueKind, reg.ValueKind)); } if (!this.Value.SequenceEqual(reg.Value)) { differences.Add(new Difference(nameof(Value), string.Join("\n", this.Value), string.Join("\n", reg.Value))); } return(new ComparisonResult(differences)); }
public override Task <ComparisonResult> CompareAsync(PersistedConfiguration other, IOperationCollectionContext context) { var config = (KubernetesResourceConfiguration)other; if (this.Template.Exists != config.Exists) { return(Task.FromResult(new ComparisonResult(new[] { new Difference(nameof(config.Exists), this.Template.Exists, config.Exists) }))); } if (!this.Template.Exists) { return(Task.FromResult(ComparisonResult.Identical)); } var actual = JObject.Parse(config.NormalizedActual); var template = JObject.Parse(config.NormalizedApplied); // Kubernetes has a bad habit of not telling us when immutable properties differ // during the dry run. Figure it out ourselves. var fresh = JObject.Parse(config.NormalizedTemplate); template.Merge(fresh, new JsonMergeSettings { MergeArrayHandling = MergeArrayHandling.Merge }); // Make sure we don't have any arrays in the template that have extra elements. FixArrayMergeLength(template, fresh); // We only care about metadata and spec - the other fields are either part of // the configuration key or stats that can change during collection. return(Task.FromResult(new ComparisonResult( GetJsonDifferences("metadata", template.Property("metadata").Value, actual.Property("metadata").Value) .Concat(GetJsonDifferences("spec", template.Property("spec").Value, actual.Property("spec").Value)) ))); }
public override Task <ComparisonResult> CompareAsync(PersistedConfiguration other, IOperationCollectionContext context) { var diffs = this.comparisonResults.Where(d => d != null); if (diffs.Any()) { return(Task.FromResult(new ComparisonResult(diffs))); } else { return(Task.FromResult(ComparisonResult.Identical)); } }
public override ComparisonResult Compare(PersistedConfiguration other) { if (other == null) { throw new ArgumentNullException(nameof(other)); } if (!(other is GitHubReleaseConfiguration)) { throw new InvalidOperationException("Cannot compare configurations of different types."); } return(Compare((GitHubReleaseConfiguration)other)); }
public override ComparisonResult Compare(PersistedConfiguration other) { var config = (ProGetPackageConfiguration)other; if (config?.Current != true) { return(new ComparisonResult(new[] { new Difference("Current", true, false) })); } else { return(new ComparisonResult(Enumerable.Empty <Difference>())); } }
public override Task <ComparisonResult> CompareAsync(PersistedConfiguration other, IOperationCollectionContext context) { if (other == null) { throw new ArgumentNullException(nameof(other)); } if (!(other is GitHubMilestoneConfiguration c)) { throw new InvalidOperationException("Cannot compare configurations of different types."); } return(Task.FromResult(this.Compare(c))); }
public CachePluginAdmin() { SerializedValues = new PersistedConfiguration(); SerializedValues.diskQuota = -1; SerializedValues.archiveQuotaPerStream = -1; SerializedValues.reverseProxyRedirectURL = ""; SerializedValues.backendServer = ""; SerializedValues.enableCaching = false; SerializedValues.enableProxy = false; SerializedValues.proxyOnDemandCacheMiss = false; SerializedValues.cacheOnDemandCacheMiss = false; SerializedValues.handleUpstreamCacheRequests = false; SerializedValues.protocol = protocolEnum.clientprotocol; RegisteredChangeHandler = null; }
public bool LoadSettingsFromXmlFile(string strPath) { FileStream fs = null; bool bSucceeded = false; try { // A FileStream is needed to read the XML document. fs = new FileStream(strPath, FileMode.Open); } catch (Exception e) { Console.WriteLine("Exception: {0}\n{1}", e.Message, e.StackTrace); return(false); } XmlTextReader reader = new XmlTextReader(fs); // Create an instance of the XmlSerializer specifying type and namespace. XmlSerializer serializer = new XmlSerializer(typeof(PersistedConfiguration)); PersistedConfiguration tmpSettings = null; try { tmpSettings = (PersistedConfiguration)serializer.Deserialize(reader); } catch (Exception e) { Console.WriteLine("Exception: {0}\n{1}", e.Message, e.StackTrace); } if (null != tmpSettings) { SerializedValues = null; SerializedValues = tmpSettings; tmpSettings = null; bSucceeded = true; } serializer = null; reader.Close(); reader = null; strPathToConfigDoc = strPath; return(bSucceeded); }
public override ComparisonResult Compare(PersistedConfiguration other) { var result = base.Compare(other); var differences = result.Differences.Where(d => d.Name != nameof(this.Bindings)).ToList(); if (this.Bindings == null && this.BindingInformation != null) { this.Bindings = new[] { BindingInfo.FromBindingInformation(this.BindingInformation, this.BindingProtocol).ToDictionary() } } ; if (this.Bindings == null) { return(new ComparisonResult(differences)); } var otherBindings = ((IisSiteConfiguration)other).Bindings; if (otherBindings == null && ((IisSiteConfiguration)other).BindingInformation != null) { otherBindings = new[] { BindingInfo.FromBindingInformation(((IisSiteConfiguration)other).BindingInformation, ((IisSiteConfiguration)other).BindingProtocol).ToDictionary() } } ; if (otherBindings == null) { otherBindings = Enumerable.Empty <IReadOnlyDictionary <string, RuntimeValue> >(); } var template = this.Bindings.Select(b => BindingInfo.FromMap(b)).ToHashSet(); var actual = otherBindings.Select(b => BindingInfo.FromMap(b)).ToHashSet(); if (template.SetEquals(actual)) { return(new ComparisonResult(differences)); } var diff = new Difference(nameof(this.Bindings), string.Join("; ", template), string.Join("; ", actual)); differences.Add(diff); return(new ComparisonResult(differences)); }
public void LoadSettingsFromServerNamespace() { if (null == g_NamedValues) { return; } if (null == SerializedValues) { SerializedValues = new PersistedConfiguration(); FetchNameValFromServerNamespace("ArchiveQuotaPerStream", SerializedValues.archiveQuotaPerStream); FetchNameValFromServerNamespace("BackendServer", SerializedValues.backendServer); FetchNameValFromServerNamespace("CacheDirectoryPath", SerializedValues.cacheDirectoryPath); FetchNameValFromServerNamespace("CacheOnDemandCacheMiss", SerializedValues.cacheOnDemandCacheMiss); FetchNameValFromServerNamespace("DiskQuota", SerializedValues.diskQuota); FetchNameValFromServerNamespace("EnableCaching", SerializedValues.enableCaching); FetchNameValFromServerNamespace("EnableProxy", SerializedValues.enableProxy); FetchNameValFromServerNamespace("HandleUpstreamCacheRequests", SerializedValues.handleUpstreamCacheRequests); FetchNameValFromServerNamespace("PreferredProtocol", SerializedValues.protocol); FetchNameValFromServerNamespace("ProxyOnDemandCacheMiss", SerializedValues.proxyOnDemandCacheMiss); FetchNameValFromServerNamespace("ReverseProxyRedirectURL", SerializedValues.reverseProxyRedirectURL); } }
public override ComparisonResult Compare(PersistedConfiguration other) { var actual = (ChocolateySourceConfiguration)other; if (this.Template.Exists != actual.Exists) { return(new ComparisonResult(new[] { new Difference(nameof(this.Template.Exists), this.Template.Exists, actual.Exists) })); } if (!this.Template.Exists) { return(ComparisonResult.Identical); } var differences = new List <Difference>(); if (this.Template.Url != actual.Url) { differences.Add(new Difference(nameof(this.Template.Url), this.Template.Url, actual.Url)); } if (this.Template.UserName != actual.UserName) { differences.Add(new Difference(nameof(this.Template.UserName), this.Template.UserName, actual.UserName)); } // Can't check password if (this.Template.Priority != actual.Priority) { differences.Add(new Difference(nameof(this.Template.Priority), this.Template.Priority, actual.Priority)); } if (actual.Disabled) { differences.Add(new Difference(nameof(this.Template.Disabled), false, true)); } return(new ComparisonResult(differences)); }
public override Task StoreConfigurationStatusAsync(PersistedConfiguration actual, ComparisonResult results, ConfigurationPersistenceContext context) => this.collectedConfiguration.StoreConfigurationStatusAsync(context);
SerializedValues.cacheOnDemandCacheMiss = value; RegisterChange( "CacheOnDemandCacheMiss", value ); } } } public int ArchiveQuotaPerStream { [DispIdAttribute( 6 )] get { return( SerializedValues.archiveQuotaPerStream ); } [DispIdAttribute( 6 )] set { if( value != SerializedValues.archiveQuotaPerStream ) { SerializedValues.archiveQuotaPerStream = value; RegisterChange( "ArchiveQuotaPerStream", value ); } } } public string ProxyRedirectURL { [DispIdAttribute( 7 )] get { return( SerializedValues.reverseProxyRedirectURL ); } [DispIdAttribute( 7 )] set { if( value != SerializedValues.reverseProxyRedirectURL ) { SerializedValues.reverseProxyRedirectURL = value; RegisterChange( "ProxyRedirectURL", value ); } } } public string BackendServer { [DispIdAttribute( 8 )] get { return( SerializedValues.backendServer ); } [DispIdAttribute( 8 )] set { if( value != SerializedValues.backendServer )
break; default: Console.WriteLine( "*** BAD VALUE DETECTED: {0}", value ); enumProtocol = protocolEnum.clientprotocol; break; } if( enumProtocol != SerializedValues.protocol ) { SerializedValues.protocol = enumProtocol; RegisterChange( "PreferredProtocol", value ); } } } public bool CacheOnDemandCacheMiss { [DispIdAttribute( 5 )] get { return( SerializedValues.cacheOnDemandCacheMiss ); } [DispIdAttribute( 5 )] set { if( value != SerializedValues.cacheOnDemandCacheMiss )
FetchNameValFromServerNamespace( "EnableProxy", SerializedValues.enableProxy ); FetchNameValFromServerNamespace( "HandleUpstreamCacheRequests", SerializedValues.handleUpstreamCacheRequests ); FetchNameValFromServerNamespace( "PreferredProtocol", SerializedValues.protocol ); FetchNameValFromServerNamespace( "ProxyOnDemandCacheMiss", SerializedValues.proxyOnDemandCacheMiss ); FetchNameValFromServerNamespace( "ReverseProxyRedirectURL", SerializedValues.reverseProxyRedirectURL ); } } public bool LoadSettingsFromXmlFile( string strPath ) { FileStream fs = null; bool bSucceeded = false; try { // A FileStream is needed to read the XML document.