diff --git a/internal/store/fixtures.go b/internal/store/fixtures.go index c3ab46e40..72da7be3e 100644 --- a/internal/store/fixtures.go +++ b/internal/store/fixtures.go @@ -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, }, diff --git a/internal/store/json_test.go b/internal/store/json_test.go index 1ac0bc04f..04ded98ef 100644 --- a/internal/store/json_test.go +++ b/internal/store/json_test.go @@ -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", }, }, }, diff --git a/internal/target/local_target.go b/internal/target/local_target.go index b7661bc87..157cde15d 100644 --- a/internal/target/local_target.go +++ b/internal/target/local_target.go @@ -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) } diff --git a/internal/target/target.go b/internal/target/target.go index 33099be1d..745f7b8c7 100644 --- a/internal/target/target.go +++ b/internal/target/target.go @@ -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: