]> dgit.raspbian.org Git - git-annex.git/commitdiff
add git configs for clusters
authorJoey Hess <joeyh@joeyh.name>
Fri, 14 Jun 2024 15:42:32 +0000 (11:42 -0400)
committerJoey Hess <joeyh@joeyh.name>
Fri, 14 Jun 2024 16:20:17 +0000 (12:20 -0400)
CHANGELOG
Types/Cluster.hs
Types/GitConfig.hs
doc/git-annex-preferred-content.mdwn
doc/git-annex-updateproxy.mdwn
doc/git-annex.mdwn

index d956868768af551c8f90a30667f90e83869a5d28..89df0811c6c3e855b00e3868acda72eb25881fb9 100644 (file)
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,6 +1,9 @@
 git-annex (10.20240532) UNRELEASED; urgency=medium
 
-  * Added updateproxy command and remote.name.annex-proxy configuration.
+  * Added git-annex updateproxy command and remote.name.annex-proxy
+    configuration.
+  * Added git-annex cluster command and remote.name.annex-cluster-node
+    and annex.cluster.name configuration.
   * Fix a bug where interrupting git-annex while it is updating the
     git-annex branch for an export could later lead to git fsck
     complaining about missing tree objects.
index 0ce3e0db0b65490b57f4250b64762156e2e6f392..08a349f3bab1508dbe54509fa2db7b3587e1a833 100644 (file)
@@ -34,8 +34,8 @@ newtype ClusterUUID = ClusterUUID UUID
 
 -- Smart constructor for a ClusterUUID.
 --
--- The input UUID can be a regular UUID (eg V4). It is converted to a valid
--- cluster uuid.
+-- The input UUID can be any regular UUID (eg V4). It is converted to a valid
+-- cluster UUID.
 mkClusterUUID :: UUID -> Maybe ClusterUUID
 mkClusterUUID (UUID b)
        | B.length b > 14 = Just $ ClusterUUID $ UUID $
index b72dc29c5c3c3a7e3165a28a7eb9659de00251b7..016e51a68acf1f3b6c6cc951fa0ff76def6a2c17 100644 (file)
@@ -45,6 +45,7 @@ import Types.RefSpec
 import Types.RepoVersion
 import Types.StallDetection
 import Types.View
+import Types.Cluster
 import Config.DynamicConfig
 import Utility.HumanTime
 import Utility.Gpg (GpgCmd, mkGpgCmd)
@@ -155,6 +156,7 @@ data GitConfig = GitConfig
        , annexPrivateRepos :: S.Set UUID
        , annexAdviceNoSshCaching :: Bool
        , annexViewUnsetDirectory :: ViewUnset
+       , annexClusters :: M.Map String ClusterUUID
        }
 
 extractGitConfig :: ConfigSource -> Git.Repo -> GitConfig
@@ -283,6 +285,12 @@ extractGitConfig configsource r = GitConfig
        , annexAdviceNoSshCaching = getbool (annexConfig "advicenosshcaching") True
        , annexViewUnsetDirectory = ViewUnset $ fromMaybe "_" $
                getmaybe (annexConfig "viewunsetdirectory")
+       , annexClusters = 
+               M.mapMaybe (mkClusterUUID . toUUID) $
+               M.mapKeys (drop (B.length clusterprefix) . fromConfigKey) $
+               M.filterWithKey
+                       (\(ConfigKey k) _ -> clusterprefix `B.isPrefixOf` k)
+                       (config r)
        }
   where
        getbool k d = fromMaybe d $ getmaybebool k
@@ -307,6 +315,8 @@ extractGitConfig configsource r = GitConfig
        
        hereuuid = maybe NoUUID toUUID $ getmaybe (annexConfig "uuid")
 
+       clusterprefix = annexConfigPrefix <> "cluster."
+
 {- Merge a GitConfig that comes from git-config with one containing
  - repository-global defaults. -}
 mergeGitConfig :: GitConfig -> GitConfig -> GitConfig
@@ -377,6 +387,7 @@ data RemoteGitConfig = RemoteGitConfig
        , remoteAnnexMaxGitBundles :: Int
        , remoteAnnexAllowEncryptedGitRepo :: Bool
        , remoteAnnexProxy :: Bool
+       , remoteAnnexClusterNode :: Maybe [String]
        , remoteUrl :: Maybe String
 
        {- These settings are specific to particular types of remotes
@@ -462,6 +473,7 @@ extractRemoteGitConfig r remotename = do
                , remoteAnnexAllowEncryptedGitRepo = 
                        getbool AllowEncryptedGitRepoField False
                , remoteAnnexProxy = getbool ProxyField False
+               , remoteAnnexClusterNode = words <$> getmaybe ClusterNodeField
                , remoteUrl = 
                        case Git.Config.getMaybe (remoteConfig remotename (remoteGitConfigKey UrlField)) r of
                                Just (ConfigValue b)
@@ -539,6 +551,7 @@ data RemoteGitConfigField
        | MaxGitBundlesField
        | AllowEncryptedGitRepoField
        | ProxyField
+       | ClusterNodeField
        | UrlField
        | ShellField
        | SshOptionsField
@@ -603,6 +616,7 @@ remoteGitConfigField = \case
        AllowEncryptedGitRepoField -> inherited "allow-encrypted-gitrepo"
        -- Allow proxy chains.
        ProxyField -> inherited "proxy"
+       ClusterNodeField -> uninherited "cluster-node"
        UrlField -> inherited "url"
        ShellField -> inherited "shell"
        SshOptionsField -> inherited "ssh-options"
@@ -654,9 +668,12 @@ dummyRemoteGitConfig = atomically $
 
 type UnqualifiedConfigKey = B.ByteString
 
+annexConfigPrefix :: B.ByteString
+annexConfigPrefix = "annex."
+
 {- A global annex setting in git config. -}
 annexConfig :: UnqualifiedConfigKey -> ConfigKey
-annexConfig key = ConfigKey ("annex." <> key)
+annexConfig key = ConfigKey (annexConfigPrefix <> key)
 
 class RemoteNameable r where
        getRemoteName :: r -> RemoteName
index 890c5195961d94914a569fb5cbf268b370366a8e..466215792a5a8acf6851b4a84ef1947a86f61850 100644 (file)
@@ -8,7 +8,7 @@ Each repository has a preferred content setting, which specifies content
 that the repository wants to have present. These settings can be configured
 using `git annex vicfg` or `git annex wanted`.
 They are used by the `--auto` option, by `git annex sync --content`,
-and by the git-annex assistant.
+by clusters, and by the git-annex assistant.
 
 While preferred content expresses a preference, it can be overridden
 by simply using `git annex drop`. On the other hand, required content
index 20cbeef278f86ca16dcea4d208b50eb45d77044f..9ce216e52b6a2d2a846bdcf52aff6d748bf77ebd 100644 (file)
@@ -22,7 +22,9 @@ git-annex branch. That tells other repositories about the proxy
 configuration.
 
 Suppose, for example, that remote "work" has had this command run in
-it. Then git-annex will know about an additional remote, "work-foo".
+it. Then after pulling from "work", git-annex will know about an
+additional remote, "work-foo". That remote will be accessed using "work" as
+a proxy. (This only works for remotes accessed over ssh.)
 
 # OPTIONS
 
@@ -31,6 +33,7 @@ it. Then git-annex will know about an additional remote, "work-foo".
 # SEE ALSO
 
 [[git-annex]](1)
+[[git-annex-cluster]](1)
 
 # AUTHOR
 
index 3a7a6bd39f3b2a11d8476f001d23bc0cd7a4f1d1..a6a303610c64d22dcfff1c548683532d98e0754c 100644 (file)
@@ -1377,6 +1377,14 @@ repository, using [[git-annex-config]]. See its man page for a list.)
   set in global git configuration.
   For details, see <https://git-annex.branchable.com/tuning/>.
 
+* `annex.cluster.<name>`
+
+  [[git-annex-cluster]] sets this to the UUID of a cluster, to 
+  enable the local repository to act as a proxy to the cluster.
+
+  Note that cluster UUIDs are not the same as repository UUIDs,
+  and a repository UUID cannot be used here.
+
 # CONFIGURATION OF REMOTES
 
 Remotes are configured using these settings in `.git/config`.
@@ -1649,7 +1657,18 @@ Remotes are configured using these settings in `.git/config`.
 * `remote.<name>.annex-proxy`
 
   Set to "true" to make the local repository able to act as a proxy to this
-  remote. After configuring this, run [[git-annex-updateproxy](1) to store
+  remote. 
+
+  After configuring this, run [[git-annex-updateproxy](1) to store
+  the new configuration in the git-annex branch.
+
+* `remote.<name>.annex-cluster-node`
+
+  Set to the name of a cluster to make this remote be part of
+  the cluster. Names of multiple clusters can be separated by
+  whitespace to make a remote be part of more than one cluster.
+  
+  After configuring this, run [[git-annex-updatecluster](1) to store
   the new configuration in the git-annex branch.
 
 * `remote.<name>.annex-private`