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

Feature/string push #23

Closed
wants to merge 5 commits into from

Conversation

dagdynamik
Copy link

@dagdynamik dagdynamik commented Jul 20, 2023

resolve: #18

as discussed ability too push strings

return nil
case "text/plain":
var text = string(b[:])
if len(text) < 10 {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

probably, its better to check if the received string is an actual valid image reference.

@@ -31,9 +29,11 @@ func RequireHeaders(headers []kobold.Header, handler http.Handler) http.Handler
func NewPushWebhook(id string, subs []chan events.PushData, ph events.PayloadHandler) http.Handler {
logger := log.With().Str("endpoint", id).Logger()
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
logger.Info().Str("endpoint", id).Msg("push event received")
var ct string = r.Header.Get("Content-Type")
logger.Info().Str("endpoint", id).Msg(fmt.Sprintf("push event received with Content-Type: %s", ct))
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

zerolog is based on structured data. So it would be more idiomatic to add another Str call before the message

Something like below:

logger.Info().Str("endpoint", id).Str("contentType", ct).Msg("push event received")

@@ -13,6 +13,7 @@ require (
github.com/google/go-licenses v1.6.0
github.com/hashicorp/go-retryablehttp v0.7.4
github.com/mitchellh/mapstructure v1.5.0
github.com/novln/docker-parser v1.0.0
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you think this is really required? I would assume there is a way around it. That library is quite old and not alot used. I think its possible to get the tag from the google other library.

@bluebrown bluebrown force-pushed the main branch 3 times, most recently from 3fdab58 to d9d064f Compare July 27, 2023 20:06
@bluebrown
Copy link
Owner

Closing as its already implemented by #25

@bluebrown bluebrown closed this Sep 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Generic endpoint to receive a plain text image reference
2 participants