forked from canonical/chisel
-
Notifications
You must be signed in to change notification settings - Fork 0
feat: store package support #16
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
Draft
upils
wants to merge
20
commits into
slicer-source-interface
Choose a base branch
from
store-download
base: slicer-source-interface
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
43da580
feat: draft accessing bin store
upils 28b9244
fix: adjust naming
upils c4b53fd
style: linting errors
upils ce800d7
feat: refining
upils 217330d
fix: open all stores
upils bc63f31
fix: reapply
upils ff51f2f
feat: wire to Run
upils 987d776
fix: review
upils 636052b
fix: improve naming and add more tests
upils 3e7411a
fix: properly build track value with store version
upils 7d54d04
feat: refine download host validation
upils ee15b40
feat: use revisions/resolve endpoint
upils e1fd757
fix: raise consistency
upils 846f440
fix: use RealName in extract error
upils 51ac9bc
fix: clean model and add guardrail
upils 736dca1
refactor: clean useless method
upils fe06c73
fix: review
upils 8c03288
test: fix inconsistencies
upils bd877a6
test: refine
upils 7e1212d
fix: revert unwanted changes
upils 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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| package store | ||
|
|
||
| import "net/http" | ||
|
|
||
| var ( | ||
| ValidateDownloadURL = validateDownloadURL | ||
| BinStagingEnvVar = binStagingEnvVar | ||
| ) | ||
|
|
||
| func FakeDo(do func(req *http.Request) (*http.Response, error)) (restore func()) { | ||
| _httpDo := httpDo | ||
| _bulkDo := bulkDo | ||
| httpDo = do | ||
| bulkDo = do | ||
| return func() { | ||
| httpDo = _httpDo | ||
| bulkDo = _bulkDo | ||
| } | ||
| } |
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,53 @@ | ||
| package store | ||
|
|
||
| import ( | ||
| "fmt" | ||
| "sync" | ||
| ) | ||
|
|
||
| // Avoid importing the log type information unnecessarily. There's a small cost | ||
| // associated with using an interface rather than the type. Depending on how | ||
| // often the logger is plugged in, it would be worth using the type instead. | ||
| type log_Logger interface { | ||
| Output(calldepth int, s string) error | ||
| } | ||
|
|
||
| var globalLoggerLock sync.Mutex | ||
| var globalLogger log_Logger | ||
| var globalDebug bool | ||
|
|
||
| // Specify the *log.Logger object where log messages should be sent to. | ||
| func SetLogger(logger log_Logger) { | ||
| globalLoggerLock.Lock() | ||
| globalLogger = logger | ||
| globalLoggerLock.Unlock() | ||
| } | ||
|
|
||
| // Enable the delivery of debug messages to the logger. Only meaningful | ||
| // if a logger is also set. | ||
| func SetDebug(debug bool) { | ||
| globalLoggerLock.Lock() | ||
| globalDebug = debug | ||
| globalLoggerLock.Unlock() | ||
| } | ||
|
|
||
| // logf sends to the logger registered via SetLogger the string resulting | ||
| // from running format and args through Sprintf. | ||
| func logf(format string, args ...any) { | ||
| globalLoggerLock.Lock() | ||
| defer globalLoggerLock.Unlock() | ||
| if globalLogger != nil { | ||
| globalLogger.Output(2, fmt.Sprintf(format, args...)) | ||
| } | ||
| } | ||
|
|
||
| // debugf sends to the logger registered via SetLogger the string resulting | ||
| // from running format and args through Sprintf, but only if debugging was | ||
| // enabled via SetDebug. | ||
| func debugf(format string, args ...any) { | ||
| globalLoggerLock.Lock() | ||
| defer globalLoggerLock.Unlock() | ||
| if globalDebug && globalLogger != nil { | ||
| globalLogger.Output(2, fmt.Sprintf(format, args...)) | ||
| } | ||
| } |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Per the comments in the other PR, this distinction makes sense and makes the code simpler in a way. Normally in Go you don't define generics to abstract over a type (i.e. a store) but to abstract over an operation, in this case there are clearly two:
As we discussed in the previous PR, this was contemplated but it turned out to be much more complex AFAIK. I also see the difficulty in Go where the type system is not powerful so it is hard to model fetching where
archive.fetch(name)takes only one args vs three instore.fetch(name, track, risk)for example.Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We agree. I could have reworked the
Archiveinterface to have something more generic, used for archives and stores, but in reality they are different enough that 2 different interfaces made more sense.As I go through the complete implementation I may discover that this new interface must be tweaked.