Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reduce noise when importing MySQL Flexible Server Configurations #4282

Merged
merged 4 commits into from
Sep 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/*
* Copyright (c) Microsoft Corporation.
* Licensed under the MIT license.
*/

package customizations

import (
"context"

api "github.com/Azure/azure-service-operator/v2/api/dbformysql/v1api20230630"
"github.com/Azure/azure-service-operator/v2/pkg/genruntime"
"github.com/Azure/azure-service-operator/v2/pkg/genruntime/extensions"
)

var _ extensions.Importer = &FlexibleServersConfigurationExtension{}

// Import skips databases that can't be managed by ARM
func (extension *FlexibleServersConfigurationExtension) Import(
ctx context.Context,
rsrc genruntime.ImportableResource,
owner *genruntime.ResourceReference,
next extensions.ImporterFunc,
) (extensions.ImportResult, error) {
result, err := next(ctx, rsrc, owner)
if err != nil {
return extensions.ImportResult{}, err
}

// If this cast doesn't compile, update the `api` import to reference the now latest
// stable version of the dbformysql group (this will happen when we import a new
// API version in the generator.)
if config, ok := rsrc.(*api.FlexibleServersConfiguration); ok {
// Skip system defaults
if config.Spec.Source != nil &&
*config.Spec.Source == "system-default" {
return extensions.ImportSkipped("system-defaults don't need to be imported"), nil
}

// Skip readonly configuration
if config.Status.IsReadOnly != nil &&
*config.Status.IsReadOnly == api.ConfigurationProperties_IsReadOnly_STATUS_True {
return extensions.ImportSkipped("readonly configuration can't be set"), nil
}

// Skip default values
if config.Status.DefaultValue != nil &&
config.Status.Value != nil &&
*config.Status.DefaultValue == *config.Status.Value {
return extensions.ImportSkipped("default value is the same as the current value"), nil
}
}

return result, nil
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ func (extension *FlexibleServersConfigurationExtension) Import(
}

// If this cast doesn't compile, update the `api` import to reference the now latest
// stable version of the authorization group (this will happen when we import a new
// stable version of the dbforpostgresql group (this will happen when we import a new
// API version in the generator.)
if config, ok := rsrc.(*api.FlexibleServersConfiguration); ok {
// Skip system defaults
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ func (extension *FlexibleServersDatabaseExtension) Import(
next extensions.ImporterFunc,
) (extensions.ImportResult, error) {
// If this cast doesn't compile, update the `api` import to reference the now latest
// stable version of the authorization group (this will happen when we import a new
// stable version of the dbforpostgresql group (this will happen when we import a new
// API version in the generator.)
if server, ok := rsrc.(*api.FlexibleServersDatabase); ok {
if server.Spec.AzureName == "azure_maintenance" {
Expand Down
Loading