65
65
AUTH_PARAMS = ('user' , 'password' , 'pubkey' , 'privkey' , 'passphrase' ,
66
66
'insecure_auth' )
67
67
68
- # Import salt libs
69
- import salt . utils .gitfs
68
+ from hubblestack . utils . signing import find_wrapf
69
+ from hubblestack . extmods . utils .gitfs import GitFS
70
70
from salt .exceptions import FileserverConfigError
71
71
72
72
log = logging .getLogger (__name__ )
76
76
77
77
78
78
def _gitfs (init_remotes = True ):
79
- return salt .utils .gitfs .GitFS (
80
- __opts__ ,
81
- __opts__ ['gitfs_remotes' ],
79
+ return GitFS ( __opts__ , __opts__ ['gitfs_remotes' ],
82
80
per_remote_overrides = PER_REMOTE_OVERRIDES ,
83
81
per_remote_only = PER_REMOTE_ONLY ,
84
82
init_remotes = init_remotes )
85
83
86
-
87
84
def __virtual__ ():
88
85
'''
89
86
Only load if the desired provider module is present and gitfs is enabled
90
87
properly in the master config file.
91
88
'''
92
89
if __virtualname__ not in __opts__ ['fileserver_backend' ]:
90
+ log .info ("no fileserver_backend configs, skipping gitfs" )
93
91
return False
94
92
try :
95
93
_gitfs (init_remotes = False )
96
94
# Initialization of the GitFS object did not fail, so we know we have
97
95
# valid configuration syntax and that a valid provider was detected.
96
+ log .error ("have fileserver_backend configs and GitFS object loads: success loading %s" , __virtualname__ )
98
97
return __virtualname__
99
98
except FileserverConfigError :
100
99
pass
100
+ log .error ("something went wrong loading GitFS object, claiming to not have gitfs" )
101
101
return False
102
102
103
-
104
103
def clear_cache ():
105
104
'''
106
105
Completely clear gitfs cache
107
106
'''
108
107
return _gitfs (init_remotes = False ).clear_cache ()
109
108
110
-
111
109
def clear_lock (remote = None , lock_type = 'update' ):
112
110
'''
113
111
Clear update.lk
114
112
'''
115
113
return _gitfs ().clear_lock (remote = remote , lock_type = lock_type )
116
114
117
-
118
115
def lock (remote = None ):
119
116
'''
120
117
Place an update.lk
@@ -125,81 +122,71 @@ def lock(remote=None):
125
122
'''
126
123
return _gitfs ().lock (remote = remote )
127
124
128
-
129
125
def update (remotes = None ):
130
126
'''
131
127
Execute a git fetch on all of the repos
132
128
'''
133
129
_gitfs ().update (remotes )
134
130
135
-
136
131
def update_intervals ():
137
132
'''
138
133
Returns the update intervals for each configured remote
139
134
'''
140
135
return _gitfs ().update_intervals ()
141
136
142
-
143
137
def envs (ignore_cache = False ):
144
138
'''
145
139
Return a list of refs that can be used as environments
146
140
'''
147
141
return _gitfs ().envs (ignore_cache = ignore_cache )
148
142
149
-
143
+ @ find_wrapf ( not_found = { 'rel' : '' , 'path' : '' }, real_path = 'path' )
150
144
def find_file (path , tgt_env = 'base' , ** kwargs ): # pylint: disable=W0613
151
145
'''
152
146
Find the first file to match the path and ref, read the file out of git
153
147
and send the path to the newly cached file
154
148
'''
155
149
return _gitfs ().find_file (path , tgt_env = tgt_env , ** kwargs )
156
150
157
-
158
151
def init ():
159
152
'''
160
153
Initialize remotes. This is only used by the master's pre-flight checks,
161
154
and is not invoked by GitFS.
162
155
'''
163
156
_gitfs ()
164
157
165
-
166
158
def serve_file (load , fnd ):
167
159
'''
168
160
Return a chunk from a file based on the data received
169
161
'''
170
162
return _gitfs ().serve_file (load , fnd )
171
163
172
-
173
164
def file_hash (load , fnd ):
174
165
'''
175
166
Return a file hash, the hash type is set in the master config file
176
167
'''
177
168
return _gitfs ().file_hash (load , fnd )
178
169
179
-
180
170
def file_list (load ):
181
171
'''
182
172
Return a list of all files on the file server in a specified
183
173
environment (specified as a key within the load dict).
184
174
'''
185
175
return _gitfs ().file_list (load )
186
176
187
-
188
177
def file_list_emptydirs (load ): # pylint: disable=W0613
189
178
'''
190
179
Return a list of all empty directories on the master
191
180
'''
192
181
# Cannot have empty dirs in git
193
182
return []
194
183
195
-
196
184
def dir_list (load ):
197
185
'''
198
186
Return a list of all directories on the master
199
187
'''
200
188
return _gitfs ().dir_list (load )
201
189
202
-
203
190
def symlink_list (load ):
204
191
'''
205
192
Return a dict of all symlinks based on a given path in the repo
0 commit comments