target: add the pulp.ostree target to the marshal functions

This commit is contained in:
Achilleas Koutsou 2023-08-17 19:32:17 +02:00
parent ab659c013c
commit 503fbfb312
2 changed files with 8 additions and 0 deletions

View file

@ -93,6 +93,8 @@ func (target *Target) UnmarshalJSON(data []byte) error {
options = new(ContainerTargetOptions)
case TargetNameWorkerServer:
options = new(WorkerServerTargetOptions)
case TargetNamePulpOSTree:
options = new(PulpOSTreeTargetOptions)
default:
return fmt.Errorf("unexpected target name: %s", rawTarget.Name)
}
@ -278,6 +280,10 @@ func (target Target) MarshalJSON() ([]byte, error) {
// the incompatible change.
rawOptions, err = json.Marshal(target.Options)
case *PulpOSTreeTargetOptions:
// added after incompatibility change
rawOptions, err = json.Marshal(target.Options)
default:
return nil, fmt.Errorf("unexpected target options type: %t", t)
}

View file

@ -76,6 +76,8 @@ func UnmarshalTargetResultOptions(trName TargetName, rawOptions json.RawMessage)
options = new(OCIObjectStorageTargetResultOptions)
case TargetNameContainer:
options = new(ContainerTargetResultOptions)
case TargetNamePulpOSTree:
options = new(PulpOSTreeTargetResultOptions)
default:
return nil, fmt.Errorf("unexpected target result name: %s", trName)
}