Skip to content
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

go.mod file still causing issues #18925

Closed
rhalar opened this issue Jul 12, 2023 · 8 comments
Closed

go.mod file still causing issues #18925

rhalar opened this issue Jul 12, 2023 · 8 comments

Comments

@rhalar
Copy link

rhalar commented Jul 12, 2023

This was noticed because some versions of harbor were not being indexed, see
golang/go#61312

This seems to have been brought up before but closed due to inactivity
#10251

@yuriy-yarosh
Copy link

@rhalar I'm building a custom harbor img and currently there are some minor quirks due to go-swagger codegen haven't been updated for quite a while.

    go install github.com/go-swagger/go-swagger/cmd/swagger@v0.30.5 
    $HOME/bin/swagger generate server  \
      --template-dir=tools/swagger/templates \
      --spec=api/v2.0/swagger.yaml  \
      --exclude-main \
      --additional-initialism=CVE \
      --additional-initialism=GC \
      --additional-initialism=OIDC \
      --name=harbor \
      --target=src/server/v2.0
    cd src/
    go get -u github.com/go-openapi/errors
    go get -u github.com/go-openapi/validate
    go mod tidy
    go mod vendor

Other than that - there are no major issues.

I'd be more concerned regarding go.mod updates and automated testing - a lot of things haven't been updated for quite a while.

@rhalar
Copy link
Author

rhalar commented Jul 13, 2023

I'm less concerned about usability, this issue has more to do with how it isn't being indexed on the pkg.go.dev site for me.
I saw this was brought up once before here, and the golang people had some objections as well, so I wanted to revive the issue to see if this could get resolved, or not.

@zyyw
Copy link
Contributor

zyyw commented Jul 17, 2023

It's not only about go.mod file, but also be a good idea to make the goharobr/harbor project conform to this golang-standard-project-layout for the long term purpose. However, this process could be a little bit complicated. As mentioned in here.

cc: @wy65701436

@zyyw
Copy link
Contributor

zyyw commented Jul 17, 2023

Hi @rhalar, if you are trying to interact with a Harbor instance using GoLang, maybe you can use go-swagger to generate a copy of harbor client as local files.

For example, if your use case is trying to create a Registry endpoint of a given Harbor instance for replication or proxycache in your GoLang project. You may need to create a file like registry_client.go using go-swagger and call the

func (a *Client) CreateRegistry(ctx context.Context, params *CreateRegistryParams) (*CreateRegistryCreated, error) {}

method.
Even goharbor/harbor project will have the codebase reorganized to conform to golang-standard-project-layout. The Harbor client code will be most likely not included in the codebase.

registry_client.go code example:

// Code generated by go-swagger; DO NOT EDIT.

package registry

// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command

import (
	"context"

	"github.com/go-openapi/runtime"

	strfmt "github.com/go-openapi/strfmt"
)

//go:generate mockery -name API -inpkg

// API is the interface of the registry client
type API interface {
	/*
	   CreateRegistry creates a registry

	   Create a registry*/
	CreateRegistry(ctx context.Context, params *CreateRegistryParams) (*CreateRegistryCreated, error)
	/*
	   DeleteRegistry deletes the specific registry

     // other code being removed
}

// New creates a new registry API client.
func New(transport runtime.ClientTransport, formats strfmt.Registry, authInfo runtime.ClientAuthInfoWriter) *Client {
	return &Client{
		transport: transport,
		formats:   formats,
		authInfo:  authInfo,
	}
}

/*
Client for registry API
*/
type Client struct {
	transport runtime.ClientTransport
	formats   strfmt.Registry
	authInfo  runtime.ClientAuthInfoWriter
}

/*
CreateRegistry creates a registry

Create a registry
*/
func (a *Client) CreateRegistry(ctx context.Context, params *CreateRegistryParams) (*CreateRegistryCreated, error) {

	result, err := a.transport.Submit(&runtime.ClientOperation{
		ID:                 "createRegistry",
		Method:             "POST",
		PathPattern:        "/registries",
		ProducesMediaTypes: []string{"application/json"},
		ConsumesMediaTypes: []string{"application/json"},
		Schemes:            []string{"http", "https"},
		Params:             params,
		Reader:             &CreateRegistryReader{formats: a.formats},
		AuthInfo:           a.authInfo,
		Context:            ctx,
		Client:             params.HTTPClient,
	})
	if err != nil {
		return nil, err
	}
	return result.(*CreateRegistryCreated), nil

}

// some other code being removed

@github-actions
Copy link

This issue is being marked stale due to a period of inactivity. If this issue is still relevant, please comment or remove the stale label. Otherwise, this issue will close in 30 days.

@github-actions github-actions bot added the Stale label Sep 15, 2023
@rhalar
Copy link
Author

rhalar commented Sep 15, 2023

Do as you wish, this was brought up a couple of times but no definitive answer or intention was given.
My interest is only as I noticed it making things more difficult to track the package in a consistent way, which has other implications.

@github-actions github-actions bot removed the Stale label Sep 16, 2023
Copy link

This issue is being marked stale due to a period of inactivity. If this issue is still relevant, please comment or remove the stale label. Otherwise, this issue will close in 30 days.

@github-actions github-actions bot added the Stale label Nov 15, 2023
Copy link

This issue was closed because it has been stalled for 30 days with no activity. If this issue is still relevant, please re-open a new issue.

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Dec 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants