1515
1616import com .amazonaws .auth .DefaultAWSCredentialsProviderChain ;
1717import com .amazonaws .auth .profile .ProfileCredentialsProvider ;
18- import com .amazonaws .regions .Regions ;
18+ import com .amazonaws .regions .Region ;
19+ import com .amazonaws .regions .RegionUtils ;
1920import com .amazonaws .services .codeartifact .AWSCodeArtifactClientBuilder ;
2021import com .amazonaws .services .codeartifact .model .GetAuthorizationTokenRequest ;
2122import com .amazonaws .util .AwsHostNameUtils ;
22- import com .redhat .hacbs .container .deploy .git .Git ;
2323import com .redhat .hacbs .container .deploy .mavenrepository .CodeArtifactRepository ;
2424import com .redhat .hacbs .container .deploy .mavenrepository .MavenRepositoryDeployer ;
2525
@@ -48,36 +48,6 @@ public class TagDeployCommand implements Runnable {
4848 @ CommandLine .Option (names = "--mvn-repo" )
4949 String mvnRepo ;
5050
51- @ ConfigProperty (name = "git.deploy.token" )
52- Optional <String > gitToken ;
53-
54- // If endpoint is null then default GitHub API endpoint is used. Otherwise:
55- // for GitHub, endpoint like https://api.github.com
56- // for GitLib, endpoint like https://gitlab.com
57- @ CommandLine .Option (names = "--git-url" )
58- String gitURL ;
59-
60- @ CommandLine .Option (names = "--git-identity" )
61- String gitIdentity ;
62-
63- @ CommandLine .Option (names = "--git-disable-ssl-verification" )
64- boolean gitDisableSSLVerification ;
65-
66- @ CommandLine .Option (names = "--git-reuse-repository" )
67- boolean reuseRepository ;
68-
69- @ CommandLine .Option (names = "--image-id" )
70- String imageId ;
71-
72- @ CommandLine .Option (required = true , names = "--scm-uri" )
73- String scmUri ;
74-
75- @ CommandLine .Option (required = true , names = "--scm-commit" )
76- String commit ;
77-
78- @ CommandLine .Option (required = true , names = "--source-path" )
79- Path sourcePath ;
80-
8151 @ Inject
8252 BootstrapMavenContext mvnCtx ;
8353
@@ -86,21 +56,6 @@ public void run() {
8656
8757 var deploymentPath = Path .of (artifactDirectory );
8858
89- // TODO: Should we write out to a 'DependencyPipelineResults' a GitArchive?
90- Git .GitStatus archivedSourceTags = new Git .GitStatus ();
91- // Save the source first regardless of deployment checks
92- if (isNotEmpty (gitIdentity ) && gitToken .isPresent ()) {
93- var git = Git .builder (gitURL , gitIdentity , gitToken .get (), gitDisableSSLVerification );
94- if (reuseRepository ) {
95- git .initialise (scmUri );
96- } else {
97- Log .warnf ("Not reusing repository; creating under %s" , scmUri );
98- git .create (scmUri );
99- }
100- Log .infof ("Pushing changes back to URL %s" , git .getName ());
101- archivedSourceTags = git .add (sourcePath , commit , imageId );
102- }
103-
10459 if (!deploymentPath .toFile ().exists ()) {
10560 Log .warnf ("No deployed artifacts found. Has the build been correctly configured to deploy?" );
10661 throw new RuntimeException ("Deploy failed" );
@@ -127,11 +82,11 @@ public void run() {
12782 String domainOwner = repo .substring (firstDash + 1 , repo .indexOf ("." ));
12883 Log .infof ("Generating AWS token for domain %s, owner %s, region %s" , domain , domainOwner , parsedRegion );
12984
130- Regions region = Regions . fromName (parsedRegion );
85+ Region region = RegionUtils . getRegion (parsedRegion );
13186 var awsClient = AWSCodeArtifactClientBuilder .standard ()
13287 .withCredentials (awsProfile .isEmpty () ? DefaultAWSCredentialsProviderChain .getInstance ()
13388 : new ProfileCredentialsProvider (awsProfile .get ()))
134- .withRegion (region ).build ();
89+ .withRegion (region . getName () ).build ();
13590 mvnPassword = Optional .of (awsClient .getAuthorizationToken (
13691 new GetAuthorizationTokenRequest ().withDomain (domain ).withDomainOwner (domainOwner ))
13792 .getAuthorizationToken ());
0 commit comments