-
Notifications
You must be signed in to change notification settings - Fork 811
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(provider/kubernetes): scale manifest (#1803)
- Loading branch information
Showing
4 changed files
with
134 additions
and
36 deletions.
There are no files selected for viewing
38 changes: 38 additions & 0 deletions
38
...n/groovy/com/netflix/spinnaker/orca/clouddriver/pipeline/manifest/ScaleManifestStage.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,38 @@ | ||
/* | ||
* Copyright 2017 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.orca.clouddriver.pipeline.manifest; | ||
|
||
import com.netflix.spinnaker.orca.clouddriver.tasks.MonitorKatoTask; | ||
import com.netflix.spinnaker.orca.clouddriver.tasks.manifest.ScaleManifestTask; | ||
import com.netflix.spinnaker.orca.clouddriver.tasks.manifest.UpdateManifestForceCacheRefreshTask; | ||
import com.netflix.spinnaker.orca.pipeline.StageDefinitionBuilder; | ||
import com.netflix.spinnaker.orca.pipeline.TaskNode; | ||
import com.netflix.spinnaker.orca.pipeline.model.Stage; | ||
import org.springframework.stereotype.Component; | ||
|
||
@Component | ||
public class ScaleManifestStage implements StageDefinitionBuilder { | ||
public static final String PIPELINE_CONFIG_TYPE = "scaleManifest"; | ||
|
||
@Override | ||
public void taskGraph(Stage stage, TaskNode.Builder builder) { | ||
builder.withTask(ScaleManifestTask.TASK_NAME, ScaleManifestTask.class) | ||
.withTask("monitorScale", MonitorKatoTask.class) | ||
.withTask(UpdateManifestForceCacheRefreshTask.TASK_NAME, UpdateManifestForceCacheRefreshTask.class); | ||
} | ||
} |
63 changes: 63 additions & 0 deletions
63
...oovy/com/netflix/spinnaker/orca/clouddriver/tasks/manifest/GenericUpdateManifestTask.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,63 @@ | ||
/* | ||
* Copyright 2017 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.orca.clouddriver.tasks.manifest; | ||
|
||
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; | ||
import com.netflix.spinnaker.orca.clouddriver.tasks.AbstractCloudProviderAwareTask; | ||
import com.netflix.spinnaker.orca.pipeline.model.Stage; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.stereotype.Component; | ||
|
||
import javax.annotation.Nonnull; | ||
import java.util.Collections; | ||
import java.util.Map; | ||
|
||
@Component | ||
public abstract class GenericUpdateManifestTask extends AbstractCloudProviderAwareTask implements Task { | ||
@Autowired | ||
KatoService kato; | ||
|
||
protected abstract String taskName(); | ||
|
||
@Nonnull | ||
@Override | ||
public TaskResult execute(@Nonnull Stage stage) { | ||
String credentials = getCredentials(stage); | ||
String cloudProvider = getCloudProvider(stage); | ||
Map<String, Map> operation = new ImmutableMap.Builder<String, Map>() | ||
.put(taskName(), stage.getContext()) | ||
.build(); | ||
|
||
TaskId taskId = kato.requestOperations(cloudProvider, Collections.singletonList(operation)).toBlocking().first(); | ||
|
||
Map<String, Object> outputs = new ImmutableMap.Builder<String, Object>() | ||
.put("kato.result.expected", false) | ||
.put("kato.last.task.id", taskId) | ||
.put("manifest.account.name", credentials) | ||
.put("manifest.name", stage.getContext().get("name")) | ||
.put("manifest.location", stage.getContext().get("location")) | ||
.build(); | ||
|
||
return new TaskResult(ExecutionStatus.SUCCEEDED, outputs); | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
.../main/groovy/com/netflix/spinnaker/orca/clouddriver/tasks/manifest/ScaleManifestTask.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,30 @@ | ||
/* | ||
* Copyright 2017 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.orca.clouddriver.tasks.manifest; | ||
|
||
import org.springframework.stereotype.Component; | ||
|
||
@Component | ||
public class ScaleManifestTask extends GenericUpdateManifestTask { | ||
public static final String TASK_NAME = "scaleManifest"; | ||
|
||
@Override | ||
protected String taskName() { | ||
return TASK_NAME; | ||
} | ||
} |
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