Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

internal/v1: export snapshot date #1406

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions internal/common/testdata/exported_blueprint.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"url": "http://snappy-url/snappy/baseos"
}
],
"snapshot_date": "2012-12-20",
"customizations": {
"custom_repositories": [
{
Expand Down
4 changes: 4 additions & 0 deletions internal/v1/api.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions internal/v1/api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1077,6 +1077,11 @@ components:
description: |
List of custom repositories including all the repository details needed in order
to recreate the repositories.
snapshot_date:
type: string
description: |
Importing the snapshot date will not yet be supported. It is exported for informative reasons.
The format is YYYY-MM-DD.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isntt there a date type in OpenAPI JSON Schema?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be, but I would probably leave this in the same format that we have in the image requests snapshot_date field for consistency.

BlueprintMetadata:
required:
- parent_id
Expand Down
4 changes: 4 additions & 0 deletions internal/v1/handler_blueprints.go
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,10 @@ func (h *Handlers) ExportBlueprint(ctx echo.Context, id openapi_types.UUID) erro
},
}

if len(blueprint.ImageRequests) != 0 {
blueprintExportResponse.SnapshotDate = blueprint.ImageRequests[0].SnapshotDate
}

repoUUIDs := []string{}
if blueprint.Customizations.CustomRepositories != nil {
for _, repo := range *blueprint.Customizations.CustomRepositories {
Expand Down
4 changes: 4 additions & 0 deletions internal/v1/handler_blueprints_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ type BlueprintExportResponseUnmarshal struct {
Distribution Distributions `json:"distribution"`
Metadata BlueprintMetadata `json:"metadata"`
Name string `json:"name"`
SnapshotDate *string `json:"snapshot_date,omitempty"`
}

func makeTestServer(t *testing.T, apiSrv *string, csSrv *string) (dbase db.DB, srvURL string, shutdown func()) {
Expand Down Expand Up @@ -1011,6 +1012,7 @@ func TestHandlers_ExportBlueprint(t *testing.T) {
Type: UploadTypesAws,
Options: uploadOptions,
},
SnapshotDate: common.ToPtr("2012-12-20"),
},
{
Architecture: ImageRequestArchitectureAarch64,
Expand All @@ -1019,6 +1021,7 @@ func TestHandlers_ExportBlueprint(t *testing.T) {
Type: UploadTypesAws,
Options: uploadOptions,
},
SnapshotDate: common.ToPtr("2012-12-21"),
},
},
}
Expand Down Expand Up @@ -1056,6 +1059,7 @@ func TestHandlers_ExportBlueprint(t *testing.T) {
require.Equal(t, "payload", *result.ContentSources[0].Name)
require.Equal(t, "http://snappy-url/snappy/baseos", *result.ContentSources[0].Url)
require.Equal(t, "some-gpg-key", *result.ContentSources[0].GpgKey)
require.Equal(t, "2012-12-20", *result.SnapshotDate)
require.Len(t, result.ContentSources, 1)
// Check that the password returned is redacted
for _, u := range *result.Customizations.Users {
Expand Down
Loading