Skip to content
This repository has been archived by the owner on Jul 5, 2024. It is now read-only.

Commit

Permalink
Merge remote-tracking branch 'smokeballdb/add-aws-sso' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
caesay committed Dec 26, 2023
2 parents 6e28389 + 2fdb4f2 commit 4a695bd
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 6 deletions.
12 changes: 8 additions & 4 deletions src/Squirrel.Csq/Commands/S3BaseCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ public class S3BaseCommand : BaseCommand

public string Secret { get; private set; }

public string Session { get; private set; }

public string Region { get; private set; }

public string Endpoint { get; private set; }
Expand All @@ -20,18 +22,20 @@ protected S3BaseCommand(string name, string description)
{
AddOption<string>((v) => KeyId = v, "--keyId")
.SetDescription("Authentication identifier or access key.")
.SetArgumentHelpName("KEYID")
.SetRequired();
.SetArgumentHelpName("KEYID");

AddOption<string>((v) => Secret = v, "--secret")
.SetDescription("Authentication secret key.")
.SetArgumentHelpName("KEY")
.SetRequired();
.SetArgumentHelpName("KEY");

var region = AddOption<string>((v) => Region = v, "--region")
.SetDescription("AWS service region (eg. us-west-1).")
.SetArgumentHelpName("REGION");

AddOption<string>((v) => Session = v, "--session")
.SetDescription("Authentication session token.")
.SetArgumentHelpName("SESSION");

region.Validators.Add(MustBeValidAwsRegion);

var endpoint = AddOption<Uri>((v) => Endpoint = v.ToAbsoluteOrNull(), "--endpoint")
Expand Down
1 change: 1 addition & 0 deletions src/Squirrel.Csq/Compat/EmbeddedRunner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ public Task ExecuteS3Download(S3DownloadCommand command)
PathPrefix = command.PathPrefix,
Region = command.Region,
ReleaseDir = command.GetReleaseDirectory(),
Session = command.Session,
Secret = command.Secret,
};
return new S3Repository(_logger).DownloadRecentPackages(options);
Expand Down
10 changes: 8 additions & 2 deletions src/Squirrel.Deployment/S3Repository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,13 @@ namespace Squirrel.Deployment;
public class S3Options
{
public DirectoryInfo ReleaseDir { get; set; }

public string KeyId { get; set; }

public string Secret { get; set; }

public string Session { get; set; }

public string Region { get; set; }

public string Endpoint { get; set; }
Expand Down Expand Up @@ -44,10 +47,13 @@ private static AmazonS3Client GetS3Client(S3Options options)
{
if (options.Region != null) {
var r = RegionEndpoint.GetBySystemName(options.Region);
return new AmazonS3Client(options.KeyId, options.Secret, r);
if (string.IsNullOrWhiteSpace(options.KeyId)) {
return new AmazonS3Client(r);
}
return new AmazonS3Client(options.KeyId, options.Secret, options.Session, r);
} else if (options.Endpoint != null) {
var config = new AmazonS3Config() { ServiceURL = options.Endpoint };
return new AmazonS3Client(options.KeyId, options.Secret, config);
return new AmazonS3Client(options.KeyId, options.Secret, options.Session, config);
} else {
throw new InvalidOperationException("Missing endpoint");
}
Expand Down

0 comments on commit 4a695bd

Please sign in to comment.