GithubHelp home page GithubHelp logo

go-gitea / go-sdk Goto Github PK

View Code? Open in Web Editor NEW

This project forked from gogs/go-gogs-client

28.0 17.0 53.0 251 KB

Gitea: Golang SDK, moved to https://gitea.com/gitea/go-sdk

Home Page: http://gitea.io

License: MIT License

Go 98.45% Makefile 1.55%
gitea api sdk rest

go-sdk's Introduction

Gitea SDK for Go

Build Status Join the chat at https://img.shields.io/discord/322538954119184384.svg Go Report Card GoDoc

This project acts as a client SDK implementation written in Go to interact with the Gitea API implementation. For further informations take a look at the current documentation.

Contributing

Fork -> Patch -> Push -> Pull Request

Authors

License

This project is under the MIT License. See the LICENSE file for the full license text.

go-sdk's People

Contributors

adelowo avatar andreynering avatar appleboy avatar bkcsoft avatar cez81 avatar drmegavolt avatar ethantkoenig avatar iwanbk avatar jolheiser avatar jonasfranz avatar kmadel avatar kolaente avatar lafriks avatar lstahlman avatar lunny avatar metalmatze avatar ngourdon avatar noerw avatar richmahn avatar roblabla avatar rubenv avatar sapk avatar segevfiner avatar tboerger avatar techknowlogick avatar thehowl avatar typeless avatar unknwon avatar vtemian avatar zeripath avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

go-sdk's Issues

allow a Repository to be created or configured with PullRequest settings

The UI lets you configure a Repository to Allow Pull Request merge commits and so forth:
repo-config

when creating a Repository via the go API all these are false. This means if you create a Pull Request there's no UI in gitea that lets you merge the PR.

I don't see any way to specify or default these values in the go-gitea REST API - so it'd be nice to add these flags so we can pass them into the CreateRepo method

Improve lint

Currently we have a 12% for go lint.
I suggest to make multiple PR by files to improve this and to raise the percent higher.

AdminCreateOrg json unmarshal error

Trying to use gitea go sdk (import "code.gitea.io/sdk/gitea"), the
client.AdminCreateOrg() function returns the following error

json: cannot unmarshal array into Go value of type map[string]interface {}

running with gitea server in docker : 2016 Gitea Version: 1.0.0+276-g9d2b8302


Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

AdminCreateUser fails with json: cannot unmarshal array into Go value of type map[string]interface {}

Similar to #40, I noticed this when trying to use this SDK to write a Terraform provider plugin.

package gitea

import (
	"fmt"
	"testing"

	"code.gitea.io/sdk/gitea"
)

func TestGiteaUserCreate(t *testing.T) {
	client := gitea.NewClient("http://localhost:3000", "978fd3ee4f71d6cf8a87556201d37293d719230d")
	user, err := client.AdminCreateUser(gitea.CreateUserOption{
		Email:     "[email protected]",
		LoginName: "random",
		Username:  "random",
	})

	if err != nil {
		t.Fatal(err)
	}

	fmt.Printf("%#v", user)

}

gomobile errors on bind

I've tried to create an android library out of the gitea go-sdk via gomobile. But gomobile fails with the following errors.

Executed command:

gomobile bind -target android -o gitea.aar -javapkg io.gitea.code.sdk code.gitea.io/sdk/gitea

Error(s):

gomobile: go build -pkgdir=$GOPATH/pkg/gomobile/pkg_android_arm -buildmode=c-shared -o=/tmp/gomobile-work-631988229/android/src/main/jniLibs/armeabi-v7a/libgojni.so /tmp/gomobile-work-631988229/androidlib/main.go failed: exit status 2
# _/tmp/gomobile-work-631988229/gomobile_bind
/tmp/gomobile-work-631988229/gomobile_bind/java_gitea.c:1998:1: error: redefinition of 'Java_io_gitea_code_sdk_gitea_CreatePayload_setSecret'
/tmp/gomobile-work-631988229/gomobile_bind/java_gitea.c:1991:1: note: previous definition is here
/tmp/gomobile-work-631988229/gomobile_bind/java_gitea.c:3658:1: error: redefinition of 'Java_io_gitea_code_sdk_gitea_IssuePayload_setSecret'
/tmp/gomobile-work-631988229/gomobile_bind/java_gitea.c:3651:1: note: previous definition is here
/tmp/gomobile-work-631988229/gomobile_bind/java_gitea.c:5048:1: error: redefinition of 'Java_io_gitea_code_sdk_gitea_PullRequestPayload_setSecret'
/tmp/gomobile-work-631988229/gomobile_bind/java_gitea.c:5041:1: note: previous definition is here
/tmp/gomobile-work-631988229/gomobile_bind/java_gitea.c:5171:1: error: redefinition of 'Java_io_gitea_code_sdk_gitea_PushPayload_setSecret'
/tmp/gomobile-work-631988229/gomobile_bind/java_gitea.c:5164:1: note: previous definition is here
/tmp/gomobile-work-631988229/gomobile_bind/java_gitea.c:5818:1: error: redefinition of 'Java_io_gitea_code_sdk_gitea_RepositoryPayload_setSecret'
/tmp/gomobile-work-631988229/gomobile_bind/java_gitea.c:5811:1: note: previous definition is here

ListPullRequestsOptions does not work?

return prs, c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s/pulls", owner, repo), jsonHeader, bytes.NewReader(body), &prs)

How does this work?

func (c *Client) getParsedResponse(method, path string, header http.Header, body io.Reader, obj interface{}) error {

func (c *Client) getResponse(method, path string, header http.Header, body io.Reader) ([]byte, error) {

func (c *Client) doRequest(method, path string, header http.Header, body io.Reader) (*http.Response, error) {

You passed body as a JSON to a GET request and expect it will be converted to a query string?

Test Framework

How can someone set up a test environment for adding tests to this SDK? I'm at a loss as I don't quite understand how the main gitea project is doing tests. I'd think it's possible to do something with Docker, but I'm not terribly confident that you can spin up a gitea server and then run go test with it.

Would it be possible to set up something equivalent to a golden file/db so you could use it as a baseline for tests?

improve error handling if a REST request has missing data

I was trying to create a webhook and was getting this opaque message back:

error: json: cannot unmarshal array into Go value of type map[string]interface {}

After a bit of debugging it turned out a 422 was being returned with nice error message that was hidden.

A PR is on its way shortly to fix this to return the issue with the missing data

SDK depends on Gitea

go-sdk depends currently on code.gitea.io/gitea that implicates that all dependencies of gitea are needed to for go-sdk. We should consider fixing this since it will increase the size of binaries of tools using the sdk.

Information necessary for calling func (*Client) CreatePullRequest

When calling CreatePullRequest(owner, repo string, opt CreatePullRequestOption), I am facing an issue since I do not know how to specify information about the base and head repos, since they are simple strings in the CreatePullRequestOption struct.

I would expect to be able to specify at least some repo information (such as id, name, owner, etc.) and branch information.

But I do not see how to do it since these fields are simple strings.

Any hints?

cannot use file (type *io.Reader) as type io.Reader in argument to io.Copy

Hey @JonasFranzDEV, I get the following compilation error using the latest commit:

# bitbucket.org/gridarrow/gridarrow-manager/vendor/code.gitea.io/sdk/gitea
vendor/code.gitea.io/sdk/gitea/attachment.go:11:2: imported and not used: "io/ioutil"
vendor/code.gitea.io/sdk/gitea/attachment.go:58:21: cannot use file (type *io.Reader) as type io.Reader in argument to io.Copy:
	*io.Reader is pointer to interface, not interface

This is with the following glide dependency:

- package: code.gitea.io/sdk
  subpackages:
  - gitea

Previous commit works fine for me. Not a go expert, so perhaps it's my bad somehow...

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.