Skip to content

Commit 1ad9f4d

Browse files
Konstantin Bogdanovthevar1able
Konstantin Bogdanov
authored andcommitted
go fmt
1 parent 856df6a commit 1ad9f4d

File tree

4 files changed

+33
-26
lines changed

4 files changed

+33
-26
lines changed

api/v1alpha1/database_types.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ type DatabaseSpec struct {
3030

3131
// (Optional) Database storage and compute resources
3232
// +optional
33-
Resources *DatabaseResources `json:"resources,omitempty"` // TODO: Add validation webhook: some resources must be specified
33+
Resources *DatabaseResources `json:"resources,omitempty"` // TODO: Add validation webhook: some resources must be specified
3434

3535
// (Optional) Shared resources can be used by serverless databases.
3636
// +optional

internal/cms/tenant.go

+7-7
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ import (
55
"errors"
66
"fmt"
77

8-
ydbv1alpha1 "github.com/ydb-platform/ydb-kubernetes-operator/api/v1alpha1"
98
"github.com/ydb-platform/ydb-go-genproto/protos/Ydb"
109
"github.com/ydb-platform/ydb-go-genproto/protos/Ydb_Cms"
10+
ydbv1alpha1 "github.com/ydb-platform/ydb-kubernetes-operator/api/v1alpha1"
1111
"github.com/ydb-platform/ydb-kubernetes-operator/internal/grpc"
1212
"sigs.k8s.io/controller-runtime/pkg/log"
1313
)
@@ -17,11 +17,11 @@ const (
1717
)
1818

1919
type Tenant struct {
20-
StorageEndpoint string
21-
Path string
22-
StorageUnits []ydbv1alpha1.StorageUnit
23-
Shared bool
24-
SharedDatabasePath string
20+
StorageEndpoint string
21+
Path string
22+
StorageUnits []ydbv1alpha1.StorageUnit
23+
Shared bool
24+
SharedDatabasePath string
2525
UseGrpcSecureChannel bool
2626
}
2727

@@ -51,7 +51,7 @@ func (t *Tenant) makeCreateDatabaseRequest() *Ydb_Cms.CreateDatabaseRequest {
5151
request := &Ydb_Cms.CreateDatabaseRequest{Path: t.Path}
5252
if t.SharedDatabasePath != "" {
5353
request.ResourcesKind = &Ydb_Cms.CreateDatabaseRequest_ServerlessResources{
54-
ServerlessResources: &Ydb_Cms.ServerlessResources{
54+
ServerlessResources: &Ydb_Cms.ServerlessResources{
5555
SharedDatabasePath: t.SharedDatabasePath,
5656
},
5757
}

internal/controllers/database/sync.go

+21-14
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ package database
22

33
import (
44
"context"
5+
"errors"
56
"fmt"
6-
"time"
77
"reflect"
8-
"errors"
8+
"time"
99

1010
ydbv1alpha1 "github.com/ydb-platform/ydb-kubernetes-operator/api/v1alpha1"
1111
"github.com/ydb-platform/ydb-kubernetes-operator/internal/cms"
@@ -27,7 +27,7 @@ const (
2727
Ready ClusterState = "Ready"
2828

2929
DefaultRequeueDelay = 10 * time.Second
30-
StatusUpdateRequeueDelay = 1 * time.Second
30+
StatusUpdateRequeueDelay = 1 * time.Second
3131
TenantCreationRequeueDelay = 30 * time.Second
3232
StorageAwaitRequeueDelay = 60 * time.Second
3333
SharedDatabaseAwaitRequeueDelay = 60 * time.Second
@@ -173,12 +173,12 @@ func (r *DatabaseReconciler) handleResourcesSync(ctx context.Context, database *
173173
r.Log.Info("running step handleResourcesSync")
174174

175175
for _, builder := range database.GetResourceBuilders() {
176-
new_resource := builder.Placeholder(database)
176+
newResource := builder.Placeholder(database)
177177

178-
result, err := resources.CreateOrUpdateIgnoreStatus(ctx, r.Client, new_resource, func() error {
178+
result, err := resources.CreateOrUpdateIgnoreStatus(ctx, r.Client, newResource, func() error {
179179
var err error
180180

181-
err = builder.Build(new_resource)
181+
err = builder.Build(newResource)
182182
if err != nil {
183183
r.Recorder.Event(
184184
database,
@@ -189,7 +189,7 @@ func (r *DatabaseReconciler) handleResourcesSync(ctx context.Context, database *
189189
return err
190190
}
191191

192-
err = ctrl.SetControllerReference(database.Unwrap(), new_resource, r.Scheme)
192+
err = ctrl.SetControllerReference(database.Unwrap(), newResource, r.Scheme)
193193
if err != nil {
194194
r.Recorder.Event(
195195
database,
@@ -205,24 +205,24 @@ func (r *DatabaseReconciler) handleResourcesSync(ctx context.Context, database *
205205

206206
var eventMessage string = fmt.Sprintf(
207207
"Resource: %s, Namespace: %s, Name: %s",
208-
reflect.TypeOf(new_resource),
209-
new_resource.GetNamespace(),
210-
new_resource.GetName(),
208+
reflect.TypeOf(newResource),
209+
newResource.GetNamespace(),
210+
newResource.GetName(),
211211
)
212212
if err != nil {
213213
r.Recorder.Event(
214214
database,
215215
corev1.EventTypeWarning,
216216
"ProvisioningFailed",
217-
eventMessage + fmt.Sprintf(", failed to sync, error: %s", err),
217+
eventMessage+fmt.Sprintf(", failed to sync, error: %s", err),
218218
)
219219
return Stop, ctrl.Result{RequeueAfter: DefaultRequeueDelay}, err
220-
} else if (result == controllerutil.OperationResultCreated || result == controllerutil.OperationResultUpdated) {
220+
} else if result == controllerutil.OperationResultCreated || result == controllerutil.OperationResultUpdated {
221221
r.Recorder.Event(
222222
database,
223223
corev1.EventTypeNormal,
224224
"Provisioning",
225-
eventMessage + fmt.Sprintf(", changed, result: %s", result),
225+
eventMessage+fmt.Sprintf(", changed, result: %s", result),
226226
)
227227
}
228228
}
@@ -321,7 +321,14 @@ func (r *DatabaseReconciler) handleTenantCreation(ctx context.Context, database
321321
r.Recorder.Event(database, corev1.EventTypeWarning, "ControllerError", msg)
322322
return Stop, ctrl.Result{RequeueAfter: DefaultRequeueDelay}, errors.New(msg)
323323
}
324-
tenant := cms.Tenant{database.GetStorageEndpoint(), Path, StorageUnits, Shared, SharedDatabasePath, database.Spec.Service.GRPC.TLSConfiguration.Enabled}
324+
tenant := cms.Tenant{
325+
StorageEndpoint: database.GetStorageEndpoint(),
326+
Path: Path,
327+
StorageUnits: StorageUnits,
328+
Shared: Shared,
329+
SharedDatabasePath: SharedDatabasePath,
330+
UseGrpcSecureChannel: database.Spec.Service.GRPC.TLSConfiguration.Enabled,
331+
}
325332
err := tenant.Create(ctx)
326333
if err != nil {
327334
r.Recorder.Event(

internal/resources/resource.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
package resources
22

33
import (
4-
"fmt"
54
"context"
5+
"fmt"
66

7+
"github.com/banzaicloud/k8s-objectmatcher/patch"
78
appsv1 "k8s.io/api/apps/v1"
8-
ctrl "sigs.k8s.io/controller-runtime"
9-
ctrlutil "sigs.k8s.io/controller-runtime/pkg/controller/controllerutil"
109
"k8s.io/apimachinery/pkg/api/errors"
1110
"k8s.io/apimachinery/pkg/runtime"
11+
ctrl "sigs.k8s.io/controller-runtime"
1212
"sigs.k8s.io/controller-runtime/pkg/client"
13-
"github.com/banzaicloud/k8s-objectmatcher/patch"
13+
ctrlutil "sigs.k8s.io/controller-runtime/pkg/controller/controllerutil"
1414
)
1515

1616
const (

0 commit comments

Comments
 (0)