Lydrin

u/Lydrin


r/golang•

Hi everybody !

I want to create a new entity (a Group) from results of an API (Vault) that returns JSON :

package services

// Get will fetch the group based on given params

func (gs *GroupService) Get(path string) (*domains.GroupEntity, error) {
	secret, err := gs.vaultClient.Logical().Read(path)
	if err != nil {return nil, err}
	if secret == nil {return nil, nil}
	return domains.NewGroupEntityFromJson(secret.Data)
}

Since I don't want to repeat the code of converting it, I created a method in my domains alongside my Group that does this conversion :

package domains

import "encoding/json"

type GroupEntity struct {
	ID string `json:"id"`
}

func NewGroupEntityFromJson
15

r/golang•

Hi everybody !

I want to create a new entity (a Group) from results of an API (Vault) that returns JSON :

package services

// Get will fetch the group based on given params
func (gs *GroupService) Get(path) (*domains.GroupEntity, error) {
secret, err := gs.vaultClient.Logical().Read(path)
if err != nil {
return nil, err
}
if secret == nil {
return nil, nil
}
return domains.NewSupportGroupEntityFromJson(secret.Data)
}

​

Since I don't want to repeat the code of converting it, I created a method in my domains alongside my Group that does this conversion :

package domains

type GroupEntity struct {
ID string \json:"

10

r/golang•

Hi Gophers !

I'm trying to learn Go on my spare time coming from Java / Node.js background and there is something I don't really understand about interfaces.

Let's say that I have an http.ResponseWriter :

type ResponseWriter interface {
    [...]
    Write([]byte) (int, error)
    [...]
}

And now let's consider the io.Writer interface :

type Writer interface {
    Write(p []byte) (n int, err error)
}

Put it this way, it's kind of obvious, http.ResponseWriter implements io.Writer, thus I can use something like this :

func Handler(w http.ResponseWriter, req *http.Request) {
    io.WriteString(w, "blabla.\n")
}

As a new Gopher, this is kind o

06

r/aws•

Hi there !

I was reading this blog article.

This explain how to restrict some actions on an S3 bucket to only a specific role (identified by the aws:userid). It works great as expected !

But I was curious and I wanted to explore more : What if I deny all actions on this specific bucket except for a role that doesn't exist ?

So I created this policy :

{
    "Version": "2012-10-17",
    "Id": "MyID",
    "Statement": [
        {
            "Sid": "Stmt1595515547508",
23

r/devops•

Hi DevOps community !

I want to have a Dashboard that sums up all metrics about the health of a project such as build passed/failed over time, total AWS cost (through AWS tags) and also a bunch of useful metrics of SonarQube such as the code quality.

About SonarQube, I wonder about the technical solution that I can implement. There is no official SonarQube integration inside Datadog so it will be custom metrics. But how can I push those custom metrics ?

I was thinking of a Lambda function that periodically get all useful metrics from SonarQube and push them to Datadog API.

What do you think about it ? I need some advice, thank you very much in advance for your answers :)

​

E

20

r/gitlab•

Hi everyone,

I have a question about the default parameters in a Gitlab CI pipeline.

In the documentation it's said that in order to have a default parameter you need to write it this way :

default:
    image: ruby:2.5

rspec:
    script: bundle exec rspec

rspec 2.6:
    image: ruby:2.6
    script: bundle exec rspec

But, I see a lot of pipeline without this default keyword, for example this one for a Spring Boot application :

image: java:8

stages:
    - build
before_script:
    - chmod +x mvnw

build:
    stage: build
    script: ./mvnw package
    artifacts:
    paths:
        - target/demo-0.0.1-SNAPS
10

r/gitlab•

Hi everyone !

I'm new to Gitlab CI/CD and I love it, but there is a thing that I don't really understand.

I host my personnal private Gitlab repository, and I registered a Gitlab Runner (running inside a Docker container), let's call it my-runner, I choose Docker executor for my jobs.

So if I understand well, I have a registered my-runner wich is a Docker Container, and each job of my pipeline will be executed inside a container ?

Does that means that the container my-runner runs Docker-in-Docker ? When I try to execute Docker inside my-runner it says that Docker is an unknown command.

So how can I have Docker executors for my jobs inside my-runner ?

Thank you !

56

You've reached the end of this feed.