-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Make ECR repository name configurable in container based deploy…
…ments
- Loading branch information
Showing
13 changed files
with
115 additions
and
20 deletions.
There are no files selected for viewing
55 changes: 55 additions & 0 deletions
55
src/AWS.Deploy.CLI/Commands/TypeHints/ECRRepositoryCommand.cs
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,55 @@ | ||
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
using Amazon.ECR.Model; | ||
using AWS.Deploy.Common; | ||
using AWS.Deploy.Common.Recipes; | ||
using AWS.Deploy.Common.TypeHintData; | ||
using AWS.Deploy.Orchestration.Data; | ||
|
||
namespace AWS.Deploy.CLI.Commands.TypeHints | ||
{ | ||
public class ECRRepositoryCommand : ITypeHintCommand | ||
{ | ||
private readonly IAWSResourceQueryer _awsResourceQueryer; | ||
private readonly IConsoleUtilities _consoleUtilities; | ||
|
||
public ECRRepositoryCommand(IAWSResourceQueryer awsResourceQueryer, IConsoleUtilities consoleUtilities) | ||
{ | ||
_awsResourceQueryer = awsResourceQueryer; | ||
_consoleUtilities = consoleUtilities; | ||
} | ||
|
||
public async Task<object> Execute(Recommendation recommendation, OptionSettingItem optionSetting) | ||
{ | ||
var repositories = await GetData(); | ||
var currentRepositoryName = recommendation.GetOptionSettingValue<string>(optionSetting); | ||
|
||
var userInputConfiguration = new UserInputConfiguration<Repository>( | ||
rep => rep.RepositoryName, | ||
rep => rep.RepositoryName.Equals(currentRepositoryName), | ||
currentRepositoryName) | ||
{ | ||
AskNewName = true, | ||
}; | ||
|
||
var userResponse = _consoleUtilities.AskUserToChooseOrCreateNew(repositories, "Select ECR Repository:", userInputConfiguration); | ||
|
||
return userResponse.SelectedOption?.RepositoryName ?? userResponse.NewName | ||
?? throw new UserPromptForNameReturnedNullException(DeployToolErrorCode.ECRRepositoryPromptForNameReturnedNull, "The user response for an ECR Repository was null"); | ||
} | ||
public async Task<List<TypeHintResource>?> GetResources(Recommendation recommendation, OptionSettingItem optionSetting) | ||
{ | ||
var repositories = await GetData(); | ||
return repositories.Select(x => new TypeHintResource(x.RepositoryName, x.RepositoryName)).ToList(); | ||
} | ||
|
||
private async Task<List<Repository>> GetData() | ||
{ | ||
return await _awsResourceQueryer.GetECRRepositories(); | ||
} | ||
} | ||
} |
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
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