FDio / govpp

Go toolset for the VPP.
Apache License 2.0
193 stars 82 forks source link

go.fd.io/govpp/extras cannot be imported #111

Closed yoursunny closed 1 year ago

yoursunny commented 1 year ago

extras directory is declared as its own module: https://github.com/FDio/govpp/blob/2155ba39d4353b5d5e36473edfb2268be7b5d9c8/extras/go.mod#L1

However, the HTTP server at go.fd.io/govpp/extras is not returning the necessary <meta name="go-import"> tag, so that the module cannot be imported.

$ go get go.fd.io/govpp/extras@latest
go: module go.fd.io/govpp@latest found (v0.7.0), but does not contain package go.fd.io/govpp/extras

⚠️ Please, read the following comment with update: ➡️ https://github.com/FDio/govpp/issues/111#issuecomment-1487424368

edwarnicke commented 1 year ago

Could you provide the document that needs to be pushed up?

ondrej-fabry commented 1 year ago

@edwarnicke Could you share link to the location of source code for the site? I will open PR.

edwarnicke commented 1 year ago

So far I've just been pushing up the raw file (since its sufficiently simple):

curl https://go.fd.io/govpp
<html><head>
    <meta name="go-import" content="go.fd.io/govpp git https://github.com/FDio/govpp">
    <meta name="go-source" content="go.fd.io/govpp     https://github.com/FDio/govpp https://github.com/FDio/govpp/tree/master{/dir} https://github.com/FDio/govpp/blob/master{/dir}/{file}#L{line}">
    <meta http-equiv="refresh" content="0; url=https://pkg.go.dev/go.fd.io/govpp" />
</head></html>  
edwarnicke commented 1 year ago

If we are going to move to having more of a site, it may make sense to build more infra around it.

ondrej-fabry commented 1 year ago

So far I've just been pushing up the raw file (since its sufficiently simple):

Right, understandable. I guess it should not be that much work to use go branch in the FD.io site repo to improve maintainability and allow collaboration. For Ligato we just based of master branch and added redirects with static HTML files for each Go module. See https://github.com/ligato/site/blob/go/static/_redirects

sknat commented 1 year ago

@edwarnicke do you know where this is hosted ? We can probably push a patch, as this seems hugo-based.

edwarnicke commented 1 year ago

@sknat I gave @ondrej-fabry access on netlify to fix it last week. I simply statically uploaded a directory tarball since it was simple before.

sknat commented 1 year ago

Ok works, thanks

edwarnicke commented 1 year ago

@sknat Apologies... should have updated here as well :) Glad all is well.

ondrej-fabry commented 1 year ago

This should work now.

➤ go mod download -json go.fd.io/govpp/extras@latest
{
    "Path": "go.fd.io/govpp/extras",
    "Version": "v0.7.0",
    "Query": "latest",
    "Info": "/home/ondrej/go/pkg/mod/cache/download/go.fd.io/govpp/extras/@v/v0.7.0.info",
    "GoMod": "/home/ondrej/go/pkg/mod/cache/download/go.fd.io/govpp/extras/@v/v0.7.0.mod",
    "Zip": "/home/ondrej/go/pkg/mod/cache/download/go.fd.io/govpp/extras/@v/v0.7.0.zip",
    "Dir": "/home/ondrej/go/pkg/mod/go.fd.io/govpp/extras@v0.7.0",
    "Sum": "h1:bAokcUUDzIUCnhtUmoOug+QuWZI3Erqe56J1RfBLWRc=",
    "GoModSum": "h1:VxUPq8HGQH6/9IL9saMURL3UcHsUuN8XmETuao5HA7o=",
    "Origin": {
        "VCS": "git",
        "URL": "https://github.com/FDio/govpp",
        "Ref": "refs/tags/v0.7.0",
        "Hash": "2155ba39d4353b5d5e36473edfb2268be7b5d9c8"
    }
} 

EDIT: actually, this is most likely incorrect, see next comment

ondrej-fabry commented 1 year ago

⚠️ Important Update

so... I think I might have accidentally messed up the extras module info cached in the public Go Proxy. This is because at first I have entered incorrect values for the HTML meta tags in the go.fd.io/govpp/extras and when I was testing it, it filled the Go Proxy with invalid info about the module. 😟

I believe the problem is that Go Proxy now returns the info for main GoVPP module instead of extras submodule, see here:

# listing versions WITH Go Proxy
➤ go list -json -m -versions go.fd.io/govpp/extras
{
    "Path": "go.fd.io/govpp/extras",
    "Versions": [
        "v0.6.0-alpha",
        "v0.6.0",
        "v0.7.0",
        "v0.8.0-alpha"
    ]
}

# listing versions WITHOUT Go Proxy
➤ GOPROXY=direct go list -json -m -versions go.fd.io/govpp/extras
{
    "Path": "go.fd.io/govpp/extras",
    "Versions": [
        "v0.1.0"
    ],
    "Origin": {
        "VCS": "git",
        "URL": "https://github.com/FDio/govpp",
        "Subdir": "extras",
        "TagPrefix": "extras/",
        "TagSum": "t1:x7xgAj5aeOC+DZu5HLiZUY3DgMQA9RRScS5l/36Vcls="
    }
}

I have pushed the tag extras/v0.1.0 to publish stable version of the extras module and without Go Proxy the latest gets picked up correctly:

# downloading latest version WITHOUT Go Proxy
➤ GOPROXY=direct go mod download -json go.fd.io/govpp/extras@latest
{
    "Path": "go.fd.io/govpp/extras",
    "Version": "v0.1.0",
    "Query": "latest",
    "Info": "/home/ondrej/go/pkg/mod/cache/download/go.fd.io/govpp/extras/@v/v0.1.0.info",
    "GoMod": "/home/ondrej/go/pkg/mod/cache/download/go.fd.io/govpp/extras/@v/v0.1.0.mod",
    "Zip": "/home/ondrej/go/pkg/mod/cache/download/go.fd.io/govpp/extras/@v/v0.1.0.zip",
    "Dir": "/home/ondrej/go/pkg/mod/go.fd.io/govpp/extras@v0.1.0",
    "Sum": "h1:vY9nWLGGHD8VoEaL47sP8sQTNBWNE0mN0aERixEUzBE=",
    "GoModSum": "h1:s2FPOGIWR+p3ItFhlC2Zgbw1U5HwZxNYLffeK8Ld/kE=",
    "Origin": {
        "VCS": "git",
        "URL": "https://github.com/FDio/govpp",
        "Subdir": "extras",
        "TagPrefix": "extras/",
        "TagSum": "t1:x7xgAj5aeOC+DZu5HLiZUY3DgMQA9RRScS5l/36Vcls=",
        "Ref": "refs/tags/extras/v0.1.0",
        "Hash": "8b655acb0cc10b9f64247118295c366023980a4d"
    }
}

However with the Go Proxy it returns the same response (for govpp main module v0.7.0) as I posted in previous post.

I am afraid this means that users will most likely run into issues when adding the dependency to their Go apps:

# get latest version WITH Go Proxy
➤ go get go.fd.io/govpp/extras@latest
go: go.fd.io/govpp/extras@v0.7.0: parsing go.mod:
    module declares its path as: go.fd.io/govpp
            but was required as: go.fd.io/govpp/extras

#  get latest version WITHOUT Go Proxy
➤ GOPROXY=direct go get go.fd.io/govpp/extras@latest
go: added go.fd.io/govpp/extras v0.1.0

Specifying the version does not help either:

# specifying v0.1.0
➤ go get go.fd.io/govpp/extras@v0.1.0
go: downloading go.fd.io/govpp v0.1.0
go: warning: go.fd.io/govpp/extras@v0.1.0: retracted by module author: Versions v0.5.0 and older use old module path git.fd.io/govpp.git
go: to switch to the latest unretracted version, run:
    go get go.fd.io/govpp/extras@latest

🩹 Available Workaround

So, please use GOPROXY=direct when adding the dependency.


PS: There is one more thing I want to try, that is publishing version that is > v0.7.0 which might force Go Proxy to consider it newer than any version from GoVPP and it might fix the incorrect module info..

yoursunny commented 1 year ago

Specifying the version does not help either:

Setting the version does retrieve the module, but there's a retracted warning.

$ go get go.fd.io/govpp/extras@v0.1.0
go: downloading go.fd.io/govpp/extras v0.1.0
go: downloading go.fd.io/govpp v0.1.0
go: warning: go.fd.io/govpp/extras@v0.1.0: retracted by module author: Versions v0.5.0 and older use old module path git.fd.io/govpp.git
go: to switch to the latest unretracted version, run:
        go get go.fd.io/govpp/extras@latest
go: added go.fd.io/govpp/extras v0.1.0

go.sum entry:

go.fd.io/govpp/extras v0.1.0 h1:vY9nWLGGHD8VoEaL47sP8sQTNBWNE0mN0aERixEUzBE=
go.fd.io/govpp/extras v0.1.0/go.mod h1:s2FPOGIWR+p3ItFhlC2Zgbw1U5HwZxNYLffeK8Ld/kE=
ondrej-fabry commented 1 year ago

Setting the version does retrieve the module, but there's a retracted warning.

But, only govpp main module has retracted version. The extras does not. I believe this is precisely because of the invalid cached info in the GoProxy I described above.

Please try running:

GOPROXY=direct go get go.fd.io/govpp/extras@v0.1.0
sknat commented 1 year ago

Running

GOPROXY=direct go get go.fd.io/govpp/extras@v0.1.0

seemed to work for us in https://github.com/projectcalico/vpp-dataplane/pull/577/files#diff-33ef32bf6c23acb95f5902d7097b7a1d5128ca061167ec0716715b0b9eeaa5f6R111 Thanks @ondrej-fabry

ondrej-fabry commented 1 year ago

Closing as resolved.