Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
apollo
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
openSource
apollo
Commits
db65452d
Commit
db65452d
authored
Jan 19, 2017
by
lepdou
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
emergency publish
parent
4949eb55
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
29 changed files
with
283 additions
and
70 deletions
+283
-70
ReleaseController.java
...ork/apollo/adminservice/controller/ReleaseController.java
+10
-6
ReleaseControllerTest.java
...apollo/adminservice/controller/ReleaseControllerTest.java
+1
-1
ReleaseService.java
...om/ctrip/framework/apollo/biz/service/ReleaseService.java
+0
-0
ReleaseCreationTest.java
...rip/framework/apollo/biz/service/ReleaseCreationTest.java
+8
-9
ReleaseOperationContext.java
...work/apollo/common/constants/ReleaseOperationContext.java
+1
-0
AdminServiceAPI.java
...om/ctrip/framework/apollo/portal/api/AdminServiceAPI.java
+8
-7
PortalConfig.java
...amework/apollo/portal/components/config/PortalConfig.java
+14
-0
ConfigPublishEmailBuilder.java
...al/components/emailbuilder/ConfigPublishEmailBuilder.java
+17
-1
NamespaceBranchController.java
...k/apollo/portal/controller/NamespaceBranchController.java
+10
-1
NamespaceLockController.java
...ork/apollo/portal/controller/NamespaceLockController.java
+11
-0
ReleaseController.java
...framework/apollo/portal/controller/ReleaseController.java
+12
-0
NamespaceReleaseModel.java
...ork/apollo/portal/entity/model/NamespaceReleaseModel.java
+9
-0
LockInfo.java
...com/ctrip/framework/apollo/portal/entity/vo/LockInfo.java
+23
-0
NamespaceBranchService.java
...amework/apollo/portal/service/NamespaceBranchService.java
+5
-4
NamespaceLockService.java
...framework/apollo/portal/service/NamespaceLockService.java
+16
-0
ReleaseService.java
...ctrip/framework/apollo/portal/service/ReleaseService.java
+12
-9
config.html
apollo-portal/src/main/resources/static/config.html
+2
-4
history.html
apollo-portal/src/main/resources/static/config/history.html
+2
-1
merge-and-publish-modal-directive.js
...ic/scripts/directive/merge-and-publish-modal-directive.js
+7
-2
namespace-panel-directive.js
...ces/static/scripts/directive/namespace-panel-directive.js
+13
-12
publish-deny-modal-directive.js
.../static/scripts/directive/publish-deny-modal-directive.js
+44
-0
release-modal-directive.js
...urces/static/scripts/directive/release-modal-directive.js
+9
-2
EventManager.js
...rc/main/resources/static/scripts/services/EventManager.js
+2
-1
NamespaceBranchService.js
...sources/static/scripts/services/NamespaceBranchService.js
+3
-2
NamespaceLockService.js
...resources/static/scripts/services/NamespaceLockService.js
+1
-1
ReleaseService.js
.../main/resources/static/scripts/services/ReleaseService.js
+8
-6
ServerConfigService.js
.../resources/static/scripts/services/ServerConfigService.js
+1
-1
common-style.css
...-portal/src/main/resources/static/styles/common-style.css
+6
-0
publish-deny-modal.html
.../resources/static/views/component/publish-deny-modal.html
+28
-0
No files found.
apollo-adminservice/src/main/java/com/ctrip/framework/apollo/adminservice/controller/ReleaseController.java
View file @
db65452d
...
@@ -33,6 +33,7 @@ import java.util.stream.Collectors;
...
@@ -33,6 +33,7 @@ import java.util.stream.Collectors;
@RestController
@RestController
public
class
ReleaseController
{
public
class
ReleaseController
{
private
static
final
Splitter
RELEASES_SPLITTER
=
Splitter
.
on
(
","
).
omitEmptyStrings
()
private
static
final
Splitter
RELEASES_SPLITTER
=
Splitter
.
on
(
","
).
omitEmptyStrings
()
.
trimResults
();
.
trimResults
();
...
@@ -57,7 +58,7 @@ public class ReleaseController {
...
@@ -57,7 +58,7 @@ public class ReleaseController {
}
}
@RequestMapping
(
"/releases"
)
@RequestMapping
(
"/releases"
)
public
List
<
ReleaseDTO
>
findReleaseByIds
(
@RequestParam
(
"releaseIds"
)
String
releaseIds
){
public
List
<
ReleaseDTO
>
findReleaseByIds
(
@RequestParam
(
"releaseIds"
)
String
releaseIds
)
{
Set
<
Long
>
releaseIdSet
=
RELEASES_SPLITTER
.
splitToList
(
releaseIds
).
stream
().
map
(
Long:
:
parseLong
)
Set
<
Long
>
releaseIdSet
=
RELEASES_SPLITTER
.
splitToList
(
releaseIds
).
stream
().
map
(
Long:
:
parseLong
)
.
collect
(
Collectors
.
toSet
());
.
collect
(
Collectors
.
toSet
());
...
@@ -99,13 +100,14 @@ public class ReleaseController {
...
@@ -99,13 +100,14 @@ public class ReleaseController {
@PathVariable
(
"namespaceName"
)
String
namespaceName
,
@PathVariable
(
"namespaceName"
)
String
namespaceName
,
@RequestParam
(
"name"
)
String
releaseName
,
@RequestParam
(
"name"
)
String
releaseName
,
@RequestParam
(
name
=
"comment"
,
required
=
false
)
String
releaseComment
,
@RequestParam
(
name
=
"comment"
,
required
=
false
)
String
releaseComment
,
@RequestParam
(
"operator"
)
String
operator
)
{
@RequestParam
(
"operator"
)
String
operator
,
@RequestParam
(
name
=
"isEmergencyPublish"
,
defaultValue
=
"false"
)
boolean
isEmergencyPublish
)
{
Namespace
namespace
=
namespaceService
.
findOne
(
appId
,
clusterName
,
namespaceName
);
Namespace
namespace
=
namespaceService
.
findOne
(
appId
,
clusterName
,
namespaceName
);
if
(
namespace
==
null
)
{
if
(
namespace
==
null
)
{
throw
new
NotFoundException
(
String
.
format
(
"Could not find namespace for %s %s %s"
,
appId
,
throw
new
NotFoundException
(
String
.
format
(
"Could not find namespace for %s %s %s"
,
appId
,
clusterName
,
namespaceName
));
clusterName
,
namespaceName
));
}
}
Release
release
=
releaseService
.
publish
(
namespace
,
releaseName
,
releaseComment
,
operator
);
Release
release
=
releaseService
.
publish
(
namespace
,
releaseName
,
releaseComment
,
operator
,
isEmergencyPublish
);
//send release message
//send release message
Namespace
parentNamespace
=
namespaceService
.
findParentNamespace
(
namespace
);
Namespace
parentNamespace
=
namespaceService
.
findParentNamespace
(
namespace
);
...
@@ -122,7 +124,8 @@ public class ReleaseController {
...
@@ -122,7 +124,8 @@ public class ReleaseController {
/**
/**
*merge branch items to master and publish master
* merge branch items to master and publish master
*
* @return published result
* @return published result
*/
*/
@Transactional
@Transactional
...
@@ -134,6 +137,7 @@ public class ReleaseController {
...
@@ -134,6 +137,7 @@ public class ReleaseController {
@RequestParam
(
"branchName"
)
String
branchName
,
@RequestParam
(
"branchName"
)
String
branchName
,
@RequestParam
(
value
=
"deleteBranch"
,
defaultValue
=
"true"
)
boolean
deleteBranch
,
@RequestParam
(
value
=
"deleteBranch"
,
defaultValue
=
"true"
)
boolean
deleteBranch
,
@RequestParam
(
name
=
"releaseComment"
,
required
=
false
)
String
releaseComment
,
@RequestParam
(
name
=
"releaseComment"
,
required
=
false
)
String
releaseComment
,
@RequestParam
(
name
=
"isEmergencyPublish"
,
defaultValue
=
"false"
)
boolean
isEmergencyPublish
,
@RequestBody
ItemChangeSets
changeSets
)
{
@RequestBody
ItemChangeSets
changeSets
)
{
Namespace
namespace
=
namespaceService
.
findOne
(
appId
,
clusterName
,
namespaceName
);
Namespace
namespace
=
namespaceService
.
findOne
(
appId
,
clusterName
,
namespaceName
);
if
(
namespace
==
null
)
{
if
(
namespace
==
null
)
{
...
@@ -141,8 +145,8 @@ public class ReleaseController {
...
@@ -141,8 +145,8 @@ public class ReleaseController {
clusterName
,
namespaceName
));
clusterName
,
namespaceName
));
}
}
Release
release
=
releaseService
.
mergeBranchChangeSetsAndRelease
(
namespace
,
branchName
,
Release
release
=
releaseService
.
mergeBranchChangeSetsAndRelease
(
namespace
,
branchName
,
releaseName
,
releaseName
,
releaseComment
,
changeSets
);
releaseComment
,
isEmergencyPublish
,
changeSets
);
if
(
deleteBranch
)
{
if
(
deleteBranch
)
{
namespaceBranchService
.
deleteBranch
(
appId
,
clusterName
,
namespaceName
,
branchName
,
namespaceBranchService
.
deleteBranch
(
appId
,
clusterName
,
namespaceName
,
branchName
,
...
...
apollo-adminservice/src/test/java/com/ctrip/framework/apollo/adminservice/controller/ReleaseControllerTest.java
View file @
db65452d
...
@@ -121,7 +121,7 @@ public class ReleaseControllerTest extends AbstractControllerTest {
...
@@ -121,7 +121,7 @@ public class ReleaseControllerTest extends AbstractControllerTest {
.
thenReturn
(
someNamespace
);
.
thenReturn
(
someNamespace
);
releaseController
releaseController
.
publish
(
someAppId
,
someCluster
,
someNamespaceName
,
someName
,
someComment
,
"test"
);
.
publish
(
someAppId
,
someCluster
,
someNamespaceName
,
someName
,
someComment
,
"test"
,
false
);
verify
(
someMessageSender
,
times
(
1
))
verify
(
someMessageSender
,
times
(
1
))
.
sendMessage
(
Joiner
.
on
(
ConfigConsts
.
CLUSTER_NAMESPACE_SEPARATOR
)
.
sendMessage
(
Joiner
.
on
(
ConfigConsts
.
CLUSTER_NAMESPACE_SEPARATOR
)
...
...
apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/service/ReleaseService.java
View file @
db65452d
This diff is collapsed.
Click to expand it.
apollo-biz/src/test/java/com/ctrip/framework/apollo/biz/service/ReleaseCreationTest.java
View file @
db65452d
...
@@ -8,6 +8,7 @@ import com.ctrip.framework.apollo.biz.entity.GrayReleaseRule;
...
@@ -8,6 +8,7 @@ import com.ctrip.framework.apollo.biz.entity.GrayReleaseRule;
import
com.ctrip.framework.apollo.biz.entity.Namespace
;
import
com.ctrip.framework.apollo.biz.entity.Namespace
;
import
com.ctrip.framework.apollo.biz.entity.Release
;
import
com.ctrip.framework.apollo.biz.entity.Release
;
import
com.ctrip.framework.apollo.biz.entity.ReleaseHistory
;
import
com.ctrip.framework.apollo.biz.entity.ReleaseHistory
;
import
com.ctrip.framework.apollo.common.constants.GsonType
;
import
com.ctrip.framework.apollo.common.constants.ReleaseOperation
;
import
com.ctrip.framework.apollo.common.constants.ReleaseOperation
;
import
org.junit.Assert
;
import
org.junit.Assert
;
...
@@ -24,8 +25,6 @@ import java.util.Map;
...
@@ -24,8 +25,6 @@ import java.util.Map;
public
class
ReleaseCreationTest
extends
AbstractIntegrationTest
{
public
class
ReleaseCreationTest
extends
AbstractIntegrationTest
{
private
Gson
gson
=
new
Gson
();
private
Gson
gson
=
new
Gson
();
private
Type
configurationTypeReference
=
new
TypeToken
<
Map
<
String
,
String
>>()
{
}.
getType
();
@Autowired
@Autowired
private
ReleaseService
releaseService
;
private
ReleaseService
releaseService
;
...
@@ -47,7 +46,7 @@ public class ReleaseCreationTest extends AbstractIntegrationTest {
...
@@ -47,7 +46,7 @@ public class ReleaseCreationTest extends AbstractIntegrationTest {
String
clusterName
=
"only-master"
;
String
clusterName
=
"only-master"
;
Namespace
namespace
=
instanceNamespace
(
namespaceId
,
clusterName
);
Namespace
namespace
=
instanceNamespace
(
namespaceId
,
clusterName
);
releaseService
.
publish
(
namespace
,
""
,
""
,
operator
);
releaseService
.
publish
(
namespace
,
""
,
""
,
operator
,
false
);
Release
latestRelease
=
releaseService
.
findLatestActiveRelease
(
namespace
);
Release
latestRelease
=
releaseService
.
findLatestActiveRelease
(
namespace
);
...
@@ -92,7 +91,7 @@ public class ReleaseCreationTest extends AbstractIntegrationTest {
...
@@ -92,7 +91,7 @@ public class ReleaseCreationTest extends AbstractIntegrationTest {
String
childClusterName
=
"child-cluster1"
;
String
childClusterName
=
"child-cluster1"
;
Namespace
parentNamespace
=
instanceNamespace
(
parentNamespaceId
,
parentClusterName
);
Namespace
parentNamespace
=
instanceNamespace
(
parentNamespaceId
,
parentClusterName
);
releaseService
.
publish
(
parentNamespace
,
""
,
""
,
operator
);
releaseService
.
publish
(
parentNamespace
,
""
,
""
,
operator
,
false
);
Release
latestParentNamespaceRelease
=
releaseService
.
findLatestActiveRelease
(
parentNamespace
);
Release
latestParentNamespaceRelease
=
releaseService
.
findLatestActiveRelease
(
parentNamespace
);
...
@@ -166,7 +165,7 @@ public class ReleaseCreationTest extends AbstractIntegrationTest {
...
@@ -166,7 +165,7 @@ public class ReleaseCreationTest extends AbstractIntegrationTest {
String
childClusterName
=
"child-cluster2"
;
String
childClusterName
=
"child-cluster2"
;
Namespace
parentNamespace
=
instanceNamespace
(
parentNamespaceId
,
parentClusterName
);
Namespace
parentNamespace
=
instanceNamespace
(
parentNamespaceId
,
parentClusterName
);
releaseService
.
publish
(
parentNamespace
,
""
,
""
,
operator
);
releaseService
.
publish
(
parentNamespace
,
""
,
""
,
operator
,
false
);
Release
latestParentNamespaceRelease
=
releaseService
.
findLatestActiveRelease
(
parentNamespace
);
Release
latestParentNamespaceRelease
=
releaseService
.
findLatestActiveRelease
(
parentNamespace
);
...
@@ -237,7 +236,7 @@ public class ReleaseCreationTest extends AbstractIntegrationTest {
...
@@ -237,7 +236,7 @@ public class ReleaseCreationTest extends AbstractIntegrationTest {
String
childClusterName
=
"child-cluster3"
;
String
childClusterName
=
"child-cluster3"
;
Namespace
parentNamespace
=
instanceNamespace
(
parentNamespaceId
,
parentClusterName
);
Namespace
parentNamespace
=
instanceNamespace
(
parentNamespaceId
,
parentClusterName
);
releaseService
.
publish
(
parentNamespace
,
""
,
""
,
operator
);
releaseService
.
publish
(
parentNamespace
,
""
,
""
,
operator
,
false
);
Release
latestParentNamespaceRelease
=
releaseService
.
findLatestActiveRelease
(
parentNamespace
);
Release
latestParentNamespaceRelease
=
releaseService
.
findLatestActiveRelease
(
parentNamespace
);
...
@@ -306,7 +305,7 @@ public class ReleaseCreationTest extends AbstractIntegrationTest {
...
@@ -306,7 +305,7 @@ public class ReleaseCreationTest extends AbstractIntegrationTest {
String
childClusterName
=
"child-cluster4"
;
String
childClusterName
=
"child-cluster4"
;
//assert child namespace
//assert child namespace
Namespace
childNamespace
=
instanceNamespace
(
childNamespaceId
,
childClusterName
);
Namespace
childNamespace
=
instanceNamespace
(
childNamespaceId
,
childClusterName
);
releaseService
.
publish
(
childNamespace
,
""
,
""
,
operator
);
releaseService
.
publish
(
childNamespace
,
""
,
""
,
operator
,
false
);
Release
latestChildNamespaceRelease
=
releaseService
.
findLatestActiveRelease
(
childNamespace
);
Release
latestChildNamespaceRelease
=
releaseService
.
findLatestActiveRelease
(
childNamespace
);
...
@@ -377,7 +376,7 @@ public class ReleaseCreationTest extends AbstractIntegrationTest {
...
@@ -377,7 +376,7 @@ public class ReleaseCreationTest extends AbstractIntegrationTest {
String
childClusterName
=
"child-cluster5"
;
String
childClusterName
=
"child-cluster5"
;
//assert child namespace
//assert child namespace
Namespace
childNamespace
=
instanceNamespace
(
childNamespaceId
,
childClusterName
);
Namespace
childNamespace
=
instanceNamespace
(
childNamespaceId
,
childClusterName
);
releaseService
.
publish
(
childNamespace
,
""
,
""
,
operator
);
releaseService
.
publish
(
childNamespace
,
""
,
""
,
operator
,
false
);
Release
latestChildNamespaceRelease
=
releaseService
.
findLatestActiveRelease
(
childNamespace
);
Release
latestChildNamespaceRelease
=
releaseService
.
findLatestActiveRelease
(
childNamespace
);
...
@@ -495,7 +494,7 @@ public class ReleaseCreationTest extends AbstractIntegrationTest {
...
@@ -495,7 +494,7 @@ public class ReleaseCreationTest extends AbstractIntegrationTest {
}
}
private
Map
<
String
,
String
>
parseConfiguration
(
String
configuration
)
{
private
Map
<
String
,
String
>
parseConfiguration
(
String
configuration
)
{
return
gson
.
fromJson
(
configuration
,
configurationTypeReference
);
return
gson
.
fromJson
(
configuration
,
GsonType
.
CONFIG
);
}
}
}
}
apollo-common/src/main/java/com/ctrip/framework/apollo/common/constants/ReleaseOperationContext.java
View file @
db65452d
...
@@ -8,4 +8,5 @@ public interface ReleaseOperationContext {
...
@@ -8,4 +8,5 @@ public interface ReleaseOperationContext {
String
RULES
=
"rules"
;
String
RULES
=
"rules"
;
String
OLD_RULES
=
"oldRules"
;
String
OLD_RULES
=
"oldRules"
;
String
BASE_RELEASE_ID
=
"baseReleaseId"
;
String
BASE_RELEASE_ID
=
"baseReleaseId"
;
String
IS_EMERGENCY_PUBLISH
=
"isEmergencyPublish"
;
}
}
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/api/AdminServiceAPI.java
View file @
db65452d
...
@@ -230,31 +230,32 @@ public class AdminServiceAPI {
...
@@ -230,31 +230,32 @@ public class AdminServiceAPI {
}
}
public
ReleaseDTO
createRelease
(
String
appId
,
Env
env
,
String
clusterName
,
String
namespace
,
public
ReleaseDTO
createRelease
(
String
appId
,
Env
env
,
String
clusterName
,
String
namespace
,
String
releaseName
,
String
releaseComment
,
String
operator
)
{
String
releaseName
,
String
releaseComment
,
String
operator
,
boolean
isEmergencyPublish
)
{
HttpHeaders
headers
=
new
HttpHeaders
();
HttpHeaders
headers
=
new
HttpHeaders
();
headers
.
setContentType
(
MediaType
.
parseMediaType
(
MediaType
.
APPLICATION_FORM_URLENCODED_VALUE
+
";charset=UTF-8"
));
headers
.
setContentType
(
MediaType
.
parseMediaType
(
MediaType
.
APPLICATION_FORM_URLENCODED_VALUE
+
";charset=UTF-8"
));
MultiValueMap
<
String
,
String
>
parameters
=
new
LinkedMultiValueMap
<>();
MultiValueMap
<
String
,
String
>
parameters
=
new
LinkedMultiValueMap
<>();
parameters
.
add
(
"name"
,
releaseName
);
parameters
.
add
(
"name"
,
releaseName
);
parameters
.
add
(
"comment"
,
releaseComment
);
parameters
.
add
(
"comment"
,
releaseComment
);
parameters
.
add
(
"operator"
,
operator
);
parameters
.
add
(
"operator"
,
operator
);
parameters
.
add
(
"isEmergencyPublish"
,
String
.
valueOf
(
isEmergencyPublish
));
HttpEntity
<
MultiValueMap
<
String
,
String
>>
entity
=
HttpEntity
<
MultiValueMap
<
String
,
String
>>
entity
=
new
HttpEntity
<>(
parameters
,
headers
);
new
HttpEntity
<>(
parameters
,
headers
);
ReleaseDTO
response
=
restTemplate
.
post
(
ReleaseDTO
response
=
restTemplate
.
post
(
env
,
"apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName}/releases"
,
entity
,
env
,
"apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName}/releases"
,
entity
,
ReleaseDTO
.
class
,
ReleaseDTO
.
class
,
appId
,
clusterName
,
namespace
);
appId
,
clusterName
,
namespace
);
return
response
;
return
response
;
}
}
public
ReleaseDTO
updateAndPublish
(
String
appId
,
Env
env
,
String
clusterName
,
String
namespace
,
public
ReleaseDTO
updateAndPublish
(
String
appId
,
Env
env
,
String
clusterName
,
String
namespace
,
String
releaseName
,
String
releaseComment
,
String
branchName
,
String
releaseName
,
String
releaseComment
,
String
branchName
,
boolean
deleteBranch
,
ItemChangeSets
changeSets
)
{
boolean
isEmergencyPublish
,
boolean
deleteBranch
,
ItemChangeSets
changeSets
)
{
return
restTemplate
.
post
(
env
,
return
restTemplate
.
post
(
env
,
"apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName}/updateAndPublish?"
"apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName}/updateAndPublish?"
+
"releaseName={releaseName}&releaseComment={releaseComment}&branchName={branchName}&deleteBranch={deleteBranch}"
,
+
"releaseName={releaseName}&releaseComment={releaseComment}&branchName={branchName}"
changeSets
,
ReleaseDTO
.
class
,
+
"&deleteBranch={deleteBranch}&isEmergencyPublish={isEmergencyPublish}"
,
appId
,
clusterName
,
namespace
,
releaseName
,
releaseComment
,
branchName
,
deleteBranch
);
changeSets
,
ReleaseDTO
.
class
,
appId
,
clusterName
,
namespace
,
releaseName
,
releaseComment
,
branchName
,
deleteBranch
,
isEmergencyPublish
);
}
}
...
...
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/components/config/PortalConfig.java
View file @
db65452d
...
@@ -20,6 +20,7 @@ import org.springframework.util.StringUtils;
...
@@ -20,6 +20,7 @@ import org.springframework.util.StringUtils;
import
java.lang.reflect.Type
;
import
java.lang.reflect.Type
;
import
java.util.Collections
;
import
java.util.Collections
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Objects
;
import
java.util.Set
;
import
java.util.Set
;
@Component
@Component
...
@@ -97,6 +98,19 @@ public class PortalConfig extends RefreshableConfig {
...
@@ -97,6 +98,19 @@ public class PortalConfig extends RefreshableConfig {
return
getValue
(
"apollo.portal.address"
);
return
getValue
(
"apollo.portal.address"
);
}
}
public
boolean
isEmergencyPublishAllowed
(
Env
env
)
{
String
targetEnv
=
env
.
name
();
String
[]
emergencyPublishSupportedEnvs
=
getArrayProperty
(
"emergencyPublish.supported.envs"
,
new
String
[
0
]);
for
(
String
supportedEnv:
emergencyPublishSupportedEnvs
)
{
if
(
Objects
.
equals
(
targetEnv
,
supportedEnv
.
toUpperCase
().
trim
()))
{
return
true
;
}
}
return
false
;
}
/***
/***
* Level: low
* Level: low
...
...
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/components/emailbuilder/ConfigPublishEmailBuilder.java
View file @
db65452d
...
@@ -4,6 +4,7 @@ package com.ctrip.framework.apollo.portal.components.emailbuilder;
...
@@ -4,6 +4,7 @@ package com.ctrip.framework.apollo.portal.components.emailbuilder;
import
com.google.common.collect.Lists
;
import
com.google.common.collect.Lists
;
import
com.ctrip.framework.apollo.common.constants.ReleaseOperation
;
import
com.ctrip.framework.apollo.common.constants.ReleaseOperation
;
import
com.ctrip.framework.apollo.common.constants.ReleaseOperationContext
;
import
com.ctrip.framework.apollo.common.dto.ReleaseDTO
;
import
com.ctrip.framework.apollo.common.dto.ReleaseDTO
;
import
com.ctrip.framework.apollo.common.entity.AppNamespace
;
import
com.ctrip.framework.apollo.common.entity.AppNamespace
;
import
com.ctrip.framework.apollo.core.enums.ConfigFileFormat
;
import
com.ctrip.framework.apollo.core.enums.ConfigFileFormat
;
...
@@ -29,12 +30,15 @@ import java.util.ArrayList;
...
@@ -29,12 +30,15 @@ import java.util.ArrayList;
import
java.util.Collections
;
import
java.util.Collections
;
import
java.util.HashSet
;
import
java.util.HashSet
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Set
;
import
java.util.Set
;
import
java.util.regex.Matcher
;
import
java.util.regex.Matcher
;
public
abstract
class
ConfigPublishEmailBuilder
{
public
abstract
class
ConfigPublishEmailBuilder
{
private
static
final
String
EMERGENCY_PUBLISH_TAG
=
"<span style='color:red'>(紧急发布)</span>"
;
//email content common field placeholder
//email content common field placeholder
private
static
final
String
EMAIL_CONTENT_FIELD_APPID
=
"#\\{appId\\}"
;
private
static
final
String
EMAIL_CONTENT_FIELD_APPID
=
"#\\{appId\\}"
;
private
static
final
String
EMAIL_CONTENT_FIELD_ENV
=
"#\\{env}"
;
private
static
final
String
EMAIL_CONTENT_FIELD_ENV
=
"#\\{env}"
;
...
@@ -48,6 +52,7 @@ public abstract class ConfigPublishEmailBuilder {
...
@@ -48,6 +52,7 @@ public abstract class ConfigPublishEmailBuilder {
private
static
final
String
EMAIL_CONTENT_FIELD_RELEASE_COMMENT
=
"#\\{releaseComment}"
;
private
static
final
String
EMAIL_CONTENT_FIELD_RELEASE_COMMENT
=
"#\\{releaseComment}"
;
private
static
final
String
EMAIL_CONTENT_FIELD_APOLLO_SERVER_ADDRESS
=
"#\\{apollo.portal.address}"
;
private
static
final
String
EMAIL_CONTENT_FIELD_APOLLO_SERVER_ADDRESS
=
"#\\{apollo.portal.address}"
;
private
static
final
String
EMAIL_CONTENT_FIELD_DIFF_CONTENT
=
"#\\{diffContent}"
;
private
static
final
String
EMAIL_CONTENT_FIELD_DIFF_CONTENT
=
"#\\{diffContent}"
;
private
static
final
String
EMAIL_CONTENT_FIELD_EMERGENCY_PUBLISH
=
"#\\{emergencyPublish}"
;
private
static
final
String
EMAIL_CONTENT_DIFF_MODULE
=
"#\\{diffModule}"
;
private
static
final
String
EMAIL_CONTENT_DIFF_MODULE
=
"#\\{diffModule}"
;
protected
static
final
String
EMAIL_CONTENT_GRAY_RULES_MODULE
=
"#\\{rulesModule}"
;
protected
static
final
String
EMAIL_CONTENT_GRAY_RULES_MODULE
=
"#\\{rulesModule}"
;
...
@@ -118,7 +123,18 @@ public abstract class ConfigPublishEmailBuilder {
...
@@ -118,7 +123,18 @@ public abstract class ConfigPublishEmailBuilder {
}
}
private
String
renderReleaseBasicInfo
(
String
template
,
Env
env
,
ReleaseHistoryBO
releaseHistory
)
{
private
String
renderReleaseBasicInfo
(
String
template
,
Env
env
,
ReleaseHistoryBO
releaseHistory
)
{
String
renderResult
=
template
.
replaceAll
(
EMAIL_CONTENT_FIELD_APPID
,
Matcher
.
quoteReplacement
(
releaseHistory
.
getAppId
()));
String
renderResult
=
template
;
Map
<
String
,
Object
>
operationContext
=
releaseHistory
.
getOperationContext
();
boolean
isEmergencyPublish
=
operationContext
.
containsKey
(
ReleaseOperationContext
.
IS_EMERGENCY_PUBLISH
)
&&
(
boolean
)
operationContext
.
get
(
ReleaseOperationContext
.
IS_EMERGENCY_PUBLISH
);
if
(
isEmergencyPublish
)
{
renderResult
=
renderResult
.
replaceAll
(
EMAIL_CONTENT_FIELD_EMERGENCY_PUBLISH
,
Matcher
.
quoteReplacement
(
EMERGENCY_PUBLISH_TAG
));
}
else
{
renderResult
=
renderResult
.
replaceAll
(
EMAIL_CONTENT_FIELD_EMERGENCY_PUBLISH
,
""
);
}
renderResult
=
renderResult
.
replaceAll
(
EMAIL_CONTENT_FIELD_APPID
,
Matcher
.
quoteReplacement
(
releaseHistory
.
getAppId
()));
renderResult
=
renderResult
.
replaceAll
(
EMAIL_CONTENT_FIELD_ENV
,
Matcher
.
quoteReplacement
(
env
.
toString
()));
renderResult
=
renderResult
.
replaceAll
(
EMAIL_CONTENT_FIELD_ENV
,
Matcher
.
quoteReplacement
(
env
.
toString
()));
renderResult
=
renderResult
.
replaceAll
(
EMAIL_CONTENT_FIELD_CLUSTER
,
Matcher
.
quoteReplacement
(
releaseHistory
.
getClusterName
()));
renderResult
=
renderResult
.
replaceAll
(
EMAIL_CONTENT_FIELD_CLUSTER
,
Matcher
.
quoteReplacement
(
releaseHistory
.
getClusterName
()));
renderResult
=
renderResult
.
replaceAll
(
EMAIL_CONTENT_FIELD_NAMESPACE
,
Matcher
.
quoteReplacement
(
releaseHistory
.
getNamespaceName
()));
renderResult
=
renderResult
.
replaceAll
(
EMAIL_CONTENT_FIELD_NAMESPACE
,
Matcher
.
quoteReplacement
(
releaseHistory
.
getNamespaceName
()));
...
...
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/controller/NamespaceBranchController.java
View file @
db65452d
...
@@ -3,8 +3,10 @@ package com.ctrip.framework.apollo.portal.controller;
...
@@ -3,8 +3,10 @@ package com.ctrip.framework.apollo.portal.controller;
import
com.ctrip.framework.apollo.common.dto.GrayReleaseRuleDTO
;
import
com.ctrip.framework.apollo.common.dto.GrayReleaseRuleDTO
;
import
com.ctrip.framework.apollo.common.dto.NamespaceDTO
;
import
com.ctrip.framework.apollo.common.dto.NamespaceDTO
;
import
com.ctrip.framework.apollo.common.dto.ReleaseDTO
;
import
com.ctrip.framework.apollo.common.dto.ReleaseDTO
;
import
com.ctrip.framework.apollo.common.exception.BadRequestException
;
import
com.ctrip.framework.apollo.core.enums.Env
;
import
com.ctrip.framework.apollo.core.enums.Env
;
import
com.ctrip.framework.apollo.portal.components.PermissionValidator
;
import
com.ctrip.framework.apollo.portal.components.PermissionValidator
;
import
com.ctrip.framework.apollo.portal.components.config.PortalConfig
;
import
com.ctrip.framework.apollo.portal.entity.model.NamespaceReleaseModel
;
import
com.ctrip.framework.apollo.portal.entity.model.NamespaceReleaseModel
;
import
com.ctrip.framework.apollo.portal.entity.bo.NamespaceBO
;
import
com.ctrip.framework.apollo.portal.entity.bo.NamespaceBO
;
import
com.ctrip.framework.apollo.portal.listener.ConfigPublishEvent
;
import
com.ctrip.framework.apollo.portal.listener.ConfigPublishEvent
;
...
@@ -33,6 +35,8 @@ public class NamespaceBranchController {
...
@@ -33,6 +35,8 @@ public class NamespaceBranchController {
private
NamespaceBranchService
namespaceBranchService
;
private
NamespaceBranchService
namespaceBranchService
;
@Autowired
@Autowired
private
ApplicationEventPublisher
publisher
;
private
ApplicationEventPublisher
publisher
;
@Autowired
private
PortalConfig
portalConfig
;
@RequestMapping
(
"/apps/{appId}/envs/{env}/clusters/{clusterName}/namespaces/{namespaceName}/branches"
)
@RequestMapping
(
"/apps/{appId}/envs/{env}/clusters/{clusterName}/namespaces/{namespaceName}/branches"
)
public
NamespaceBO
findBranch
(
@PathVariable
String
appId
,
public
NamespaceBO
findBranch
(
@PathVariable
String
appId
,
...
@@ -84,8 +88,13 @@ public class NamespaceBranchController {
...
@@ -84,8 +88,13 @@ public class NamespaceBranchController {
@PathVariable
String
branchName
,
@RequestParam
(
value
=
"deleteBranch"
,
defaultValue
=
"true"
)
boolean
deleteBranch
,
@PathVariable
String
branchName
,
@RequestParam
(
value
=
"deleteBranch"
,
defaultValue
=
"true"
)
boolean
deleteBranch
,
@RequestBody
NamespaceReleaseModel
model
)
{
@RequestBody
NamespaceReleaseModel
model
)
{
if
(
model
.
isEmergencyPublish
()
&&
!
portalConfig
.
isEmergencyPublishAllowed
(
Env
.
fromString
(
env
)))
{
throw
new
BadRequestException
(
String
.
format
(
"Env: %s is not supported emergency publish now"
,
env
));
}
ReleaseDTO
createdRelease
=
namespaceBranchService
.
merge
(
appId
,
Env
.
valueOf
(
env
),
clusterName
,
namespaceName
,
branchName
,
ReleaseDTO
createdRelease
=
namespaceBranchService
.
merge
(
appId
,
Env
.
valueOf
(
env
),
clusterName
,
namespaceName
,
branchName
,
model
.
getReleaseTitle
(),
model
.
getReleaseComment
(),
deleteBranch
);
model
.
getReleaseTitle
(),
model
.
getReleaseComment
(),
model
.
isEmergencyPublish
(),
deleteBranch
);
ConfigPublishEvent
event
=
ConfigPublishEvent
.
instance
();
ConfigPublishEvent
event
=
ConfigPublishEvent
.
instance
();
event
.
withAppId
(
appId
)
event
.
withAppId
(
appId
)
...
...
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/controller/NamespaceLockController.java
View file @
db65452d
...
@@ -2,6 +2,7 @@ package com.ctrip.framework.apollo.portal.controller;
...
@@ -2,6 +2,7 @@ package com.ctrip.framework.apollo.portal.controller;
import
com.ctrip.framework.apollo.common.dto.NamespaceLockDTO
;
import
com.ctrip.framework.apollo.common.dto.NamespaceLockDTO
;
import
com.ctrip.framework.apollo.core.enums.Env
;
import
com.ctrip.framework.apollo.core.enums.Env
;
import
com.ctrip.framework.apollo.portal.entity.vo.LockInfo
;
import
com.ctrip.framework.apollo.portal.service.NamespaceLockService
;
import
com.ctrip.framework.apollo.portal.service.NamespaceLockService
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
@@ -15,6 +16,7 @@ public class NamespaceLockController {
...
@@ -15,6 +16,7 @@ public class NamespaceLockController {
@Autowired
@Autowired
private
NamespaceLockService
namespaceLockService
;
private
NamespaceLockService
namespaceLockService
;
@Deprecated
@RequestMapping
(
"/apps/{appId}/envs/{env}/clusters/{clusterName}/namespaces/{namespaceName}/lock"
)
@RequestMapping
(
"/apps/{appId}/envs/{env}/clusters/{clusterName}/namespaces/{namespaceName}/lock"
)
public
NamespaceLockDTO
getNamespaceLock
(
@PathVariable
String
appId
,
@PathVariable
String
env
,
public
NamespaceLockDTO
getNamespaceLock
(
@PathVariable
String
appId
,
@PathVariable
String
env
,
@PathVariable
String
clusterName
,
@PathVariable
String
namespaceName
)
{
@PathVariable
String
clusterName
,
@PathVariable
String
namespaceName
)
{
...
@@ -22,4 +24,13 @@ public class NamespaceLockController {
...
@@ -22,4 +24,13 @@ public class NamespaceLockController {
return
namespaceLockService
.
getNamespaceLock
(
appId
,
Env
.
valueOf
(
env
),
clusterName
,
namespaceName
);
return
namespaceLockService
.
getNamespaceLock
(
appId
,
Env
.
valueOf
(
env
),
clusterName
,
namespaceName
);
}
}
@RequestMapping
(
"/apps/{appId}/envs/{env}/clusters/{clusterName}/namespaces/{namespaceName}/lock-info"
)
public
LockInfo
getNamespaceLockInfo
(
@PathVariable
String
appId
,
@PathVariable
String
env
,
@PathVariable
String
clusterName
,
@PathVariable
String
namespaceName
)
{
return
namespaceLockService
.
getNamespaceLockInfo
(
appId
,
Env
.
fromString
(
env
),
clusterName
,
namespaceName
);
}
}
}
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/controller/ReleaseController.java
View file @
db65452d
package
com
.
ctrip
.
framework
.
apollo
.
portal
.
controller
;
package
com
.
ctrip
.
framework
.
apollo
.
portal
.
controller
;
import
com.ctrip.framework.apollo.common.dto.ReleaseDTO
;
import
com.ctrip.framework.apollo.common.dto.ReleaseDTO
;
import
com.ctrip.framework.apollo.common.exception.BadRequestException
;
import
com.ctrip.framework.apollo.common.utils.RequestPrecondition
;
import
com.ctrip.framework.apollo.common.utils.RequestPrecondition
;
import
com.ctrip.framework.apollo.core.enums.Env
;
import
com.ctrip.framework.apollo.core.enums.Env
;
import
com.ctrip.framework.apollo.portal.components.config.PortalConfig
;
import
com.ctrip.framework.apollo.portal.entity.model.NamespaceReleaseModel
;
import
com.ctrip.framework.apollo.portal.entity.model.NamespaceReleaseModel
;
import
com.ctrip.framework.apollo.portal.entity.vo.ReleaseCompareResult
;
import
com.ctrip.framework.apollo.portal.entity.vo.ReleaseCompareResult
;
import
com.ctrip.framework.apollo.portal.entity.bo.ReleaseBO
;
import
com.ctrip.framework.apollo.portal.entity.bo.ReleaseBO
;
...
@@ -30,6 +32,8 @@ public class ReleaseController {
...
@@ -30,6 +32,8 @@ public class ReleaseController {
private
ReleaseService
releaseService
;
private
ReleaseService
releaseService
;
@Autowired
@Autowired
private
ApplicationEventPublisher
publisher
;
private
ApplicationEventPublisher
publisher
;
@Autowired
private
PortalConfig
portalConfig
;
@PreAuthorize
(
value
=
"@permissionValidator.hasReleaseNamespacePermission(#appId, #namespaceName)"
)
@PreAuthorize
(
value
=
"@permissionValidator.hasReleaseNamespacePermission(#appId, #namespaceName)"
)
@RequestMapping
(
value
=
"/apps/{appId}/envs/{env}/clusters/{clusterName}/namespaces/{namespaceName}/releases"
,
method
=
RequestMethod
.
POST
)
@RequestMapping
(
value
=
"/apps/{appId}/envs/{env}/clusters/{clusterName}/namespaces/{namespaceName}/releases"
,
method
=
RequestMethod
.
POST
)
...
@@ -43,6 +47,10 @@ public class ReleaseController {
...
@@ -43,6 +47,10 @@ public class ReleaseController {
model
.
setClusterName
(
clusterName
);
model
.
setClusterName
(
clusterName
);
model
.
setNamespaceName
(
namespaceName
);
model
.
setNamespaceName
(
namespaceName
);
if
(
model
.
isEmergencyPublish
()
&&
!
portalConfig
.
isEmergencyPublishAllowed
(
Env
.
valueOf
(
env
)))
{
throw
new
BadRequestException
(
String
.
format
(
"Env: %s is not supported emergency publish now"
,
env
));
}
ReleaseDTO
createdRelease
=
releaseService
.
publish
(
model
);
ReleaseDTO
createdRelease
=
releaseService
.
publish
(
model
);
ConfigPublishEvent
event
=
ConfigPublishEvent
.
instance
();
ConfigPublishEvent
event
=
ConfigPublishEvent
.
instance
();
...
@@ -72,6 +80,10 @@ public class ReleaseController {
...
@@ -72,6 +80,10 @@ public class ReleaseController {
model
.
setClusterName
(
branchName
);
model
.
setClusterName
(
branchName
);
model
.
setNamespaceName
(
namespaceName
);
model
.
setNamespaceName
(
namespaceName
);
if
(
model
.
isEmergencyPublish
()
&&
!
portalConfig
.
isEmergencyPublishAllowed
(
Env
.
valueOf
(
env
)))
{
throw
new
BadRequestException
(
String
.
format
(
"Env: %s is not supported emergency publish now"
,
env
));
}
ReleaseDTO
createdRelease
=
releaseService
.
publish
(
model
);
ReleaseDTO
createdRelease
=
releaseService
.
publish
(
model
);
ConfigPublishEvent
event
=
ConfigPublishEvent
.
instance
();
ConfigPublishEvent
event
=
ConfigPublishEvent
.
instance
();
...
...
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/model/NamespaceReleaseModel.java
View file @
db65452d
...
@@ -13,6 +13,7 @@ public class NamespaceReleaseModel implements Verifiable {
...
@@ -13,6 +13,7 @@ public class NamespaceReleaseModel implements Verifiable {
private
String
releaseTitle
;
private
String
releaseTitle
;
private
String
releaseComment
;
private
String
releaseComment
;
private
String
releasedBy
;
private
String
releasedBy
;
private
boolean
isEmergencyPublish
;
@Override
@Override
public
boolean
isInvalid
()
{
public
boolean
isInvalid
()
{
...
@@ -74,4 +75,12 @@ public class NamespaceReleaseModel implements Verifiable {
...
@@ -74,4 +75,12 @@ public class NamespaceReleaseModel implements Verifiable {
public
void
setReleasedBy
(
String
releasedBy
)
{
public
void
setReleasedBy
(
String
releasedBy
)
{
this
.
releasedBy
=
releasedBy
;
this
.
releasedBy
=
releasedBy
;
}
}
public
boolean
isEmergencyPublish
()
{
return
isEmergencyPublish
;
}
public
void
setEmergencyPublish
(
boolean
emergencyPublish
)
{
isEmergencyPublish
=
emergencyPublish
;
}
}
}
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/vo/LockInfo.java
0 → 100644
View file @
db65452d
package
com
.
ctrip
.
framework
.
apollo
.
portal
.
entity
.
vo
;
public
class
LockInfo
{
private
String
lockOwner
;
private
boolean
isEmergencyPublishAllowed
;
public
String
getLockOwner
()
{
return
lockOwner
;
}
public
void
setLockOwner
(
String
lockOwner
)
{
this
.
lockOwner
=
lockOwner
;
}
public
boolean
isEmergencyPublishAllowed
()
{
return
isEmergencyPublishAllowed
;
}
public
void
setEmergencyPublishAllowed
(
boolean
emergencyPublishAllowed
)
{
isEmergencyPublishAllowed
=
emergencyPublishAllowed
;
}
}
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/service/NamespaceBranchService.java
View file @
db65452d
...
@@ -84,13 +84,14 @@ public class NamespaceBranchService {
...
@@ -84,13 +84,14 @@ public class NamespaceBranchService {
public
ReleaseDTO
merge
(
String
appId
,
Env
env
,
String
clusterName
,
String
namespaceName
,
public
ReleaseDTO
merge
(
String
appId
,
Env
env
,
String
clusterName
,
String
namespaceName
,
String
branchName
,
String
title
,
String
comment
,
boolean
deleteBranch
)
{
String
branchName
,
String
title
,
String
comment
,
boolean
isEmergencyPublish
,
boolean
deleteBranch
)
{
ItemChangeSets
changeSets
=
calculateBranchChangeSet
(
appId
,
env
,
clusterName
,
namespaceName
,
branchName
);
ItemChangeSets
changeSets
=
calculateBranchChangeSet
(
appId
,
env
,
clusterName
,
namespaceName
,
branchName
);
ReleaseDTO
ReleaseDTO
mergedResult
=
mergedResult
=
releaseService
.
updateAndPublish
(
appId
,
env
,
clusterName
,
namespaceName
,
title
,
comment
,
releaseService
.
updateAndPublish
(
appId
,
env
,
clusterName
,
namespaceName
,
title
,
comment
,
branchName
,
deleteBranch
,
changeSets
);
branchName
,
isEmergencyPublish
,
deleteBranch
,
changeSets
);
Tracer
.
logEvent
(
CatEventType
.
MERGE_GRAY_RELEASE
,
Tracer
.
logEvent
(
CatEventType
.
MERGE_GRAY_RELEASE
,
String
.
format
(
"%s+%s+%s+%s"
,
appId
,
env
,
clusterName
,
namespaceName
));
String
.
format
(
"%s+%s+%s+%s"
,
appId
,
env
,
clusterName
,
namespaceName
));
...
...
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/service/NamespaceLockService.java
View file @
db65452d
...
@@ -3,6 +3,8 @@ package com.ctrip.framework.apollo.portal.service;
...
@@ -3,6 +3,8 @@ package com.ctrip.framework.apollo.portal.service;
import
com.ctrip.framework.apollo.common.dto.NamespaceLockDTO
;
import
com.ctrip.framework.apollo.common.dto.NamespaceLockDTO
;
import
com.ctrip.framework.apollo.core.enums.Env
;
import
com.ctrip.framework.apollo.core.enums.Env
;
import
com.ctrip.framework.apollo.portal.api.AdminServiceAPI
;
import
com.ctrip.framework.apollo.portal.api.AdminServiceAPI
;
import
com.ctrip.framework.apollo.portal.components.config.PortalConfig
;
import
com.ctrip.framework.apollo.portal.entity.vo.LockInfo
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
...
@@ -12,10 +14,24 @@ public class NamespaceLockService {
...
@@ -12,10 +14,24 @@ public class NamespaceLockService {
@Autowired
@Autowired
private
AdminServiceAPI
.
NamespaceLockAPI
namespaceLockAPI
;
private
AdminServiceAPI
.
NamespaceLockAPI
namespaceLockAPI
;
@Autowired
private
PortalConfig
portalConfig
;
public
NamespaceLockDTO
getNamespaceLock
(
String
appId
,
Env
env
,
String
clusterName
,
String
namespaceName
)
{
public
NamespaceLockDTO
getNamespaceLock
(
String
appId
,
Env
env
,
String
clusterName
,
String
namespaceName
)
{
return
namespaceLockAPI
.
getNamespaceLockOwner
(
appId
,
env
,
clusterName
,
namespaceName
);
return
namespaceLockAPI
.
getNamespaceLockOwner
(
appId
,
env
,
clusterName
,
namespaceName
);
}
public
LockInfo
getNamespaceLockInfo
(
String
appId
,
Env
env
,
String
clusterName
,
String
namespaceName
)
{
LockInfo
lockInfo
=
new
LockInfo
();
NamespaceLockDTO
namespaceLockDTO
=
namespaceLockAPI
.
getNamespaceLockOwner
(
appId
,
env
,
clusterName
,
namespaceName
);
String
lockOwner
=
namespaceLockDTO
==
null
?
""
:
namespaceLockDTO
.
getDataChangeCreatedBy
();
lockInfo
.
setLockOwner
(
lockOwner
);
lockInfo
.
setEmergencyPublishAllowed
(
portalConfig
.
isEmergencyPublishAllowed
(
env
));
return
lockInfo
;
}
}
}
}
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/service/ReleaseService.java
View file @
db65452d
...
@@ -42,27 +42,30 @@ public class ReleaseService {
...
@@ -42,27 +42,30 @@ public class ReleaseService {
private
AdminServiceAPI
.
ReleaseAPI
releaseAPI
;
private
AdminServiceAPI
.
ReleaseAPI
releaseAPI
;
public
ReleaseDTO
publish
(
NamespaceReleaseModel
model
)
{
public
ReleaseDTO
publish
(
NamespaceReleaseModel
model
)
{
String
appId
=
model
.
getAppId
();
Env
env
=
model
.
getEnv
();
Env
env
=
model
.
getEnv
();
boolean
isEmergencyPublish
=
model
.
isEmergencyPublish
();
String
appId
=
model
.
getAppId
();
String
clusterName
=
model
.
getClusterName
();
String
clusterName
=
model
.
getClusterName
();
String
namespaceName
=
model
.
getNamespaceName
();
String
namespaceName
=
model
.
getNamespaceName
();
String
releaseBy
=
String
releaseBy
=
StringUtils
.
isEmpty
(
model
.
getReleasedBy
())
?
StringUtils
.
isEmpty
(
model
.
getReleasedBy
())
?
userInfoHolder
.
getUser
().
getUserId
()
:
model
.
getReleasedBy
();
userInfoHolder
.
getUser
().
getUserId
()
:
model
.
getReleasedBy
();
ReleaseDTO
releaseDTO
=
releaseAPI
.
createRelease
(
appId
,
env
,
clusterName
,
namespaceName
,
model
.
getReleaseTitle
(),
model
.
getReleaseComment
(),
releaseBy
,
isEmergencyPublish
);
ReleaseDTO
releaseDTO
=
releaseAPI
Tracer
.
logEvent
(
CatEventType
.
RELEASE_NAMESPACE
,
.
createRelease
(
appId
,
env
,
clusterName
,
namespaceName
,
model
.
getReleaseTitle
(),
model
.
getReleaseComment
()
String
.
format
(
"%s+%s+%s+%s"
,
appId
,
env
,
clusterName
,
namespaceName
));
,
releaseBy
);
Tracer
.
logEvent
(
CatEventType
.
RELEASE_NAMESPACE
,
String
.
format
(
"%s+%s+%s+%s"
,
appId
,
env
,
clusterName
,
namespaceName
));
return
releaseDTO
;
return
releaseDTO
;
}
}
public
ReleaseDTO
updateAndPublish
(
String
appId
,
Env
env
,
String
clusterName
,
String
namespaceName
,
public
ReleaseDTO
updateAndPublish
(
String
appId
,
Env
env
,
String
clusterName
,
String
namespaceName
,
String
releaseTitle
,
String
releaseComment
,
String
branchName
,
String
releaseTitle
,
String
releaseComment
,
String
branchName
,
boolean
deleteBranch
,
ItemChangeSets
changeSets
)
{
boolean
isEmergencyPublish
,
boolean
deleteBranch
,
ItemChangeSets
changeSets
)
{
return
releaseAPI
.
updateAndPublish
(
appId
,
env
,
clusterName
,
namespaceName
,
releaseTitle
,
releaseComment
,
branchName
,
return
releaseAPI
.
updateAndPublish
(
appId
,
env
,
clusterName
,
namespaceName
,
releaseTitle
,
releaseComment
,
branchName
,
deleteBranch
,
changeSets
);
isEmergencyPublish
,
deleteBranch
,
changeSets
);
}
}
public
List
<
ReleaseBO
>
findAllReleases
(
String
appId
,
Env
env
,
String
clusterName
,
String
namespaceName
,
int
page
,
public
List
<
ReleaseBO
>
findAllReleases
(
String
appId
,
Env
env
,
String
clusterName
,
String
namespaceName
,
int
page
,
...
...
apollo-portal/src/main/resources/static/config.html
View file @
db65452d
...
@@ -229,6 +229,7 @@
...
@@ -229,6 +229,7 @@
cluster=
"pageContext.clusterName"
>
cluster=
"pageContext.clusterName"
>
</mergeandpublishmodal>
</mergeandpublishmodal>
<publishdenymodal></publishdenymodal>
<apolloconfirmdialog
apollo-dialog-id=
"'deleteConfirmDialog'"
apollo-title=
"'删除配置'"
<apolloconfirmdialog
apollo-dialog-id=
"'deleteConfirmDialog'"
apollo-title=
"'删除配置'"
apollo-detail=
"'确定要删除配置吗?'"
apollo-detail=
"'确定要删除配置吗?'"
...
@@ -251,10 +252,6 @@
...
@@ -251,10 +252,6 @@
apollo-detail=
"'当前namespace正在被 ' + lockOwner + ' 编辑,一次发布只能被一个人修改.'"
apollo-detail=
"'当前namespace正在被 ' + lockOwner + ' 编辑,一次发布只能被一个人修改.'"
apollo-show-cancel-btn=
"false"
></apolloconfirmdialog>
apollo-show-cancel-btn=
"false"
></apolloconfirmdialog>
<apolloconfirmdialog
apollo-dialog-id=
"'releaseDenyDialog'"
apollo-title=
"'发布受限'"
apollo-detail=
"'您不能发布哟~ ' + pageContext.env + '环境配置的编辑和发布必须为不同的人,请找另一个具有当前namespace发布权的人操作发布~'"
apollo-show-cancel-btn=
"false"
></apolloconfirmdialog>
<apolloconfirmdialog
apollo-dialog-id=
"'rollbackAlertDialog'"
apollo-title=
"'回滚'"
<apolloconfirmdialog
apollo-dialog-id=
"'rollbackAlertDialog'"
apollo-title=
"'回滚'"
apollo-detail=
"'确定要回滚吗?'"
apollo-detail=
"'确定要回滚吗?'"
apollo-show-cancel-btn=
"true"
apollo-confirm=
"rollback"
></apolloconfirmdialog>
apollo-show-cancel-btn=
"true"
apollo-confirm=
"rollback"
></apolloconfirmdialog>
...
@@ -373,6 +370,7 @@
...
@@ -373,6 +370,7 @@
<script
type=
"application/javascript"
src=
"scripts/directive/rollback-modal-directive.js"
></script>
<script
type=
"application/javascript"
src=
"scripts/directive/rollback-modal-directive.js"
></script>
<script
type=
"application/javascript"
src=
"scripts/directive/gray-release-rules-modal-directive.js"
></script>
<script
type=
"application/javascript"
src=
"scripts/directive/gray-release-rules-modal-directive.js"
></script>
<script
type=
"application/javascript"
src=
"scripts/directive/merge-and-publish-modal-directive.js"
></script>
<script
type=
"application/javascript"
src=
"scripts/directive/merge-and-publish-modal-directive.js"
></script>
<script
type=
"application/javascript"
src=
"scripts/directive/publish-deny-modal-directive.js"
></script>
<!--controller-->
<!--controller-->
<script
type=
"application/javascript"
src=
"scripts/controller/config/ConfigNamespaceController.js"
></script>
<script
type=
"application/javascript"
src=
"scripts/controller/config/ConfigNamespaceController.js"
></script>
...
...
apollo-portal/src/main/resources/static/config/history.html
View file @
db65452d
...
@@ -75,7 +75,8 @@
...
@@ -75,7 +75,8 @@
<h5
class=
"col-md-7 word-break"
ng-show=
"releaseHistory.operation == 8"
>
删除灰度(全量发布)
</h5>
<h5
class=
"col-md-7 word-break"
ng-show=
"releaseHistory.operation == 8"
>
删除灰度(全量发布)
</h5>
<h6
class=
"col-md-5 text-right"
ng-bind=
"releaseHistory.releaseTimeFormatted"
></h6>
<h6
class=
"col-md-5 text-right"
ng-bind=
"releaseHistory.releaseTimeFormatted"
></h6>
<span
class=
"label label-warning no-radius emergency-publish"
ng-if=
"releaseHistory.operationContext.isEmergencyPublish"
>
紧急发布
</span>
</div>
</div>
</div>
</div>
...
...
apollo-portal/src/main/resources/static/scripts/directive/merge-and-publish-modal-directive.js
View file @
db65452d
...
@@ -20,6 +20,8 @@ function mergeAndPublishDirective(AppUtil, EventManager) {
...
@@ -20,6 +20,8 @@ function mergeAndPublishDirective(AppUtil, EventManager) {
var
branch
=
context
.
branch
;
var
branch
=
context
.
branch
;
scope
.
toReleaseNamespace
=
branch
;
scope
.
toReleaseNamespace
=
branch
;
scope
.
toDeleteBranch
=
branch
;
scope
.
toDeleteBranch
=
branch
;
scope
.
isEmergencyPublish
=
context
.
isEmergencyPublish
?
context
.
isEmergencyPublish
:
false
;
var
branchStatusMerge
=
2
;
var
branchStatusMerge
=
2
;
branch
.
branchStatus
=
branchStatusMerge
;
branch
.
branchStatus
=
branchStatusMerge
;
...
@@ -28,9 +30,12 @@ function mergeAndPublishDirective(AppUtil, EventManager) {
...
@@ -28,9 +30,12 @@ function mergeAndPublishDirective(AppUtil, EventManager) {
AppUtil
.
showModal
(
'#mergeAndPublishModal'
);
AppUtil
.
showModal
(
'#mergeAndPublishModal'
);
});
});
function
showReleaseModal
()
{
function
showReleaseModal
()
{
EventManager
.
emit
(
EventManager
.
EventType
.
PUBLISH_NAMESPACE
,
{
namespace
:
scope
.
toReleaseNamespace
});
EventManager
.
emit
(
EventManager
.
EventType
.
PUBLISH_NAMESPACE
,
{
namespace
:
scope
.
toReleaseNamespace
,
isEmergencyPublish
:
scope
.
isEmergencyPublish
});
}
}
}
}
...
...
apollo-portal/src/main/resources/static/scripts/directive/namespace-panel-directive.js
View file @
db65452d
...
@@ -279,16 +279,12 @@ function directive($window, toastr, AppUtil, EventManager, PermissionService, Na
...
@@ -279,16 +279,12 @@ function directive($window, toastr, AppUtil, EventManager, PermissionService, Na
}
}
function
initNamespaceLock
(
namespace
)
{
function
initNamespaceLock
(
namespace
)
{
NamespaceLockService
.
get_namespace_lock
(
NamespaceLockService
.
get_namespace_lock
(
scope
.
appId
,
scope
.
env
,
scope
.
appId
,
scope
.
env
,
namespace
.
baseInfo
.
clusterName
,
namespace
.
baseInfo
.
clusterName
,
namespace
.
baseInfo
.
namespaceName
)
namespace
.
baseInfo
.
namespaceName
)
.
then
(
function
(
result
)
{
.
then
(
function
(
result
)
{
if
(
result
.
dataChangeCreatedBy
)
{
namespace
.
lockOwner
=
result
.
lockOwner
;
namespace
.
lockOwner
=
result
.
dataChangeCreatedBy
;
namespace
.
isEmergencyPublishAllowed
=
result
.
isEmergencyPublishAllowed
;
}
else
{
namespace
.
lockOwner
=
""
;
}
});
});
}
}
...
@@ -748,7 +744,10 @@ function directive($window, toastr, AppUtil, EventManager, PermissionService, Na
...
@@ -748,7 +744,10 @@ function directive($window, toastr, AppUtil, EventManager, PermissionService, Na
return
;
return
;
}
else
if
(
namespace
.
lockOwner
&&
scope
.
user
==
namespace
.
lockOwner
)
{
}
else
if
(
namespace
.
lockOwner
&&
scope
.
user
==
namespace
.
lockOwner
)
{
//can not publish if config modified by himself
//can not publish if config modified by himself
AppUtil
.
showModal
(
'#releaseDenyDialog'
);
EventManager
.
emit
(
EventManager
.
EventType
.
PUBLISH_DENY
,
{
namespace
:
namespace
,
mergeAndPublish
:
false
});
return
;
return
;
}
}
...
@@ -766,12 +765,14 @@ function directive($window, toastr, AppUtil, EventManager, PermissionService, Na
...
@@ -766,12 +765,14 @@ function directive($window, toastr, AppUtil, EventManager, PermissionService, Na
var
parentNamespace
=
branch
.
parentNamespace
;
var
parentNamespace
=
branch
.
parentNamespace
;
if
(
!
parentNamespace
.
hasReleasePermission
)
{
if
(
!
parentNamespace
.
hasReleasePermission
)
{
AppUtil
.
showModal
(
'#releaseNoPermissionDialog'
);
AppUtil
.
showModal
(
'#releaseNoPermissionDialog'
);
}
else
if
(
branch
.
lockOwner
&&
scope
.
user
==
branch
.
lockOwner
)
{
AppUtil
.
showModal
(
'#releaseDenyDialog'
);
}
else
if
(
parentNamespace
.
itemModifiedCnt
>
0
)
{
}
else
if
(
parentNamespace
.
itemModifiedCnt
>
0
)
{
AppUtil
.
showModal
(
'#mergeAndReleaseDenyDialog'
);
AppUtil
.
showModal
(
'#mergeAndReleaseDenyDialog'
);
}
}
else
if
(
branch
.
lockOwner
&&
scope
.
user
==
branch
.
lockOwner
)
{
else
{
EventManager
.
emit
(
EventManager
.
EventType
.
PUBLISH_DENY
,
{
namespace
:
branch
,
mergeAndPublish
:
true
});
}
else
{
EventManager
.
emit
(
EventManager
.
EventType
.
MERGE_AND_PUBLISH_NAMESPACE
,
{
branch
:
branch
});
EventManager
.
emit
(
EventManager
.
EventType
.
MERGE_AND_PUBLISH_NAMESPACE
,
{
branch
:
branch
});
}
}
}
}
...
...
apollo-portal/src/main/resources/static/scripts/directive/publish-deny-modal-directive.js
0 → 100644
View file @
db65452d
directive_module
.
directive
(
'publishdenymodal'
,
publishDenyDirective
);
function
publishDenyDirective
(
AppUtil
,
EventManager
)
{
return
{
restrict
:
'E'
,
templateUrl
:
'../../views/component/publish-deny-modal.html'
,
transclude
:
true
,
replace
:
true
,
scope
:
{
},
link
:
function
(
scope
)
{
var
MODAL_ID
=
"#publishDenyModal"
;
EventManager
.
subscribe
(
EventManager
.
EventType
.
PUBLISH_DENY
,
function
(
context
)
{
scope
.
toReleaseNamespace
=
context
.
namespace
;
scope
.
mergeAndPublish
=
!!
context
.
mergeAndPublish
;
AppUtil
.
showModal
(
MODAL_ID
);
});
scope
.
emergencyPublish
=
emergencyPublish
;
function
emergencyPublish
()
{
AppUtil
.
hideModal
(
MODAL_ID
);
if
(
scope
.
mergeAndPublish
)
{
EventManager
.
emit
(
EventManager
.
EventType
.
MERGE_AND_PUBLISH_NAMESPACE
,
{
branch
:
scope
.
toReleaseNamespace
,
isEmergencyPublish
:
true
});
}
else
{
EventManager
.
emit
(
EventManager
.
EventType
.
PUBLISH_NAMESPACE
,
{
namespace
:
scope
.
toReleaseNamespace
,
isEmergencyPublish
:
true
});
}
}
}
}
}
apollo-portal/src/main/resources/static/scripts/directive/release-modal-directive.js
View file @
db65452d
...
@@ -19,12 +19,14 @@ function releaseModalDirective(toastr, AppUtil, EventManager, ReleaseService, Na
...
@@ -19,12 +19,14 @@ function releaseModalDirective(toastr, AppUtil, EventManager, ReleaseService, Na
scope
.
releaseBtnDisabled
=
false
;
scope
.
releaseBtnDisabled
=
false
;
scope
.
releaseChangeViewType
=
'change'
;
scope
.
releaseChangeViewType
=
'change'
;
scope
.
releaseComment
=
''
;
scope
.
releaseComment
=
''
;
scope
.
isEmergencyPublish
=
false
;
EventManager
.
subscribe
(
EventManager
.
EventType
.
PUBLISH_NAMESPACE
,
EventManager
.
subscribe
(
EventManager
.
EventType
.
PUBLISH_NAMESPACE
,
function
(
context
)
{
function
(
context
)
{
var
namespace
=
context
.
namespace
;
var
namespace
=
context
.
namespace
;
scope
.
toReleaseNamespace
=
context
.
namespace
;
scope
.
toReleaseNamespace
=
context
.
namespace
;
scope
.
isEmergencyPublish
=
!!
context
.
isEmergencyPublish
;
var
date
=
new
Date
().
Format
(
"yyyyMMddhhmmss"
);
var
date
=
new
Date
().
Format
(
"yyyyMMddhhmmss"
);
if
(
namespace
.
mergeAndPublish
)
{
if
(
namespace
.
mergeAndPublish
)
{
...
@@ -55,7 +57,8 @@ function releaseModalDirective(toastr, AppUtil, EventManager, ReleaseService, Na
...
@@ -55,7 +57,8 @@ function releaseModalDirective(toastr, AppUtil, EventManager, ReleaseService, Na
scope
.
toReleaseNamespace
.
baseInfo
.
clusterName
,
scope
.
toReleaseNamespace
.
baseInfo
.
clusterName
,
scope
.
toReleaseNamespace
.
baseInfo
.
namespaceName
,
scope
.
toReleaseNamespace
.
baseInfo
.
namespaceName
,
scope
.
toReleaseNamespace
.
releaseTitle
,
scope
.
toReleaseNamespace
.
releaseTitle
,
scope
.
releaseComment
).
then
(
scope
.
releaseComment
,
scope
.
isEmergencyPublish
).
then
(
function
(
result
)
{
function
(
result
)
{
AppUtil
.
hideModal
(
'#releaseModal'
);
AppUtil
.
hideModal
(
'#releaseModal'
);
toastr
.
success
(
"发布成功"
);
toastr
.
success
(
"发布成功"
);
...
@@ -83,7 +86,8 @@ function releaseModalDirective(toastr, AppUtil, EventManager, ReleaseService, Na
...
@@ -83,7 +86,8 @@ function releaseModalDirective(toastr, AppUtil, EventManager, ReleaseService, Na
scope
.
toReleaseNamespace
.
baseInfo
.
namespaceName
,
scope
.
toReleaseNamespace
.
baseInfo
.
namespaceName
,
scope
.
toReleaseNamespace
.
baseInfo
.
clusterName
,
scope
.
toReleaseNamespace
.
baseInfo
.
clusterName
,
scope
.
toReleaseNamespace
.
releaseTitle
,
scope
.
toReleaseNamespace
.
releaseTitle
,
scope
.
releaseComment
).
then
(
scope
.
releaseComment
,
scope
.
isEmergencyPublish
).
then
(
function
(
result
)
{
function
(
result
)
{
AppUtil
.
hideModal
(
'#releaseModal'
);
AppUtil
.
hideModal
(
'#releaseModal'
);
toastr
.
success
(
"灰度发布成功"
);
toastr
.
success
(
"灰度发布成功"
);
...
@@ -98,7 +102,9 @@ function releaseModalDirective(toastr, AppUtil, EventManager, ReleaseService, Na
...
@@ -98,7 +102,9 @@ function releaseModalDirective(toastr, AppUtil, EventManager, ReleaseService, Na
item
.
isModified
=
false
;
item
.
isModified
=
false
;
}
}
});
});
//reset namespace status
scope
.
toReleaseNamespace
.
itemModifiedCnt
=
0
;
scope
.
toReleaseNamespace
.
itemModifiedCnt
=
0
;
scope
.
toReleaseNamespace
.
lockOwner
=
undefined
;
//check rules
//check rules
if
(
!
scope
.
toReleaseNamespace
.
rules
if
(
!
scope
.
toReleaseNamespace
.
rules
...
@@ -125,6 +131,7 @@ function releaseModalDirective(toastr, AppUtil, EventManager, ReleaseService, Na
...
@@ -125,6 +131,7 @@ function releaseModalDirective(toastr, AppUtil, EventManager, ReleaseService, Na
scope
.
toReleaseNamespace
.
baseInfo
.
clusterName
,
scope
.
toReleaseNamespace
.
baseInfo
.
clusterName
,
scope
.
toReleaseNamespace
.
releaseTitle
,
scope
.
toReleaseNamespace
.
releaseTitle
,
scope
.
releaseComment
,
scope
.
releaseComment
,
scope
.
isEmergencyPublish
,
scope
.
toReleaseNamespace
.
mergeAfterDeleteBranch
)
scope
.
toReleaseNamespace
.
mergeAfterDeleteBranch
)
.
then
(
function
(
result
)
{
.
then
(
function
(
result
)
{
...
...
apollo-portal/src/main/resources/static/scripts/services/EventManager.js
View file @
db65452d
...
@@ -131,7 +131,8 @@ appService.service('EventManager', [function () {
...
@@ -131,7 +131,8 @@ appService.service('EventManager', [function () {
PRE_ROLLBACK_NAMESPACE
:
'pre_rollback_namespace'
,
PRE_ROLLBACK_NAMESPACE
:
'pre_rollback_namespace'
,
ROLLBACK_NAMESPACE
:
'rollback_namespace'
,
ROLLBACK_NAMESPACE
:
'rollback_namespace'
,
EDIT_GRAY_RELEASE_RULES
:
'edit_gray_release_rules'
,
EDIT_GRAY_RELEASE_RULES
:
'edit_gray_release_rules'
,
UPDATE_GRAY_RELEASE_RULES
:
'update_gray_release_rules'
UPDATE_GRAY_RELEASE_RULES
:
'update_gray_release_rules'
,
PUBLISH_DENY
:
'publish_deny'
}
}
}
}
...
...
apollo-portal/src/main/resources/static/scripts/services/NamespaceBranchService.js
View file @
db65452d
...
@@ -83,7 +83,7 @@ appService.service('NamespaceBranchService', ['$resource', '$q', function ($reso
...
@@ -83,7 +83,7 @@ appService.service('NamespaceBranchService', ['$resource', '$q', function ($reso
}
}
function
merge_and_release_branch
(
appId
,
env
,
clusterName
,
namespaceName
,
function
merge_and_release_branch
(
appId
,
env
,
clusterName
,
namespaceName
,
branchName
,
title
,
comment
,
deleteBranch
)
{
branchName
,
title
,
comment
,
isEmergencyPublish
,
deleteBranch
)
{
var
d
=
$q
.
defer
();
var
d
=
$q
.
defer
();
resource
.
merge_and_release_branch
({
resource
.
merge_and_release_branch
({
appId
:
appId
,
appId
:
appId
,
...
@@ -94,7 +94,8 @@ appService.service('NamespaceBranchService', ['$resource', '$q', function ($reso
...
@@ -94,7 +94,8 @@ appService.service('NamespaceBranchService', ['$resource', '$q', function ($reso
deleteBranch
:
deleteBranch
deleteBranch
:
deleteBranch
},
{
},
{
releaseTitle
:
title
,
releaseTitle
:
title
,
releaseComment
:
comment
releaseComment
:
comment
,
isEmergencyPublish
:
isEmergencyPublish
},
},
function
(
result
)
{
function
(
result
)
{
d
.
resolve
(
result
);
d
.
resolve
(
result
);
...
...
apollo-portal/src/main/resources/static/scripts/services/NamespaceLockService.js
View file @
db65452d
...
@@ -2,7 +2,7 @@ appService.service('NamespaceLockService', ['$resource', '$q', function ($resour
...
@@ -2,7 +2,7 @@ appService.service('NamespaceLockService', ['$resource', '$q', function ($resour
var
resource
=
$resource
(
''
,
{},
{
var
resource
=
$resource
(
''
,
{},
{
get_namespace_lock
:
{
get_namespace_lock
:
{
method
:
'GET'
,
method
:
'GET'
,
url
:
'apps/:appId/envs/:env/clusters/:clusterName/namespaces/:namespaceName/lock'
url
:
'apps/:appId/envs/:env/clusters/:clusterName/namespaces/:namespaceName/lock
-info
'
}
}
});
});
...
...
apollo-portal/src/main/resources/static/scripts/services/ReleaseService.js
View file @
db65452d
...
@@ -28,7 +28,7 @@ appService.service('ReleaseService', ['$resource', '$q', function ($resource, $q
...
@@ -28,7 +28,7 @@ appService.service('ReleaseService', ['$resource', '$q', function ($resource, $q
}
}
});
});
function
createRelease
(
appId
,
env
,
clusterName
,
namespaceName
,
releaseTitle
,
comment
)
{
function
createRelease
(
appId
,
env
,
clusterName
,
namespaceName
,
releaseTitle
,
comment
,
isEmergencyPublish
)
{
var
d
=
$q
.
defer
();
var
d
=
$q
.
defer
();
resource
.
release
({
resource
.
release
({
appId
:
appId
,
appId
:
appId
,
...
@@ -37,7 +37,8 @@ appService.service('ReleaseService', ['$resource', '$q', function ($resource, $q
...
@@ -37,7 +37,8 @@ appService.service('ReleaseService', ['$resource', '$q', function ($resource, $q
namespaceName
:
namespaceName
namespaceName
:
namespaceName
},
{
},
{
releaseTitle
:
releaseTitle
,
releaseTitle
:
releaseTitle
,
releaseComment
:
comment
releaseComment
:
comment
,
isEmergencyPublish
:
isEmergencyPublish
},
function
(
result
)
{
},
function
(
result
)
{
d
.
resolve
(
result
);
d
.
resolve
(
result
);
},
function
(
result
)
{
},
function
(
result
)
{
...
@@ -46,17 +47,18 @@ appService.service('ReleaseService', ['$resource', '$q', function ($resource, $q
...
@@ -46,17 +47,18 @@ appService.service('ReleaseService', ['$resource', '$q', function ($resource, $q
return
d
.
promise
;
return
d
.
promise
;
}
}
function
createGrayRelease
(
appId
,
env
,
clusterName
,
namespaceName
,
branchName
,
releaseTitle
,
comment
)
{
function
createGrayRelease
(
appId
,
env
,
clusterName
,
namespaceName
,
branchName
,
releaseTitle
,
comment
,
isEmergencyPublish
)
{
var
d
=
$q
.
defer
();
var
d
=
$q
.
defer
();
resource
.
gray_release
({
resource
.
gray_release
({
appId
:
appId
,
appId
:
appId
,
env
:
env
,
env
:
env
,
clusterName
:
clusterName
,
clusterName
:
clusterName
,
namespaceName
:
namespaceName
,
namespaceName
:
namespaceName
,
branchName
:
branchName
branchName
:
branchName
},
{
},
{
releaseTitle
:
releaseTitle
,
releaseTitle
:
releaseTitle
,
releaseComment
:
comment
releaseComment
:
comment
,
isEmergencyPublish
:
isEmergencyPublish
},
function
(
result
)
{
},
function
(
result
)
{
d
.
resolve
(
result
);
d
.
resolve
(
result
);
},
function
(
result
)
{
},
function
(
result
)
{
...
@@ -109,7 +111,7 @@ appService.service('ReleaseService', ['$resource', '$q', function ($resource, $q
...
@@ -109,7 +111,7 @@ appService.service('ReleaseService', ['$resource', '$q', function ($resource, $q
page
:
0
,
page
:
0
,
size
:
1
size
:
1
},
function
(
result
)
{
},
function
(
result
)
{
if
(
result
&&
result
.
length
){
if
(
result
&&
result
.
length
)
{
d
.
resolve
(
result
[
0
]);
d
.
resolve
(
result
[
0
]);
}
}
...
...
apollo-portal/src/main/resources/static/scripts/services/ServerConfigService.js
View file @
db65452d
...
@@ -2,7 +2,7 @@ appService.service('ServerConfigService', ['$resource', '$q', function ($resourc
...
@@ -2,7 +2,7 @@ appService.service('ServerConfigService', ['$resource', '$q', function ($resourc
var
server_config_resource
=
$resource
(
''
,
{},
{
var
server_config_resource
=
$resource
(
''
,
{},
{
create_server_config
:
{
create_server_config
:
{
method
:
'POST'
,
method
:
'POST'
,
url
:
'/server/config'
url
:
'/server/config'
}
}
});
});
return
{
return
{
...
...
apollo-portal/src/main/resources/static/styles/common-style.css
View file @
db65452d
...
@@ -607,6 +607,12 @@ table th {
...
@@ -607,6 +607,12 @@ table th {
padding
:
0
;
padding
:
0
;
}
}
.release-history
.release-history-list
.emergency-publish
{
position
:
absolute
;
left
:
0
;
top
:
0
;
}
.release-history
.release-history-list
.load-more
{
.release-history
.release-history-list
.load-more
{
height
:
45px
;
height
:
45px
;
background
:
#f5f5f5
;
background
:
#f5f5f5
;
...
...
apollo-portal/src/main/resources/static/views/component/publish-deny-modal.html
0 → 100644
View file @
db65452d
<div
class=
"modal fade"
id=
"publishDenyModal"
tabindex=
"-1"
role=
"dialog"
>
<div
class=
"modal-dialog"
role=
"document"
>
<div
class=
"modal-content"
>
<div
class=
"modal-header panel-primary"
>
<button
type=
"button"
class=
"close"
data-dismiss=
"modal"
aria-label=
"Close"
>
<span
aria-hidden=
"true"
>
×
</span></button>
<h4
class=
"modal-title"
>
发布受限
</h4>
</div>
<div
class=
"modal-body"
>
您不能发布哟~{{env}}环境配置的编辑和发布必须为不同的人,请找另一个具有当前namespace发布权的人操作发布~
<span
ng-if=
"toReleaseNamespace.isEmergencyPublishAllowed"
>
<br><br><small>
(如果是非工作时间或者特殊情况,您可以通过点击
<mark>
紧急发布
</mark>
按钮进行发布)
</small>
</span>
</div>
<div
class=
"modal-footer"
>
<button
type=
"button"
class=
"btn btn-danger"
data-dismiss=
"modal"
ng-if=
"toReleaseNamespace.isEmergencyPublishAllowed"
ng-click=
"emergencyPublish()"
>
紧急发布
</button>
<button
type=
"button"
class=
"btn btn-primary"
data-dismiss=
"modal"
>
关闭
</button>
</div>
</div>
</div>
</div>
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment