-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #95 from vijeyash1/dockerhub
Dockerhub
- Loading branch information
Showing
12 changed files
with
373 additions
and
91 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package handler | ||
|
||
import ( | ||
"errors" | ||
"io" | ||
"log" | ||
"net/http" | ||
) | ||
|
||
// parse errors | ||
var ( | ||
ErrReadingBody = errors.New("error reading the request body") | ||
ErrPublishToNats = errors.New("error while publishing to nats") | ||
) | ||
|
||
func (ah *APIHandler) PostEventDockerHub(w http.ResponseWriter, r *http.Request) { | ||
defer func() { | ||
_, _ = io.Copy(io.Discard, r.Body) | ||
_ = r.Body.Close() | ||
}() | ||
payload, err := io.ReadAll(r.Body) | ||
if err != nil || len(payload) == 0 { | ||
log.Printf("%v: %v", ErrReadingBody, err) | ||
return | ||
} | ||
log.Printf("Received event from docker artifactory: %v", string(payload)) | ||
err = ah.conn.Publish(payload, "Dockerhub_Registry") | ||
if err != nil { | ||
log.Printf("%v: %v", ErrPublishToNats, err) | ||
return | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package handler | ||
|
||
import ( | ||
"errors" | ||
"io" | ||
"log" | ||
"net/http" | ||
) | ||
|
||
var ( | ||
ErrMissingGithubEventHeader = errors.New("missing X-GitHub-Event Header") | ||
) | ||
|
||
func (ah *APIHandler) PostEventDockerGithub(w http.ResponseWriter, r *http.Request) { | ||
defer func() { | ||
_, _ = io.Copy(io.Discard, r.Body) | ||
_ = r.Body.Close() | ||
}() | ||
event := r.Header.Get("X-GitHub-Event") | ||
if event == "" { | ||
log.Printf("%v", ErrMissingGithubEventHeader) | ||
return | ||
} | ||
|
||
payload, err := io.ReadAll(r.Body) | ||
if err != nil || len(payload) == 0 { | ||
log.Printf("%v: %v", ErrReadingBody, err) | ||
return | ||
} | ||
|
||
log.Printf("Received docker event from github artifactory: %v", string(payload)) | ||
err = ah.conn.Publish(payload, "Github_Registry") | ||
if err != nil { | ||
log.Printf("%v: %v", ErrPublishToNats, err) | ||
return | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.