-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmirrorDockerfileController.js
More file actions
56 lines (49 loc) · 1.64 KB
/
mirrorDockerfileController.js
File metadata and controls
56 lines (49 loc) · 1.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
'use strict';
require('app')
.controller('MirrorDockerfileController', MirrorDockerfileController);
function MirrorDockerfileController(
$q,
$rootScope,
errs,
doesDockerfileExist,
fetchRepoDockerfile,
fetchRepoDockerfiles,
keypather
) {
var MDC = this;
if (!MDC.repo) {
throw new Error('A repo is required for this controller');
}
MDC.resetDockerfilePaths = function () {
MDC.newDockerfilePaths = [];
MDC.newDockerComposeFilePaths = [];
delete MDC.state.dockerfile;
delete MDC.state.dockerComposeFile;
};
var oauthName = keypather.get($rootScope, 'dataApp.data.activeAccount.oauthName()');
var name = keypather.get(MDC.repo, 'attrs.name');
MDC.getFullRepo = function() {
return keypather.get(MDC.repo, 'attrs.full_name') || (oauthName + '/' + name);
};
MDC.branchName = MDC.branchName || keypather.get(MDC.repo, 'attrs.default_branch');
MDC.state.configurationMethod = null;
MDC.loadDefaultDockerfile = function (repo, branchName, filePath, fileType) {
return fetchRepoDockerfile(repo, branchName, filePath)
.then(doesDockerfileExist)
.then(function (dockerfile) {
if (!dockerfile) {
return $q.reject('file doesn’t exist');
}
if (fileType === 'Dockerfile') {
MDC.state.dockerComposeFile = null;
MDC.state.dockerfile = dockerfile;
} else if (fileType === 'Docker Compose') {
MDC.state.dockerComposeFile = dockerfile;
MDC.state.dockerfile = null;
}
});
};
MDC.isSaving = function () {
return $rootScope.isLoading.newContainerSingleRepo || $rootScope.isLoading.creatingDockerCompose;
};
}