-
Notifications
You must be signed in to change notification settings - Fork 705
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: allow edit canary datadog (#1738)
allows halyard command edit canary datadog allows setting metadataCachingIntervalMS in the same manner as prometheus Co-authored-by: Kevin Woo <kevinawoo@gmail.com> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
- Loading branch information
1 parent
054fb99
commit 71b8e21
Showing
4 changed files
with
96 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
76 changes: 76 additions & 0 deletions
76
...flix/spinnaker/halyard/cli/command/v1/config/canary/datadog/EditCanaryDatadogCommand.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
/* | ||
* Copyright 2018 Google, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License") | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.netflix.spinnaker.halyard.cli.command.v1.config.canary.datadog; | ||
|
||
import com.beust.jcommander.Parameter; | ||
import com.beust.jcommander.Parameters; | ||
import com.netflix.spinnaker.halyard.cli.command.v1.config.canary.AbstractEditCanaryServiceIntegrationCommand; | ||
import com.netflix.spinnaker.halyard.cli.command.v1.config.canary.account.CanaryUtils; | ||
import com.netflix.spinnaker.halyard.cli.services.v1.Daemon; | ||
import com.netflix.spinnaker.halyard.cli.services.v1.OperationHandler; | ||
import com.netflix.spinnaker.halyard.cli.ui.v1.AnsiUi; | ||
import com.netflix.spinnaker.halyard.config.model.v1.canary.Canary; | ||
import com.netflix.spinnaker.halyard.config.model.v1.canary.datadog.DatadogCanaryServiceIntegration; | ||
|
||
@Parameters(separators = "=") | ||
public class EditCanaryDatadogCommand extends AbstractEditCanaryServiceIntegrationCommand { | ||
|
||
@Override | ||
protected String getServiceIntegration() { | ||
return "Datadog"; | ||
} | ||
|
||
@Parameter( | ||
names = "--metadata-caching-interval-ms", | ||
description = | ||
"Number of milliseconds to wait in between caching the names of available metric types (for use in building canary configs; *Default*: `60000`).") | ||
private Long metadataCachingIntervalMS; | ||
|
||
@Override | ||
protected void executeThis() { | ||
String currentDeployment = getCurrentDeployment(); | ||
// Disable validation here, since we don't want an illegal config to prevent us from fixing it. | ||
Canary canary = | ||
new OperationHandler<Canary>() | ||
.setFailureMesssage("Failed to get canary.") | ||
.setOperation(Daemon.getCanary(currentDeployment, false)) | ||
.get(); | ||
|
||
int originalHash = canary.hashCode(); | ||
|
||
DatadogCanaryServiceIntegration datadogCanaryServiceIntegration = | ||
(DatadogCanaryServiceIntegration) | ||
CanaryUtils.getServiceIntegrationByClass(canary, DatadogCanaryServiceIntegration.class); | ||
|
||
datadogCanaryServiceIntegration.setMetadataCachingIntervalMS( | ||
isSet(metadataCachingIntervalMS) | ||
? metadataCachingIntervalMS | ||
: datadogCanaryServiceIntegration.getMetadataCachingIntervalMS()); | ||
|
||
if (originalHash == canary.hashCode()) { | ||
AnsiUi.failure("No changes supplied."); | ||
return; | ||
} | ||
|
||
new OperationHandler<Void>() | ||
.setOperation(Daemon.setCanary(currentDeployment, !noValidate, canary)) | ||
.setFailureMesssage("Failed to edit canary analysis Datadog service integration settings.") | ||
.setSuccessMessage( | ||
"Successfully edited canary analysis Datadog service integration settings.") | ||
.get(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters