flow-cli icon indicating copy to clipboard operation
flow-cli copied to clipboard

Installation using go toolchain

Open janezpodhostnik opened this issue 2 years ago • 5 comments

Issue To Be Solved

Enable install/update using go toolchain:

go install github.com/onflow/flow-cli/cmd/flow@latest

(Optional): Suggest A Solution

I opened a draft PR to demonstrate what wold need to be done here:

With that PR this already works: https://github.com/onflow/flow-cli/pull/877

> go install github.com/onflow/flow-cli/cmd/flow@f5ece204f6833075aeecddbda60711e184629102
go: downloading github.com/onflow/flow-cli v0.46.3-0.20230223123946-f5ece204f683
> which flow
/home/user/go/bin/flow

But there are 2 problems:

  1. flow version does not work
    flow version
    Version information unknown!
    
  2. using replace in go mods is not allowed for go install to work. see: https://utcc.utoronto.ca/~cks/space/blog/programming/GoInstallLimitation (It's terrible). This would mean there is an extra step during releases where the flowkit version in go.mod would be updated

I think problem 1. is fixable, but problem 2. will requires overhead (hopefully CI overhead).

If anyone else would like this feature, maybe this can get pushed along, but I'm not sure if anyone (besides me) would like to have this.

janezpodhostnik avatar Feb 23 '23 12:02 janezpodhostnik

Problem 2 is fixable by us actually using flowkit without replacing, which should be reality in the first place, I plan to address a bunch of flowkit debt soon and after that we can start using it by referencing a tag.

The thing that concerns me a bit more is how we are going to add build flags in general? so there are couple of build flags that we use to pass in certain values like version, but also API access token etc. Would that be possible to do with this? @janezpodhostnik

devbugging avatar Feb 23 '23 15:02 devbugging

I was looking at golangcli-lint

It seems like they also somehow pass flags, but they actually have this disclaimer on their website: https://golangci-lint.run/usage/install/#install-from-source

janezpodhostnik avatar Feb 23 '23 17:02 janezpodhostnik

The thing that concerns me a bit more is how we are going to add build flags in general?

I don't think this can be possible with go install ( except version )

bluesign avatar Feb 23 '23 21:02 bluesign

Have you considered not using buildtags for this but instead put this information in a file and embed it in the app using go:embed? so when you push a tag you actually generate that file with ci or something?

bjartek avatar Feb 28 '23 12:02 bjartek

The initial purpose of this flags was to provide API tokens via GH secrets, but I guess at this point it's becoming more clear that we don't have a good way to do that and use homebrew, so I believe ditching this security by obscurity system can be ok.

devbugging avatar Feb 28 '23 13:02 devbugging