Created
December 3, 2014 19:14
-
-
Save pweil-/a77ff5a348b6d6bb7f68 to your computer and use it in GitHub Desktop.
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 is a mock up of the minimal viable product for rollbacks. It is NOT a complete solution. | |
A rollback is essentially a posting of an old deployment config on top of the current config. However, | |
the user will indicate which version of the deployment config they'd like to use by specifying a deployment | |
from 'list deployments' or whatever the replication controller version evolves into. | |
To demonstrate the mechanics the code below mocks what an actual api call would do. In an actual solution | |
I envision that it would be something like: | |
1. user posts to rollback endpoint with .json containing config parameters or with GET params | |
2. endpoint uses parameters to call DeploymentConfigRollbackGenerator.Generate(deploymentId) and receives | |
a new deployment config back that is based on the old deployment | |
3. endpoint performs validation | |
4. endpoint calls DeploymentConfig.Update(newConfig) | |
*/ | |
//1. user has posted a config - currently bootstrapped on top of the DeploymentConfig | |
glog.V(4).Infof("Reading rollback config") | |
rollbackConfig, err := ReadRollbackFile(cfg.RollbackConfigName) | |
if err != nil { | |
return err | |
} | |
//2. endpoint uses parameters to generate a new configuration | |
glog.V(4).Infof("Finding current deploy config named %s", rollbackConfig.ObjectMeta.Name) | |
currentConfig, err := osClient.DeploymentConfigs("").Get(rollbackConfig.ObjectMeta.Name) | |
if err != nil { | |
return err | |
} | |
glog.V(4).Infof("Finding rollback deployment with name %s", rollbackConfig.Rollback.To) | |
oldConfig, err := osClient.Deployments("").Get(rollbackConfig.Rollback.To) | |
if err != nil { | |
return err | |
} | |
currentConfig.Template.ControllerTemplate = oldConfig.ControllerTemplate | |
//3. endpoint performs validation (todo) | |
//4. endpoint calls update | |
osClient.DeploymentConfigs("").Update(currentConfig) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment