Skip to content

Commit

Permalink
refactor: refactor AWS provider module
Browse files Browse the repository at this point in the history
  • Loading branch information
vst committed May 9, 2024
1 parent e5dab16 commit f4834c2
Show file tree
Hide file tree
Showing 7 changed files with 595 additions and 513 deletions.
4 changes: 2 additions & 2 deletions src/Clompse/Programs/ListObjectBuckets.hs
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,11 @@ listObjectBucketsForCloudConnection
=> CloudConnection
-> m [Types.ObjectBucket]
listObjectBucketsForCloudConnection (CloudConnectionAws conn) = do
eBucketsS3 <- runExceptT (Providers.Aws.awsListAllS3Buckets conn)
eBucketsS3 <- runExceptT (Providers.Aws.listBucketsS3 conn)
bucketsS3 <- case eBucketsS3 of
Left e -> _log (" ERROR (AWS S3): " <> Z.Text.tshow e) >> pure []
Right buckets -> pure (fmap (\(n, c) -> Types.ObjectBucket n Types.ProviderAws "s3" (Just c)) buckets)
eBucketsLightsail <- runExceptT (Providers.Aws.awsListAllLightsailBuckets conn)
eBucketsLightsail <- runExceptT (Providers.Aws.listBucketsLightsail conn)
bucketsLightsail <- case eBucketsLightsail of
Left e -> _log (" ERROR (AWS Lightsail): " <> Z.Text.tshow e) >> pure []
Right buckets -> pure (fmap (\(n, c) -> Types.ObjectBucket n Types.ProviderAws "lightsail" (Just c)) buckets)
Expand Down
7 changes: 3 additions & 4 deletions src/Clompse/Programs/ListServers.hs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ module Clompse.Programs.ListServers where

import qualified Autodocodec as ADC
import Clompse.Config (CloudConnection (..), CloudProfile (..), Config (..))
import qualified Clompse.Providers.Aws as Providers
import qualified Clompse.Providers.Aws as Providers.Aws
import qualified Clompse.Providers.Do as Providers.Do
import qualified Clompse.Providers.Hetzner as Providers.Hetzner
Expand Down Expand Up @@ -70,15 +69,15 @@ listServersForCloudConnection
=> CloudConnection
-> m [Server]
listServersForCloudConnection (CloudConnectionAws conn) = do
eServersEc2 <- runExceptT (Providers.Aws.awsEc2ListAllInstances conn)
eServersEc2 <- runExceptT (Providers.Aws.listServersEc2 conn)
serversEc2 <- case eServersEc2 of
Left e -> _log (" ERROR (AWS EC2): " <> Z.Text.tshow e) >> pure []
Right servers -> pure servers
eServersLightsail <- runExceptT (Providers.Aws.awsLightsailListAllInstances conn)
eServersLightsail <- runExceptT (Providers.Aws.listServersLightsail conn)
serversLightsail <- case eServersLightsail of
Left e -> _log (" ERROR (AWS Lightsail): " <> Z.Text.tshow e) >> pure []
Right servers -> pure servers
pure (fmap Providers.ec2InstanceToServer serversEc2 <> fmap (uncurry Providers.lightsailInstanceToServer) serversLightsail)
pure (serversEc2 <> serversLightsail)
listServersForCloudConnection (CloudConnectionDo conn) = do
eServers <- runExceptT (Providers.Do.listServers conn)
case eServers of
Expand Down
Loading

0 comments on commit f4834c2

Please sign in to comment.