-
Notifications
You must be signed in to change notification settings - Fork 554
fix: disable api update if disabled from UI #3487
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 5 commits
c615ac1
05f31b8
efcc379
b530443
286cd35
d5ffaad
b13b001
8b90776
5bd3132
05817b0
9880939
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -68,6 +68,9 @@ import ( | |
| "go.uber.org/zap" | ||
| ) | ||
|
|
||
| const DashboardConfigMap = "dashboard-cm" | ||
| const ConfigMapNamespace = "devtroncd" | ||
|
|
||
| var DefaultPipelineValue = []byte(`{"ConfigMaps":{"enabled":false},"ConfigSecrets":{"enabled":false},"ContainerPort":[],"EnvVariables":[],"GracePeriod":30,"LivenessProbe":{},"MaxSurge":1,"MaxUnavailable":0,"MinReadySeconds":60,"ReadinessProbe":{},"Spec":{"Affinity":{"Values":"nodes","key":""}},"app":"13","appMetrics":false,"args":{},"autoscaling":{},"command":{"enabled":false,"value":[]},"containers":[],"dbMigrationConfig":{"enabled":false},"deployment":{"strategy":{"rolling":{"maxSurge":"25%","maxUnavailable":1}}},"deploymentType":"ROLLING","env":"1","envoyproxy":{"configMapName":"","image":"","resources":{"limits":{"cpu":"50m","memory":"50Mi"},"requests":{"cpu":"50m","memory":"50Mi"}}},"image":{"pullPolicy":"IfNotPresent"},"ingress":{},"ingressInternal":{"annotations":{},"enabled":false,"host":"","path":"","tls":[]},"initContainers":[],"pauseForSecondsBeforeSwitchActive":30,"pipelineName":"","prometheus":{"release":"monitoring"},"rawYaml":[],"releaseVersion":"1","replicaCount":1,"resources":{"limits":{"cpu":"0.05","memory":"50Mi"},"requests":{"cpu":"0.01","memory":"10Mi"}},"secret":{"data":{},"enabled":false},"server":{"deployment":{"image":"","image_tag":""}},"service":{"annotations":{},"type":"ClusterIP"},"servicemonitor":{"additionalLabels":{}},"tolerations":[],"volumeMounts":[],"volumes":[],"waitForSecondsBeforeScalingDown":30}`) | ||
|
|
||
| type EcrConfig struct { | ||
|
|
@@ -211,6 +214,7 @@ type PipelineBuilderImpl struct { | |
| enforcerUtil rbac.EnforcerUtil | ||
| appGroupService appGroup2.AppGroupService | ||
| chartDeploymentService util.ChartDeploymentService | ||
| K8sUtil *util.K8sUtil | ||
| } | ||
|
|
||
| func NewPipelineBuilderImpl(logger *zap.SugaredLogger, | ||
|
|
@@ -261,7 +265,8 @@ func NewPipelineBuilderImpl(logger *zap.SugaredLogger, | |
| enforcerUtil rbac.EnforcerUtil, ArgoUserService argo.ArgoUserService, | ||
| ciWorkflowRepository pipelineConfig.CiWorkflowRepository, | ||
| appGroupService appGroup2.AppGroupService, | ||
| chartDeploymentService util.ChartDeploymentService) *PipelineBuilderImpl { | ||
| chartDeploymentService util.ChartDeploymentService, | ||
| K8sUtil *util.K8sUtil) *PipelineBuilderImpl { | ||
| return &PipelineBuilderImpl{ | ||
| logger: logger, | ||
| ciCdPipelineOrchestrator: ciCdPipelineOrchestrator, | ||
|
|
@@ -320,6 +325,7 @@ func NewPipelineBuilderImpl(logger *zap.SugaredLogger, | |
| ciWorkflowRepository: ciWorkflowRepository, | ||
| appGroupService: appGroupService, | ||
| chartDeploymentService: chartDeploymentService, | ||
| K8sUtil: K8sUtil, | ||
| } | ||
| } | ||
|
|
||
|
|
@@ -1413,6 +1419,24 @@ func (impl PipelineBuilderImpl) PatchCiPipeline(request *bean.CiPatchRequest) (c | |
| ciConfig.AppWorkflowId = request.AppWorkflowId | ||
| ciConfig.UserId = request.UserId | ||
| if request.CiPipeline != nil { | ||
| client, err := impl.K8sUtil.GetClientForInCluster() | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. will it works only for in cluster ? if not handle by cluster id. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes working . |
||
| if err != nil { | ||
| impl.logger.Errorw("exception while getting unique client id", "error", err) | ||
| return nil, err | ||
| } | ||
| cm, err := impl.K8sUtil.GetConfigMap(ConfigMapNamespace, DashboardConfigMap, client) | ||
|
||
| if err != nil { | ||
| impl.logger.Errorw("error while getting dashboard-cm", "error", err) | ||
| return nil, err | ||
| } | ||
| datamap := cm.Data | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What if cm is nil, handle that case also There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. not able to see it handled There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. might not be showing that time, handled it. |
||
| forceScanConfig, err := strconv.ParseBool(datamap["FORCE_SECURITY_SCANNING"]) | ||
|
||
| if err != nil { | ||
| forceScanConfig = false | ||
| } | ||
| if forceScanConfig { | ||
| request.CiPipeline.ScanEnabled = true | ||
| } | ||
| ciConfig.ScanEnabled = request.CiPipeline.ScanEnabled | ||
| } | ||
| switch request.Action { | ||
|
|
||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
check similar constants already used, remove namespace const.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dashboard-cm const is not used, removed namespace const.