Skip to content
This repository has been archived by the owner on Jul 19, 2022. It is now read-only.

Commit

Permalink
feat(cf): Move service polling into orca
Browse files Browse the repository at this point in the history
spinnaker/spinnaker#3637

Co-Authored-By: Jason Chu <jchu@pivotal.io>
  • Loading branch information
2 people authored and jkschneider committed Feb 15, 2019
1 parent c440a4c commit c306256
Show file tree
Hide file tree
Showing 14 changed files with 720 additions and 41 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
* Copyright 2019 Pivotal 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.orca.clouddriver.pipeline.providers.cf;

import com.netflix.spinnaker.orca.clouddriver.pipeline.servicebroker.DeployServiceStagePreprocessor;
import com.netflix.spinnaker.orca.clouddriver.tasks.providers.cf.CloudFoundryDeployServiceTask;
import com.netflix.spinnaker.orca.clouddriver.tasks.providers.cf.CloudFoundryMonitorKatoServicesTask;
import com.netflix.spinnaker.orca.kato.pipeline.support.StageData;
import com.netflix.spinnaker.orca.pipeline.TaskNode;
import com.netflix.spinnaker.orca.pipeline.model.Stage;
import org.springframework.stereotype.Component;

@Component
public class CloudFoundryDeployServiceStagePreprocessor implements DeployServiceStagePreprocessor {
@Override
public boolean supports(Stage stage) {
return "cloudfoundry".equals(stage.mapTo(StageData.class).getCloudProvider());
}

@Override
public void addSteps(TaskNode.Builder builder, Stage stage) {
builder.withTask("deployService", CloudFoundryDeployServiceTask.class)
.withTask("monitorDeployService", CloudFoundryMonitorKatoServicesTask.class);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
* Copyright 2019 Pivotal 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.orca.clouddriver.pipeline.providers.cf;

import com.netflix.spinnaker.orca.clouddriver.pipeline.servicebroker.DestroyServiceStagePreprocessor;
import com.netflix.spinnaker.orca.clouddriver.tasks.providers.cf.CloudFoundryDestroyServiceTask;
import com.netflix.spinnaker.orca.clouddriver.tasks.providers.cf.CloudFoundryMonitorKatoServicesTask;
import com.netflix.spinnaker.orca.kato.pipeline.support.StageData;
import com.netflix.spinnaker.orca.pipeline.TaskNode;
import com.netflix.spinnaker.orca.pipeline.model.Stage;
import org.springframework.stereotype.Component;

@Component
public class CloudFoundryDestroyServiceStagePreprocessor implements DestroyServiceStagePreprocessor {
@Override
public boolean supports(Stage stage) {
return "cloudfoundry".equals(stage.mapTo(StageData.class).getCloudProvider());
}

@Override
public void addSteps(TaskNode.Builder builder, Stage stage) {
builder.withTask("destroyService", CloudFoundryDestroyServiceTask.class)
.withTask("monitorDestroyService", CloudFoundryMonitorKatoServicesTask.class);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,25 +16,35 @@

package com.netflix.spinnaker.orca.clouddriver.pipeline.servicebroker;

import com.netflix.spinnaker.orca.clouddriver.tasks.MonitorKatoTask;
import com.netflix.spinnaker.orca.clouddriver.tasks.servicebroker.DeployServiceTask;
import com.netflix.spinnaker.orca.pipeline.StageDefinitionBuilder;
import com.netflix.spinnaker.orca.clouddriver.pipeline.AbstractCloudProviderAwareStage;
import com.netflix.spinnaker.orca.pipeline.TaskNode;
import com.netflix.spinnaker.orca.pipeline.model.Stage;
import groovy.transform.CompileStatic;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import javax.annotation.Nonnull;
import java.util.ArrayList;
import java.util.List;

@Component
@CompileStatic
class DeployServiceStage implements StageDefinitionBuilder {
class DeployServiceStage extends AbstractCloudProviderAwareStage {

public static final String PIPELINE_CONFIG_TYPE = "deployService";

@Autowired(required = false)
List<DeployServiceStagePreprocessor> deployServiceStagePreprocessors = new ArrayList<>();

public DeployServiceStage() {
super(PIPELINE_CONFIG_TYPE);
}

@Override
public void taskGraph(@Nonnull Stage stage, @Nonnull TaskNode.Builder builder) {
builder
.withTask("deployService", DeployServiceTask.class)
.withTask("monitorDeployService", MonitorKatoTask.class);
deployServiceStagePreprocessors
.stream()
.filter(it -> it.supports(stage))
.forEach(it -> it.addSteps(builder, stage));
}
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
* Copyright 2019 Pivotal 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.orca.clouddriver.pipeline.servicebroker;

import com.netflix.spinnaker.orca.pipeline.TaskNode;
import com.netflix.spinnaker.orca.pipeline.model.Stage;

/**
* Supports generic modification of a Deploy Service stage.
*
* Common use-cases:
* - injecting cloud-aware steps
*/
public interface DeployServiceStagePreprocessor {
boolean supports(Stage stage);

void addSteps(TaskNode.Builder builder, Stage stage);
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,25 +16,34 @@

package com.netflix.spinnaker.orca.clouddriver.pipeline.servicebroker;

import com.netflix.spinnaker.orca.clouddriver.tasks.MonitorKatoTask;
import com.netflix.spinnaker.orca.clouddriver.tasks.servicebroker.DestroyServiceTask;
import com.netflix.spinnaker.orca.pipeline.StageDefinitionBuilder;
import com.netflix.spinnaker.orca.clouddriver.pipeline.AbstractCloudProviderAwareStage;
import com.netflix.spinnaker.orca.pipeline.TaskNode;
import com.netflix.spinnaker.orca.pipeline.model.Stage;
import groovy.transform.CompileStatic;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import javax.annotation.Nonnull;
import java.util.ArrayList;
import java.util.List;

@Component
@CompileStatic
class DestroyServiceStage implements StageDefinitionBuilder {
class DestroyServiceStage extends AbstractCloudProviderAwareStage {
public static final String PIPELINE_CONFIG_TYPE = "destroyService";

@Autowired(required = false)
List<DestroyServiceStagePreprocessor> destroyServiceStagePreprocessors = new ArrayList<>();

public DestroyServiceStage() {
super(PIPELINE_CONFIG_TYPE);
}

@Override
public void taskGraph(@Nonnull Stage stage, @Nonnull TaskNode.Builder builder) {
builder
.withTask("destroyService", DestroyServiceTask.class)
.withTask("monitorDestroyService", MonitorKatoTask.class);
destroyServiceStagePreprocessors
.stream()
.filter(it -> it.supports(stage))
.forEach(it -> it.addSteps(builder, stage));
}
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
* Copyright 2019 Pivotal 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.orca.clouddriver.pipeline.servicebroker;

import com.netflix.spinnaker.orca.pipeline.TaskNode;
import com.netflix.spinnaker.orca.pipeline.model.Stage;

/**
* Supports generic modification of a Deploy Service stage.
*
* Common use-cases:
* - injecting cloud-aware steps
*/
public interface DestroyServiceStagePreprocessor {
boolean supports(Stage stage);

void addSteps(TaskNode.Builder builder, Stage stage);
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
/*
* Copyright 2018-Present Pivotal, Inc.
* Copyright 2019 Pivotal 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
* 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
* 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,
Expand All @@ -14,7 +14,7 @@
* limitations under the License.
*/

package com.netflix.spinnaker.orca.clouddriver.tasks.servicebroker;
package com.netflix.spinnaker.orca.clouddriver.tasks.providers.cf;

import com.google.common.collect.ImmutableMap;
import com.netflix.spinnaker.orca.ExecutionStatus;
Expand All @@ -30,11 +30,10 @@
import java.util.*;

@Component
public class DeployServiceTask extends AbstractCloudProviderAwareTask implements Task {
public class CloudFoundryDeployServiceTask extends AbstractCloudProviderAwareTask {
private KatoService kato;

private final KatoService kato;

public DeployServiceTask(KatoService kato) {
public CloudFoundryDeployServiceTask(KatoService kato) {
this.kato = kato;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,24 +1,23 @@
/*
* Copyright 2018 Pivotal, Inc.
* Copyright 2019 Pivotal 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
* 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.
* 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.orca.clouddriver.tasks.servicebroker;
package com.netflix.spinnaker.orca.clouddriver.tasks.providers.cf;

import com.google.common.collect.ImmutableMap;
import com.netflix.spinnaker.orca.ExecutionStatus;
import com.netflix.spinnaker.orca.Task;
import com.netflix.spinnaker.orca.TaskResult;
import com.netflix.spinnaker.orca.clouddriver.KatoService;
import com.netflix.spinnaker.orca.clouddriver.model.TaskId;
Expand All @@ -31,11 +30,10 @@
import java.util.Map;

@Component
public class DestroyServiceTask extends AbstractCloudProviderAwareTask implements Task {
public class CloudFoundryDestroyServiceTask extends AbstractCloudProviderAwareTask {
private KatoService kato;

private final KatoService kato;

public DestroyServiceTask(KatoService kato) {
public CloudFoundryDestroyServiceTask(KatoService kato) {
this.kato = kato;
}

Expand Down
Loading

0 comments on commit c306256

Please sign in to comment.