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

Error message during plugin build #5

Open
ilijabojanovic opened this issue Feb 4, 2020 · 1 comment
Open

Error message during plugin build #5

ilijabojanovic opened this issue Feb 4, 2020 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@ilijabojanovic
Copy link
Member

On v2.9.3-rc1 tag

When we run command to generate go plugin we have errors in console. Go plugin is created but message is visible

Reproduction steps:

  1. In terminal execute docker run -v pwd:/go/src/plugin-build tykio/tyk-plugin-compiler:v2.9.3-rc1 my-post-plugin.so

Console message:

hybrid docker run -v `pwd`:/go/src/plugin-build tykio/tyk-plugin-compiler:v2.9.3-rc1 my-post-plugin.so
+ PLUGIN_BUILD_PATH=/go/src/plugin-build
+ plugin_name=my-post-plugin.so
+ '[' -z my-post-plugin.so ']'
+ yes
+ cp -r /go/src/plugin-build/vendor /go/src
cp: cannot stat '/go/src/plugin-build/vendor': No such file or directory
+ true
+ rm -rf /go/src/plugin-build/vendor
+ cd /go/src/plugin-build
+ go build -buildmode=plugin -o my-post-plugin.so

cp: cannot stat '/go/src/plugin-build/vendor': No such file or directory

Testing go file:

package main
import (
	"encoding/json"
	"net/http"
	"time"
	"github.com/TykTechnologies/tyk/log"
)
func ResponseSendCurrentTime(rw http.ResponseWriter, r *http.Request) {
	var logger = log.Get()
	logger.Info("Processing HTTP request in Golang plugin!! - ResponseSendCurrentTime")
	now := time.Now().String()
	// prepare data to send
	replyData := map[string]string{
		"current_time": now,
	}
	jsonData, err := json.Marshal(replyData)
	if err != nil {
		rw.WriteHeader(http.StatusInternalServerError)
		return
	}
	// check if we don't need to send reply
	if r.URL.Query().Get("get_time") != "2" {
		// allow request to be processed and sent to upstream
		r.Header.Add("current_time", now)
		return
	}
	// send HTTP response from Golang plugin
	rw.Header().Set("Content-Type", "application/json")
	rw.WriteHeader(http.StatusOK)
	rw.Write(jsonData)
}
func main() {}
@ilijabojanovic ilijabojanovic added the bug Something isn't working label Feb 4, 2020
@letzya
Copy link
Contributor

letzya commented Feb 26, 2020

This is important for our DX. User doesn't know if he should or not ignore this so we should either get rid of the error or print a message " you can ignore this error".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants