This repository has been archived by the owner on Jul 6, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 99
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enable CosmosDB Account Updates (#526)
* Adding update schema * DRY cleanup and implement update * Cleanup, Actually call deployer.Update
- Loading branch information
1 parent
47739e5
commit ab0b831
Showing
11 changed files
with
326 additions
and
30 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
This file was deleted.
Oops, something went wrong.
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,59 @@ | ||
package cosmosdb | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/Azure/open-service-broker-azure/pkg/service" | ||
) | ||
|
||
func (c *cosmosAccountManager) updateDeployment( | ||
pp *service.ProvisioningParameters, | ||
up *service.ProvisioningParameters, | ||
dt *cosmosdbInstanceDetails, | ||
kind string, | ||
capability string, | ||
additionalTags map[string]string, | ||
) error { | ||
p, err := c.buildGoTemplateParams(up, dt, kind) | ||
if err != nil { | ||
return err | ||
} | ||
if capability != "" { | ||
p["capability"] = capability | ||
} | ||
tags := getTags(pp) | ||
for k, v := range additionalTags { | ||
tags[k] = v | ||
} | ||
err = c.deployUpdatedARMTemplate( | ||
up, | ||
dt, | ||
p, | ||
tags, | ||
) | ||
if err != nil { | ||
return fmt.Errorf("error deploying ARM template: %s", err) | ||
} | ||
return nil | ||
} | ||
|
||
func (c *cosmosAccountManager) deployUpdatedARMTemplate( | ||
pp *service.ProvisioningParameters, | ||
dt *cosmosdbInstanceDetails, | ||
goParams map[string]interface{}, | ||
tags map[string]string, | ||
) error { | ||
_, err := c.armDeployer.Update( | ||
dt.ARMDeploymentName, | ||
pp.GetString("resourceGroup"), | ||
pp.GetString("location"), | ||
armTemplateBytes, | ||
goParams, // Go template params | ||
map[string]interface{}{}, | ||
tags, | ||
) | ||
if err != nil { | ||
return fmt.Errorf("error deploying ARM template: %s", err) | ||
} | ||
return nil | ||
} |
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,43 @@ | ||
package cosmosdb | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
|
||
"github.com/Azure/open-service-broker-azure/pkg/service" | ||
) | ||
|
||
func (g *graphAccountManager) ValidateUpdatingParameters( | ||
instance service.Instance, | ||
) error { | ||
return nil | ||
} | ||
|
||
func (g *graphAccountManager) GetUpdater( | ||
service.Plan, | ||
) (service.Updater, error) { | ||
// There isn't a need to do any "pre-provision here. just the update step" | ||
return service.NewUpdater( | ||
service.NewUpdatingStep("updateARMTemplate", g.updateARMTemplate), | ||
) | ||
} | ||
|
||
func (g *graphAccountManager) updateARMTemplate( | ||
_ context.Context, | ||
instance service.Instance, | ||
) (service.InstanceDetails, error) { | ||
err := g.cosmosAccountManager.updateDeployment( | ||
instance.ProvisioningParameters, | ||
instance.UpdatingParameters, | ||
instance.Details.(*cosmosdbInstanceDetails), | ||
"GlobalDocumentDB", | ||
"EnableGremlin", | ||
map[string]string{ | ||
"defaultExperience": "Graph", | ||
}, | ||
) | ||
if err != nil { | ||
return nil, fmt.Errorf("error deploying ARM template: %s", err) | ||
} | ||
return instance.Details, nil | ||
} |
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,41 @@ | ||
package cosmosdb | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
|
||
"github.com/Azure/open-service-broker-azure/pkg/service" | ||
) | ||
|
||
func (m *mongoAccountManager) ValidateUpdatingParameters( | ||
instance service.Instance, | ||
) error { | ||
return nil | ||
} | ||
|
||
func (m *mongoAccountManager) GetUpdater( | ||
service.Plan, | ||
) (service.Updater, error) { | ||
// There isn't a need to do any "pre-provision here. just the update step" | ||
return service.NewUpdater( | ||
service.NewUpdatingStep("updateARMTemplate", m.updateARMTemplate), | ||
) | ||
} | ||
|
||
func (m *mongoAccountManager) updateARMTemplate( | ||
_ context.Context, | ||
instance service.Instance, | ||
) (service.InstanceDetails, error) { | ||
err := m.cosmosAccountManager.updateDeployment( | ||
instance.ProvisioningParameters, | ||
instance.UpdatingParameters, | ||
instance.Details.(*cosmosdbInstanceDetails), | ||
"MongoDB", | ||
"", | ||
map[string]string{}, | ||
) | ||
if err != nil { | ||
return nil, fmt.Errorf("error deploying ARM template: %s", err) | ||
} | ||
return instance.Details, nil | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package cosmosdb | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
|
||
"github.com/Azure/open-service-broker-azure/pkg/service" | ||
) | ||
|
||
func (s *sqlAccountManager) ValidateUpdatingParameters( | ||
instance service.Instance, | ||
) error { | ||
return nil | ||
} | ||
|
||
func (s *sqlAccountManager) GetUpdater(service.Plan) (service.Updater, error) { | ||
// There isn't a need to do any "pre-provision here. just the update step" | ||
return service.NewUpdater( | ||
service.NewUpdatingStep("updateARMTemplate", s.updateARMTemplate), | ||
) | ||
} | ||
|
||
func (s *sqlAccountManager) updateARMTemplate( | ||
_ context.Context, | ||
instance service.Instance, | ||
) (service.InstanceDetails, error) { | ||
err := s.cosmosAccountManager.updateDeployment( | ||
instance.ProvisioningParameters, | ||
instance.UpdatingParameters, | ||
instance.Details.(*cosmosdbInstanceDetails), | ||
"GlobalDocumentDB", | ||
"", | ||
map[string]string{ | ||
"defaultExperience": "DocumentDB", | ||
}, | ||
) | ||
if err != nil { | ||
return nil, fmt.Errorf("error deploying ARM template: %s", err) | ||
} | ||
return instance.Details, nil | ||
} |
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,42 @@ | ||
package cosmosdb | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
|
||
"github.com/Azure/open-service-broker-azure/pkg/service" | ||
) | ||
|
||
func (s *sqlAllInOneManager) ValidateUpdatingParameters( | ||
instance service.Instance, | ||
) error { | ||
return nil | ||
} | ||
|
||
func (s *sqlAllInOneManager) GetUpdater(service.Plan) (service.Updater, error) { | ||
// There isn't a need to do any "pre-provision here. just the update step" | ||
return service.NewUpdater( | ||
service.NewUpdatingStep("updateARMTemplate", s.updateARMTemplate), | ||
) | ||
} | ||
|
||
func (s *sqlAllInOneManager) updateARMTemplate( | ||
_ context.Context, | ||
instance service.Instance, | ||
) (service.InstanceDetails, error) { | ||
dt := instance.Details.(*sqlAllInOneInstanceDetails) | ||
err := s.cosmosAccountManager.updateDeployment( | ||
instance.ProvisioningParameters, | ||
instance.UpdatingParameters, | ||
&dt.cosmosdbInstanceDetails, | ||
"GlobalDocumentDB", | ||
"", | ||
map[string]string{ | ||
"defaultExperience": "DocumentDB", | ||
}, | ||
) | ||
if err != nil { | ||
return nil, fmt.Errorf("error deploying ARM template: %s", err) | ||
} | ||
return instance.Details, nil | ||
} |
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,15 @@ | ||
package cosmosdb | ||
|
||
import ( | ||
"github.com/Azure/open-service-broker-azure/pkg/service" | ||
) | ||
|
||
func (s *sqlDatabaseManager) ValidateUpdatingParameters( | ||
service.Instance, | ||
) error { | ||
return nil | ||
} | ||
|
||
func (s *sqlDatabaseManager) GetUpdater(service.Plan) (service.Updater, error) { | ||
return service.NewUpdater() | ||
} |
Oops, something went wrong.