Protobuf is a great encoding format. It’s become wildly popular as an encoding protocol, not only for gRPC messages, but for all kinds of information exchange.

When using Protobuf in a streaming situation — i.e. when writing to a file, or over a socket — the problem of delimiting one message from the next becomes apparent. Encoded Protobuf messages do not mark the end of each message, so it is not be possible to reliably distinguish one message from another when reading the stream on the other end.

While Protobuf has no official guidelines regarding this problem, there is a…


Why give up all those S3 tools because you are using Azure?

The S3 API has become more or less a standard interface for cloud storage. Whether you’re using AWS, GCP, IBM Cloud, DigitalOcean, well, pretty much any cloud provider except for Azure, storage is provided with a S3-compliant API.

For this reason, it is quite common that tools within the Open Source community does not support Azure Blob Storage. After all, these tools contain what is contributed to them, and most people are using S3-compliant storage.

While setting up Argo Workflows, I found out that it is possible to…


A primer on customizing Protobuf to JSON serialization in Golang

A new version of Protobuf was released in March 2020, See this post for more info. Please ensure that you have the latest version of the protoc-gen-go plugin, or this article may diff from what you see locally.

Let’s start with a toy example:

Generate the code:

protoc --go_out=. todo.proto

Output:

Create and serialize an example Todo:

JSON output:

There are two obvious problems with this: the enum is serialized as an int, and the timestamp is serialized as.. a struct of seconds and nanos?

protocolbuffers/protobuf-go/encoding/protojson

The…


If you are already using Kubectl, this article is not for you. I wrote this as an on-boarding material for new employees. The aim of the article is to provide the minimum necessary instructions on how to inspect and debug running applications.

The Kubeconfig

After retrieving redentials to a Kubernetes cluster, e.g. on GCP, Azure or AWS, a “context” is created and merged it into your Kubeconfig. The kubeconfig is a yaml file that is normally stored in your home folder at ${HOME}/.kube/config. …


Telepresence is a versatile CNCF sandbox project that aims to provide “Fast, local development for Kubernetes and OpenShift microservice.”

I personally believe that Telepresence is more than that — it simplifies configuration management for local development, allowing developers to work as though the application was running in the remote environment.

This article contains two sections: an introduction to the Telepresence shell and swapping remote deployments. The goal is to, from a functional standpoint, outline when you would use the Telepresence shell and how it can be used to bridge the gap between remote and local development configuration.

Making use of the Telepresence shell

You just joined…


Out-of-the-box errors provided by the validation library used by Go Gin aren’t that great.

Running the server

go run main.go

And sending a request yields us:

$ curl localhost:8080/car
"Key: 'Name' Error:Field validation for 'Name' failed on the 'required' tag"

Retrieving errors from Validator

Gin uses the go-playground/validator under the hood. When ShouldBind fails, the error returned is actually a map[string]validator.FieldError which maps the field name to its error.

if err := c.ShouldBind(&query); err != nil {
for _, fieldErr := range err.(validator.ValidationErrors) {
c.JSON(http.StatusBadRequest, fieldErr)
return // exit on first error
}
}

Porting from validator.v8 to v9

If you just formatted your main.go file, you’ll notice…


There is a long-running issue with go get imports of Azure DevOps repositories due to the fact that the HTTPS URL contains a “_git” segment:

The case for using PAT instead of SSH

When a module that is imported in your Go code is missing, Go will attempt to fetch the package using go get path/to/package. If the package is missing in $GOPATH/src and $GOPATH/pkg/mod , an attempt is made with HTTPS.

In order for Git to access the private repository, you may choose to either use a Personal Access Token (PAT) or to register an SSH key and redirect traffic from the HTTPS URL to the SSH…


A quick guide on how to set up PAT authentication without installing a Git Credentials Manager.

Creating a new PAT

Open the Security section of your account:

Click “New Token”:


This article will explore how the UserData EC2 property can be used to bootstrap an EC2 instance with environment variables. If you are already familiar with UserData, feel free to check out the final template in this gist.

While working on a project in Serverless Framework, I faced the problem of passing environment variables to an EC2 instance. Naively, I thought that it would be as easy as passing variables to lambda functions. Unlike the Lambda resource type however, the CloudFormation resource type AWS::EC2::Instance does not have an environment property.

UserData

By passing a script to the UserData property, we can…

Sebastian Nyberg

Software Engineer @ Securitas Intelligent Products

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store