target: deprecate local target and don't use it anywhere
Completely remove the use of `local` target from all code, which is not required to keep backward compatibility. The target has not been used in composer for some time already, but some unit tests still used its data structures. Mark the target as deprecated and adjust all unit tests that depended on it. The backward compatibility is kept mostly to enable long running osbuild-composer instances, which were upgraded to still read old jobs from the store. While a target with the same intention will be reintroduced, the current `local` target data structures contain many fields which would not be relevant for the new target. In addition, while the "local" target will be ever used only by Weldr API, the name would be a bit misleading. Although the worker usually runs on the same system when using Weldr API, there is no hard requirement enforcing this setup. In reality, the worker will be uploading the image back to the worker server, so there is room for a better name.
This commit is contained in:
parent
a7b97697de
commit
40abb32dec
4 changed files with 103 additions and 91 deletions
|
|
@ -26,15 +26,6 @@ func FixtureBase() *Store {
|
|||
|
||||
var date = time.Date(2019, 11, 27, 13, 19, 0, 0, time.FixedZone("UTC+1", 60*60))
|
||||
|
||||
var localTarget = &target.Target{
|
||||
Uuid: uuid.MustParse("20000000-0000-0000-0000-000000000000"),
|
||||
Name: target.TargetNameLocal,
|
||||
ImageName: "localimage",
|
||||
Created: date,
|
||||
Status: common.IBWaiting,
|
||||
Options: &target.LocalTargetOptions{},
|
||||
}
|
||||
|
||||
var awsTarget = &target.Target{
|
||||
Uuid: uuid.MustParse("10000000-0000-0000-0000-000000000000"),
|
||||
Name: target.TargetNameAWS,
|
||||
|
|
@ -88,7 +79,7 @@ func FixtureBase() *Store {
|
|||
QueueStatus: common.IBWaiting,
|
||||
ImageType: imgType,
|
||||
Manifest: manifest,
|
||||
Targets: []*target.Target{localTarget, awsTarget},
|
||||
Targets: []*target.Target{awsTarget},
|
||||
JobCreated: date,
|
||||
},
|
||||
Packages: []rpmmd.PackageSpec{},
|
||||
|
|
@ -99,7 +90,7 @@ func FixtureBase() *Store {
|
|||
QueueStatus: common.IBRunning,
|
||||
ImageType: imgType,
|
||||
Manifest: manifest,
|
||||
Targets: []*target.Target{localTarget},
|
||||
Targets: []*target.Target{},
|
||||
JobCreated: date,
|
||||
JobStarted: date,
|
||||
},
|
||||
|
|
@ -111,7 +102,7 @@ func FixtureBase() *Store {
|
|||
QueueStatus: common.IBFinished,
|
||||
ImageType: imgType,
|
||||
Manifest: manifest,
|
||||
Targets: []*target.Target{localTarget, awsTarget},
|
||||
Targets: []*target.Target{awsTarget},
|
||||
JobCreated: date,
|
||||
JobStarted: date,
|
||||
JobFinished: date,
|
||||
|
|
@ -124,7 +115,7 @@ func FixtureBase() *Store {
|
|||
QueueStatus: common.IBFailed,
|
||||
ImageType: imgType,
|
||||
Manifest: manifest,
|
||||
Targets: []*target.Target{localTarget, awsTarget},
|
||||
Targets: []*target.Target{awsTarget},
|
||||
JobCreated: date,
|
||||
JobStarted: date,
|
||||
JobFinished: date,
|
||||
|
|
@ -137,7 +128,7 @@ func FixtureBase() *Store {
|
|||
QueueStatus: common.IBFinished,
|
||||
ImageType: imgType,
|
||||
Manifest: manifest,
|
||||
Targets: []*target.Target{localTarget, awsTarget},
|
||||
Targets: []*target.Target{awsTarget},
|
||||
JobCreated: date,
|
||||
JobStarted: date,
|
||||
JobFinished: date,
|
||||
|
|
@ -161,13 +152,13 @@ func FixtureFinished() *Store {
|
|||
|
||||
var date = time.Date(2019, 11, 27, 13, 19, 0, 0, time.FixedZone("UTC+1", 60*60))
|
||||
|
||||
var localTarget = &target.Target{
|
||||
var gcpTarget = &target.Target{
|
||||
Uuid: uuid.MustParse("20000000-0000-0000-0000-000000000000"),
|
||||
Name: target.TargetNameLocal,
|
||||
Name: target.TargetNameGCP,
|
||||
ImageName: "localimage",
|
||||
Created: date,
|
||||
Status: common.IBWaiting,
|
||||
Options: &target.LocalTargetOptions{},
|
||||
Options: &target.GCPTargetOptions{},
|
||||
}
|
||||
|
||||
var awsTarget = &target.Target{
|
||||
|
|
@ -223,7 +214,7 @@ func FixtureFinished() *Store {
|
|||
QueueStatus: common.IBFinished,
|
||||
ImageType: imgType,
|
||||
Manifest: manifest,
|
||||
Targets: []*target.Target{localTarget, awsTarget},
|
||||
Targets: []*target.Target{gcpTarget, awsTarget},
|
||||
JobCreated: date,
|
||||
},
|
||||
Packages: []rpmmd.PackageSpec{},
|
||||
|
|
@ -234,7 +225,7 @@ func FixtureFinished() *Store {
|
|||
QueueStatus: common.IBFinished,
|
||||
ImageType: imgType,
|
||||
Manifest: manifest,
|
||||
Targets: []*target.Target{localTarget},
|
||||
Targets: []*target.Target{gcpTarget},
|
||||
JobCreated: date,
|
||||
JobStarted: date,
|
||||
},
|
||||
|
|
@ -246,7 +237,7 @@ func FixtureFinished() *Store {
|
|||
QueueStatus: common.IBFailed,
|
||||
ImageType: imgType,
|
||||
Manifest: manifest,
|
||||
Targets: []*target.Target{localTarget, awsTarget},
|
||||
Targets: []*target.Target{gcpTarget, awsTarget},
|
||||
JobCreated: date,
|
||||
JobStarted: date,
|
||||
JobFinished: date,
|
||||
|
|
@ -259,7 +250,7 @@ func FixtureFinished() *Store {
|
|||
QueueStatus: common.IBFinished,
|
||||
ImageType: imgType,
|
||||
Manifest: manifest,
|
||||
Targets: []*target.Target{localTarget},
|
||||
Targets: []*target.Target{gcpTarget},
|
||||
JobCreated: date,
|
||||
JobStarted: date,
|
||||
},
|
||||
|
|
|
|||
|
|
@ -1016,13 +1016,14 @@ func Test_newComposeV0(t *testing.T) {
|
|||
{
|
||||
Uuid: uuid.MustParse("f53b49c0-d321-447e-8ab8-6e827891e3f0"),
|
||||
ImageName: "",
|
||||
Name: target.TargetNameLocal,
|
||||
Name: target.TargetNameAWS,
|
||||
Created: MustParseTime("2020-08-12T09:21:44.427717205-07:00"),
|
||||
Status: common.IBWaiting,
|
||||
Options: target.LocalTargetOptions{
|
||||
ComposeId: uuid.MustParse("6b512b52-1e9d-4dac-869c-108fd4860a3e"),
|
||||
ImageBuildId: 0,
|
||||
Filename: "disk.qcow2",
|
||||
Options: target.AWSTargetOptions{
|
||||
Region: "us-east-1",
|
||||
Bucket: "bucket",
|
||||
Key: "key",
|
||||
Filename: "disk.qcow2",
|
||||
},
|
||||
},
|
||||
},
|
||||
|
|
@ -1045,13 +1046,14 @@ func Test_newComposeV0(t *testing.T) {
|
|||
{
|
||||
Uuid: uuid.MustParse("f53b49c0-d321-447e-8ab8-6e827891e3f0"),
|
||||
ImageName: "",
|
||||
Name: target.TargetNameLocal,
|
||||
Name: target.TargetNameAWS,
|
||||
Created: MustParseTime("2020-08-12T09:21:44.427717205-07:00"),
|
||||
Status: common.IBWaiting,
|
||||
Options: target.LocalTargetOptions{
|
||||
ComposeId: uuid.MustParse("6b512b52-1e9d-4dac-869c-108fd4860a3e"),
|
||||
ImageBuildId: 0,
|
||||
Filename: "disk.qcow2",
|
||||
Options: target.AWSTargetOptions{
|
||||
Region: "us-east-1",
|
||||
Bucket: "bucket",
|
||||
Key: "key",
|
||||
Filename: "disk.qcow2",
|
||||
},
|
||||
},
|
||||
},
|
||||
|
|
@ -1118,13 +1120,14 @@ func Test_newComposeFromV0(t *testing.T) {
|
|||
{
|
||||
Uuid: uuid.MustParse("f53b49c0-d321-447e-8ab8-6e827891e3f0"),
|
||||
ImageName: "",
|
||||
Name: target.TargetNameLocal,
|
||||
Name: target.TargetNameAWS,
|
||||
Created: MustParseTime("2020-08-12T09:21:44.427717205-07:00"),
|
||||
Status: common.IBWaiting,
|
||||
Options: target.LocalTargetOptions{
|
||||
ComposeId: uuid.MustParse("6b512b52-1e9d-4dac-869c-108fd4860a3e"),
|
||||
ImageBuildId: 0,
|
||||
Filename: "disk.qcow2",
|
||||
Options: target.AWSTargetOptions{
|
||||
Region: "us-east-1",
|
||||
Bucket: "bucket",
|
||||
Key: "key",
|
||||
Filename: "disk.qcow2",
|
||||
},
|
||||
},
|
||||
},
|
||||
|
|
@ -1147,13 +1150,14 @@ func Test_newComposeFromV0(t *testing.T) {
|
|||
{
|
||||
Uuid: uuid.MustParse("f53b49c0-d321-447e-8ab8-6e827891e3f0"),
|
||||
ImageName: "",
|
||||
Name: target.TargetNameLocal,
|
||||
Name: target.TargetNameAWS,
|
||||
Created: MustParseTime("2020-08-12T09:21:44.427717205-07:00"),
|
||||
Status: common.IBWaiting,
|
||||
Options: target.LocalTargetOptions{
|
||||
ComposeId: uuid.MustParse("6b512b52-1e9d-4dac-869c-108fd4860a3e"),
|
||||
ImageBuildId: 0,
|
||||
Filename: "disk.qcow2",
|
||||
Options: target.AWSTargetOptions{
|
||||
Region: "us-east-1",
|
||||
Bucket: "bucket",
|
||||
Key: "key",
|
||||
Filename: "disk.qcow2",
|
||||
},
|
||||
},
|
||||
},
|
||||
|
|
@ -1213,13 +1217,14 @@ func Test_newComposesV0(t *testing.T) {
|
|||
{
|
||||
Uuid: uuid.MustParse("f53b49c0-d321-447e-8ab8-6e827891e3f0"),
|
||||
ImageName: "",
|
||||
Name: target.TargetNameLocal,
|
||||
Name: target.TargetNameAWS,
|
||||
Created: MustParseTime("2020-08-12T09:21:44.427717205-07:00"),
|
||||
Status: common.IBWaiting,
|
||||
Options: target.LocalTargetOptions{
|
||||
ComposeId: uuid.MustParse("6b512b52-1e9d-4dac-869c-108fd4860a3e"),
|
||||
ImageBuildId: 0,
|
||||
Filename: "disk.qcow2",
|
||||
Options: target.AWSTargetOptions{
|
||||
Region: "us-east-1",
|
||||
Bucket: "bucket",
|
||||
Key: "key",
|
||||
Filename: "disk.qcow2",
|
||||
},
|
||||
},
|
||||
},
|
||||
|
|
@ -1241,13 +1246,14 @@ func Test_newComposesV0(t *testing.T) {
|
|||
{
|
||||
Uuid: uuid.MustParse("14c454d0-26f3-4a56-8ceb-a5673aaba686"),
|
||||
ImageName: "",
|
||||
Name: target.TargetNameLocal,
|
||||
Name: target.TargetNameAWS,
|
||||
Created: MustParseTime("2020-08-12T09:21:44.427717205-07:00"),
|
||||
Status: common.IBWaiting,
|
||||
Options: target.LocalTargetOptions{
|
||||
ComposeId: uuid.MustParse("14c454d0-26f3-4a56-8ceb-a5673aaba686"),
|
||||
ImageBuildId: 0,
|
||||
Filename: "disk.qcow2",
|
||||
Options: target.AWSTargetOptions{
|
||||
Region: "us-east-1",
|
||||
Bucket: "bucket",
|
||||
Key: "key",
|
||||
Filename: "disk.qcow2",
|
||||
},
|
||||
},
|
||||
},
|
||||
|
|
@ -1272,13 +1278,14 @@ func Test_newComposesV0(t *testing.T) {
|
|||
{
|
||||
Uuid: uuid.MustParse("f53b49c0-d321-447e-8ab8-6e827891e3f0"),
|
||||
ImageName: "",
|
||||
Name: target.TargetNameLocal,
|
||||
Name: target.TargetNameAWS,
|
||||
Created: MustParseTime("2020-08-12T09:21:44.427717205-07:00"),
|
||||
Status: common.IBWaiting,
|
||||
Options: target.LocalTargetOptions{
|
||||
ComposeId: uuid.MustParse("6b512b52-1e9d-4dac-869c-108fd4860a3e"),
|
||||
ImageBuildId: 0,
|
||||
Filename: "disk.qcow2",
|
||||
Options: target.AWSTargetOptions{
|
||||
Region: "us-east-1",
|
||||
Bucket: "bucket",
|
||||
Key: "key",
|
||||
Filename: "disk.qcow2",
|
||||
},
|
||||
},
|
||||
},
|
||||
|
|
@ -1303,13 +1310,14 @@ func Test_newComposesV0(t *testing.T) {
|
|||
{
|
||||
Uuid: uuid.MustParse("14c454d0-26f3-4a56-8ceb-a5673aaba686"),
|
||||
ImageName: "",
|
||||
Name: target.TargetNameLocal,
|
||||
Name: target.TargetNameAWS,
|
||||
Created: MustParseTime("2020-08-12T09:21:44.427717205-07:00"),
|
||||
Status: common.IBWaiting,
|
||||
Options: target.LocalTargetOptions{
|
||||
ComposeId: uuid.MustParse("14c454d0-26f3-4a56-8ceb-a5673aaba686"),
|
||||
ImageBuildId: 0,
|
||||
Filename: "disk.qcow2",
|
||||
Options: target.AWSTargetOptions{
|
||||
Region: "us-east-1",
|
||||
Bucket: "bucket",
|
||||
Key: "key",
|
||||
Filename: "disk.qcow2",
|
||||
},
|
||||
},
|
||||
},
|
||||
|
|
@ -1375,13 +1383,14 @@ func Test_newComposesFromV0(t *testing.T) {
|
|||
{
|
||||
Uuid: uuid.MustParse("f53b49c0-d321-447e-8ab8-6e827891e3f0"),
|
||||
ImageName: "",
|
||||
Name: target.TargetNameLocal,
|
||||
Name: target.TargetNameAWS,
|
||||
Created: MustParseTime("2020-08-12T09:21:44.427717205-07:00"),
|
||||
Status: common.IBWaiting,
|
||||
Options: target.LocalTargetOptions{
|
||||
ComposeId: uuid.MustParse("6b512b52-1e9d-4dac-869c-108fd4860a3e"),
|
||||
ImageBuildId: 0,
|
||||
Filename: "disk.qcow2",
|
||||
Options: target.AWSTargetOptions{
|
||||
Region: "us-east-1",
|
||||
Bucket: "bucket",
|
||||
Key: "key",
|
||||
Filename: "disk.qcow2",
|
||||
},
|
||||
},
|
||||
},
|
||||
|
|
@ -1405,13 +1414,14 @@ func Test_newComposesFromV0(t *testing.T) {
|
|||
{
|
||||
Uuid: uuid.MustParse("14c454d0-26f3-4a56-8ceb-a5673aaba686"),
|
||||
ImageName: "",
|
||||
Name: target.TargetNameLocal,
|
||||
Name: target.TargetNameAWS,
|
||||
Created: MustParseTime("2020-08-12T09:21:44.427717205-07:00"),
|
||||
Status: common.IBWaiting,
|
||||
Options: target.LocalTargetOptions{
|
||||
ComposeId: uuid.MustParse("14c454d0-26f3-4a56-8ceb-a5673aaba686"),
|
||||
ImageBuildId: 0,
|
||||
Filename: "disk.qcow2",
|
||||
Options: target.AWSTargetOptions{
|
||||
Region: "us-east-1",
|
||||
Bucket: "bucket",
|
||||
Key: "key",
|
||||
Filename: "disk.qcow2",
|
||||
},
|
||||
},
|
||||
},
|
||||
|
|
@ -1436,13 +1446,14 @@ func Test_newComposesFromV0(t *testing.T) {
|
|||
{
|
||||
Uuid: uuid.MustParse("f53b49c0-d321-447e-8ab8-6e827891e3f0"),
|
||||
ImageName: "",
|
||||
Name: target.TargetNameLocal,
|
||||
Name: target.TargetNameAWS,
|
||||
Created: MustParseTime("2020-08-12T09:21:44.427717205-07:00"),
|
||||
Status: common.IBWaiting,
|
||||
Options: target.LocalTargetOptions{
|
||||
ComposeId: uuid.MustParse("6b512b52-1e9d-4dac-869c-108fd4860a3e"),
|
||||
ImageBuildId: 0,
|
||||
Filename: "disk.qcow2",
|
||||
Options: target.AWSTargetOptions{
|
||||
Region: "us-east-1",
|
||||
Bucket: "bucket",
|
||||
Key: "key",
|
||||
Filename: "disk.qcow2",
|
||||
},
|
||||
},
|
||||
},
|
||||
|
|
@ -1465,13 +1476,14 @@ func Test_newComposesFromV0(t *testing.T) {
|
|||
{
|
||||
Uuid: uuid.MustParse("14c454d0-26f3-4a56-8ceb-a5673aaba686"),
|
||||
ImageName: "",
|
||||
Name: target.TargetNameLocal,
|
||||
Name: target.TargetNameAWS,
|
||||
Created: MustParseTime("2020-08-12T09:21:44.427717205-07:00"),
|
||||
Status: common.IBWaiting,
|
||||
Options: target.LocalTargetOptions{
|
||||
ComposeId: uuid.MustParse("14c454d0-26f3-4a56-8ceb-a5673aaba686"),
|
||||
ImageBuildId: 0,
|
||||
Filename: "disk.qcow2",
|
||||
Options: target.AWSTargetOptions{
|
||||
Region: "us-east-1",
|
||||
Bucket: "bucket",
|
||||
Key: "key",
|
||||
Filename: "disk.qcow2",
|
||||
},
|
||||
},
|
||||
},
|
||||
|
|
@ -1527,13 +1539,14 @@ func Test_newImageBuildFromV0(t *testing.T) {
|
|||
{
|
||||
Uuid: uuid.MustParse("f53b49c0-d321-447e-8ab8-6e827891e3f0"),
|
||||
ImageName: "",
|
||||
Name: target.TargetNameLocal,
|
||||
Name: target.TargetNameAWS,
|
||||
Created: MustParseTime("2020-08-12T09:21:44.427717205-07:00"),
|
||||
Status: common.IBWaiting,
|
||||
Options: target.LocalTargetOptions{
|
||||
ComposeId: uuid.MustParse("6b512b52-1e9d-4dac-869c-108fd4860a3e"),
|
||||
ImageBuildId: 0,
|
||||
Filename: "disk.qcow2",
|
||||
Options: target.AWSTargetOptions{
|
||||
Region: "us-east-1",
|
||||
Bucket: "bucket",
|
||||
Key: "key",
|
||||
Filename: "disk.qcow2",
|
||||
},
|
||||
},
|
||||
},
|
||||
|
|
@ -1552,13 +1565,14 @@ func Test_newImageBuildFromV0(t *testing.T) {
|
|||
{
|
||||
Uuid: uuid.MustParse("f53b49c0-d321-447e-8ab8-6e827891e3f0"),
|
||||
ImageName: "",
|
||||
Name: target.TargetNameLocal,
|
||||
Name: target.TargetNameAWS,
|
||||
Created: MustParseTime("2020-08-12T09:21:44.427717205-07:00"),
|
||||
Status: common.IBWaiting,
|
||||
Options: target.LocalTargetOptions{
|
||||
ComposeId: uuid.MustParse("6b512b52-1e9d-4dac-869c-108fd4860a3e"),
|
||||
ImageBuildId: 0,
|
||||
Filename: "disk.qcow2",
|
||||
Options: target.AWSTargetOptions{
|
||||
Region: "us-east-1",
|
||||
Bucket: "bucket",
|
||||
Key: "key",
|
||||
Filename: "disk.qcow2",
|
||||
},
|
||||
},
|
||||
},
|
||||
|
|
|
|||
|
|
@ -2,8 +2,13 @@ package target
|
|||
|
||||
import "github.com/google/uuid"
|
||||
|
||||
// Deprecated: TargetNameLocal should not be used by any new code.
|
||||
const TargetNameLocal TargetName = "org.osbuild.local"
|
||||
|
||||
// Deprecated: LocalTargetOptions should not be used by any new code.
|
||||
// The data structure is kept for backward compatibility and to ensure
|
||||
// that old osbuild-composer instances which were upgraded will be able
|
||||
// to read the target details from the local store.
|
||||
type LocalTargetOptions struct {
|
||||
ComposeId uuid.UUID `json:"compose_id"`
|
||||
ImageBuildId int `json:"image_build_id"`
|
||||
|
|
@ -13,6 +18,7 @@ type LocalTargetOptions struct {
|
|||
|
||||
func (LocalTargetOptions) isTargetOptions() {}
|
||||
|
||||
// Deprecated: NewLocalTarget should not be used by any new code.
|
||||
func NewLocalTarget(options *LocalTargetOptions) *Target {
|
||||
return newTarget(TargetNameLocal, options)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -77,6 +77,7 @@ func UnmarshalTargetOptions(targetName TargetName, rawOptions json.RawMessage) (
|
|||
options = new(GCPTargetOptions)
|
||||
case TargetNameAzureImage:
|
||||
options = new(AzureImageTargetOptions)
|
||||
// Kept for backward compatibility
|
||||
case TargetNameLocal:
|
||||
options = new(LocalTargetOptions)
|
||||
case TargetNameKoji:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue