Skip to content

Commit

Permalink
chore: bump atlas to latest (#128)
Browse files Browse the repository at this point in the history
  • Loading branch information
giautm authored Jan 15, 2024
1 parent 5d27fa5 commit e573477
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 18 deletions.
2 changes: 1 addition & 1 deletion config/crd/bases/db.atlasgo.io_atlasmigrations.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2023 The Atlas Operator Authors.
# Copyright 2024 The Atlas Operator Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion config/crd/bases/db.atlasgo.io_atlasschemas.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2023 The Atlas Operator Authors.
# Copyright 2024 The Atlas Operator Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion config/rbac/role.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2023 The Atlas Operator Authors.
# Copyright 2024 The Atlas Operator Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
6 changes: 3 additions & 3 deletions controllers/atlasmigration_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ func TestMigration_ConfigMap(t *testing.T) {
"Normal Applied Version 20230412003626 applied",
"Normal Applied Version 20230412003626 applied",
"Normal Applied Version 20230808132722 applied",
`Warning Error sql/migrate: execute: executing statement "SYNTAX ERROR" from version "20230808140359": near "SYNTAX": syntax error`,
`Warning Error sql/migrate: executing statement "SYNTAX ERROR" from version "20230808140359": near "SYNTAX": syntax error`,
}, h.events())
}

Expand Down Expand Up @@ -227,7 +227,7 @@ func TestMigration_Local(t *testing.T) {
"Normal Applied Version 20230412003626 applied",
"Normal Applied Version 20230412003626 applied",
"Normal Applied Version 20230808132722 applied",
`Warning Error sql/migrate: execute: executing statement "SYNTAX ERROR" from version "20230808140359": near "SYNTAX": syntax error`,
`Warning Error sql/migrate: executing statement "SYNTAX ERROR" from version "20230808140359": near "SYNTAX": syntax error`,
}, h.events())
}

Expand Down Expand Up @@ -293,7 +293,7 @@ func TestReconcile_BadSQL(t *testing.T) {

status = tt.status()
require.EqualValues(tt, metav1.ConditionFalse, status.Conditions[0].Status)
require.Contains(tt, status.Conditions[0].Message, "sql/migrate: execute: executing statement")
require.Contains(tt, status.Conditions[0].Message, "sql/migrate: executing statement")
}

func TestReconcile_LocalMigrationDir(t *testing.T) {
Expand Down
16 changes: 8 additions & 8 deletions controllers/atlasschema_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ package controllers
import (
"bytes"
"context"
"errors"
"fmt"
"net/url"
"os"
Expand All @@ -34,7 +35,7 @@ import (
"github.com/stretchr/testify/require"
appsv1 "k8s.io/api/apps/v1"
corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/errors"
kerr "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
Expand Down Expand Up @@ -369,7 +370,7 @@ func TestBadSQL(t *testing.T) {
require.EqualValues(t, schemaReadyCond, cont.Type)
require.EqualValues(t, metav1.ConditionFalse, cont.Status)
require.EqualValues(t, "LintPolicyError", cont.Reason)
require.Contains(t, cont.Message, "sql/migrate: execute: executing statement")
require.Contains(t, cont.Message, "executing statement:")
}

func TestDiffPolicy(t *testing.T) {
Expand Down Expand Up @@ -579,7 +580,7 @@ func (m *mockClient) Get(ctx context.Context, key client.ObjectKey, obj client.O
// retrieve the object from the state map
o, ok := m.state[key]
if !ok {
return errors.NewNotFound(schema.GroupResource{
return kerr.NewNotFound(schema.GroupResource{
Group: obj.GetObjectKind().GroupVersionKind().Group,
}, key.Name)
}
Expand Down Expand Up @@ -657,7 +658,7 @@ func TestMock(t *testing.T) {
err := tt.k8s.Get(context.Background(), client.ObjectKey{
Name: "non-existent",
}, &d)
require.True(t, errors.IsNotFound(err))
require.True(t, kerr.IsNotFound(err))
// Retrieve an existing object
err = tt.k8s.Get(context.Background(), client.ObjectKey{
Name: "test",
Expand Down Expand Up @@ -735,8 +736,7 @@ func events(r record.EventRecorder) []string {
// ensures we support both formats.
func TestSQLErrRegression(t *testing.T) {
m := `executing statement "create table bar (id int)"`
e1 := fmt.Errorf(`sql/migrate: execute: %s`, m)
e2 := fmt.Errorf(`sql/migrate: %s`, m)
require.True(t, isSQLErr(e1))
require.True(t, isSQLErr(e2))
require.True(t, isSQLErr(fmt.Errorf(`sql/migrate: execute: %s`, m)))
require.True(t, isSQLErr(fmt.Errorf(`sql/migrate: %s`, m)))
require.True(t, isSQLErr(errors.New(`Error: read state from "schema.sql": executing statement: "bad sql;": near "bad": syntax error`)))
}
3 changes: 2 additions & 1 deletion controllers/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,8 @@ func isSQLErr(err error) bool {
if err == nil {
return false
}
return sqlErrRegex.MatchString(err.Error())
s := err.Error()
return strings.Contains(s, "executing statement:") || sqlErrRegex.MatchString(s)
}

// isChecksumErr returns true if the error is a checksum error.
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ go 1.21
toolchain go1.21.5

require (
ariga.io/atlas v0.15.1-0.20231119120023-a36a5859611e
ariga.io/atlas v0.18.1-0.20240114134328-21ed71fbcdc2
ariga.io/atlas-go-sdk v0.3.0
github.com/stretchr/testify v1.8.4
golang.org/x/exp v0.0.0-20231006140011-7918f672742d
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
ariga.io/atlas v0.15.1-0.20231119120023-a36a5859611e h1:4wjFo2K/J7yPL00qKy252Y8GON5qEzyUT7zh8hstZGg=
ariga.io/atlas v0.15.1-0.20231119120023-a36a5859611e/go.mod h1:uj3pm+hUTVN/X5yfdBexHlZv+1Xu5u5ZbZx7+CDavNU=
ariga.io/atlas v0.18.1-0.20240114134328-21ed71fbcdc2 h1:YNayTWgHEtBAqo+QZzhrJKK1ybX+oxtbouMPs2dS9uI=
ariga.io/atlas v0.18.1-0.20240114134328-21ed71fbcdc2/go.mod h1:uj3pm+hUTVN/X5yfdBexHlZv+1Xu5u5ZbZx7+CDavNU=
ariga.io/atlas-go-sdk v0.3.0 h1:19hxr3Fm/Jg/pNSLq3mpTQs1k1sPNhQXpLgVtIDQ0J8=
ariga.io/atlas-go-sdk v0.3.0/go.mod h1:owkEEXw6jqne5KPVDfKsYB7cwMiMk3jtOiAAeKxS/yU=
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
Expand Down

0 comments on commit e573477

Please sign in to comment.