validateChanges compares the current DbConfig with the "old" config, and returns an error if any disallowed changes are attempted.
(ctx context.Context, old DbConfig)
| 724 | // validateChanges compares the current DbConfig with the "old" config, and returns an error if any disallowed changes |
| 725 | // are attempted. |
| 726 | func (dbConfig *DbConfig) validateChanges(ctx context.Context, old DbConfig) error { |
| 727 | // allow switching from implicit `_default` to explicit `_default` scope |
| 728 | _, newIsDefaultScope := dbConfig.Scopes[base.DefaultScope] |
| 729 | if old.Scopes == nil && len(dbConfig.Scopes) == 1 && newIsDefaultScope { |
| 730 | return nil |
| 731 | } |
| 732 | // early exit |
| 733 | if len(dbConfig.Scopes) != len(old.Scopes) { |
| 734 | return fmt.Errorf("cannot change scopes after database creation") |
| 735 | } |
| 736 | newScopes := make(base.Set, len(dbConfig.Scopes)) |
| 737 | oldScopes := make(base.Set, len(old.Scopes)) |
| 738 | for scopeName := range dbConfig.Scopes { |
| 739 | newScopes.Add(scopeName) |
| 740 | } |
| 741 | for scopeName := range old.Scopes { |
| 742 | oldScopes.Add(scopeName) |
| 743 | } |
| 744 | if !newScopes.Equals(oldScopes) { |
| 745 | return fmt.Errorf("cannot change scopes after database creation") |
| 746 | } |
| 747 | return nil |
| 748 | } |
| 749 | |
| 750 | // validate checks the DbConfig for any invalid or unsupported values and return a http error. If validateReplications is true, return an error if any replications are not valid. Otherwise issue a warning. |
| 751 | func (dbConfig *DbConfig) validate(ctx context.Context, validateOIDCConfig, validateReplications bool) error { |
no test coverage detected