Skip to content

Commit

Permalink
Fixing manifest paths
Browse files Browse the repository at this point in the history
  • Loading branch information
alephnull committed Apr 22, 2021
1 parent cfb0c8e commit 54db8b6
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 17 deletions.
2 changes: 0 additions & 2 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ builds:
- -X github.com/TykTechnologies/gromit/util.commit={{.Commit}}
- -X github.com/TykTechnologies/gromit/util.buildDate={{.Date}}
mod_timestamp: '{{ .CommitTimestamp }}'
hooks:
pre: go generate ./confgen ./devenv

archives:
- replacements:
Expand Down
12 changes: 7 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,19 @@ test:
go test -coverprofile cp.out ./... # dlv test ./cmd #

sow: clean
docker build -t $(@) . && docker run --rm --name $(@) \
-e GROMIT_TABLENAME=DeveloperEnvironments \
-e GROMIT_REPOS=tyk,tyk-analytics,tyk-pump \
docker run --rm --name $(@) \
-e GROMIT_TABLENAME=GromitTest \
-e GROMIT_REPOS=tyk,tyk-analytics,tyk-pump,tyk-identity-broker,raava \
-e AWS_ACCESS_KEY_ID=$(aws_id) \
-e AWS_SECRET_ACCESS_KEY=$(aws_key) \
-e AWS_REGION=eu-central-1 \
-e TF_API_TOKEN=$(tf_api) \
-e GROMIT_DOMAIN=dev.tyk.technology \
-e GROMIT_ZONEID=Z06422931MJIQS870BBM7 \
-e GROMIT_ZONEID=Z0326653CS8RP88TOKKI \
-e GROMIT_BASE=base-devenv-euc1-test \
-e GROMIT_INFRA=infra-devenv-euc1-test \
--mount type=bind,src=$(PWD)/$(CONF_VOL),target=/config \
$(@) -l trace /config
tykio/gromit:latest -l trace sow /config

licenser: clean
docker build -t $(@) . && docker run --rm --name $(@) \
Expand Down
13 changes: 9 additions & 4 deletions confgen/templates.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,20 +34,25 @@ func makeConfigTree(fs embed.FS, src string, dest string, tVars templateVars) er
makeConfigTree(fs, srcPath, destPath, tVars)
} else {
// e is a file
data, err := ioutil.ReadFile(srcPath)
i, err := fs.Open(srcPath)
if err != nil {
return err
}
data, err := ioutil.ReadAll(i)
if err != nil {
log.Error().Err(err).Str("srcPath", srcPath).Msgf("could not read from embedded file")
return err
}
tempStr := string(data)
t := template.Must(template.New(e.Name()).Parse(tempStr))
f, err := os.Create(destPath)

o, err := os.Create(destPath)
if err != nil {
log.Error().Err(err).Msgf("could not create: %s", destPath)
return err
}
defer f.Close()
err = t.Execute(f, tVars)
defer o.Close()
err = t.Execute(o, tVars)
if err != nil {
return err
}
Expand Down
18 changes: 15 additions & 3 deletions devenv/terraform.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,15 @@ func (d *DevEnv) Reap(confPath string) error {
// See master.tfvars for a sample inputfile in hcl format
func (d *DevEnv) makeInputVarfile(tfDir string) error {
varFile := fmt.Sprintf("%s.tfvars.json", d.Name)
varsJSON, err := json.Marshal(d.versions)
inputMap := make(map[string]string)
for k, v := range d.versions {
inputMap[k] = v
}
inputMap["base"] = os.Getenv("GROMIT_BASE")
inputMap["infra"] = os.Getenv("GROMIT_INFRA")
inputMap["name"] = d.Name

varsJSON, err := json.Marshal(inputMap)
if err != nil {
return err
}
Expand Down Expand Up @@ -137,7 +145,11 @@ func copyEmbedDir(fs embed.FS, src string, dest string) error {
copyEmbedDir(fs, srcPath, destPath)
} else {
// e is a file
data, err := ioutil.ReadFile(srcPath)
f, err := fs.Open(srcPath)
if err != nil {
return err
}
data, err := ioutil.ReadAll(f)
if err != nil {
return err
}
Expand All @@ -157,7 +169,7 @@ func deployManifest(fs embed.FS, destPrefix string) (string, error) {
return "", err
}

err = copyEmbedDir(fs, ".", tmpDir)
err = copyEmbedDir(fs, "terraform", tmpDir)
if err != nil {
log.Fatal().Err(err).Str("dest", tmpDir).Msg("could not restore embedded manifests")
}
Expand Down
11 changes: 8 additions & 3 deletions devenv/terraform/variables.tf
Original file line number Diff line number Diff line change
@@ -1,39 +1,44 @@
variable "base" {
description = "State to use for base resources"
type = string
type = string
}

variable "infra" {
description = "State to use for infra resources"
type = string
type = string
}

variable "name" {
description = "The DNS record will be name-{gw,db,etc}"
type = string
type = string
}

variable "tyk" {
description = "Image tag for the tyk service"
type = string
default = "master"
}

variable "tyk-analytics" {
description = "Image tag for the tyk-analytics service"
type = string
default = "master"
}

variable "tyk-pump" {
description = "Image tag for the tyk-pump service"
type = string
default = "master"
}

variable "raava" {
description = "Image tag for the raava service"
type = string
default = "master"
}

variable "tyk-identity-broker" {
description = "Image tag for the tib service"
type = string
default = "master"
}

0 comments on commit 54db8b6

Please sign in to comment.