From 3620f42a7614a901e64a6bb7a7081b02a5aaa8f0 Mon Sep 17 00:00:00 2001 From: Andre Detsch Date: Thu, 14 Nov 2024 15:36:00 -0300 Subject: [PATCH] targets: Handle OrigUri and OrigUriApps when adding targets For custom apps targets, origUri must be set, while uri and origUriApps must be empty. For custom ostree targets, origUriApps must be set, while uri and origUri must be empty. Signed-off-by: Andre Detsch --- client/foundries.go | 1 + subcommands/targets/add.go | 10 ++++++++++ 2 files changed, 11 insertions(+) diff --git a/client/foundries.go b/client/foundries.go index 0e172d2e..581a76f2 100644 --- a/client/foundries.go +++ b/client/foundries.go @@ -137,6 +137,7 @@ type TufCustom struct { OverridesSha string `json:"meta-subscriber-overrides-sha,omitempty"` Uri string `json:"uri,omitempty"` OrigUri string `json:"origUri,omitempty"` + OrigUriApps string `json:"origUriApps,omitempty"` CreatedAt string `json:"createdAt,omitempty"` UpdatedAt string `json:"updatedAt,omitempty"` LmpVer string `json:"lmp-ver,omitempty"` diff --git a/subcommands/targets/add.go b/subcommands/targets/add.go index 64d5b379..8dfb0410 100644 --- a/subcommands/targets/add.go +++ b/subcommands/targets/add.go @@ -107,6 +107,11 @@ func createAppTargets(factory string, tags []string, srcTag string, appUris []st return deriveTargets(factory, nil, srcTag, func(target *client.Target) error { target.Custom.Tags = tags target.Custom.ComposeApps = newTargetApps + if target.Custom.OrigUri == "" { + target.Custom.OrigUri = target.Custom.Uri + } + target.Custom.Uri = "" + target.Custom.OrigUriApps = "" return nil }) } @@ -134,6 +139,11 @@ func createOstreeTarget(factory string, tags []string, srcTag string, hwIdToHash return deriveTargets(factory, hwIdToHash, srcTag, func(target *client.Target) error { target.Custom.Tags = tags err := target.SetHash(hwIdToHash[target.HardwareId()].(string)) + if target.Custom.OrigUriApps == "" { + target.Custom.OrigUriApps = target.Custom.Uri + } + target.Custom.Uri = "" + target.Custom.OrigUri = "" return err }) }