Skip to content

Commit

Permalink
targets: Handle OrigUri and OrigUriApps when adding targets
Browse files Browse the repository at this point in the history
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 <andre.detsch@foundries.io>
  • Loading branch information
detsch committed Nov 18, 2024
1 parent 8f5d958 commit 3620f42
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions client/foundries.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand Down
10 changes: 10 additions & 0 deletions subcommands/targets/add.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
})
}
Expand Down Expand Up @@ -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
})
}
Expand Down

0 comments on commit 3620f42

Please sign in to comment.