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
4f3dd644
Commit
4f3dd644
authored
Jan 19, 2017
by
Jason Song
Committed by
GitHub
Jan 19, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #520 from lepdou/emergency_publish
emergency publish
parents
ddbd9448
db65452d
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
29 changed files
with
303 additions
and
90 deletions
+303
-90
ReleaseController.java
...ork/apollo/adminservice/controller/ReleaseController.java
+18
-14
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
+8
-3
namespace-panel-directive.js
...ces/static/scripts/directive/namespace-panel-directive.js
+15
-14
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
+10
-3
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
+16
-14
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 @
4f3dd644
...
...
@@ -33,6 +33,7 @@ import java.util.stream.Collectors;
@RestController
public
class
ReleaseController
{
private
static
final
Splitter
RELEASES_SPLITTER
=
Splitter
.
on
(
","
).
omitEmptyStrings
()
.
trimResults
();
...
...
@@ -57,7 +58,7 @@ public class ReleaseController {
}
@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
)
.
collect
(
Collectors
.
toSet
());
...
...
@@ -99,13 +100,14 @@ public class ReleaseController {
@PathVariable
(
"namespaceName"
)
String
namespaceName
,
@RequestParam
(
"name"
)
String
releaseName
,
@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
);
if
(
namespace
==
null
)
{
throw
new
NotFoundException
(
String
.
format
(
"Could not find namespace for %s %s %s"
,
appId
,
clusterName
,
namespaceName
));
}
Release
release
=
releaseService
.
publish
(
namespace
,
releaseName
,
releaseComment
,
operator
);
Release
release
=
releaseService
.
publish
(
namespace
,
releaseName
,
releaseComment
,
operator
,
isEmergencyPublish
);
//send release message
Namespace
parentNamespace
=
namespaceService
.
findParentNamespace
(
namespace
);
...
...
@@ -122,31 +124,33 @@ public class ReleaseController {
/**
*merge branch items to master and publish master
* merge branch items to master and publish master
*
* @return published result
*/
@Transactional
@RequestMapping
(
path
=
"/apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName}/updateAndPublish"
,
method
=
RequestMethod
.
POST
)
public
ReleaseDTO
updateAndPublish
(
@PathVariable
(
"appId"
)
String
appId
,
@PathVariable
(
"clusterName"
)
String
clusterName
,
@PathVariable
(
"namespaceName"
)
String
namespaceName
,
@RequestParam
(
"releaseName"
)
String
releaseName
,
@RequestParam
(
"branchName"
)
String
branchName
,
@RequestParam
(
value
=
"deleteBranch"
,
defaultValue
=
"true"
)
boolean
deleteBranch
,
@RequestParam
(
name
=
"releaseComment"
,
required
=
false
)
String
releaseComment
,
@RequestBody
ItemChangeSets
changeSets
)
{
@PathVariable
(
"clusterName"
)
String
clusterName
,
@PathVariable
(
"namespaceName"
)
String
namespaceName
,
@RequestParam
(
"releaseName"
)
String
releaseName
,
@RequestParam
(
"branchName"
)
String
branchName
,
@RequestParam
(
value
=
"deleteBranch"
,
defaultValue
=
"true"
)
boolean
deleteBranch
,
@RequestParam
(
name
=
"releaseComment"
,
required
=
false
)
String
releaseComment
,
@RequestParam
(
name
=
"isEmergencyPublish"
,
defaultValue
=
"false"
)
boolean
isEmergencyPublish
,
@RequestBody
ItemChangeSets
changeSets
)
{
Namespace
namespace
=
namespaceService
.
findOne
(
appId
,
clusterName
,
namespaceName
);
if
(
namespace
==
null
)
{
throw
new
NotFoundException
(
String
.
format
(
"Could not find namespace for %s %s %s"
,
appId
,
clusterName
,
namespaceName
));
}
Release
release
=
releaseService
.
mergeBranchChangeSetsAndRelease
(
namespace
,
branchName
,
releaseName
,
releaseComment
,
changeSets
);
Release
release
=
releaseService
.
mergeBranchChangeSetsAndRelease
(
namespace
,
branchName
,
releaseName
,
releaseComment
,
isEmergencyPublish
,
changeSets
);
if
(
deleteBranch
)
{
namespaceBranchService
.
deleteBranch
(
appId
,
clusterName
,
namespaceName
,
branchName
,
NamespaceBranchStatus
.
MERGED
,
changeSets
.
getDataChangeLastModifiedBy
());
NamespaceBranchStatus
.
MERGED
,
changeSets
.
getDataChangeLastModifiedBy
());
}
messageSender
.
sendMessage
(
ReleaseMessageKeyGenerator
.
generate
(
appId
,
clusterName
,
namespaceName
),
...
...
apollo-adminservice/src/test/java/com/ctrip/framework/apollo/adminservice/controller/ReleaseControllerTest.java
View file @
4f3dd644
...
...
@@ -121,7 +121,7 @@ public class ReleaseControllerTest extends AbstractControllerTest {
.
thenReturn
(
someNamespace
);
releaseController
.
publish
(
someAppId
,
someCluster
,
someNamespaceName
,
someName
,
someComment
,
"test"
);
.
publish
(
someAppId
,
someCluster
,
someNamespaceName
,
someName
,
someComment
,
"test"
,
false
);
verify
(
someMessageSender
,
times
(
1
))
.
sendMessage
(
Joiner
.
on
(
ConfigConsts
.
CLUSTER_NAMESPACE_SEPARATOR
)
...
...
apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/service/ReleaseService.java
View file @
4f3dd644
This diff is collapsed.
Click to expand it.
apollo-biz/src/test/java/com/ctrip/framework/apollo/biz/service/ReleaseCreationTest.java
View file @
4f3dd644
...
...
@@ -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.Release
;
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
org.junit.Assert
;
...
...
@@ -24,8 +25,6 @@ import java.util.Map;
public
class
ReleaseCreationTest
extends
AbstractIntegrationTest
{
private
Gson
gson
=
new
Gson
();
private
Type
configurationTypeReference
=
new
TypeToken
<
Map
<
String
,
String
>>()
{
}.
getType
();
@Autowired
private
ReleaseService
releaseService
;
...
...
@@ -47,7 +46,7 @@ public class ReleaseCreationTest extends AbstractIntegrationTest {
String
clusterName
=
"only-master"
;
Namespace
namespace
=
instanceNamespace
(
namespaceId
,
clusterName
);
releaseService
.
publish
(
namespace
,
""
,
""
,
operator
);
releaseService
.
publish
(
namespace
,
""
,
""
,
operator
,
false
);
Release
latestRelease
=
releaseService
.
findLatestActiveRelease
(
namespace
);
...
...
@@ -92,7 +91,7 @@ public class ReleaseCreationTest extends AbstractIntegrationTest {
String
childClusterName
=
"child-cluster1"
;
Namespace
parentNamespace
=
instanceNamespace
(
parentNamespaceId
,
parentClusterName
);
releaseService
.
publish
(
parentNamespace
,
""
,
""
,
operator
);
releaseService
.
publish
(
parentNamespace
,
""
,
""
,
operator
,
false
);
Release
latestParentNamespaceRelease
=
releaseService
.
findLatestActiveRelease
(
parentNamespace
);
...
...
@@ -166,7 +165,7 @@ public class ReleaseCreationTest extends AbstractIntegrationTest {
String
childClusterName
=
"child-cluster2"
;
Namespace
parentNamespace
=
instanceNamespace
(
parentNamespaceId
,
parentClusterName
);
releaseService
.
publish
(
parentNamespace
,
""
,
""
,
operator
);
releaseService
.
publish
(
parentNamespace
,
""
,
""
,
operator
,
false
);
Release
latestParentNamespaceRelease
=
releaseService
.
findLatestActiveRelease
(
parentNamespace
);
...
...
@@ -237,7 +236,7 @@ public class ReleaseCreationTest extends AbstractIntegrationTest {
String
childClusterName
=
"child-cluster3"
;
Namespace
parentNamespace
=
instanceNamespace
(
parentNamespaceId
,
parentClusterName
);
releaseService
.
publish
(
parentNamespace
,
""
,
""
,
operator
);
releaseService
.
publish
(
parentNamespace
,
""
,
""
,
operator
,
false
);
Release
latestParentNamespaceRelease
=
releaseService
.
findLatestActiveRelease
(
parentNamespace
);
...
...
@@ -306,7 +305,7 @@ public class ReleaseCreationTest extends AbstractIntegrationTest {
String
childClusterName
=
"child-cluster4"
;
//assert child namespace
Namespace
childNamespace
=
instanceNamespace
(
childNamespaceId
,
childClusterName
);
releaseService
.
publish
(
childNamespace
,
""
,
""
,
operator
);
releaseService
.
publish
(
childNamespace
,
""
,
""
,
operator
,
false
);
Release
latestChildNamespaceRelease
=
releaseService
.
findLatestActiveRelease
(
childNamespace
);
...
...
@@ -377,7 +376,7 @@ public class ReleaseCreationTest extends AbstractIntegrationTest {
String
childClusterName
=
"child-cluster5"
;
//assert child namespace
Namespace
childNamespace
=
instanceNamespace
(
childNamespaceId
,
childClusterName
);
releaseService
.
publish
(
childNamespace
,
""
,
""
,
operator
);
releaseService
.
publish
(
childNamespace
,
""
,
""
,
operator
,
false
);
Release
latestChildNamespaceRelease
=
releaseService
.
findLatestActiveRelease
(
childNamespace
);
...
...
@@ -495,7 +494,7 @@ public class ReleaseCreationTest extends AbstractIntegrationTest {
}
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 @
4f3dd644
...
...
@@ -8,4 +8,5 @@ public interface ReleaseOperationContext {
String
RULES
=
"rules"
;
String
OLD_RULES
=
"oldRules"
;
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 @
4f3dd644
...
...
@@ -230,31 +230,32 @@ public class AdminServiceAPI {
}
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
();
headers
.
setContentType
(
MediaType
.
parseMediaType
(
MediaType
.
APPLICATION_FORM_URLENCODED_VALUE
+
";charset=UTF-8"
));
MultiValueMap
<
String
,
String
>
parameters
=
new
LinkedMultiValueMap
<>();
parameters
.
add
(
"name"
,
releaseName
);
parameters
.
add
(
"comment"
,
releaseComment
);
parameters
.
add
(
"operator"
,
operator
);
parameters
.
add
(
"isEmergencyPublish"
,
String
.
valueOf
(
isEmergencyPublish
));
HttpEntity
<
MultiValueMap
<
String
,
String
>>
entity
=
new
HttpEntity
<>(
parameters
,
headers
);
ReleaseDTO
response
=
restTemplate
.
post
(
env
,
"apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName}/releases"
,
entity
,
ReleaseDTO
.
class
,
appId
,
clusterName
,
namespace
);
ReleaseDTO
.
class
,
appId
,
clusterName
,
namespace
);
return
response
;
}
public
ReleaseDTO
updateAndPublish
(
String
appId
,
Env
env
,
String
clusterName
,
String
namespace
,
String
releaseName
,
String
releaseComment
,
String
branchName
,
boolean
deleteBranch
,
ItemChangeSets
changeSets
)
{
boolean
isEmergencyPublish
,
boolean
deleteBranch
,
ItemChangeSets
changeSets
)
{
return
restTemplate
.
post
(
env
,
"apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName}/updateAndPublish?"
+
"releaseName={releaseName}&releaseComment={releaseComment}&branchName={branchName}&deleteBranch={deleteBranch}"
,
changeSets
,
ReleaseDTO
.
class
,
appId
,
clusterName
,
namespace
,
releaseName
,
releaseComment
,
branchName
,
deleteBranch
);
+
"releaseName={releaseName}&releaseComment={releaseComment}&branchName={branchName}"
+
"&deleteBranch={deleteBranch}&isEmergencyPublish={isEmergencyPublish}"
,
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 @
4f3dd644
...
...
@@ -20,6 +20,7 @@ import org.springframework.util.StringUtils;
import
java.lang.reflect.Type
;
import
java.util.Collections
;
import
java.util.List
;
import
java.util.Objects
;
import
java.util.Set
;
@Component
...
...
@@ -97,6 +98,19 @@ public class PortalConfig extends RefreshableConfig {
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
...
...
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/components/emailbuilder/ConfigPublishEmailBuilder.java
View file @
4f3dd644
...
...
@@ -4,6 +4,7 @@ package com.ctrip.framework.apollo.portal.components.emailbuilder;
import
com.google.common.collect.Lists
;
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.entity.AppNamespace
;
import
com.ctrip.framework.apollo.core.enums.ConfigFileFormat
;
...
...
@@ -29,12 +30,15 @@ import java.util.ArrayList;
import
java.util.Collections
;
import
java.util.HashSet
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Set
;
import
java.util.regex.Matcher
;
public
abstract
class
ConfigPublishEmailBuilder
{
private
static
final
String
EMERGENCY_PUBLISH_TAG
=
"<span style='color:red'>(紧急发布)</span>"
;
//email content common field placeholder
private
static
final
String
EMAIL_CONTENT_FIELD_APPID
=
"#\\{appId\\}"
;
private
static
final
String
EMAIL_CONTENT_FIELD_ENV
=
"#\\{env}"
;
...
...
@@ -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_APOLLO_SERVER_ADDRESS
=
"#\\{apollo.portal.address}"
;
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}"
;
protected
static
final
String
EMAIL_CONTENT_GRAY_RULES_MODULE
=
"#\\{rulesModule}"
;
...
...
@@ -118,7 +123,18 @@ public abstract class ConfigPublishEmailBuilder {
}
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_CLUSTER
,
Matcher
.
quoteReplacement
(
releaseHistory
.
getClusterName
()));
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 @
4f3dd644
...
...
@@ -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.NamespaceDTO
;
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.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.bo.NamespaceBO
;
import
com.ctrip.framework.apollo.portal.listener.ConfigPublishEvent
;
...
...
@@ -33,6 +35,8 @@ public class NamespaceBranchController {
private
NamespaceBranchService
namespaceBranchService
;
@Autowired
private
ApplicationEventPublisher
publisher
;
@Autowired
private
PortalConfig
portalConfig
;
@RequestMapping
(
"/apps/{appId}/envs/{env}/clusters/{clusterName}/namespaces/{namespaceName}/branches"
)
public
NamespaceBO
findBranch
(
@PathVariable
String
appId
,
...
...
@@ -84,8 +88,13 @@ public class NamespaceBranchController {
@PathVariable
String
branchName
,
@RequestParam
(
value
=
"deleteBranch"
,
defaultValue
=
"true"
)
boolean
deleteBranch
,
@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
,
model
.
getReleaseTitle
(),
model
.
getReleaseComment
(),
deleteBranch
);
model
.
getReleaseTitle
(),
model
.
getReleaseComment
(),
model
.
isEmergencyPublish
(),
deleteBranch
);
ConfigPublishEvent
event
=
ConfigPublishEvent
.
instance
();
event
.
withAppId
(
appId
)
...
...
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/controller/NamespaceLockController.java
View file @
4f3dd644
...
...
@@ -2,6 +2,7 @@ package com.ctrip.framework.apollo.portal.controller;
import
com.ctrip.framework.apollo.common.dto.NamespaceLockDTO
;
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
org.springframework.beans.factory.annotation.Autowired
;
...
...
@@ -15,6 +16,7 @@ public class NamespaceLockController {
@Autowired
private
NamespaceLockService
namespaceLockService
;
@Deprecated
@RequestMapping
(
"/apps/{appId}/envs/{env}/clusters/{clusterName}/namespaces/{namespaceName}/lock"
)
public
NamespaceLockDTO
getNamespaceLock
(
@PathVariable
String
appId
,
@PathVariable
String
env
,
@PathVariable
String
clusterName
,
@PathVariable
String
namespaceName
)
{
...
...
@@ -22,4 +24,13 @@ public class NamespaceLockController {
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 @
4f3dd644
package
com
.
ctrip
.
framework
.
apollo
.
portal
.
controller
;
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.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.vo.ReleaseCompareResult
;
import
com.ctrip.framework.apollo.portal.entity.bo.ReleaseBO
;
...
...
@@ -30,6 +32,8 @@ public class ReleaseController {
private
ReleaseService
releaseService
;
@Autowired
private
ApplicationEventPublisher
publisher
;
@Autowired
private
PortalConfig
portalConfig
;
@PreAuthorize
(
value
=
"@permissionValidator.hasReleaseNamespacePermission(#appId, #namespaceName)"
)
@RequestMapping
(
value
=
"/apps/{appId}/envs/{env}/clusters/{clusterName}/namespaces/{namespaceName}/releases"
,
method
=
RequestMethod
.
POST
)
...
...
@@ -43,6 +47,10 @@ public class ReleaseController {
model
.
setClusterName
(
clusterName
);
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
);
ConfigPublishEvent
event
=
ConfigPublishEvent
.
instance
();
...
...
@@ -72,6 +80,10 @@ public class ReleaseController {
model
.
setClusterName
(
branchName
);
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
);
ConfigPublishEvent
event
=
ConfigPublishEvent
.
instance
();
...
...
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/model/NamespaceReleaseModel.java
View file @
4f3dd644
...
...
@@ -13,6 +13,7 @@ public class NamespaceReleaseModel implements Verifiable {
private
String
releaseTitle
;
private
String
releaseComment
;
private
String
releasedBy
;
private
boolean
isEmergencyPublish
;
@Override
public
boolean
isInvalid
()
{
...
...
@@ -74,4 +75,12 @@ public class NamespaceReleaseModel implements Verifiable {
public
void
setReleasedBy
(
String
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 @
4f3dd644
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 @
4f3dd644
...
...
@@ -84,13 +84,14 @@ public class NamespaceBranchService {
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
);
ReleaseDTO
mergedResult
=
releaseService
.
updateAndPublish
(
appId
,
env
,
clusterName
,
namespaceName
,
title
,
comment
,
branchName
,
deleteBranch
,
changeSets
);
ReleaseDTO
mergedResult
=
releaseService
.
updateAndPublish
(
appId
,
env
,
clusterName
,
namespaceName
,
title
,
comment
,
branchName
,
isEmergencyPublish
,
deleteBranch
,
changeSets
);
Tracer
.
logEvent
(
CatEventType
.
MERGE_GRAY_RELEASE
,
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 @
4f3dd644
...
...
@@ -3,6 +3,8 @@ package com.ctrip.framework.apollo.portal.service;
import
com.ctrip.framework.apollo.common.dto.NamespaceLockDTO
;
import
com.ctrip.framework.apollo.core.enums.Env
;
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.stereotype.Service
;
...
...
@@ -12,10 +14,24 @@ public class NamespaceLockService {
@Autowired
private
AdminServiceAPI
.
NamespaceLockAPI
namespaceLockAPI
;
@Autowired
private
PortalConfig
portalConfig
;
public
NamespaceLockDTO
getNamespaceLock
(
String
appId
,
Env
env
,
String
clusterName
,
String
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 @
4f3dd644
...
...
@@ -42,27 +42,30 @@ public class ReleaseService {
private
AdminServiceAPI
.
ReleaseAPI
releaseAPI
;
public
ReleaseDTO
publish
(
NamespaceReleaseModel
model
)
{
String
appId
=
model
.
getAppId
();
Env
env
=
model
.
getEnv
();
boolean
isEmergencyPublish
=
model
.
isEmergencyPublish
();
String
appId
=
model
.
getAppId
();
String
clusterName
=
model
.
getClusterName
();
String
namespaceName
=
model
.
getNamespaceName
();
String
releaseBy
=
StringUtils
.
isEmpty
(
model
.
getReleasedBy
())
?
userInfoHolder
.
getUser
().
getUserId
()
:
model
.
getReleasedBy
();
String
releaseBy
=
StringUtils
.
isEmpty
(
model
.
getReleasedBy
())
?
userInfoHolder
.
getUser
().
getUserId
()
:
model
.
getReleasedBy
();
ReleaseDTO
releaseDTO
=
releaseAPI
.
createRelease
(
appId
,
env
,
clusterName
,
namespaceName
,
model
.
getReleaseTitle
(),
model
.
getReleaseComment
(),
releaseBy
,
isEmergencyPublish
);
ReleaseDTO
releaseDTO
=
releaseAPI
.
createRelease
(
appId
,
env
,
clusterName
,
namespaceName
,
model
.
getReleaseTitle
(),
model
.
getReleaseComment
()
,
releaseBy
);
Tracer
.
logEvent
(
CatEventType
.
RELEASE_NAMESPACE
,
String
.
format
(
"%s+%s+%s+%s"
,
appId
,
env
,
clusterName
,
namespaceName
));
Tracer
.
logEvent
(
CatEventType
.
RELEASE_NAMESPACE
,
String
.
format
(
"%s+%s+%s+%s"
,
appId
,
env
,
clusterName
,
namespaceName
));
return
releaseDTO
;
}
public
ReleaseDTO
updateAndPublish
(
String
appId
,
Env
env
,
String
clusterName
,
String
namespaceName
,
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
,
deleteBranch
,
changeSets
);
isEmergencyPublish
,
deleteBranch
,
changeSets
);
}
public
List
<
ReleaseBO
>
findAllReleases
(
String
appId
,
Env
env
,
String
clusterName
,
String
namespaceName
,
int
page
,
...
...
apollo-portal/src/main/resources/static/config.html
View file @
4f3dd644
...
...
@@ -229,6 +229,7 @@
cluster=
"pageContext.clusterName"
>
</mergeandpublishmodal>
<publishdenymodal></publishdenymodal>
<apolloconfirmdialog
apollo-dialog-id=
"'deleteConfirmDialog'"
apollo-title=
"'删除配置'"
apollo-detail=
"'确定要删除配置吗?'"
...
...
@@ -251,10 +252,6 @@
apollo-detail=
"'当前namespace正在被 ' + lockOwner + ' 编辑,一次发布只能被一个人修改.'"
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=
"'回滚'"
apollo-detail=
"'确定要回滚吗?'"
apollo-show-cancel-btn=
"true"
apollo-confirm=
"rollback"
></apolloconfirmdialog>
...
...
@@ -373,6 +370,7 @@
<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/merge-and-publish-modal-directive.js"
></script>
<script
type=
"application/javascript"
src=
"scripts/directive/publish-deny-modal-directive.js"
></script>
<!--controller-->
<script
type=
"application/javascript"
src=
"scripts/controller/config/ConfigNamespaceController.js"
></script>
...
...
apollo-portal/src/main/resources/static/config/history.html
View file @
4f3dd644
...
...
@@ -75,7 +75,8 @@
<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>
<span
class=
"label label-warning no-radius emergency-publish"
ng-if=
"releaseHistory.operationContext.isEmergencyPublish"
>
紧急发布
</span>
</div>
</div>
...
...
apollo-portal/src/main/resources/static/scripts/directive/merge-and-publish-modal-directive.js
View file @
4f3dd644
...
...
@@ -20,17 +20,22 @@ function mergeAndPublishDirective(AppUtil, EventManager) {
var
branch
=
context
.
branch
;
scope
.
toReleaseNamespace
=
branch
;
scope
.
toDeleteBranch
=
branch
;
scope
.
isEmergencyPublish
=
context
.
isEmergencyPublish
?
context
.
isEmergencyPublish
:
false
;
var
branchStatusMerge
=
2
;
branch
.
branchStatus
=
branchStatusMerge
;
branch
.
mergeAndPublish
=
true
;
AppUtil
.
showModal
(
'#mergeAndPublishModal'
);
});
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 @
4f3dd644
...
...
@@ -279,16 +279,12 @@ function directive($window, toastr, AppUtil, EventManager, PermissionService, Na
}
function
initNamespaceLock
(
namespace
)
{
NamespaceLockService
.
get_namespace_lock
(
scope
.
appId
,
scope
.
env
,
namespace
.
baseInfo
.
clusterName
,
namespace
.
baseInfo
.
namespaceName
)
NamespaceLockService
.
get_namespace_lock
(
scope
.
appId
,
scope
.
env
,
namespace
.
baseInfo
.
clusterName
,
namespace
.
baseInfo
.
namespaceName
)
.
then
(
function
(
result
)
{
if
(
result
.
dataChangeCreatedBy
)
{
namespace
.
lockOwner
=
result
.
dataChangeCreatedBy
;
}
else
{
namespace
.
lockOwner
=
""
;
}
namespace
.
lockOwner
=
result
.
lockOwner
;
namespace
.
isEmergencyPublishAllowed
=
result
.
isEmergencyPublishAllowed
;
});
}
...
...
@@ -748,7 +744,10 @@ function directive($window, toastr, AppUtil, EventManager, PermissionService, Na
return
;
}
else
if
(
namespace
.
lockOwner
&&
scope
.
user
==
namespace
.
lockOwner
)
{
//can not publish if config modified by himself
AppUtil
.
showModal
(
'#releaseDenyDialog'
);
EventManager
.
emit
(
EventManager
.
EventType
.
PUBLISH_DENY
,
{
namespace
:
namespace
,
mergeAndPublish
:
false
});
return
;
}
...
...
@@ -766,12 +765,14 @@ function directive($window, toastr, AppUtil, EventManager, PermissionService, Na
var
parentNamespace
=
branch
.
parentNamespace
;
if
(
!
parentNamespace
.
hasReleasePermission
)
{
AppUtil
.
showModal
(
'#releaseNoPermissionDialog'
);
}
else
if
(
branch
.
lockOwner
&&
scope
.
user
==
branch
.
lockOwner
)
{
AppUtil
.
showModal
(
'#releaseDenyDialog'
);
}
else
if
(
parentNamespace
.
itemModifiedCnt
>
0
)
{
AppUtil
.
showModal
(
'#mergeAndReleaseDenyDialog'
);
}
else
{
}
else
if
(
branch
.
lockOwner
&&
scope
.
user
==
branch
.
lockOwner
)
{
EventManager
.
emit
(
EventManager
.
EventType
.
PUBLISH_DENY
,
{
namespace
:
branch
,
mergeAndPublish
:
true
});
}
else
{
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 @
4f3dd644
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 @
4f3dd644
...
...
@@ -19,12 +19,14 @@ function releaseModalDirective(toastr, AppUtil, EventManager, ReleaseService, Na
scope
.
releaseBtnDisabled
=
false
;
scope
.
releaseChangeViewType
=
'change'
;
scope
.
releaseComment
=
''
;
scope
.
isEmergencyPublish
=
false
;
EventManager
.
subscribe
(
EventManager
.
EventType
.
PUBLISH_NAMESPACE
,
function
(
context
)
{
var
namespace
=
context
.
namespace
;
scope
.
toReleaseNamespace
=
context
.
namespace
;
scope
.
isEmergencyPublish
=
!!
context
.
isEmergencyPublish
;
var
date
=
new
Date
().
Format
(
"yyyyMMddhhmmss"
);
if
(
namespace
.
mergeAndPublish
)
{
...
...
@@ -55,7 +57,8 @@ function releaseModalDirective(toastr, AppUtil, EventManager, ReleaseService, Na
scope
.
toReleaseNamespace
.
baseInfo
.
clusterName
,
scope
.
toReleaseNamespace
.
baseInfo
.
namespaceName
,
scope
.
toReleaseNamespace
.
releaseTitle
,
scope
.
releaseComment
).
then
(
scope
.
releaseComment
,
scope
.
isEmergencyPublish
).
then
(
function
(
result
)
{
AppUtil
.
hideModal
(
'#releaseModal'
);
toastr
.
success
(
"发布成功"
);
...
...
@@ -83,7 +86,8 @@ function releaseModalDirective(toastr, AppUtil, EventManager, ReleaseService, Na
scope
.
toReleaseNamespace
.
baseInfo
.
namespaceName
,
scope
.
toReleaseNamespace
.
baseInfo
.
clusterName
,
scope
.
toReleaseNamespace
.
releaseTitle
,
scope
.
releaseComment
).
then
(
scope
.
releaseComment
,
scope
.
isEmergencyPublish
).
then
(
function
(
result
)
{
AppUtil
.
hideModal
(
'#releaseModal'
);
toastr
.
success
(
"灰度发布成功"
);
...
...
@@ -98,7 +102,9 @@ function releaseModalDirective(toastr, AppUtil, EventManager, ReleaseService, Na
item
.
isModified
=
false
;
}
});
//reset namespace status
scope
.
toReleaseNamespace
.
itemModifiedCnt
=
0
;
scope
.
toReleaseNamespace
.
lockOwner
=
undefined
;
//check rules
if
(
!
scope
.
toReleaseNamespace
.
rules
...
...
@@ -125,6 +131,7 @@ function releaseModalDirective(toastr, AppUtil, EventManager, ReleaseService, Na
scope
.
toReleaseNamespace
.
baseInfo
.
clusterName
,
scope
.
toReleaseNamespace
.
releaseTitle
,
scope
.
releaseComment
,
scope
.
isEmergencyPublish
,
scope
.
toReleaseNamespace
.
mergeAfterDeleteBranch
)
.
then
(
function
(
result
)
{
...
...
apollo-portal/src/main/resources/static/scripts/services/EventManager.js
View file @
4f3dd644
...
...
@@ -131,7 +131,8 @@ appService.service('EventManager', [function () {
PRE_ROLLBACK_NAMESPACE
:
'pre_rollback_namespace'
,
ROLLBACK_NAMESPACE
:
'rollback_namespace'
,
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 @
4f3dd644
...
...
@@ -83,7 +83,7 @@ appService.service('NamespaceBranchService', ['$resource', '$q', function ($reso
}
function
merge_and_release_branch
(
appId
,
env
,
clusterName
,
namespaceName
,
branchName
,
title
,
comment
,
deleteBranch
)
{
branchName
,
title
,
comment
,
isEmergencyPublish
,
deleteBranch
)
{
var
d
=
$q
.
defer
();
resource
.
merge_and_release_branch
({
appId
:
appId
,
...
...
@@ -94,7 +94,8 @@ appService.service('NamespaceBranchService', ['$resource', '$q', function ($reso
deleteBranch
:
deleteBranch
},
{
releaseTitle
:
title
,
releaseComment
:
comment
releaseComment
:
comment
,
isEmergencyPublish
:
isEmergencyPublish
},
function
(
result
)
{
d
.
resolve
(
result
);
...
...
apollo-portal/src/main/resources/static/scripts/services/NamespaceLockService.js
View file @
4f3dd644
...
...
@@ -2,7 +2,7 @@ appService.service('NamespaceLockService', ['$resource', '$q', function ($resour
var
resource
=
$resource
(
''
,
{},
{
get_namespace_lock
:
{
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 @
4f3dd644
...
...
@@ -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
();
resource
.
release
({
appId
:
appId
,
...
...
@@ -37,7 +37,8 @@ appService.service('ReleaseService', ['$resource', '$q', function ($resource, $q
namespaceName
:
namespaceName
},
{
releaseTitle
:
releaseTitle
,
releaseComment
:
comment
releaseComment
:
comment
,
isEmergencyPublish
:
isEmergencyPublish
},
function
(
result
)
{
d
.
resolve
(
result
);
},
function
(
result
)
{
...
...
@@ -46,18 +47,19 @@ appService.service('ReleaseService', ['$resource', '$q', function ($resource, $q
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
();
resource
.
gray_release
({
appId
:
appId
,
env
:
env
,
clusterName
:
clusterName
,
namespaceName
:
namespaceName
,
branchName
:
branchName
},
{
releaseTitle
:
releaseTitle
,
releaseComment
:
comment
},
function
(
result
)
{
appId
:
appId
,
env
:
env
,
clusterName
:
clusterName
,
namespaceName
:
namespaceName
,
branchName
:
branchName
},
{
releaseTitle
:
releaseTitle
,
releaseComment
:
comment
,
isEmergencyPublish
:
isEmergencyPublish
},
function
(
result
)
{
d
.
resolve
(
result
);
},
function
(
result
)
{
d
.
reject
(
result
);
...
...
@@ -98,7 +100,7 @@ appService.service('ReleaseService', ['$resource', '$q', function ($resource, $q
});
return
d
.
promise
;
}
function
findLatestActiveRelease
(
appId
,
env
,
clusterName
,
namespaceName
)
{
var
d
=
$q
.
defer
();
resource
.
find_active_releases
({
...
...
@@ -109,7 +111,7 @@ appService.service('ReleaseService', ['$resource', '$q', function ($resource, $q
page
:
0
,
size
:
1
},
function
(
result
)
{
if
(
result
&&
result
.
length
){
if
(
result
&&
result
.
length
)
{
d
.
resolve
(
result
[
0
]);
}
...
...
apollo-portal/src/main/resources/static/scripts/services/ServerConfigService.js
View file @
4f3dd644
...
...
@@ -2,7 +2,7 @@ appService.service('ServerConfigService', ['$resource', '$q', function ($resourc
var
server_config_resource
=
$resource
(
''
,
{},
{
create_server_config
:
{
method
:
'POST'
,
url
:
'/server/config'
url
:
'/server/config'
}
});
return
{
...
...
apollo-portal/src/main/resources/static/styles/common-style.css
View file @
4f3dd644
...
...
@@ -607,6 +607,12 @@ table th {
padding
:
0
;
}
.release-history
.release-history-list
.emergency-publish
{
position
:
absolute
;
left
:
0
;
top
:
0
;
}
.release-history
.release-history-list
.load-more
{
height
:
45px
;
background
:
#f5f5f5
;
...
...
apollo-portal/src/main/resources/static/views/component/publish-deny-modal.html
0 → 100644
View file @
4f3dd644
<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