From d1661ae7dc3eaa3fa13b98e2934c7ea300b0b1dd Mon Sep 17 00:00:00 2001 From: Alejandro Lopez Date: Thu, 4 May 2023 11:00:45 +0300 Subject: [PATCH] [#308] Remove downloadContractsFromGithub from the frostfs-adm Signed-off-by: Alejandro Lopez --- .../internal/modules/morph/download.go | 40 ------------------ .../modules/morph/initialize_deploy.go | 3 +- .../internal/modules/morph/root.go | 6 ++- go.mod | 2 - go.sum | Bin 95865 -> 95389 bytes 5 files changed, 5 insertions(+), 46 deletions(-) delete mode 100644 cmd/frostfs-adm/internal/modules/morph/download.go diff --git a/cmd/frostfs-adm/internal/modules/morph/download.go b/cmd/frostfs-adm/internal/modules/morph/download.go deleted file mode 100644 index 3c50c0b34e..0000000000 --- a/cmd/frostfs-adm/internal/modules/morph/download.go +++ /dev/null @@ -1,40 +0,0 @@ -package morph - -import ( - "context" - "errors" - "fmt" - "io" - "net/http" - "strings" - - "github.com/google/go-github/v39/github" - "github.com/spf13/cobra" -) - -func downloadContractsFromGithub(cmd *cobra.Command) (io.ReadCloser, error) { - gcl := github.NewClient(nil) - release, _, err := gcl.Repositories.GetLatestRelease(context.Background(), "nspcc-dev", "frostfs-contract") - if err != nil { - return nil, fmt.Errorf("can't fetch release info: %w", err) - } - - cmd.Printf("Found %s (%s), downloading...\n", release.GetTagName(), release.GetName()) - - var url string - for _, a := range release.Assets { - if strings.HasPrefix(a.GetName(), "frostfs-contract") { - url = a.GetBrowserDownloadURL() - break - } - } - if url == "" { - return nil, errors.New("can't find contracts archive in release assets") - } - - resp, err := http.Get(url) - if err != nil { - return nil, fmt.Errorf("can't fetch contracts archive: %w", err) - } - return resp.Body, nil -} diff --git a/cmd/frostfs-adm/internal/modules/morph/initialize_deploy.go b/cmd/frostfs-adm/internal/modules/morph/initialize_deploy.go index 1e35fb79f0..7e03eae20a 100644 --- a/cmd/frostfs-adm/internal/modules/morph/initialize_deploy.go +++ b/cmd/frostfs-adm/internal/modules/morph/initialize_deploy.go @@ -401,8 +401,7 @@ func (c *initializeContext) readContracts(names []string) error { } else { var r io.ReadCloser if c.ContractPath == "" { - c.Command.Println("Contracts flag is missing, latest release will be fetched from Github.") - r, err = downloadContractsFromGithub(c.Command) + return errors.New("contracts flag is missing") } else { r, err = os.Open(c.ContractPath) } diff --git a/cmd/frostfs-adm/internal/modules/morph/root.go b/cmd/frostfs-adm/internal/modules/morph/root.go index 1361fe1584..431be125c8 100644 --- a/cmd/frostfs-adm/internal/modules/morph/root.go +++ b/cmd/frostfs-adm/internal/modules/morph/root.go @@ -309,7 +309,8 @@ func initUpdateContractsCmd() { RootCmd.AddCommand(updateContractsCmd) updateContractsCmd.Flags().String(alphabetWalletsFlag, "", "Path to alphabet wallets dir") updateContractsCmd.Flags().StringP(endpointFlag, "r", "", "N3 RPC node endpoint") - updateContractsCmd.Flags().String(contractsInitFlag, "", "Path to archive with compiled FrostFS contracts (default fetched from latest github release)") + updateContractsCmd.Flags().String(contractsInitFlag, "", "Path to archive with compiled FrostFS contracts") + _ = updateContractsCmd.MarkFlagRequired(contractsInitFlag) } func initDumpBalancesCmd() { @@ -370,7 +371,8 @@ func initInitCmd() { RootCmd.AddCommand(initCmd) initCmd.Flags().String(alphabetWalletsFlag, "", "Path to alphabet wallets dir") initCmd.Flags().StringP(endpointFlag, "r", "", "N3 RPC node endpoint") - initCmd.Flags().String(contractsInitFlag, "", "Path to archive with compiled FrostFS contracts (default fetched from latest github release)") + initCmd.Flags().String(contractsInitFlag, "", "Path to archive with compiled FrostFS contracts") + _ = initCmd.MarkFlagRequired(contractsInitFlag) initCmd.Flags().Uint(epochDurationCLIFlag, 240, "Amount of side chain blocks in one FrostFS epoch") initCmd.Flags().Uint(maxObjectSizeCLIFlag, 67108864, "Max single object size in bytes") initCmd.Flags().Bool(homomorphicHashDisabledCLIFlag, false, "Disable object homomorphic hashing") diff --git a/go.mod b/go.mod index 551fb0fb76..2f0244c6ed 100644 --- a/go.mod +++ b/go.mod @@ -11,7 +11,6 @@ require ( github.com/cheggaaa/pb v1.0.29 github.com/chzyer/readline v1.5.1 github.com/flynn-archive/go-shlex v0.0.0-20150515145356-3f9db97f8568 - github.com/google/go-github/v39 v39.2.0 github.com/google/uuid v1.3.0 github.com/hashicorp/golang-lru/v2 v2.0.1 github.com/klauspost/compress v1.16.5 @@ -59,7 +58,6 @@ require ( github.com/go-logr/stdr v1.2.2 // indirect github.com/golang/protobuf v1.5.3 // indirect github.com/golang/snappy v0.0.3 // indirect - github.com/google/go-querystring v1.1.0 // indirect github.com/gorilla/websocket v1.4.2 // indirect github.com/grpc-ecosystem/grpc-gateway/v2 v2.7.0 // indirect github.com/hashicorp/golang-lru v0.6.0 // indirect diff --git a/go.sum b/go.sum index 185e3e00d9daaeb67f606d64d6928f1edf564333..3e5bcd57042f107b565b9a56f1c9bcf5e910b39f 100644 GIT binary patch delta 19 bcmezQhIQ^s)(xKFo3}^k)ol*Gt~MV4XYUEt delta 344 zcmZwBO-{l<7=YmwH*moc*M_!Vr_)Z|wMA+R1^JUfSA|Mjl@3hHkQ!s+8CV;yV8U5E zgozh$C&Z13F5c~v_vNGV^;voI#&$hUi)1~O1u|>%+7{<$P4E(%Z=Z)%Yqh@NWnS