-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: Extract Reconciler from Parser (#1461)
- Split the Parser interface into Parser & SyncStatusClient. - Replace the root & namespace structs with seperate implementations of the Parser & SyncStatusClient interfaces. - Create a new common reconciler struct which composes the Parser & SyncStatusClient interfaces. The reconciler struct can now hold common methods, and the current ReconcilerState, which encompases spec, status, and cache for all reconciler phases, not just the parser. - Add a new Reconciler interface, for use by the EventHandler and DefaultRunFunc. We may want to move DefaultRunFunc to be a reconciler method in the future, but this would relocate all the run code, so we can do it in a seperate change. - Move the Mutex out of the Options and into the Reconciler. Options should generally not be mutated after construction. - Change interface methods to public. There's no reason to have private interface methods, even if the interface itself is private. - Add ReconcilerOptions, to contain options that the Parser doesn't use itself. ReconcilerOptions extends parse.Options to ensure the injected values are consistent and simplify usage. - Move SyncErrorCache into the ReconcilerState, since it's not just Parser or Updater errors. - Move DeclaredCRDs method from the Updater into declared.Resources. Then inject the resources into the Parser, so it doesn't need to depend on the whole Updater just to get the list of valid CRDs. The naming here is still confusing, since it's not just the resource/objects declared in the source, but actually the set of valid & unskipped/known-scoped source objects, after being parsed. Managing the declared.Resources should probably be moved from the Updater to the Reconciler in the future.
- Loading branch information
Showing
18 changed files
with
1,569 additions
and
1,217 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// Copyright 2024 Google LLC | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
package parse | ||
|
||
import ( | ||
"context" | ||
|
||
"kpt.dev/configsync/pkg/importer/analyzer/ast" | ||
"kpt.dev/configsync/pkg/status" | ||
) | ||
|
||
// Parser represents a parser that can be pointed at and continuously parse a source. | ||
type Parser interface { | ||
// ParseSource parses the source manifest files and returns the objects. | ||
ParseSource(ctx context.Context, state *sourceState) ([]ast.FileObject, status.MultiError) | ||
} |
Oops, something went wrong.