Skip to content

Commit 823c486

Browse files
committed
Set ImageContent.Download as required
Fixes: #261
1 parent bb636ca commit 823c486

6 files changed

Lines changed: 5 additions & 14 deletions

File tree

api/v1alpha1/image_types.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -229,8 +229,8 @@ type ImageContent struct {
229229

230230
// download describes how to obtain image data by downloading it from a URL.
231231
// Must be set when creating a managed image.
232-
// +optional
233-
Download *ImageContentSourceDownload `json:"download,omitempty"`
232+
// +required
233+
Download *ImageContentSourceDownload `json:"download"`
234234
}
235235

236236
type ImageContentSourceDownload struct {

cmd/models-schema/zz_generated.openapi.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

config/crd/bases/openstack.k-orc.cloud_images.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,7 @@ spec:
238238
type: object
239239
required:
240240
- diskFormat
241+
- download
241242
type: object
242243
x-kubernetes-validations:
243244
- message: content is immutable

internal/controllers/image/upload.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -83,11 +83,6 @@ func (r *orcImageReconciler) uploadImageContent(ctx context.Context, orcImage *o
8383
}
8484

8585
download := content.Download
86-
if download == nil {
87-
// Should have been caught by validation
88-
return orcerrors.Terminal(orcv1alpha1.ConditionReasonInvalidConfiguration, "image source type URL has no url entry")
89-
}
90-
9186
req, err := http.NewRequestWithContext(ctx, http.MethodGet, download.URL, http.NoBody)
9287
if err != nil {
9388
return fmt.Errorf("error creating request for %s: %w", download.URL, err)

internal/controllers/image/webdownload.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,11 +63,6 @@ func (r *orcImageReconciler) canWebDownload(ctx context.Context, orcImage *orcv1
6363
}
6464

6565
download := content.Download
66-
if download == nil {
67-
debugLog("not type URL")
68-
return false, nil
69-
}
70-
7166
// web-download does not deterministically support decompression.
7267
// Glance can be configured to do automatic decompression of imported
7368
// images, but there's no way to determine if it is enabled so it can't

test/apivalidations/image_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ var _ = Describe("ORC Image API validations", func() {
118118
image.Spec.Resource = &orcv1alpha1.ImageResourceSpec{
119119
Content: &orcv1alpha1.ImageContent{
120120
DiskFormat: orcv1alpha1.ImageDiskFormatQCOW2,
121-
Download: &orcv1alpha1.ImageContentSourceDownload{
121+
Download: orcv1alpha1.ImageContentSourceDownload{
122122
URL: "https://example.com/example.img",
123123
},
124124
},

0 commit comments

Comments
 (0)