示例#1
0
        protected override async Task <bool> PerformActionAsync()
        {
            this.Logger.WriteLine("Name".PadRight(LAYER_NAME_WIDTH) + " " +
                                  "Description".PadRight(LAYER_DESCRIPTION_WIDTH) + " " +
                                  "Compatible Runtimes".PadRight(LAYER_COMPATIBLE_RUNTIMES_WIDTH) + " " +
                                  "Created".PadRight(TIMESTAMP_WIDTH) + " " +
                                  "Latest Version ARN".PadRight(LAYER_ARN_WIDTH)
                                  );
            this.Logger.WriteLine($"{new string('-', LAYER_NAME_WIDTH)} {new string('-', LAYER_DESCRIPTION_WIDTH)} {new string('-', LAYER_COMPATIBLE_RUNTIMES_WIDTH)} {new string('-', TIMESTAMP_WIDTH)} {new string('-', LAYER_ARN_WIDTH)}");

            var request = new ListLayersRequest();
            ListLayersResponse response = null;

            do
            {
                if (response != null)
                {
                    request.Marker = response.NextMarker;
                }

                try
                {
                    response = await this.LambdaClient.ListLayersAsync(request);
                }
                catch (Exception e)
                {
                    throw new LambdaToolsException("Error listing Lambda layers: " + e.Message, LambdaToolsException.LambdaErrorCode.LambdaListLayers, e);
                }

                foreach (var layer in response.Layers)
                {
                    var latestVersion = layer.LatestMatchingVersion;
                    this.Logger.WriteLine(layer.LayerName.PadRight(LAYER_NAME_WIDTH) + " " +
                                          LambdaUtilities.DetermineListDisplayLayerDescription(latestVersion.Description, LAYER_DESCRIPTION_WIDTH).PadRight(LAYER_DESCRIPTION_WIDTH) + " " +
                                          string.Join(", ", latestVersion.CompatibleRuntimes.ToArray()).PadRight(LAYER_COMPATIBLE_RUNTIMES_WIDTH) + " " +
                                          DateTime.Parse(latestVersion.CreatedDate).ToString("g").PadRight(TIMESTAMP_WIDTH) + " " +
                                          latestVersion.LayerVersionArn
                                          );
                }
            } while (!string.IsNullOrEmpty(response.NextMarker));

            return(true);
        }
        public void TestGettingLayerDescriptionForNonDotnetLayer(string fullLayer, string displayLayer, int maxLength)
        {
            var value = LambdaUtilities.DetermineListDisplayLayerDescription(fullLayer, maxLength);

            Assert.Equal(displayLayer, value);
        }