mirror of
https://git.selfprivacy.org/kherel/selfprivacy.org.app.git
synced 2025-01-11 18:39:45 +00:00
refactor(server-api): Move provider name from hardcode string to a polymorphic variable
- Rename 'digital-ocean' to 'digitalocean'
This commit is contained in:
parent
0dc0ba215a
commit
57d82d0f7a
|
@ -46,7 +46,10 @@ class DigitalOceanApi extends ServerProviderApi with VolumeProviderApi {
|
|||
}
|
||||
|
||||
@override
|
||||
String rootAddress = 'https://api.digitalocean.com/v2';
|
||||
final String rootAddress = 'https://api.digitalocean.com/v2';
|
||||
|
||||
@override
|
||||
final String infectProviderName = 'digitalocean';
|
||||
|
||||
@override
|
||||
Future<bool> isApiTokenValid(final String token) async {
|
||||
|
@ -311,7 +314,7 @@ class DigitalOceanApi extends ServerProviderApi with VolumeProviderApi {
|
|||
final String formattedHostname = getHostnameFromDomain(domainName);
|
||||
|
||||
final String userdataString =
|
||||
"#cloud-config\nruncmd:\n- curl https://git.selfprivacy.org/SelfPrivacy/selfprivacy-nixos-infect/raw/branch/master/nixos-infect | PROVIDER=digital-ocean NIX_CHANNEL=nixos-21.05 DOMAIN='$domainName' LUSER='${rootUser.login}' ENCODED_PASSWORD='$base64Password' CF_TOKEN=$dnsApiToken DB_PASSWORD=$dbPassword API_TOKEN=$apiToken HOSTNAME=$formattedHostname bash 2>&1 | tee /tmp/infect.log";
|
||||
"#cloud-config\nruncmd:\n- curl https://git.selfprivacy.org/SelfPrivacy/selfprivacy-nixos-infect/raw/branch/master/nixos-infect | PROVIDER=$infectProviderName NIX_CHANNEL=nixos-21.05 DOMAIN='$domainName' LUSER='${rootUser.login}' ENCODED_PASSWORD='$base64Password' CF_TOKEN=$dnsApiToken DB_PASSWORD=$dbPassword API_TOKEN=$apiToken HOSTNAME=$formattedHostname bash 2>&1 | tee /tmp/infect.log";
|
||||
print(userdataString);
|
||||
|
||||
final Dio client = await getClient();
|
||||
|
|
|
@ -46,7 +46,10 @@ class HetznerApi extends ServerProviderApi with VolumeProviderApi {
|
|||
}
|
||||
|
||||
@override
|
||||
String rootAddress = 'https://api.hetzner.cloud/v1';
|
||||
final String rootAddress = 'https://api.hetzner.cloud/v1';
|
||||
|
||||
@override
|
||||
final String infectProviderName = 'hetzner';
|
||||
|
||||
@override
|
||||
Future<bool> isApiTokenValid(final String token) async {
|
||||
|
@ -344,7 +347,7 @@ class HetznerApi extends ServerProviderApi with VolumeProviderApi {
|
|||
base64.encode(utf8.encode(rootUser.password ?? 'PASS'));
|
||||
|
||||
final String userdataString =
|
||||
"#cloud-config\nruncmd:\n- curl https://git.selfprivacy.org/SelfPrivacy/selfprivacy-nixos-infect/raw/branch/master/nixos-infect | PROVIDER=hetzner NIX_CHANNEL=nixos-21.05 DOMAIN='$domainName' LUSER='${rootUser.login}' ENCODED_PASSWORD='$base64Password' CF_TOKEN=$dnsApiToken DB_PASSWORD=$dbPassword API_TOKEN=$apiToken HOSTNAME=$hostname bash 2>&1 | tee /tmp/infect.log";
|
||||
"#cloud-config\nruncmd:\n- curl https://git.selfprivacy.org/SelfPrivacy/selfprivacy-nixos-infect/raw/branch/master/nixos-infect | PROVIDER=$infectProviderName NIX_CHANNEL=nixos-21.05 DOMAIN='$domainName' LUSER='${rootUser.login}' ENCODED_PASSWORD='$base64Password' CF_TOKEN=$dnsApiToken DB_PASSWORD=$dbPassword API_TOKEN=$apiToken HOSTNAME=$hostname bash 2>&1 | tee /tmp/infect.log";
|
||||
|
||||
ServerHostingDetails? serverDetails;
|
||||
DioError? hetznerError;
|
||||
|
|
|
@ -39,4 +39,6 @@ abstract class ServerProviderApi extends ApiMap {
|
|||
|
||||
Future<bool> isApiTokenValid(final String token);
|
||||
ProviderApiTokenValidation getApiTokenValidation();
|
||||
|
||||
abstract final String infectProviderName;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue