Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(aws): Adding support for launch templates in UpdateSecurityGroup… (
#3893) * feat(aws): Adding support for launch templates in UpdateSecurityGroupsForServerGroupStage - added UpdateLaunchTemplateTask to handle security groups for launch template backed server groups * PR feedback: Broken launch config and template into subclasses. Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
- Loading branch information
1 parent
a8b910d
commit 7006fb4
Showing
5 changed files
with
155 additions
and
25 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
66 changes: 66 additions & 0 deletions
66
...oovy/com/netflix/spinnaker/orca/clouddriver/tasks/servergroup/UpdateLaunchConfigTask.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,66 @@ | ||
/* | ||
* Copyright 2020 Netflix, 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.servergroup; | ||
|
||
import com.netflix.spinnaker.orca.api.pipeline.models.StageExecution; | ||
import com.netflix.spinnaker.orca.clouddriver.KatoService; | ||
import com.netflix.spinnaker.orca.clouddriver.model.TaskId; | ||
import groovy.util.logging.Slf4j; | ||
import java.util.Collections; | ||
import java.util.HashMap; | ||
import java.util.Map; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.beans.factory.annotation.Value; | ||
import org.springframework.stereotype.Component; | ||
|
||
@Component | ||
@Slf4j | ||
public class UpdateLaunchConfigTask extends AbstractUpdateLaunchSettingsTask { | ||
public static final String OPERATION = "updateLaunchConfig"; | ||
|
||
@Autowired | ||
public UpdateLaunchConfigTask( | ||
KatoService kato, @Value("${default.bake.account:default}") String defaultBakeAccount) { | ||
super(kato, defaultBakeAccount); | ||
} | ||
|
||
@Override | ||
public Map<String, Object> getContext(StageExecution stage, TaskId taskId) { | ||
final Map<String, Object> ctx = new HashMap<>(); | ||
final String region = (String) stage.getContext().get("region"); | ||
final String serverGroupName = | ||
(String) | ||
stage | ||
.getContext() | ||
.getOrDefault( | ||
stage.getContext().get("serverGroupName"), stage.getContext().get("asgName")); | ||
|
||
ctx.put("notification.type", "modifyasglaunchconfiguration"); | ||
ctx.put("modifyasglaunchconfiguration.account.name", getCredentials(stage)); | ||
ctx.put("modifyasglaunchconfiguration.region", region); | ||
ctx.put("kato.last.task.id", taskId); | ||
ctx.put( | ||
"deploy.server.groups", | ||
Collections.singletonMap(region, Collections.singletonList(serverGroupName))); | ||
return ctx; | ||
} | ||
|
||
@Override | ||
public String getOperation() { | ||
return OPERATION; | ||
} | ||
} |
64 changes: 64 additions & 0 deletions
64
...vy/com/netflix/spinnaker/orca/clouddriver/tasks/servergroup/UpdateLaunchTemplateTask.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,64 @@ | ||
/* | ||
* Copyright 2020 Netflix, 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.servergroup; | ||
|
||
import com.netflix.spinnaker.orca.api.pipeline.models.StageExecution; | ||
import com.netflix.spinnaker.orca.clouddriver.KatoService; | ||
import com.netflix.spinnaker.orca.clouddriver.model.TaskId; | ||
import java.util.Collections; | ||
import java.util.HashMap; | ||
import java.util.Map; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.beans.factory.annotation.Value; | ||
import org.springframework.stereotype.Component; | ||
|
||
@Component | ||
public class UpdateLaunchTemplateTask extends AbstractUpdateLaunchSettingsTask { | ||
public static final String OPERATION = "updateLaunchTemplate"; | ||
|
||
@Autowired | ||
public UpdateLaunchTemplateTask( | ||
KatoService kato, @Value("${default.bake.account:default}") String defaultBakeAccount) { | ||
super(kato, defaultBakeAccount); | ||
} | ||
|
||
@Override | ||
public Map<String, Object> getContext(StageExecution stage, TaskId taskId) { | ||
final Map<String, Object> ctx = new HashMap<>(); | ||
final String region = (String) stage.getContext().get("region"); | ||
final String serverGroupName = | ||
(String) | ||
stage | ||
.getContext() | ||
.getOrDefault( | ||
stage.getContext().get("serverGroupName"), stage.getContext().get("asgName")); | ||
|
||
ctx.put("notification.type", "modifyservergrouplaunchtemplate"); | ||
ctx.put("modifyservergrouplaunchtemplate.account.name", getCredentials(stage)); | ||
ctx.put("modifyservergrouplaunchtemplate.region", region); | ||
ctx.put("kato.last.task.id", taskId); | ||
ctx.put( | ||
"deploy.server.groups", | ||
Collections.singletonMap(region, Collections.singletonList(serverGroupName))); | ||
return ctx; | ||
} | ||
|
||
@Override | ||
public String getOperation() { | ||
return OPERATION; | ||
} | ||
} |
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