diff --git a/sandwich-contexts-kubernetes/lib/Test/Sandwich/Contexts/Kubernetes/Cluster.hs b/sandwich-contexts-kubernetes/lib/Test/Sandwich/Contexts/Kubernetes/Cluster.hs index b05e3495..1ebfb659 100644 --- a/sandwich-contexts-kubernetes/lib/Test/Sandwich/Contexts/Kubernetes/Cluster.hs +++ b/sandwich-contexts-kubernetes/lib/Test/Sandwich/Contexts/Kubernetes/Cluster.hs @@ -52,9 +52,6 @@ module Test.Sandwich.Contexts.Kubernetes.Cluster ( , KubernetesClusterContext(..) , KubernetesClusterType(..) , HasKubernetesClusterContext - - -- * Util - , Util.parseHostnameAndPort ) where import Control.Monad.Catch @@ -76,8 +73,6 @@ import qualified Test.Sandwich.Contexts.Kubernetes.KindCluster.ServiceForwardPor import qualified Test.Sandwich.Contexts.Kubernetes.MinikubeCluster as Minikube import qualified Test.Sandwich.Contexts.Kubernetes.MinikubeCluster.Forwards as Minikube -import qualified Test.Sandwich.Contexts.Kubernetes.Util as Util - -- | Forward a Kubernetes service, so that it can be reached at a local URI. withForwardKubernetesService :: ( diff --git a/sandwich-contexts-kubernetes/lib/Test/Sandwich/Contexts/Kubernetes/KubectlPortForward.hs b/sandwich-contexts-kubernetes/lib/Test/Sandwich/Contexts/Kubernetes/KubectlPortForward.hs index 7dcb85c3..e59bcc5a 100644 --- a/sandwich-contexts-kubernetes/lib/Test/Sandwich/Contexts/Kubernetes/KubectlPortForward.hs +++ b/sandwich-contexts-kubernetes/lib/Test/Sandwich/Contexts/Kubernetes/KubectlPortForward.hs @@ -10,7 +10,6 @@ module Test.Sandwich.Contexts.Kubernetes.KubectlPortForward ( import Control.Monad import Control.Monad.Catch (MonadCatch) import Control.Monad.IO.Unlift -import Control.Monad.Logger import Control.Retry import Data.String.Interpolate import qualified Data.Text as T @@ -20,6 +19,7 @@ import System.FilePath import System.Process (getPid) import Test.Sandwich import Test.Sandwich.Contexts.Files +import Test.Sandwich.Contexts.Kubernetes.Types import Test.Sandwich.Contexts.Kubernetes.Util.Ports import Test.Sandwich.Contexts.Kubernetes.Util.SocketUtil import Test.Sandwich.Util.Process (gracefullyStopProcess) @@ -41,14 +41,17 @@ newtype KubectlPortForwardContext = KubectlPortForwardContext { -- | Run a @kubectl port-forward@ process, making the port available in the 'KubectlPortForwardContext'. -- -- Note that this will stop working if the pod you're talking to goes away (even if you do it against a service). --- If this happens, a rerun of the command is needed to resume forwarding +-- If this happens, a rerun of the command is needed to resume forwarding. withKubectlPortForward :: ( - HasCallStack, MonadCatch m, MonadLogger m, MonadUnliftIO m - , HasBaseContextMonad ctx m, HasFile ctx "kubectl" + HasCallStack, MonadCatch m, KubectlBasic context m ) + -- | Path to kubeconfig file => FilePath + -- | Namespace -> Text + -- | Target name (pod, service, etc.) -> Text + -- | Target port number -> PortNumber -> (KubectlPortForwardContext -> m a) -> m a @@ -58,15 +61,19 @@ withKubectlPortForward kubeConfigFile namespace targetName targetPort action = d -- | Same as 'withKubectlPortForward', but allows you to pass in the @kubectl@ binary path. withKubectlPortForward' :: ( - HasCallStack, MonadCatch m, MonadLogger m, MonadUnliftIO m - , HasBaseContextMonad ctx m + HasCallStack, MonadCatch m, KubernetesBasic context m ) => FilePath + -- | Path to kubeconfig file -> FilePath + -- | Namespace -> Text + -- | Callback to check if the proposed local port is acceptable -> (PortNumber -> Bool) -> Maybe PortNumber + -- | Target name (pod, service, etc.) -> Text + -- | Target port number -> PortNumber -> (KubectlPortForwardContext -> m a) -> m a diff --git a/sandwich-contexts-kubernetes/lib/Test/Sandwich/Contexts/Kubernetes/MinioS3Server.hs b/sandwich-contexts-kubernetes/lib/Test/Sandwich/Contexts/Kubernetes/MinioS3Server.hs index 92c6998f..ab1adc60 100644 --- a/sandwich-contexts-kubernetes/lib/Test/Sandwich/Contexts/Kubernetes/MinioS3Server.hs +++ b/sandwich-contexts-kubernetes/lib/Test/Sandwich/Contexts/Kubernetes/MinioS3Server.hs @@ -9,6 +9,7 @@ This module can be used to install MinIO S3 servers onto a Kubernetes cluster. Such a server is provided as a generic 'TestS3Server', so that you can easily run the same tests against both Kubernetes environments and normal ones. See for example the @sandwich-contexts-minio@ package. -} + module Test.Sandwich.Contexts.Kubernetes.MinioS3Server ( introduceK8SMinioS3Server , introduceK8SMinioS3Server' diff --git a/sandwich-contexts-kubernetes/lib/Test/Sandwich/Contexts/Kubernetes/SeaweedFS.hs b/sandwich-contexts-kubernetes/lib/Test/Sandwich/Contexts/Kubernetes/SeaweedFS.hs index 7ea93d58..a1c8b46c 100644 --- a/sandwich-contexts-kubernetes/lib/Test/Sandwich/Contexts/Kubernetes/SeaweedFS.hs +++ b/sandwich-contexts-kubernetes/lib/Test/Sandwich/Contexts/Kubernetes/SeaweedFS.hs @@ -7,6 +7,12 @@ {-# OPTIONS_GHC -fno-warn-missing-signatures #-} {-# OPTIONS_GHC -fno-warn-incomplete-uni-patterns #-} +{-| + +This module can be used to install [SeaweedFS](https://github.com/seaweedfs/seaweedfs) deployments on a Kubernetes cluster. + +-} + module Test.Sandwich.Contexts.Kubernetes.SeaweedFS ( introduceSeaweedFS , withSeaweedFS diff --git a/sandwich-contexts-kubernetes/lib/Test/Sandwich/Contexts/Kubernetes/Util.hs b/sandwich-contexts-kubernetes/lib/Test/Sandwich/Contexts/Kubernetes/Util.hs deleted file mode 100644 index b0a28301..00000000 --- a/sandwich-contexts-kubernetes/lib/Test/Sandwich/Contexts/Kubernetes/Util.hs +++ /dev/null @@ -1,19 +0,0 @@ - -module Test.Sandwich.Contexts.Kubernetes.Util where - -import qualified Data.List as L -import Data.String.Interpolate -import Network.HostName (HostName) -import Network.Socket (PortNumber) -import Network.URI -import Relude -import Safe -import Test.Sandwich - - -parseHostnameAndPort :: (MonadIO m) => URI -> m (HostName, PortNumber) -parseHostnameAndPort uri = case uriAuthority uri of - Nothing -> expectationFailure [i|Server URI didn't have an authority: #{uri}|] - Just (URIAuth {..}) -> case readMay (L.drop 1 uriPort) of - Nothing -> expectationFailure [i|Couldn't read port: #{uriPort}|] - Just x -> pure (uriRegName, x) diff --git a/sandwich-contexts-kubernetes/package.yaml b/sandwich-contexts-kubernetes/package.yaml index 81e0f388..f6bde739 100644 --- a/sandwich-contexts-kubernetes/package.yaml +++ b/sandwich-contexts-kubernetes/package.yaml @@ -50,7 +50,6 @@ library: - sandwich-contexts-minio - containers - filepath - - hostname - http-client - kubernetes-client - kubernetes-client-core diff --git a/sandwich-contexts-kubernetes/sandwich-contexts-kubernetes.cabal b/sandwich-contexts-kubernetes/sandwich-contexts-kubernetes.cabal index 2f52c71f..c009e1f1 100644 --- a/sandwich-contexts-kubernetes/sandwich-contexts-kubernetes.cabal +++ b/sandwich-contexts-kubernetes/sandwich-contexts-kubernetes.cabal @@ -41,7 +41,6 @@ library Test.Sandwich.Contexts.Kubernetes.MinioS3Server.Parsing Test.Sandwich.Contexts.Kubernetes.Run Test.Sandwich.Contexts.Kubernetes.Types - Test.Sandwich.Contexts.Kubernetes.Util Test.Sandwich.Contexts.Kubernetes.Util.Aeson Test.Sandwich.Contexts.Kubernetes.Util.Container Test.Sandwich.Contexts.Kubernetes.Util.Exception @@ -75,7 +74,6 @@ library , containers , exceptions , filepath - , hostname , http-client , kubernetes-client , kubernetes-client-core