Skip to content

Commit

Permalink
chore: change to pointer
Browse files Browse the repository at this point in the history
  • Loading branch information
giautm committed Nov 27, 2023
1 parent 52b5c2f commit 747ffd4
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 20 deletions.
12 changes: 6 additions & 6 deletions api/v1alpha1/atlasschema_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ type (
// +kubebuilder:default=file
TxMode TransactionMode `json:"txMode,omitempty"`
// Policy defines the policies to apply when managing the schema change lifecycle.
Policy Policy `json:"policy,omitempty"`
Policy *Policy `json:"policy,omitempty"`
// The names of the schemas (named databases) on the target database to be managed.
Schemas []string `json:"schemas,omitempty"`
}
Expand All @@ -90,21 +90,21 @@ type (
}
// Policy defines the policies to apply when managing the schema change lifecycle.
Policy struct {
Lint Lint `json:"lint,omitempty"`
Diff Diff `json:"diff,omitempty"`
Lint *Lint `json:"lint,omitempty"`
Diff *Diff `json:"diff,omitempty"`
}
// Lint defines the linting policies to apply before applying the schema.
Lint struct {
Destructive CheckConfig `json:"destructive,omitempty"`
Destructive *CheckConfig `json:"destructive,omitempty"`
}
// CheckConfig defines the configuration of a linting check.
CheckConfig struct {
Error bool `json:"error,omitempty"`
}
// Diff defines the diff policies to apply when planning schema changes.
Diff struct {
ConcurrentIndex ConcurrentIndex `json:"concurrent_index,omitempty"`
Skip SkipChanges `json:"skip,omitempty"`
ConcurrentIndex *ConcurrentIndex `json:"concurrent_index,omitempty"`
Skip *SkipChanges `json:"skip,omitempty"`
}
// SkipChanges represents the skip changes policy.
SkipChanges struct {
Expand Down
36 changes: 30 additions & 6 deletions api/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion controllers/atlasschema_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ type (
DevURL string
Schemas []string
Exclude []string
Policy dbv1alpha1.Policy
Policy *dbv1alpha1.Policy

desired []byte
ext string
Expand Down
18 changes: 11 additions & 7 deletions controllers/atlasschema_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -377,8 +377,12 @@ func TestDiffPolicy(t *testing.T) {
sc := conditionReconciling()
sc.Spec.URL = tt.dburl
sc.Spec.Schema.SQL = "create table y (c int);"
sc.Spec.Policy.Diff.Skip = dbv1alpha1.SkipChanges{
DropTable: true,
sc.Spec.Policy = &dbv1alpha1.Policy{
Diff: &dbv1alpha1.Diff{
Skip: &dbv1alpha1.SkipChanges{
DropTable: true,
},
},
}
sc.Status.LastApplied = 1
tt.k8s.put(sc)
Expand All @@ -401,12 +405,12 @@ func TestConfigTemplate(t *testing.T) {
EnvName: defaultEnvName,
URL: must(url.Parse("mysql://root:password@localhost:3306/test")),
DevURL: "mysql://root:password@localhost:3306/dev",
Policy: dbv1alpha1.Policy{
Lint: dbv1alpha1.Lint{
Destructive: dbv1alpha1.CheckConfig{Error: true},
Policy: &dbv1alpha1.Policy{
Lint: &dbv1alpha1.Lint{
Destructive: &dbv1alpha1.CheckConfig{Error: true},
},
Diff: dbv1alpha1.Diff{
Skip: dbv1alpha1.SkipChanges{
Diff: &dbv1alpha1.Diff{
Skip: &dbv1alpha1.SkipChanges{
DropSchema: true,
DropTable: true,
},
Expand Down

0 comments on commit 747ffd4

Please sign in to comment.