adm: Allow to download contracts from Gitea #958
No reviewers
Labels
No labels
P0
P1
P2
P3
badger
frostfs-adm
frostfs-cli
frostfs-ir
frostfs-lens
frostfs-node
good first issue
triage
Infrastructure
blocked
bug
config
discussion
documentation
duplicate
enhancement
go
help wanted
internal
invalid
kludge
observability
perfomance
question
refactoring
wontfix
No milestone
No project
No assignees
6 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: TrueCloudLab/frostfs-node#958
Loading…
Reference in a new issue
No description provided.
Delete branch "okonstantinova/frostfs-node:feature/466-download_contracts_from_gitea"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Close #466
For the
morph init
command thecontract
command line parameter has become optional and thecontract-url
parameter has been introduced. Thecontract-url
parameter allows to specify an HTTP link to download a contract archive from. If neither of the parameters is used then the default behavior is to take the latest release from thefrostfs-contract
repository.Signed-off-by: Olga Konstantinova kola43843@gmail.com
[#466] Allow to download contracts from Giteato adm: Allow to download contracts from GiteaCould you please reword commit message a bit:
[#466] Allow to download...
-->[#466] adm: Allow to download...
@ -242,0 +252,4 @@
}
ctrURL, err := cmd.Flags().GetString(contractsURLFlag)
if err != nil {
It is ok to skip check for the error here, the function is redundant at all.
Thanks, fixed
@ -372,3 +373,2 @@
updateContractsCmd.Flags().StringP(endpointFlag, endpointFlagShort, "", endpointFlagDesc)
updateContractsCmd.Flags().String(contractsInitFlag, "", "Path to archive with compiled FrostFS contracts")
_ = updateContractsCmd.MarkFlagRequired(contractsInitFlag)
updateContractsCmd.Flags().String(contractsInitFlag, "", "Path to archive with compiled FrostFS contracts (the default is to fetch the latest release from the official repository)")
How about to mark flags
contracts
andcontracts-url
as mutually exclusive?Thanks, done.
@ -0,0 +14,4 @@
func downloadContracts(cmd *cobra.Command, url string) (io.ReadCloser, error) {
cmd.Printf("Downloading contracts archive from '%s'\n", url)
resp, err := http.Get(url)
Using bare
http.Get
is fine if you use it within a core of well-designed client.But in this case:
cmd.Context()
is cancelled. It means the command may hang up untilGet
is finished and we, as users, are obliged to wait for its finishingurl
is unvailable for some reasonSo, I would like to suggest to import resty client. Because we have not been using it, you need to
go get
itThen
This is quite a simple task, could we avoid importing a whole new dependency for the sake of rarely to be used command?
It would be nice if we could use just the stdlib there.
Alright, I don't mind
Well, we still could try using context: an example https://gist.github.com/superbrothers/dae0030c151d1f3c24311df77405169b
I have changed the implementation, now it sends an HTTP request with connect timeout and uses a context with timeout. Thank you!
9cffb1918d
to82dfcf9a3e
82dfcf9a3e
to9736f8f696
9736f8f696
to1034e30114
adm: Allow to download contracts from Giteato WIP: adm: Allow to download contracts from GiteaWIP: adm: Allow to download contracts from Giteato adm: Allow to download contracts from Gitea@ -152,6 +153,11 @@ func newInitializeContext(cmd *cobra.Command, v *viper.Viper) (*initializeContex
return nil, err
}
ctrURL, err := getContractsURL(cmd, needContracts)
How about this:
It is ok to skip check for the error here, the function
getContractsURL
is redundant at all.Done as recommended, thanks
@ -372,3 +373,2 @@
updateContractsCmd.Flags().StringP(endpointFlag, endpointFlagShort, "", endpointFlagDesc)
updateContractsCmd.Flags().String(contractsInitFlag, "", "Path to archive with compiled FrostFS contracts")
_ = updateContractsCmd.MarkFlagRequired(contractsInitFlag)
updateContractsCmd.Flags().String(contractsInitFlag, "", "Path to archive with compiled FrostFS contracts (the default is to fetch the latest release from the official repository)")
Please move description to the constant
contractsInitFlagDesc
and reuse it forinitCmd
.Thanks, done
@ -373,2 +374,2 @@
updateContractsCmd.Flags().String(contractsInitFlag, "", "Path to archive with compiled FrostFS contracts")
_ = updateContractsCmd.MarkFlagRequired(contractsInitFlag)
updateContractsCmd.Flags().String(contractsInitFlag, "", "Path to archive with compiled FrostFS contracts (the default is to fetch the latest release from the official repository)")
updateContractsCmd.Flags().String(contractsURLFlag, "", "URL to archive with compiled FrostFS contracts")
Please move description to the constant
contractsURLFlagDesc
and reuse it forinitCmd
.Thanks, done
Please squash commits.
@ -0,0 +26,4 @@
},
}
ctx, cancel := context.WithTimeout(context.Background(), 60*time.Second)
Good :) But instead
context.Background()
we need to usecmd.Context()
I suspected that something like this would be needed, but was not sure. Thank you for help!
1034e30114
tobb45fdf01a
bb45fdf01a
to80b581d499