Split S3KeySecret into S3Key and S3Secret
This commit is contained in:
parent
25450aecee
commit
3a10e4cb20
|
@ -1,5 +1,3 @@
|
|||
using CliWrap;
|
||||
using CliWrap.Buffered;
|
||||
using InnovEnergy.App.Backend.Database;
|
||||
using InnovEnergy.App.Backend.S3;
|
||||
using InnovEnergy.Lib.Utils;
|
||||
|
@ -19,7 +17,11 @@ public static class InstallationMethods
|
|||
public static async Task<Boolean> RenewS3BucketUrl(this Installation installation)
|
||||
{
|
||||
installation.RevokeKey();
|
||||
installation.S3KeySecret = await installation.CreateKey();
|
||||
var (key, secret) = await installation.CreateKey();
|
||||
|
||||
installation.S3Key = key;
|
||||
installation.S3Secret = secret;
|
||||
|
||||
return Db.Update(installation);
|
||||
}
|
||||
|
||||
|
@ -125,40 +127,3 @@ public static class InstallationMethods
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
public static class ExoCmd
|
||||
{
|
||||
private static readonly Command Exo = Cli.Wrap("exo");
|
||||
private static String ConfigFile = "./exoscale.toml";
|
||||
|
||||
public static async Task<String> CreateKey(this Installation installation)
|
||||
{
|
||||
if (installation.Id != 1) return "help"; //Todo remove me I am for debugging
|
||||
var preParse = await Exo
|
||||
.WithArguments("iam access-key create " + installation.BucketName()
|
||||
+ " --operation get-sos-object"
|
||||
+ " --resource sos/bucket:" + installation.BucketName()
|
||||
+ " -C " + ConfigFile
|
||||
+ " -O text")
|
||||
.ExecuteBufferedAsync();
|
||||
|
||||
return $"{preParse.StandardOutput.Split("\t")[2]};{preParse.StandardOutput.Split("\t")[3]}";
|
||||
}
|
||||
|
||||
public static async void RevokeKey(this Installation installation)
|
||||
{
|
||||
try
|
||||
{
|
||||
await Exo
|
||||
.WithArguments("iam access-key revoke " + installation.S3KeySecret.Split(";", 2)[0] + " -f " + " -C " + ConfigFile)
|
||||
.ExecuteAsync();
|
||||
|
||||
}
|
||||
catch
|
||||
{
|
||||
// todo Fill me there is no key for this installation
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue