Пример #1
0
        public void Add(string key, Input <V> value)
        {
            var inputDictionary = (Input <ImmutableDictionary <string, V> >)_outputValue;

            _outputValue = Output.Tuple(inputDictionary, value)
                           .Apply(x => x.Item1.Add(key, x.Item2));
        }
Пример #2
0
        public void AddRange(InputMap <V> values)
        {
            var inputDictionary = (Input <ImmutableDictionary <string, V> >)_outputValue;

            _outputValue = Output.Tuple(inputDictionary, values)
                           .Apply(x => x.Item1.AddRange(x.Item2));
        }
Пример #3
0
        /// <summary>
        /// Fetches the value of the named stack output, or null if the stack output was not found.
        /// </summary>
        /// <param name="name">The name of the stack output to fetch.</param>
        /// <returns>An <see cref="Output{T}"/> containing the requested value.</returns>
        public Output <object?> GetOutput(Input <string> name)
        {
            // Note that this is subltly different from "Apply" here. A default "Apply" will set the secret bit if any
            // of the inputs are a secret, and this.Outputs is always a secret if it contains any secrets. We do this dance
            // so we can ensure that the Output we return is not needlessly tainted as a secret.
            var inputs = (Input <ImmutableDictionary <string, object> >) this.Outputs;
            var value  = Output.Tuple(name, inputs).Apply(v =>
                                                          v.Item2.TryGetValue(v.Item1, out var result) ? result : null);

            return(value.WithIsSecret(IsSecretOutputName(name)));
        }
Пример #4
0
        /// <summary>
        /// Fetches the value of the named stack output, or throws an error if the output was not found.
        /// </summary>
        /// <param name="name">The name of the stack output to fetch.</param>
        /// <returns>An <see cref="Output{T}"/> containing the requested value.</returns>
        public Output <object> RequireOutput(Input <string> name)
        {
            var inputs = (Input <ImmutableDictionary <string, object> >) this.Outputs;
            var value  = Output.Tuple(name, inputs).Apply(v =>
                                                          v.Item2.TryGetValue(v.Item1, out var result)
                    ? result
                    : throw new KeyNotFoundException(
                                                              $"Required output '{name}' does not exist on stack '{Deployment.Instance.StackName}'."));

            return(value.WithIsSecret(IsSecretOutputName(name)));
        }
Пример #5
0
        /// <summary>
        /// Convert an output containing an array to an output containing the array element
        /// at the specified index.
        /// </summary>
        /// <typeparam name="T">The type of elements in the array.</typeparam>
        /// <param name="array">An array wrapped into <see cref="Output{T}"/>.</param>
        /// <param name="index">An index to get an element at.</param>
        /// <returns>An <see cref="Output{T}"/> containing an array element.</returns>
        public static Output <T> GetAt <T>(this Output <ImmutableArray <T> > array, Input <int> index)
        {
            var inputArray = (Input <ImmutableArray <T> >)array;

            return(Output.Tuple(inputArray, index).Apply(v => v.Item1[v.Item2]));
        }