Skip to content

Instantly share code, notes, and snippets.

View radu-matei's full-sized avatar

Radu Matei radu-matei

View GitHub Profile
version: "3"
services:
redis:
image: redis
web:
image: radumatei/initial-scaleout
deploy:
mode: replicated
invocation_id:"71ce7295-741e-4d7b-9270-acca0a2a49ae"
function_id:"dbabbc49-22c0-422a-b34e-b8a6dd8b0078"
input_data:<name:"req"
data:<
http:<
method:"GET"
url:"/api/HttpTriggerGo"
headers:<
key:"accept"
value:"text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"
{
"callback_url": "https://registry.hub.docker.com/u/svendowideit/testhook/hook/2141b5bi5i5b02bec211i4eeih0242eg11000a/",
"push_data": {
"images": [
"27d47432a69bca5f2700e4dff7de0388ed65f9d3fb1ec645e2bc24c223dc1cc3",
"51a9c7c1f8bb2fa19bcd09789a34e63f35abb80044bc10196e304f6634cc582c",
"..."
],
"pushed_at": 1.417566161e+09,
"pusher": "trustedbuilder",
// WebhookData struct is the data sent from Docker Hub webhooks
type WebhookData struct {
PushData struct {
PushedAt int `json:"pushed_at"`
Images []string `json:"images"`
Tag string `json:"tag"`
Pusher string `json:"pusher"`
} `json:"push_data"`
CallbackURL string `json:"callback_url"`
Repository struct {
func getContainerGroupsClient() (containerinstance.ContainerGroupsClient, error) {
var containerGroupsClient containerinstance.ContainerGroupsClient
oAuthConfig, err := adal.NewOAuthConfig(defaultActiveDirectoryEndpoint, tenantID)
if err != nil {
return containerGroupsClient, fmt.Errorf("cannot get oAuth configuration: %v", err)
}
token, err := adal.NewServicePrincipalToken(*oAuthConfig, clientID, clientSecret, defaultResourceManagerEndpoint)
if err != nil {
func updateAzureContainer(resourceGroupName, containerGroupName string, webhookData WebhookData) error {
containerGroupsClient, err := getContainerGroupsClient()
if err != nil {
return fmt.Errorf("cannot get container groups client: %v", err)
}
containerGroup, err := containerGroupsClient.Get(resourceGroupName, containerGroupName)
if err != nil {
return fmt.Errorf("cannot get container group: %v", err)
}
func handleWebhook(w http.ResponseWriter, r *http.Request) {
decoder := json.NewDecoder(r.Body)
var webhookData WebhookData
err := decoder.Decode(&webhookData)
if err != nil {
log.Printf("cannot decode request body: %v", err)
}
defer r.Body.Close()
invocation_id:\"bc37cc22-c224-47f2-9c91-958f5387604d\"
function_id:\"d208f451-a62b-4603-90d1-ff2d66fb37c4\"
input_data:<
name:\"myBlob\"
data:<
string:\"blob content...\\n\"
>
>
trigger_metadata:<
syntax = "proto3";
package rpc;
service KTK {
rpc GetVersion(Empty) returns (Version){}
rpc ServerStream(Empty) returns(stream StreamingMessage){}
}
message Version {
string sem_ver = 1;
import fs = require('fs');
import { Observable } from 'rxjs';
let exec = require('child_process').exec;
const git_commit = new Observable<string>(s => {
exec('git rev-parse HEAD',
function (error: Error, stdout: Buffer, stderr: Buffer) {
if (error !== null) {
console.log('git error: ' + error + stderr);