Skip to content

Commit

Permalink
controllers/migration: add revisions_schema (#51)
Browse files Browse the repository at this point in the history
  • Loading branch information
datdao authored Jun 15, 2023
1 parent 3625866 commit 611e328
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 4 deletions.
2 changes: 2 additions & 0 deletions api/v1alpha1/atlasmigration_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ type AtlasMigrationSpec struct {
Cloud Cloud `json:"cloud,omitempty"`
// Dir defines the directory to use for migrations as a configmap key reference.
Dir Dir `json:"dir"`
// RevisionsSchema defines the schema that revisions table resides in
RevisionsSchema string `json:"revisionsSchema,omitempty"`
}

// Cloud defines the Atlas Cloud configuration.
Expand Down
4 changes: 4 additions & 0 deletions charts/atlas-operator/templates/crds/crd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,10 @@ spec:
description: EnvName sets the environment name used for reporting
runs to Atlas Cloud.
type: string
revisionsSchema:
description: RevisionsSchema defines the schema that revisions table
resides in
type: string
url:
description: URL of the target database schema.
type: string
Expand Down
4 changes: 4 additions & 0 deletions config/crd/bases/db.atlasgo.io_atlasmigrations.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,10 @@ spec:
description: EnvName sets the environment name used for reporting
runs to Atlas Cloud.
type: string
revisionsSchema:
description: RevisionsSchema defines the schema that revisions table
resides in
type: string
url:
description: URL of the target database schema.
type: string
Expand Down
10 changes: 6 additions & 4 deletions controllers/atlasmigration_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,11 @@ func NewAtlasMigrationReconciler(mgr manager.Manager, cli MigrateCLI) *AtlasMigr
// that will be used for Atlas CLI
type (
atlasMigrationData struct {
EnvName string
URL string
Migration *migration
Cloud *cloud
EnvName string
URL string
Migration *migration
Cloud *cloud
RevisionsSchema string
}

migration struct {
Expand Down Expand Up @@ -271,6 +272,7 @@ func (r *AtlasMigrationReconciler) extractMigrationData(
tmplData.EnvName = "kubernetes"
}

tmplData.RevisionsSchema = am.Spec.RevisionsSchema
return tmplData, cleanUpDir, nil
}

Expand Down
3 changes: 3 additions & 0 deletions controllers/templates/atlas_migration.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ env {
{{- end }}
{{- with .Migration }}
dir = "{{ .Dir }}"
{{- end }}
{{- if .RevisionsSchema }}
revisions_schema = "{{ .RevisionsSchema }}"
{{- end }}
}
}

0 comments on commit 611e328

Please sign in to comment.