Exemple #1
0
func clusterTxn(view db.Database, stitch stitch.Stitch) error {
	namespace := stitch.QueryString("Namespace")
	if namespace == "" {
		namespace = "DEFAULT_NAMESPACE"
		msg := "policy did not specify 'Namespace', defaulting to '%s'"
		log.Warn(fmt.Sprintf(msg, namespace))
	}

	cluster, err := view.GetCluster()
	if err != nil {
		cluster = view.InsertCluster()
	}

	cluster.Namespace = namespace
	cluster.Spec = stitch.String()
	view.Commit(cluster)
	return nil
}