Skip to content

Commit

Permalink
Merge branch 'master' into configurable-slack-endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
diasjorge committed Oct 15, 2019
2 parents 8a8c69e + 0a103d9 commit 512c11c
Show file tree
Hide file tree
Showing 15 changed files with 337 additions and 9 deletions.
90 changes: 84 additions & 6 deletions docs/commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,10 @@
* [**hal config metric-stores datadog edit**](#hal-config-metric-stores-datadog-edit)
* [**hal config metric-stores datadog enable**](#hal-config-metric-stores-datadog-enable)
* [**hal config metric-stores edit**](#hal-config-metric-stores-edit)
* [**hal config metric-stores newrelic**](#hal-config-metric-stores-newrelic)
* [**hal config metric-stores newrelic disable**](#hal-config-metric-stores-newrelic-disable)
* [**hal config metric-stores newrelic edit**](#hal-config-metric-stores-newrelic-edit)
* [**hal config metric-stores newrelic enable**](#hal-config-metric-stores-newrelic-enable)
* [**hal config metric-stores prometheus**](#hal-config-metric-stores-prometheus)
* [**hal config metric-stores prometheus disable**](#hal-config-metric-stores-prometheus-disable)
* [**hal config metric-stores prometheus edit**](#hal-config-metric-stores-prometheus-edit)
Expand Down Expand Up @@ -6004,6 +6008,7 @@ hal config metric-stores [parameters] [subcommands]
#### Subcommands
* `datadog`: Configure your datadog metric store.
* `edit`: Configure global metric stores properties.
* `newrelic`: Configure your newrelic metric store.
* `prometheus`: Configure your prometheus metric store.
* `stackdriver`: Configure your stackdriver metric store.

Expand All @@ -6023,7 +6028,7 @@ hal config metric-stores datadog [parameters] [subcommands]

#### Subcommands
* `disable`: Set the datadog method as disabled
* `edit`: Edit the datadog authentication method.
* `edit`: Edit the datadog metric store.
* `enable`: Set the datadog method as enabled

---
Expand All @@ -6044,7 +6049,7 @@ hal config metric-stores datadog disable [parameters]
---
## hal config metric-stores datadog edit

Edit the datadog authentication method.
Edit the datadog metric store.

#### Usage
```
Expand Down Expand Up @@ -6092,6 +6097,75 @@ hal config metric-stores edit [parameters]
* `--period`: (*Required*) Set the polling period for the monitoring daemon.


---
## hal config metric-stores newrelic

Configure your newrelic metric store.

#### Usage
```
hal config metric-stores newrelic [parameters] [subcommands]
```

#### Parameters
* `--deployment`: If supplied, use this Halyard deployment. This will _not_ create a new deployment.
* `--no-validate`: (*Default*: `false`) Skip validation.

#### Subcommands
* `disable`: Set the newrelic method as disabled
* `edit`: Edit the newrelic metric store.
* `enable`: Set the newrelic method as enabled

---
## hal config metric-stores newrelic disable

Set the newrelic method as disabled

#### Usage
```
hal config metric-stores newrelic disable [parameters]
```

#### Parameters
* `--deployment`: If supplied, use this Halyard deployment. This will _not_ create a new deployment.
* `--no-validate`: (*Default*: `false`) Skip validation.


---
## hal config metric-stores newrelic edit

Edit the newrelic metric store.

#### Usage
```
hal config metric-stores newrelic edit [parameters]
```

#### Parameters
* `--add-tag`: Add this tag to the list of tags. Use the format key:value i.e. --add-tag app:test
* `--deployment`: If supplied, use this Halyard deployment. This will _not_ create a new deployment.
* `--host`: The URL to post metric data to. In almost all cases, this is set correctly by default and should not be used.
* `--insert-key`: Your New Relic Insights insert key
* `--no-validate`: (*Default*: `false`) Skip validation.
* `--remove-tag`: Remove this tag from the list of tags. Use the name of the tag you want to remove i.e. --remove-tag app
* `--tags`: (*Default*: `[]`) Your custom tags. Please delimit the KVP with colons i.e. --tags app:test env:dev


---
## hal config metric-stores newrelic enable

Set the newrelic method as enabled

#### Usage
```
hal config metric-stores newrelic enable [parameters]
```

#### Parameters
* `--deployment`: If supplied, use this Halyard deployment. This will _not_ create a new deployment.
* `--no-validate`: (*Default*: `false`) Skip validation.


---
## hal config metric-stores prometheus

Expand All @@ -6108,7 +6182,7 @@ hal config metric-stores prometheus [parameters] [subcommands]

#### Subcommands
* `disable`: Set the prometheus method as disabled
* `edit`: Edit the prometheus authentication method.
* `edit`: Edit the prometheus metric store.
* `enable`: Set the prometheus method as enabled

---
Expand All @@ -6129,7 +6203,7 @@ hal config metric-stores prometheus disable [parameters]
---
## hal config metric-stores prometheus edit

Edit the prometheus authentication method.
Edit the prometheus metric store.

#### Usage
```
Expand Down Expand Up @@ -6173,7 +6247,7 @@ hal config metric-stores stackdriver [parameters] [subcommands]

#### Subcommands
* `disable`: Set the stackdriver method as disabled
* `edit`: Edit the stackdriver authentication method.
* `edit`: Edit the stackdriver metric store.
* `enable`: Set the stackdriver method as enabled

---
Expand All @@ -6194,7 +6268,7 @@ hal config metric-stores stackdriver disable [parameters]
---
## hal config metric-stores stackdriver edit

Edit the stackdriver authentication method.
Edit the stackdriver metric store.

#### Usage
```
Expand Down Expand Up @@ -8739,6 +8813,7 @@ hal config provider kubernetes account edit ACCOUNT [parameters]

#### Parameters
`ACCOUNT`: The name of the account to operate on.
* `--add-custom-resource`: (V2 Only) Add Kubernetes custom resource to the list of custom resources to managed by clouddriver and made available for use in patch and delete manifest stages. Fields besides the Kubernetes Kind (resource name) can be set using the flags "--spinnaker-kind" and "--versioned"
* `--add-docker-registry`: Add this docker registry to the list of docker registries to use as a source of images.
* `--add-kind`: Add this kind to the list of kinds to manage.
* `--add-namespace`: Add this namespace to the list of namespaces to manage.
Expand Down Expand Up @@ -8775,6 +8850,7 @@ This can only be set when --namespaces is empty or not set.
created by Spinnaker; as opposed to attempting to configure applications for resources already present in Kubernetes.
* `--provider-version`: Some providers support multiple versions/release tracks. This allows you to pick the version of the provider (not the resources it manages) to run within Spinnaker.
* `--read-permissions`: A user must have at least one of these roles in order to view this account's cloud resources.
* `--remove-custom-resource`: Remove this Kubernetes custom resource by name from the list of custom resources to manage.
* `--remove-docker-registry`: Remove this docker registry from the list of docker registries to use as a source of images.
* `--remove-kind`: Remove this kind to the list of kinds to manage.
* `--remove-namespace`: Remove this namespace to the list of namespaces to manage.
Expand All @@ -8785,6 +8861,8 @@ created by Spinnaker; as opposed to attempting to configure applications for res
* `--remove-write-permission`: Remove this permission to from list of write permissions.
* `--required-group-membership`: A user must be a member of at least one specified group in order to make changes to this account's cloud resources.
* `--service-account`: When true, Spinnaker attempt to authenticate against Kubernetes using a Kubernetes service account. This only works when Halyard & Spinnaker are deployed in Kubernetes. Read more about service accounts here: [https://kubernetes.io/docs/tasks/configure-pod-container/configure-service-account/](https://kubernetes.io/docs/tasks/configure-pod-container/configure-service-account/).
* `--spinnaker-kind`: Set the Spinnaker kind for custom resource being added.
* `--versioned`: Configure whether the custom resource being added is versioned by Spinnaker.
* `--write-permissions`: A user must have at least one of these roles in order to make changes to this account's cloud resources.


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import com.beust.jcommander.Parameters;
import com.netflix.spinnaker.halyard.cli.command.v1.config.metricStores.EditMetricStoresCommand;
import com.netflix.spinnaker.halyard.cli.command.v1.config.metricStores.datadog.DatadogCommand;
import com.netflix.spinnaker.halyard.cli.command.v1.config.metricStores.newrelic.NewrelicCommand;
import com.netflix.spinnaker.halyard.cli.command.v1.config.metricStores.prometheus.PrometheusCommand;
import com.netflix.spinnaker.halyard.cli.command.v1.config.metricStores.stackdriver.StackdriverCommand;
import com.netflix.spinnaker.halyard.cli.services.v1.Daemon;
Expand All @@ -45,6 +46,7 @@ public class MetricStoresCommand extends AbstractConfigCommand {
public MetricStoresCommand() {
registerSubcommand(new EditMetricStoresCommand());
registerSubcommand(new DatadogCommand());
registerSubcommand(new NewrelicCommand());
registerSubcommand(new PrometheusCommand());
registerSubcommand(new StackdriverCommand());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public abstract class AbstractEditMetricStoreCommand<T extends MetricStore>
protected abstract MetricStore editMetricStore(T metricStore);

public String getShortDescription() {
return "Edit the " + getMetricStoreType().getId() + " authentication method.";
return "Edit the " + getMetricStoreType().getId() + " metric store.";
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
/*
* Copyright 2019 New Relic Corporation. All rights reserved.
*
* 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.metricStores.newrelic;

import com.beust.jcommander.Parameter;
import com.beust.jcommander.Parameters;
import com.netflix.spinnaker.halyard.cli.command.v1.config.metricStores.AbstractEditMetricStoreCommand;
import com.netflix.spinnaker.halyard.config.model.v1.metricStores.newrelic.NewrelicStore;
import com.netflix.spinnaker.halyard.config.model.v1.node.MetricStore;
import com.netflix.spinnaker.halyard.config.model.v1.node.MetricStores;
import java.util.ArrayList;
import java.util.List;

@Parameters(separators = "=")
public class EditNewrelicCommand extends AbstractEditMetricStoreCommand<NewrelicStore> {
public MetricStores.MetricStoreType getMetricStoreType() {
return MetricStores.MetricStoreType.NEWRELIC;
}

@Parameter(names = "--insert-key", description = "Your New Relic Insights insert key")
private String insertKey;

@Parameter(
names = "--host",
description =
"The URL to post metric data to. In almost all cases, this is set correctly by default and should not be used.")
private String host;

@Parameter(
names = "--tags",
variableArity = true,
description =
"Your custom tags. Please delimit the KVP with colons i.e. --tags app:test env:dev")
private List<String> tags = new ArrayList<>();

@Parameter(
names = "--add-tag",
description =
"Add this tag to the list of tags. Use the format key:value i.e. --add-tag app:test")
private String addTag;

@Parameter(
names = "--remove-tag",
description =
"Remove this tag from the list of tags. Use the name of the tag you want to remove i.e. --remove-tag app")
private String removeTag;

@Override
protected MetricStore editMetricStore(NewrelicStore newrelicStore) {
newrelicStore.setInsertKey(isSet(insertKey) ? insertKey : newrelicStore.getInsertKey());
newrelicStore.setHost(isSet(host) ? host : newrelicStore.getHost());

try {
newrelicStore.setTags(updateStringList(newrelicStore.getTags(), tags, addTag, removeTag));
} catch (IllegalArgumentException e) {
throw new IllegalArgumentException("Set either --tags or --[add/remove]-tag");
}

return newrelicStore;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*
* Copyright 2019 New Relic Corporation. All rights reserved.
*
* 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.metricStores.newrelic;

import com.beust.jcommander.Parameters;
import com.netflix.spinnaker.halyard.cli.command.v1.config.metricStores.MetricStoreCommand;
import com.netflix.spinnaker.halyard.config.model.v1.node.MetricStores;

@Parameters(separators = "=")
public class NewrelicCommand extends MetricStoreCommand {
public MetricStores.MetricStoreType getMetricStoreType() {
return MetricStores.MetricStoreType.NEWRELIC;
}

public NewrelicCommand() {
super();
registerSubcommand(new EditNewrelicCommand());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ protected Account buildAccount(String accountName) {
account.setCheckPermissionsOnStartup(checkPermissionsOnStartup);
account.setLiveManifestCalls(liveManifestCalls);
account.setCacheThreads(cacheThreads);

return account;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,4 +69,7 @@ public class KubernetesCommandProperties {
static final String CACHE_THREADS =
"Number of caching agents for this kubernetes account. Each agent handles a subset of the namespaces available to this account. "
+ "By default, only 1 agent caches all kinds for all namespaces in the account.";
static final String CUSTOM_RESOURCES =
"(V2 Only) Add Kubernetes custom resource to the list of custom resources to managed by clouddriver and made available for use in patch and delete manifest stages. "
+ "Fields besides the Kubernetes Kind (resource name) can be set using the flags \"--spinnaker-kind\" and \"--versioned\"";
}
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,31 @@ protected String getProviderName() {
@Parameter(names = "--naming-strategy", hidden = true)
public String namingStrategy;

@Parameter(
names = "--add-custom-resource",
arity = 1,
description = KubernetesCommandProperties.CUSTOM_RESOURCES)
public String addCustomResourceName;

@Parameter(
names = "--spinnaker-kind",
arity = 1,
description = "Set the Spinnaker kind for custom resource being added.")
public String addCustomResourceSpinnakerKind;

@Parameter(
names = "--versioned",
arity = 1,
description = "Configure whether the custom resource being added is versioned by Spinnaker.")
public Boolean addCustomResourceVersioned;

@Parameter(
names = "--remove-custom-resource",
arity = 1,
description =
"Remove this Kubernetes custom resource by name from the list of custom resources to manage.")
public String removeCustomResource;

@Parameter(
names = "--service-account",
arity = 1,
Expand Down Expand Up @@ -244,6 +269,36 @@ protected Account editAccount(KubernetesAccount account) {
throw new IllegalArgumentException("Set either --omit-kinds or --[add/remove]-omit-kind");
}

if (isSet(addCustomResourceName)) {
KubernetesAccount.CustomKubernetesResource customKubernetesResource =
new KubernetesAccount.CustomKubernetesResource();
customKubernetesResource.setKubernetesKind(addCustomResourceName);
customKubernetesResource.setSpinnakerKind(
isSet(addCustomResourceSpinnakerKind)
? addCustomResourceSpinnakerKind
: customKubernetesResource.getSpinnakerKind());
customKubernetesResource.setVersioned(
isSet(addCustomResourceVersioned)
? addCustomResourceVersioned
: customKubernetesResource.isVersioned());
account.getCustomResources().add(customKubernetesResource);
} else {
if (isSet(addCustomResourceSpinnakerKind) || isSet(addCustomResourceVersioned)) {
throw new IllegalArgumentException(
"\"--spinnaker-kind\" and \"--versioned\" can only be used with \"--add-custom-resource\" "
+ "to set the name for the custom resource.");
}
}

if (isSet(removeCustomResource)) {
List<KubernetesAccount.CustomKubernetesResource> newCustomResources =
account.getCustomResources().stream()
.filter(entry -> !entry.getKubernetesKind().equals(removeCustomResource))
.collect(Collectors.toList());

account.setCustomResources(newCustomResources);
}

try {
List<String> oldRegistries =
account.getDockerRegistries().stream()
Expand Down
Loading

0 comments on commit 512c11c

Please sign in to comment.