feature: enhance import project to support API conflict and reference options#210
Open
davhparry wants to merge 7 commits into
Open
feature: enhance import project to support API conflict and reference options#210davhparry wants to merge 7 commits into
davhparry wants to merge 7 commits into
Conversation
…-templates and command-templates
Exporting assets with tags caused an unmarshal error because Tags was
typed as []string, but the platform API returns tag objects with _id,
name and description fields. Changed Tags to []Tag on Transformation,
AnalyticTemplate and CommandTemplate structs, and initialised the field
to []Tag{} in each factory function so newly created assets emit
"tags": [] to match the API.
Adds Options field to all trigger structs so LCM action configuration (actionId, chooseTargetAtRuntime) is no longer dropped during export/import. Also adds a default passthrough in transformTrigger and updateTriggers so unknown trigger types are preserved rather than erroring or being silently dropped. Fixes itential#177
ApiService.request was passing the full URI (including query string) as the request path. url.URL then percent-encoded the '?' as '%3F' in the path while also appending the params via RawQuery, resulting in doubled and malformed query strings. Fix uses u.Path (path only) so params flow through RawQuery exclusively. Adds ApiService tests that verify params arrive correctly at the server and adds AddHandlerToMux to testlib for request inspection. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…to import project Mirrors the Itential Platform API import capabilities with three new flags: - --skip-reference-validation: bypass server reference checks on import - --conflict-mode: server-side conflict resolution (insert-new or overwrite) - --assign-new-references: have server assign new references to imported components --replace remains a client-side delete-then-reimport. When both --replace and --conflict-mode are supplied, --replace takes precedence and --conflict-mode is ignored. When only --conflict-mode is supplied the local existence check is skipped and the server handles the conflict. Also fixes AddMembers deduplication to prevent the server rejecting duplicate- reference members on PATCH. Adds Verbose flag to Request so runners can log import options when --verbose is set. Resolves itential#208 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes #208
Adds three new flags to
import projectthat mirror the capabilities of the Itential Platform import API, giving users server-side control over how conflicts and references are handled during import.New flags
--skip-reference-validationfalse--conflict-modeoverwriteorinsert-new--assign-new-referencesfalse--replacevs--conflict-modebehaviourThese two flags address different use cases and are mutually exclusive:
--replaceonly — client-side: deletes the entire existing project before importing (existing behaviour, unchanged)--conflict-modeonly — server-side: skips the local existence check and lets the server resolve conflicts per component--replacetakes precedence;--conflict-modeis ignoredOther fixes included
AddMembersdeduplication — when adding members to an imported project, existing members with the samereferenceas a newly-supplied member are no longer duplicated in the PATCH body. This prevents the server from rejecting the request.--verbosesupport — passing--verbosetoimport projectnow logs the resolved values of the three new options before the import call.Test plan
import projectwith no flags fails if project existsimport project --replacedeletes and reimports an existing projectimport project --conflict-mode overwritesucceeds without a local existence checkimport project --conflict-mode insert-newsucceeds without a local existence checkimport project --replace --conflict-mode overwritebehaves the same as--replacealoneimport project --conflict-mode invalidreturns a validation errorimport project --skip-reference-validationsendsskipReferenceValidation: truein the request bodyimport project --assign-new-referencessendsassignNewReferences: truein the request bodyimport project --verboselogs all three option values before importimport project --helpshows updated CONFLICT RESOLUTION and REFERENCE HANDLING sectionsmake test)