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

dev #44

Merged
merged 4 commits into from
Apr 4, 2024
Merged

dev #44

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Copyright 2023 Adevinta

FROM golang:1.21.5-alpine3.17 as builder
FROM golang:1.21.5-alpine3.19 as builder

ARG ARCH=amd64

Expand All @@ -19,7 +19,7 @@ FROM alpine:3.19.1

WORKDIR /flyway

RUN apk add --no-cache --update openjdk17-jre bash gettext libc6-compat
RUN apk add --no-cache --update openjdk17-jre-headless bash gettext libc6-compat

ARG FLYWAY_VERSION=10.10.0

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,10 @@ Those are the variables you have to use:
|PG_PORT|Database port|5432|
|PG_SSLMODE|One of these (disable,allow,prefer,require,verify-ca,verify-full)|disable|
|AWSSERVERCREDENTIALS_KEY|Parent key in the AWS Secret Manager to store server secrets|/vulcan/k8s/tracker/jira/|
|AWSSERVERCREDENTIALS_ENDPOINT|Optional AWS endpoint|http://locacalstack/|
|AWS_REGION||eu-west-1|



```bash
docker build . -t vulcantracker

Expand Down
1 change: 1 addition & 0 deletions _resources/config/local.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,5 @@ db = "vultrackerdb"

[aws]
server_credentials_key = "/vulcan/k8s/tracker/jira/"
endpoint = ""
region ="eu-west-1"
1 change: 1 addition & 0 deletions config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,5 @@ sslmode = "$PG_SSLMODE"

[aws]
server_credentials_key = "$AWSSERVERCREDENTIALS_KEY"
endpoint = "$AWSSERVERCREDENTIALS_ENDPOINT"
region ="$AWS_REGION"
1 change: 1 addition & 0 deletions pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ type logConfig struct {
// AwsConfig stores the AWS configuration.
type AwsConfig struct {
ServerCredentialsKey string `toml:"server_credentials_key"`
Endpoint string `toml:"endpoint"`
Region string `toml:"region"`
}

Expand Down
8 changes: 5 additions & 3 deletions pkg/secrets/secrets.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"encoding/json"
"fmt"
"net/http"
"path/filepath"

"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/session"
Expand Down Expand Up @@ -45,7 +46,9 @@ func NewAWSSecretManager(config config.AwsConfig, logger echo.Logger) (*AWSSecre
}
awsCfg := aws.NewConfig()
awsCfg = awsCfg.WithRegion(config.Region)

if config.Endpoint != "" {
awsCfg = awsCfg.WithEndpoint(config.Endpoint)
}
// Create Secrets Manager client.
client := secretsmanager.New(sess, awsCfg)
sc, err := secretcache.New(func(c *secretcache.Cache) { c.Client = client })
Expand All @@ -60,8 +63,7 @@ func NewAWSSecretManager(config config.AwsConfig, logger echo.Logger) (*AWSSecre
// GetServerCredentials return the Jira credentials inside a Credentials type
// from AWS secret manager for a specific server.
func (s *AWSSecrets) GetServerCredentials(serverID string) (Credentials, error) {
secretName := fmt.Sprintf("%s%s", s.config.ServerCredentialsKey, serverID)

secretName := filepath.Join(s.config.ServerCredentialsKey, serverID)
result, err := s.secretCache.GetSecretString(secretName)
if err != nil {
return Credentials{}, &vterrors.TrackingError{
Expand Down
Loading