-
Notifications
You must be signed in to change notification settings - Fork 3
fix(dvcr): Filesystem dataSource for importer #1804
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
Merged
Merged
Changes from 26 commits
Commits
Show all changes
28 commits
Select commit
Hold shift + click to select a range
6c5fa41
fix(dvcr): Filesystem dataSource for importer
danilrwx aa7ac1a
list files
danilrwx 98a3fca
update
danilrwx be46026
fix
danilrwx d922fbd
fix
danilrwx c8db9ff
fix
danilrwx 3eb5abf
update
danilrwx 625403d
fix
danilrwx 79eed48
combined output
danilrwx 827914b
fix
danilrwx 0b6d952
test
danilrwx 34bf564
fix
danilrwx bae5986
fix
danilrwx a04d0ad
fix
danilrwx 16dbcdd
fix
danilrwx f7309b7
fix
danilrwx 3af63ab
fix nil
danilrwx e440eea
fix consts
danilrwx aaee3e3
fix ctx
danilrwx e96417f
fix test
danilrwx 7f59fbd
check without qemu-img
danilrwx 7e6a821
fix year
danilrwx edb2d62
filesystem volumeMode as fallback
danilrwx 62a8f23
filesystem volmeVome as fallback
danilrwx aca3077
fix bug
danilrwx 3e639dc
remove if
danilrwx 9cb51bc
fix import
danilrwx bcaf366
fix
danilrwx File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
76 changes: 76 additions & 0 deletions
76
images/dvcr-artifact/pkg/datasource/filesystem-datasource.go
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,76 @@ | ||
| /* | ||
| Copyright 2025 Flant JSC | ||
|
|
||
| Licensed under the Apache License, Version 2.0 (the "License"); | ||
| you may not use this file except in compliance with the License. | ||
| You may obtain a copy of the License at | ||
|
|
||
| http://www.apache.org/licenses/LICENSE-2.0 | ||
|
|
||
| Unless required by applicable law or agreed to in writing, software | ||
| distributed under the License is distributed on an "AS IS" BASIS, | ||
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| See the License for the specific language governing permissions and | ||
| limitations under the License. | ||
| */ | ||
|
|
||
| package datasource | ||
|
|
||
| import ( | ||
| "context" | ||
| "fmt" | ||
| "io" | ||
| "os" | ||
|
|
||
| "github.com/google/uuid" | ||
| ) | ||
|
|
||
| type FilesystemDataSource struct { | ||
| readCloser io.ReadCloser | ||
| sourceImageSize int64 | ||
| sourceImageFilename string | ||
| } | ||
|
|
||
| func NewFilesystemDataSource(ctx context.Context) (*FilesystemDataSource, error) { | ||
| filesystemImagePath := "/tmp/fs/disk.img" | ||
|
|
||
| file, err := os.Open(filesystemImagePath) | ||
| if err != nil { | ||
| return nil, fmt.Errorf("can not get open image %s: %w", filesystemImagePath, err) | ||
| } | ||
|
|
||
| sourceImageSize, err := file.Seek(0, io.SeekEnd) | ||
| if err != nil { | ||
| return nil, fmt.Errorf("error seeking to end: %w", err) | ||
| } | ||
|
|
||
| _, err = file.Seek(0, io.SeekStart) | ||
| if err != nil { | ||
| return nil, fmt.Errorf("error seeking to start: %w", err) | ||
| } | ||
|
|
||
| uuid, _ := uuid.NewUUID() | ||
| sourceImageFilename := uuid.String() + ".img" | ||
|
|
||
| return &FilesystemDataSource{ | ||
| readCloser: file, | ||
| sourceImageSize: int64(sourceImageSize), | ||
| sourceImageFilename: sourceImageFilename, | ||
| }, nil | ||
| } | ||
|
|
||
| func (ds *FilesystemDataSource) ReadCloser() (io.ReadCloser, error) { | ||
| return ds.readCloser, nil | ||
| } | ||
|
|
||
| func (ds *FilesystemDataSource) Length() (int, error) { | ||
| return int(ds.sourceImageSize), nil | ||
| } | ||
|
|
||
| func (ds *FilesystemDataSource) Filename() (string, error) { | ||
| return ds.sourceImageFilename, nil | ||
| } | ||
|
|
||
| func (ds *FilesystemDataSource) Close() error { | ||
| return ds.readCloser.Close() | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.