-
Notifications
You must be signed in to change notification settings - Fork 90
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
1 parent
3779b0a
commit dc2cccc
Showing
26 changed files
with
1,048 additions
and
193 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{ | ||
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#", | ||
"contentVersion": "1.0.0.0", | ||
"parameters": {}, | ||
"functions": [], | ||
"variables": {}, | ||
"resources": [], | ||
"outputs": { | ||
"subscription": { | ||
"type": "object", | ||
"value": "[subscription()]" | ||
}, | ||
"resourceGroup": { | ||
"type": "object", | ||
"value": "[resourceGroup()]" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT License. | ||
|
||
using System.Collections.Generic; | ||
using System.Diagnostics; | ||
|
||
namespace PSRule.Rules.Azure | ||
{ | ||
internal static class DictionaryExtensions | ||
{ | ||
[DebuggerStepThrough] | ||
public static bool TryPopValue(this IDictionary<string, object> dictionary, string key, out object value) | ||
{ | ||
return dictionary.TryGetValue(key, out value) && dictionary.Remove(key); | ||
} | ||
|
||
[DebuggerStepThrough] | ||
public static bool TryPopValue<T>(this IDictionary<string, object> dictionary, string key, out T value) | ||
{ | ||
value = default; | ||
if (dictionary.TryGetValue(key, out object v) && dictionary.Remove(key) && v is T result) | ||
{ | ||
value = result; | ||
return true; | ||
} | ||
return false; | ||
} | ||
|
||
[DebuggerStepThrough] | ||
public static bool TryPopBool(this IDictionary<string, object> dictionary, string key, out bool value) | ||
{ | ||
value = default; | ||
return dictionary.TryGetValue(key, out object v) && dictionary.Remove(key) && bool.TryParse(v.ToString(), out value); | ||
} | ||
|
||
public static bool TryGetBool(this IDictionary<string, object> dictionary, string key, out bool? value) | ||
{ | ||
value = null; | ||
if (!dictionary.TryGetValue(key, out object o)) | ||
return false; | ||
|
||
if (o is bool bvalue || (o is string svalue && bool.TryParse(svalue, out bvalue))) | ||
{ | ||
value = bvalue; | ||
return true; | ||
} | ||
return false; | ||
} | ||
|
||
[DebuggerStepThrough] | ||
public static void AddUnique(this IDictionary<string, object> dictionary, IEnumerable<KeyValuePair<string, object>> values) | ||
{ | ||
foreach (var kv in values) | ||
if (!dictionary.ContainsKey(kv.Key)) | ||
dictionary.Add(kv.Key, kv.Value); | ||
} | ||
} | ||
} |
Oops, something went wrong.