Skip to content

Commit

Permalink
v0.4.1 (#131)
Browse files Browse the repository at this point in the history
* chore(deps): Bump cloud.google.com/go/pubsub from 1.9.1 to 1.10.0 (#127)

Bumps [cloud.google.com/go/pubsub](https://github.com/googleapis/google-cloud-go) from 1.9.1 to 1.10.0.
- [Release notes](https://github.com/googleapis/google-cloud-go/releases)
- [Changelog](https://github.com/googleapis/google-cloud-go/blob/master/CHANGES.md)
- [Commits](googleapis/google-cloud-go@pubsub/v1.9.1...pubsub/v1.10.0)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* fix go mod error (#132)

* fix go mod error

* fix: cloud build steps

* fix: rces mgr quota exhausted (#134)

* feat: better_firestore_retry (#135)

* feat: cap cloud func name length to 63 (#142)

* chore(deps): Bump cloud.google.com/go/pubsub from 1.10.0 to 1.10.1 (#141)

Bumps [cloud.google.com/go/pubsub](https://github.com/googleapis/google-cloud-go) from 1.10.0 to 1.10.1.
- [Release notes](https://github.com/googleapis/google-cloud-go/releases)
- [Changelog](https://github.com/googleapis/google-cloud-go/blob/master/CHANGES.md)
- [Commits](googleapis/google-cloud-go@pubsub/v1.10.0...pubsub/v1.10.1)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* chore(deps): Bump cloud.google.com/go from 0.78.0 to 0.79.0 (#144)

Bumps [cloud.google.com/go](https://github.com/googleapis/google-cloud-go) from 0.78.0 to 0.79.0.
- [Release notes](https://github.com/googleapis/google-cloud-go/releases)
- [Changelog](https://github.com/googleapis/google-cloud-go/blob/master/CHANGES.md)
- [Commits](googleapis/google-cloud-go@v0.78.0...v0.79.0)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* chore(deps): Bump cloud.google.com/go/logging from 1.2.0 to 1.3.0 (#139)

Bumps [cloud.google.com/go/logging](https://github.com/googleapis/google-cloud-go) from 1.2.0 to 1.3.0.
- [Release notes](https://github.com/googleapis/google-cloud-go/releases)
- [Changelog](https://github.com/googleapis/google-cloud-go/blob/master/CHANGES.md)
- [Commits](googleapis/google-cloud-go@pubsub/v1.2.0...pubsub/v1.3.0)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* chore(deps): Bump github.com/open-policy-agent/opa from 0.26.0 to 0.27.0 (#143)

Bumps [github.com/open-policy-agent/opa](https://github.com/open-policy-agent/opa) from 0.26.0 to 0.27.0.
- [Release notes](https://github.com/open-policy-agent/opa/releases)
- [Changelog](https://github.com/open-policy-agent/opa/blob/master/CHANGELOG.md)
- [Commits](open-policy-agent/opa@v0.26.0...v0.27.0)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* chore(deps): Bump cloud.google.com/go/firestore from 1.4.0 to 1.5.0 (#137)

Bumps [cloud.google.com/go/firestore](https://github.com/googleapis/google-cloud-go) from 1.4.0 to 1.5.0.
- [Release notes](https://github.com/googleapis/google-cloud-go/releases)
- [Changelog](https://github.com/googleapis/google-cloud-go/blob/master/CHANGES.md)
- [Commits](googleapis/google-cloud-go@pubsub/v1.4.0...pubsub/v1.5.0)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* chore(deps): Bump cloud.google.com/go/storage from 1.13.0 to 1.14.0 (#145)

Bumps [cloud.google.com/go/storage](https://github.com/googleapis/google-cloud-go) from 1.13.0 to 1.14.0.
- [Release notes](https://github.com/googleapis/google-cloud-go/releases)
- [Changelog](https://github.com/googleapis/google-cloud-go/blob/master/CHANGES.md)
- [Commits](googleapis/google-cloud-go@spanner/v1.13.0...spanner/v1.14.0)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* chore(deps): Bump cloud.google.com/go/bigquery from 1.15.0 to 1.16.0 (#138)

Bumps [cloud.google.com/go/bigquery](https://github.com/googleapis/google-cloud-go) from 1.15.0 to 1.16.0.
- [Release notes](https://github.com/googleapis/google-cloud-go/releases)
- [Changelog](https://github.com/googleapis/google-cloud-go/blob/master/CHANGES.md)
- [Commits](googleapis/google-cloud-go@spanner/v1.15.0...bigquery/v1.16.0)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* fix getdoc redoontransient instead of wrning (#146)

* chore(deps): Bump github.com/open-policy-agent/opa from 0.27.0 to 0.27.1 (#147)

Bumps [github.com/open-policy-agent/opa](https://github.com/open-policy-agent/opa) from 0.27.0 to 0.27.1.
- [Release notes](https://github.com/open-policy-agent/opa/releases)
- [Changelog](https://github.com/open-policy-agent/opa/blob/master/CHANGELOG.md)
- [Commits](open-policy-agent/opa@v0.27.0...v0.27.1)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* fix insertid too long (#149)

* feat dumpinventory deals with quota eceeded (#151)

* feat wait on quotqa exceeded so quotqa recovers (#153)

* feat: slo freshness dashboards (#155)

* chore(deps): Bump google.golang.org/api from 0.41.0 to 0.42.0 (#154)

Bumps [google.golang.org/api](https://github.com/googleapis/google-api-go-client) from 0.41.0 to 0.42.0.
- [Release notes](https://github.com/googleapis/google-api-go-client/releases)
- [Changelog](https://github.com/googleapis/google-api-go-client/blob/master/CHANGES.md)
- [Commits](googleapis/google-api-go-client@v0.41.0...v0.42.0)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
  • Loading branch information
BrunoReboul and dependabot[bot] committed Mar 23, 2021
1 parent c682b1e commit 999e587
Show file tree
Hide file tree
Showing 35 changed files with 775 additions and 332 deletions.
20 changes: 10 additions & 10 deletions go.mod
Expand Up @@ -3,16 +3,16 @@ module github.com/BrunoReboul/ram
go 1.13

require (
cloud.google.com/go v0.76.0
cloud.google.com/go/bigquery v1.15.0
cloud.google.com/go/firestore v1.4.0
cloud.google.com/go/logging v1.2.0
cloud.google.com/go/pubsub v1.9.1
cloud.google.com/go/storage v1.13.0
cloud.google.com/go v0.79.0
cloud.google.com/go/bigquery v1.16.0
cloud.google.com/go/firestore v1.5.0
cloud.google.com/go/logging v1.3.0
cloud.google.com/go/pubsub v1.10.1
cloud.google.com/go/storage v1.14.0
github.com/google/uuid v1.2.0
github.com/open-policy-agent/opa v0.26.0
golang.org/x/oauth2 v0.0.0-20210201163806-010130855d6c
google.golang.org/api v0.40.0
google.golang.org/genproto v0.0.0-20210204154452-deb828366460
github.com/open-policy-agent/opa v0.27.1
golang.org/x/oauth2 v0.0.0-20210313182246-cd4f82c27b84
google.golang.org/api v0.42.0
google.golang.org/genproto v0.0.0-20210312152112-fc591d9ea70f
gopkg.in/yaml.v2 v2.4.0
)
171 changes: 63 additions & 108 deletions go.sum

Large diffs are not rendered by default.

16 changes: 16 additions & 0 deletions services/dumpinventory/core.go
Expand Up @@ -35,6 +35,9 @@ import (
"github.com/google/uuid"
)

// Quota ExportAssets Requests per minute
const waitSecOnQuotaExceeded = 70

// Global structure for global variables to optimize the cloud function performances
type Global struct {
assetClient *asset.Client
Expand Down Expand Up @@ -213,6 +216,19 @@ func EntryPoint(ctxEvent context.Context, PubSubMessage gps.PubSubMessage, globa

operation, err := global.assetClient.ExportAssets(global.ctx, global.request)
if err != nil {
if strings.Contains(strings.ToLower(err.Error()), "quota") {
log.Println(glo.Entry{
MicroserviceName: global.microserviceName,
InstanceName: global.instanceName,
Environment: global.environment,
Severity: "WARNING",
Message: fmt.Sprintf("waiting_on_quota_exceeded"),
Description: fmt.Sprintf("ExportAssets quota is gone, wait for %d seconds then retry", waitSecOnQuotaExceeded),
TriggeringPubsubID: global.PubSubID,
})
time.Sleep(waitSecOnQuotaExceeded * time.Second)
return err
}
log.Println(glo.Entry{
MicroserviceName: global.microserviceName,
InstanceName: global.instanceName,
Expand Down
15 changes: 15 additions & 0 deletions services/getgroupsettings/core.go
Expand Up @@ -39,6 +39,8 @@ import (
pubsubpb "google.golang.org/genproto/googleapis/pubsub/v1"
)

const waitSecOnQuotaExceeded = 70

// Global structure for global variables to optimize the cloud function performances
type Global struct {
ctx context.Context
Expand Down Expand Up @@ -256,6 +258,19 @@ func EntryPoint(ctxEvent context.Context, PubSubMessage gps.PubSubMessage, globa
if !feedMessageGroup.Deleted {
groupSettings, err := global.groupsSettingsService.Groups.Get(feedMessageGroup.Asset.Resource.Email).Do()
if err != nil {
if strings.Contains(strings.ToLower(err.Error()), "quota") {
log.Println(glo.Entry{
MicroserviceName: global.microserviceName,
InstanceName: global.instanceName,
Environment: global.environment,
Severity: "WARNING",
Message: fmt.Sprintf("waiting_on_quota_exceeded"),
Description: fmt.Sprintf("GetGroupSettings quota is gone, wait for %d seconds then retry", waitSecOnQuotaExceeded),
TriggeringPubsubID: global.PubSubID,
})
time.Sleep(waitSecOnQuotaExceeded * time.Second)
return err
}
log.Println(glo.Entry{
MicroserviceName: global.microserviceName,
InstanceName: global.instanceName,
Expand Down
15 changes: 15 additions & 0 deletions services/listgroupmembers/core.go
Expand Up @@ -40,6 +40,8 @@ import (
admin "google.golang.org/api/admin/directory/v1"
)

const waitSecOnQuotaExceeded = 70

// Global variable to deal with GroupsListCall Pages constraint: no possible to pass variable to the function in pages()
// https://pkg.go.dev/google.golang.org/api/admin/directory/v1?tab=doc#GroupsListCall.Pages
var ancestors []string
Expand Down Expand Up @@ -311,6 +313,19 @@ func EntryPoint(ctxEvent context.Context, PubSubMessage gps.PubSubMessage, globa
// pages function except just the name of the callback function. Not an invocation of the function
err = global.dirAdminService.Members.List(feedMessageGroup.Asset.Resource.Id).MaxResults(global.maxResultsPerPage).Pages(ctx, browseMembers)
if err != nil {
if strings.Contains(strings.ToLower(err.Error()), "quota") {
log.Println(glo.Entry{
MicroserviceName: global.microserviceName,
InstanceName: global.instanceName,
Environment: global.environment,
Severity: "WARNING",
Message: fmt.Sprintf("waiting_on_quota_exceeded"),
Description: fmt.Sprintf("ListGroupMembers quota is gone, wait for %d seconds then retry", waitSecOnQuotaExceeded),
TriggeringPubsubID: global.PubSubID,
})
time.Sleep(waitSecOnQuotaExceeded * time.Second)
return err
}
log.Println(glo.Entry{
MicroserviceName: global.microserviceName,
InstanceName: global.instanceName,
Expand Down
15 changes: 15 additions & 0 deletions services/listgroups/core.go
Expand Up @@ -39,6 +39,8 @@ import (
admin "google.golang.org/api/admin/directory/v1"
)

const waitSecOnQuotaExceeded = 70

// Global variable to deal with GroupsListCall Pages constraint: no possible to pass variable to the function in pages()
// https://pkg.go.dev/google.golang.org/api/admin/directory/v1?tab=doc#GroupsListCall.Pages
var ctx context.Context
Expand Down Expand Up @@ -340,6 +342,19 @@ func EntryPoint(ctxEvent context.Context, PubSubMessage gps.PubSubMessage, globa

err = queryDirectory(settings.Domain, settings.EmailPrefix, global)
if err != nil {
if strings.Contains(strings.ToLower(err.Error()), "quota") {
log.Println(glo.Entry{
MicroserviceName: global.microserviceName,
InstanceName: global.instanceName,
Environment: global.environment,
Severity: "WARNING",
Message: fmt.Sprintf("waiting_on_quota_exceeded"),
Description: fmt.Sprintf("ListGroup quota is gone, wait for %d seconds then retry", waitSecOnQuotaExceeded),
TriggeringPubsubID: global.PubSubID,
})
time.Sleep(waitSecOnQuotaExceeded * time.Second)
return err
}
log.Println(glo.Entry{
MicroserviceName: global.microserviceName,
InstanceName: global.instanceName,
Expand Down
Expand Up @@ -20,6 +20,6 @@ func (instanceDeployment *InstanceDeployment) deployMonitoringDashboard() (err e
dashboardDeployment := mon.NewDashboardDeployment()
dashboardDeployment.Core = instanceDeployment.Core
dashboardDeployment.Settings.Instance.MON = instanceDeployment.Settings.Instance.MON
dashboardDeployment.Artifacts.Widgets = instanceDeployment.Artifacts.Widgets
dashboardDeployment.Artifacts = instanceDeployment.Artifacts
return dashboardDeployment.Deploy()
}
52 changes: 46 additions & 6 deletions services/setdashboards/meth_instancedeployment_situate.go
Expand Up @@ -15,20 +15,60 @@
package setdashboards

import (
"encoding/json"
"fmt"
"math"
"strings"

"github.com/BrunoReboul/ram/utilities/mon"
"google.golang.org/api/monitoring/v1"
)

// Situate complement settings taking in account the situation for service and instance settings
func (instanceDeployment *InstanceDeployment) Situate() (err error) {
instanceDeployment.Artifacts.Widgets = []*monitoring.Widget{}
for _, microserviceName := range instanceDeployment.Settings.Instance.MON.MicroServiceNameList {
for _, widgetType := range instanceDeployment.Settings.Instance.MON.WidgetTypeList {
widget, err := mon.GetGCFWidget(microserviceName, widgetType)
if err != nil {
return err
instanceDeployment.Artifacts.Tiles = []*monitoring.Tile{}
if instanceDeployment.Settings.Instance.MON.GridLayout.Columns != 0 {
for _, microserviceName := range instanceDeployment.Settings.Instance.MON.GridLayout.MicroServiceNameList {
for _, widgetType := range instanceDeployment.Settings.Instance.MON.GridLayout.WidgetTypeList {
widget, err := mon.GetGCFWidget(microserviceName, widgetType)
if err != nil {
return err
}
instanceDeployment.Artifacts.Widgets = append(instanceDeployment.Artifacts.Widgets, &widget)
}
instanceDeployment.Artifacts.Widgets = append(instanceDeployment.Artifacts.Widgets, &widget)
}
}
if instanceDeployment.Settings.Instance.MON.SLOFreshnessLayout.SLO != 0 {
grouwthFactor := math.Sqrt(2)
scale := 0.01
thresholdSeconds := scale * math.Pow(grouwthFactor, float64(instanceDeployment.Settings.Instance.MON.SLOFreshnessLayout.CutOffBucketNumber))
var thresholdText string
if thresholdSeconds < 60 {
thresholdText = fmt.Sprintf("%g seconds", math.Round(thresholdSeconds))
} else {
if thresholdSeconds < 60*60 {
thresholdText = fmt.Sprintf("%g minutes", math.Round(thresholdSeconds/60))
} else {
if thresholdSeconds < 60*60*60 {
thresholdText = fmt.Sprintf("%g hours", math.Round(thresholdSeconds/60/60))
}
}
}
slo := instanceDeployment.Settings.Instance.MON.SLOFreshnessLayout.SLO
sloText := fmt.Sprintf("%g%%", slo*100)
dashboardJSON := mon.SLOFreshnessTiles
dashboardJSON = strings.Replace(dashboardJSON, "<origin>", instanceDeployment.Settings.Instance.MON.SLOFreshnessLayout.Origin, -1)
dashboardJSON = strings.Replace(dashboardJSON, "<scope>", instanceDeployment.Settings.Instance.MON.SLOFreshnessLayout.Scope, -1)
dashboardJSON = strings.Replace(dashboardJSON, "<flow>", instanceDeployment.Settings.Instance.MON.SLOFreshnessLayout.Flow, -1)
dashboardJSON = strings.Replace(dashboardJSON, "<slo>", fmt.Sprintf("%g", slo), -1)
dashboardJSON = strings.Replace(dashboardJSON, "<lowerBound>", fmt.Sprintf("%g", math.Floor(slo*10)/10), -1)
dashboardJSON = strings.Replace(dashboardJSON, "<thresholdSeconds>", fmt.Sprintf("%v", thresholdSeconds), -1)
dashboardJSON = strings.Replace(dashboardJSON, "<thresholdText>", thresholdText, -1)
dashboardJSON = strings.Replace(dashboardJSON, "<sloText>", sloText, -1)
err = json.Unmarshal([]byte(dashboardJSON), &instanceDeployment.Artifacts.Tiles)
if err != nil {
return fmt.Errorf("json.Unmarshal SLOFreshnessTiles %v", err)
}
}
return nil
Expand Down
1 change: 1 addition & 0 deletions services/setdashboards/type_instancedeployment.go
Expand Up @@ -31,6 +31,7 @@ type InstanceDeployment struct {
DumpTimestamp time.Time `yaml:"dumpTimestamp"`
Artifacts struct {
Widgets []*monitoring.Widget
Tiles []*monitoring.Tile
}
Core *deploy.Core
Settings struct {
Expand Down
18 changes: 15 additions & 3 deletions services/stream2bq/core.go
Expand Up @@ -30,6 +30,7 @@ import (
"github.com/BrunoReboul/ram/utilities/glo"
"github.com/BrunoReboul/ram/utilities/gps"
"github.com/BrunoReboul/ram/utilities/solution"
"github.com/BrunoReboul/ram/utilities/str"
"github.com/google/uuid"
"google.golang.org/api/cloudresourcemanager/v1"

Expand Down Expand Up @@ -467,7 +468,11 @@ func persistComplianceStatus(pubSubJSONDoc []byte, global *Global) (insertID str
}
global.assetInventoryOrigin = complianceStatus.AssetInventoryOrigin

insertID = fmt.Sprintf("%s%v%s%v", complianceStatus.AssetName, complianceStatus.AssetInventoryTimeStamp, complianceStatus.RuleName, complianceStatus.RuleDeploymentTimeStamp)
insertID = str.Hash(fmt.Sprintf("%s%v%s%v",
complianceStatus.AssetName,
complianceStatus.AssetInventoryTimeStamp,
complianceStatus.RuleName,
complianceStatus.RuleDeploymentTimeStamp))
savers := []*bigquery.StructSaver{
{Struct: complianceStatus, Schema: gbq.GetComplianceStatusSchema(), InsertID: insertID},
}
Expand Down Expand Up @@ -523,7 +528,12 @@ func persistViolation(pubSubJSONDoc []byte, global *Global) (insertID string, er
violationBQ.FeedMessage.Asset.Resource = string(violation.FeedMessage.Asset.Resource)
violationBQ.RegoModules = string(violation.RegoModules)

insertID = fmt.Sprintf("%s%v%s%v%s", violationBQ.FeedMessage.Asset.Name, violation.FeedMessage.Window.StartTime, violation.FunctionConfig.FunctionName, violation.FunctionConfig.DeploymentTime, violation.NonCompliance.Message)
insertID = str.Hash(fmt.Sprintf("%s%v%s%v%s",
violationBQ.FeedMessage.Asset.Name,
violation.FeedMessage.Window.StartTime,
violation.FunctionConfig.FunctionName,
violation.FunctionConfig.DeploymentTime,
violation.NonCompliance.Message))
savers := []*bigquery.StructSaver{
{Struct: violationBQ, Schema: gbq.GetViolationsSchema(), InsertID: insertID},
}
Expand Down Expand Up @@ -599,7 +609,9 @@ func persistAsset(pubSubJSONDoc []byte, global *Global) (insertID string, err er

global.assetInventoryOrigin = assetFeedMessageBQ.Origin

insertID = fmt.Sprintf("%s%v", assetFeedMessageBQ.Asset.Name, assetFeedMessageBQ.Asset.Timestamp)
insertID = str.Hash(fmt.Sprintf("%s%v",
assetFeedMessageBQ.Asset.Name,
assetFeedMessageBQ.Asset.Timestamp))
savers := []*bigquery.StructSaver{
{Struct: assetFeedMessageBQ.Asset, Schema: gbq.GetAssetsSchema(), InsertID: insertID},
}
Expand Down
55 changes: 28 additions & 27 deletions utilities/cai/func_getdisplayname.go
Expand Up @@ -16,7 +16,6 @@ package cai

import (
"context"
"log"
"strings"

"cloud.google.com/go/firestore"
Expand Down Expand Up @@ -81,32 +80,34 @@ func getDisplayName(ctx context.Context,
}
// log.Printf("name %s displayName %s", name, displayName)
} else {
log.Printf("WARNING - Not found in firestore %s", documentPath)
//try resourcemamager API
switch strings.Split(name, "/")[0] {
case "organizations":
resp, err := cloudresourcemanagerService.Organizations.Get(name).Context(ctx).Do()
if err != nil {
log.Printf("WARNING - cloudresourcemanagerService.Organizations.Get %v", err)
} else {
displayName = resp.DisplayName
}
case "folders":
resp, err := cloudresourcemanagerServiceV2.Folders.Get(name).Context(ctx).Do()
if err != nil {
log.Printf("WARNING - cloudresourcemanagerServiceV2.Folders.Get %v", err)
} else {
displayName = resp.DisplayName
}
case "projects":
resp, err := cloudresourcemanagerService.Projects.Get(strings.Split(name, "/")[1]).Context(ctx).Do()
if err != nil {
log.Printf("WARNING - cloudresourcemanagerService.Projects.Get %v", err)
} else {
displayName = resp.Name
projectID = resp.ProjectId
}
}
// log.Printf("WARNING - Not found in firestore %s", documentPath)

//Do not fallback on resourcemamager API see https://github.com/BrunoReboul/ram/issues/126

// switch strings.Split(name, "/")[0] {
// case "organizations":
// resp, err := cloudresourcemanagerService.Organizations.Get(name).Context(ctx).Do()
// if err != nil {
// log.Printf("WARNING - cloudresourcemanagerService.Organizations.Get %v", err)
// } else {
// displayName = resp.DisplayName
// }
// case "folders":
// resp, err := cloudresourcemanagerServiceV2.Folders.Get(name).Context(ctx).Do()
// if err != nil {
// log.Printf("WARNING - cloudresourcemanagerServiceV2.Folders.Get %v", err)
// } else {
// displayName = resp.DisplayName
// }
// case "projects":
// resp, err := cloudresourcemanagerService.Projects.Get(strings.Split(name, "/")[1]).Context(ctx).Do()
// if err != nil {
// log.Printf("WARNING - cloudresourcemanagerService.Projects.Get %v", err)
// } else {
// displayName = resp.Name
// projectID = resp.ProjectId
// }
// }
}
return displayName, projectID
}
29 changes: 17 additions & 12 deletions utilities/gcb/meth_triggerdeployment_deploy.go
Expand Up @@ -209,28 +209,33 @@ func (triggerDeployment *TriggerDeployment) situate() {

func (triggerDeployment *TriggerDeployment) getInstanceDeploymentBuild() *cloudbuild.Build {
var steps []*cloudbuild.BuildStep
var step1, step2, step3 cloudbuild.BuildStep
var step1, step2, step3, step4 cloudbuild.BuildStep

step1.Id = "build a fresh ram cli"
step1.Id = "display go language version"
step1.Name = "golang"
step1.Args = []string{"go", "build", "ram.go"}
step1.Args = []string{"go", "version"}
steps = append(steps, &step1)

step2.Id = "display ram executable info"
step2.Name = "gcr.io/cloud-builders/gcloud"
step2.Entrypoint = "bash"
step2.Args = []string{"-c", "ls -al ram"}
step2.Id = "build a fresh ram cli"
step2.Name = "golang"
step2.Args = []string{"go", "build", "-mod=mod", "ram.go"}
steps = append(steps, &step2)

step3.Id = "display ram executable info"
step3.Name = "gcr.io/cloud-builders/gcloud"
step3.Entrypoint = "bash"
step3.Args = []string{"-c", "ls -al ram"}
steps = append(steps, &step3)

ramDeploymentCommand := fmt.Sprintf("./ram -deploy -environment=%s -service=%s -instance=%s",
triggerDeployment.Core.EnvironmentName,
triggerDeployment.Core.ServiceName,
triggerDeployment.Core.InstanceName)
step3.Id = fmt.Sprintf("deploy instance %s", triggerDeployment.Core.InstanceName)
step3.Name = "gcr.io/cloud-builders/gcloud"
step3.Entrypoint = "bash"
step3.Args = []string{"-c", ramDeploymentCommand}
steps = append(steps, &step3)
step4.Id = fmt.Sprintf("deploy instance %s", triggerDeployment.Core.InstanceName)
step4.Name = "gcr.io/cloud-builders/gcloud"
step4.Entrypoint = "bash"
step4.Args = []string{"-c", ramDeploymentCommand}
steps = append(steps, &step4)

var build cloudbuild.Build
build.Steps = steps
Expand Down

0 comments on commit 999e587

Please sign in to comment.