You've already forked golang-saas-starter-kit
mirror of
https://github.com/raseels-repos/golang-saas-starter-kit.git
synced 2025-08-08 22:36:41 +02:00
Added sitemap to webapp
This commit is contained in:
@ -35,23 +35,23 @@ func (c *Check) Health(ctx context.Context, w http.ResponseWriter, r *http.Reque
|
|||||||
}
|
}
|
||||||
|
|
||||||
data := struct {
|
data := struct {
|
||||||
Status string `json:"status"`
|
Status string `json:"status"`
|
||||||
CiCommitRefName string `json:"ci-commit-ref-name,omitempty"`
|
CiCommitRefName string `json:"ci-commit-ref-name,omitempty"`
|
||||||
CiCommitRefSlug string `json:"ci-commit-ref-slug,omitempty"`
|
CiCommitRefSlug string `json:"ci-commit-ref-slug,omitempty"`
|
||||||
CiCommitSha string `json:"ci-commit-sha,omitempty"`
|
CiCommitSha string `json:"ci-commit-sha,omitempty"`
|
||||||
CiCommitTag string `json:"ci-commit-tag,omitempty"`
|
CiCommitTag string `json:"ci-commit-tag,omitempty"`
|
||||||
CiCommitTitle string `json:"ci-commit-title,omitempty"`
|
CiCommitTitle string `json:"ci-commit-title,omitempty"`
|
||||||
CiJobId string `json:"ci-commit-job-id,omitempty"`
|
CiJobId string `json:"ci-commit-job-id,omitempty"`
|
||||||
CiPipelineId string `json:"ci-commit-pipeline-id,omitempty"`
|
CiPipelineId string `json:"ci-commit-pipeline-id,omitempty"`
|
||||||
}{
|
}{
|
||||||
Status: "ok",
|
Status: "ok",
|
||||||
CiCommitRefName: os.Getenv("CI_COMMIT_REF_NAME"),
|
CiCommitRefName: os.Getenv("CI_COMMIT_REF_NAME"),
|
||||||
CiCommitRefSlug: os.Getenv("CI_COMMIT_REF_SLUG"),
|
CiCommitRefSlug: os.Getenv("CI_COMMIT_REF_SLUG"),
|
||||||
CiCommitSha: os.Getenv("CI_COMMIT_SHA"),
|
CiCommitSha: os.Getenv("CI_COMMIT_SHA"),
|
||||||
CiCommitTag: os.Getenv("CI_COMMIT_TAG"),
|
CiCommitTag: os.Getenv("CI_COMMIT_TAG"),
|
||||||
CiCommitTitle: os.Getenv("CI_COMMIT_TITLE"),
|
CiCommitTitle: os.Getenv("CI_COMMIT_TITLE"),
|
||||||
CiJobId : os.Getenv("CI_COMMIT_JOB_ID"),
|
CiJobId: os.Getenv("CI_COMMIT_JOB_ID"),
|
||||||
CiPipelineId: os.Getenv("CI_COMMIT_PIPELINE_ID"),
|
CiPipelineId: os.Getenv("CI_COMMIT_PIPELINE_ID"),
|
||||||
}
|
}
|
||||||
|
|
||||||
return web.RespondJson(ctx, w, data, http.StatusOK)
|
return web.RespondJson(ctx, w, data, http.StatusOK)
|
||||||
|
@ -35,23 +35,23 @@ func (c *Check) Health(ctx context.Context, w http.ResponseWriter, r *http.Reque
|
|||||||
}
|
}
|
||||||
|
|
||||||
data := struct {
|
data := struct {
|
||||||
Status string `json:"status"`
|
Status string `json:"status"`
|
||||||
CiCommitRefName string `json:"ci-commit-ref-name,omitempty"`
|
CiCommitRefName string `json:"ci-commit-ref-name,omitempty"`
|
||||||
CiCommitRefSlug string `json:"ci-commit-ref-slug,omitempty"`
|
CiCommitRefSlug string `json:"ci-commit-ref-slug,omitempty"`
|
||||||
CiCommitSha string `json:"ci-commit-sha,omitempty"`
|
CiCommitSha string `json:"ci-commit-sha,omitempty"`
|
||||||
CiCommitTag string `json:"ci-commit-tag,omitempty"`
|
CiCommitTag string `json:"ci-commit-tag,omitempty"`
|
||||||
CiCommitTitle string `json:"ci-commit-title,omitempty"`
|
CiCommitTitle string `json:"ci-commit-title,omitempty"`
|
||||||
CiJobId string `json:"ci-commit-job-id,omitempty"`
|
CiJobId string `json:"ci-commit-job-id,omitempty"`
|
||||||
CiPipelineId string `json:"ci-commit-pipeline-id,omitempty"`
|
CiPipelineId string `json:"ci-commit-pipeline-id,omitempty"`
|
||||||
}{
|
}{
|
||||||
Status: "ok",
|
Status: "ok",
|
||||||
CiCommitRefName: os.Getenv("CI_COMMIT_REF_NAME"),
|
CiCommitRefName: os.Getenv("CI_COMMIT_REF_NAME"),
|
||||||
CiCommitRefSlug: os.Getenv("CI_COMMIT_REF_SLUG"),
|
CiCommitRefSlug: os.Getenv("CI_COMMIT_REF_SLUG"),
|
||||||
CiCommitSha: os.Getenv("CI_COMMIT_SHA"),
|
CiCommitSha: os.Getenv("CI_COMMIT_SHA"),
|
||||||
CiCommitTag: os.Getenv("CI_COMMIT_TAG"),
|
CiCommitTag: os.Getenv("CI_COMMIT_TAG"),
|
||||||
CiCommitTitle: os.Getenv("CI_COMMIT_TITLE"),
|
CiCommitTitle: os.Getenv("CI_COMMIT_TITLE"),
|
||||||
CiJobId : os.Getenv("CI_COMMIT_JOB_ID"),
|
CiJobId: os.Getenv("CI_COMMIT_JOB_ID"),
|
||||||
CiPipelineId: os.Getenv("CI_COMMIT_PIPELINE_ID"),
|
CiPipelineId: os.Getenv("CI_COMMIT_PIPELINE_ID"),
|
||||||
}
|
}
|
||||||
|
|
||||||
return web.RespondJson(ctx, w, data, http.StatusOK)
|
return web.RespondJson(ctx, w, data, http.StatusOK)
|
||||||
|
@ -4,28 +4,29 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/pkg/errors"
|
|
||||||
"github.com/sethgrid/pester"
|
|
||||||
"io/ioutil"
|
|
||||||
"net/http"
|
|
||||||
|
|
||||||
"geeks-accelerator/oss/saas-starter-kit/internal/platform/auth"
|
"geeks-accelerator/oss/saas-starter-kit/internal/platform/auth"
|
||||||
"geeks-accelerator/oss/saas-starter-kit/internal/platform/web"
|
"geeks-accelerator/oss/saas-starter-kit/internal/platform/web"
|
||||||
"geeks-accelerator/oss/saas-starter-kit/internal/platform/web/webcontext"
|
"geeks-accelerator/oss/saas-starter-kit/internal/platform/web/webcontext"
|
||||||
project_routes "geeks-accelerator/oss/saas-starter-kit/internal/project-routes"
|
project_routes "geeks-accelerator/oss/saas-starter-kit/internal/project-routes"
|
||||||
|
"github.com/ikeikeikeike/go-sitemap-generator/v2/stm"
|
||||||
"github.com/jmoiron/sqlx"
|
"github.com/jmoiron/sqlx"
|
||||||
|
"github.com/pkg/errors"
|
||||||
|
"github.com/sethgrid/pester"
|
||||||
|
"io/ioutil"
|
||||||
|
"net/http"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Root represents the Root API method handler set.
|
// Root represents the Root API method handler set.
|
||||||
type Root struct {
|
type Root struct {
|
||||||
MasterDB *sqlx.DB
|
MasterDB *sqlx.DB
|
||||||
Renderer web.Renderer
|
Renderer web.Renderer
|
||||||
|
Sitemap *stm.Sitemap
|
||||||
ProjectRoutes project_routes.ProjectRoutes
|
ProjectRoutes project_routes.ProjectRoutes
|
||||||
}
|
}
|
||||||
|
|
||||||
// Index determines if the user has authentication and loads the associated page.
|
// Index determines if the user has authentication and loads the associated page.
|
||||||
func (h *Root) Index(ctx context.Context, w http.ResponseWriter, r *http.Request, params map[string]string) error {
|
func (h *Root) Index(ctx context.Context, w http.ResponseWriter, r *http.Request, params map[string]string) error {
|
||||||
|
|
||||||
if claims, err := auth.ClaimsFromContext(ctx); err == nil && claims.HasAuth() {
|
if claims, err := auth.ClaimsFromContext(ctx); err == nil && claims.HasAuth() {
|
||||||
return h.indexDashboard(ctx, w, r, params)
|
return h.indexDashboard(ctx, w, r, params)
|
||||||
}
|
}
|
||||||
@ -131,3 +132,22 @@ func (h *Root) RobotTxt(ctx context.Context, w http.ResponseWriter, r *http.Requ
|
|||||||
txt := fmt.Sprintf("User-agent: *\nDisallow: /ping\nDisallow: /status\nDisallow: /debug/\nSitemap: %s", sitemapUrl)
|
txt := fmt.Sprintf("User-agent: *\nDisallow: /ping\nDisallow: /status\nDisallow: /debug/\nSitemap: %s", sitemapUrl)
|
||||||
return web.RespondText(ctx, w, txt, http.StatusOK)
|
return web.RespondText(ctx, w, txt, http.StatusOK)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type SiteMap struct {
|
||||||
|
Pages []SiteMapPage `json:"pages"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type SiteMapPage struct {
|
||||||
|
Loc string `json:"loc" xml:"loc"`
|
||||||
|
File string `json:"file" xml:"file"`
|
||||||
|
Changefreq string `json:"changefreq" xml:"changefreq"`
|
||||||
|
Mobile bool `json:"mobile" xml:"mobile"`
|
||||||
|
Priority float64 `json:"priority" xml:"priority"`
|
||||||
|
Lastmod string `json:"lastmod" xml:"lastmod"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// SitemapXml returns a robots.txt response.
|
||||||
|
func (h *Root) SitemapXml(ctx context.Context, w http.ResponseWriter, r *http.Request, params map[string]string) error {
|
||||||
|
w.Write(h.Sitemap.XMLContent())
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
@ -6,6 +6,8 @@ import (
|
|||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
|
"path/filepath"
|
||||||
|
"time"
|
||||||
|
|
||||||
"geeks-accelerator/oss/saas-starter-kit/internal/mid"
|
"geeks-accelerator/oss/saas-starter-kit/internal/mid"
|
||||||
"geeks-accelerator/oss/saas-starter-kit/internal/platform/auth"
|
"geeks-accelerator/oss/saas-starter-kit/internal/platform/auth"
|
||||||
@ -14,6 +16,7 @@ import (
|
|||||||
"geeks-accelerator/oss/saas-starter-kit/internal/platform/web/webcontext"
|
"geeks-accelerator/oss/saas-starter-kit/internal/platform/web/webcontext"
|
||||||
"geeks-accelerator/oss/saas-starter-kit/internal/platform/web/weberror"
|
"geeks-accelerator/oss/saas-starter-kit/internal/platform/web/weberror"
|
||||||
project_routes "geeks-accelerator/oss/saas-starter-kit/internal/project-routes"
|
project_routes "geeks-accelerator/oss/saas-starter-kit/internal/project-routes"
|
||||||
|
"github.com/ikeikeikeike/go-sitemap-generator/v2/stm"
|
||||||
"github.com/jmoiron/sqlx"
|
"github.com/jmoiron/sqlx"
|
||||||
"gopkg.in/DataDog/dd-trace-go.v1/contrib/go-redis/redis"
|
"gopkg.in/DataDog/dd-trace-go.v1/contrib/go-redis/redis"
|
||||||
)
|
)
|
||||||
@ -40,6 +43,24 @@ func APP(shutdown chan os.Signal, log *log.Logger, env webcontext.Env, staticDir
|
|||||||
// Construct the web.App which holds all routes as well as common Middleware.
|
// Construct the web.App which holds all routes as well as common Middleware.
|
||||||
app := web.NewApp(shutdown, log, env, middlewares...)
|
app := web.NewApp(shutdown, log, env, middlewares...)
|
||||||
|
|
||||||
|
// Build a sitemap.
|
||||||
|
sm := stm.NewSitemap(1)
|
||||||
|
sm.SetDefaultHost(projectRoutes.WebAppUrl(""))
|
||||||
|
sm.Create()
|
||||||
|
|
||||||
|
smLocAddModified := func(loc stm.URL, filename string) {
|
||||||
|
contentPath := filepath.Join(templateDir, "content", filename)
|
||||||
|
|
||||||
|
file, err := os.Stat(contentPath)
|
||||||
|
if err != nil {
|
||||||
|
log.Fatalf("main : Add sitemap file modified for %s: %+v", filename, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
lm := []interface{}{"lastmod", file.ModTime().Format(time.RFC3339)}
|
||||||
|
loc = append(loc, lm)
|
||||||
|
sm.Add(loc)
|
||||||
|
}
|
||||||
|
|
||||||
// Register project management pages.
|
// Register project management pages.
|
||||||
p := Projects{
|
p := Projects{
|
||||||
MasterDB: masterDB,
|
MasterDB: masterDB,
|
||||||
@ -149,6 +170,7 @@ func APP(shutdown chan os.Signal, log *log.Logger, env webcontext.Env, staticDir
|
|||||||
MasterDB: masterDB,
|
MasterDB: masterDB,
|
||||||
Renderer: renderer,
|
Renderer: renderer,
|
||||||
ProjectRoutes: projectRoutes,
|
ProjectRoutes: projectRoutes,
|
||||||
|
Sitemap: sm,
|
||||||
}
|
}
|
||||||
app.Handle("GET", "/api", r.SitePage)
|
app.Handle("GET", "/api", r.SitePage)
|
||||||
app.Handle("GET", "/pricing", r.SitePage)
|
app.Handle("GET", "/pricing", r.SitePage)
|
||||||
@ -158,6 +180,15 @@ func APP(shutdown chan os.Signal, log *log.Logger, env webcontext.Env, staticDir
|
|||||||
app.Handle("GET", "/", r.Index, mid.AuthenticateSessionOptional(authenticator))
|
app.Handle("GET", "/", r.Index, mid.AuthenticateSessionOptional(authenticator))
|
||||||
app.Handle("GET", "/index.html", r.IndexHtml)
|
app.Handle("GET", "/index.html", r.IndexHtml)
|
||||||
app.Handle("GET", "/robots.txt", r.RobotTxt)
|
app.Handle("GET", "/robots.txt", r.RobotTxt)
|
||||||
|
app.Handle("GET", "/sitemap.xml", r.SitemapXml)
|
||||||
|
|
||||||
|
// Add sitemap entries for Root.
|
||||||
|
smLocAddModified(stm.URL{{"loc", "/"}, {"changefreq", "weekly"}, {"mobile", true}, {"priority", 0.9}}, "site-index.gohtml")
|
||||||
|
smLocAddModified(stm.URL{{"loc", "/pricing"}, {"changefreq", "monthly"}, {"mobile", true}, {"priority", 0.8}}, "site-pricing.gohtml")
|
||||||
|
smLocAddModified(stm.URL{{"loc", "/support"}, {"changefreq", "monthly"}, {"mobile", true}, {"priority", 0.8}}, "site-support.gohtml")
|
||||||
|
smLocAddModified(stm.URL{{"loc", "/api"}, {"changefreq", "monthly"}, {"mobile", true}, {"priority", 0.7}}, "site-api.gohtml")
|
||||||
|
smLocAddModified(stm.URL{{"loc", "/legal/privacy"}, {"changefreq", "monthly"}, {"mobile", true}, {"priority", 0.5}}, "legal-privacy.gohtml")
|
||||||
|
smLocAddModified(stm.URL{{"loc", "/legal/terms"}, {"changefreq", "monthly"}, {"mobile", true}, {"priority", 0.5}}, "legal-terms.gohtml")
|
||||||
|
|
||||||
// Register health check endpoint. This route is not authenticated.
|
// Register health check endpoint. This route is not authenticated.
|
||||||
check := Check{
|
check := Check{
|
||||||
|
@ -542,7 +542,7 @@ func main() {
|
|||||||
return f.String()
|
return f.String()
|
||||||
},
|
},
|
||||||
"SiteBaseUrl": func(p string) string {
|
"SiteBaseUrl": func(p string) string {
|
||||||
u, err := url.Parse(cfg.HTTP.Host)
|
u, err := url.Parse(cfg.Service.BaseUrl)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "?"
|
return "?"
|
||||||
}
|
}
|
||||||
|
@ -1,44 +0,0 @@
|
|||||||
<urlset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:image="http://www.google.com/schemas/sitemap-image/1.1" xmlns:video="http://www.google.com/schemas/sitemap-video/1.1" xmlns:geo="http://www.google.com/geo/schemas/sitemap/1.0" xmlns:news="http://www.google.com/schemas/sitemap-news/0.9" xmlns:mobile="http://www.google.com/schemas/sitemap-mobile/1.0" xmlns:pagemap="http://www.google.com/schemas/sitemap-pagemap/1.0" xmlns:xhtml="http://www.w3.org/1999/xhtml" xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd">
|
|
||||||
<url>
|
|
||||||
<loc></loc>
|
|
||||||
<changefreq>weekly</changefreq>
|
|
||||||
<file>site-index.gohtml</file>
|
|
||||||
<priority>0.9</priority>
|
|
||||||
<mobile:mobile/>
|
|
||||||
</url>
|
|
||||||
<url>
|
|
||||||
<loc>/pricing</loc>
|
|
||||||
<changefreq>monthly</changefreq>
|
|
||||||
<file>site-pricing.gohtml</file>
|
|
||||||
<priority>0.8</priority>
|
|
||||||
<mobile:mobile/>
|
|
||||||
</url>
|
|
||||||
<url>
|
|
||||||
<loc>/support</loc>
|
|
||||||
<changefreq>monthly</changefreq>
|
|
||||||
<file>site-support.gohtml</file>
|
|
||||||
<priority>0.8</priority>
|
|
||||||
<mobile:mobile/>
|
|
||||||
</url>
|
|
||||||
<url>
|
|
||||||
<loc>/api</loc>
|
|
||||||
<changefreq>monthly</changefreq>
|
|
||||||
<file>site-api.gohtml</file>
|
|
||||||
<priority>0.7</priority>
|
|
||||||
<mobile:mobile/>
|
|
||||||
</url>
|
|
||||||
<url>
|
|
||||||
<loc>/legal/privacy</loc>
|
|
||||||
<changefreq>monthly</changefreq>
|
|
||||||
<file>legal-privacy.gohtml</file>
|
|
||||||
<priority>0.6</priority>
|
|
||||||
<mobile:mobile/>
|
|
||||||
</url>
|
|
||||||
<url>
|
|
||||||
<loc>/legal/terms</loc>
|
|
||||||
<changefreq>monthly</changefreq>
|
|
||||||
<file>legal-privacy.gohtml</file>
|
|
||||||
<priority>0.6</priority>
|
|
||||||
<mobile:mobile/>
|
|
||||||
</url>
|
|
||||||
</urlset>
|
|
1
go.mod
1
go.mod
@ -24,6 +24,7 @@ require (
|
|||||||
github.com/gorilla/sessions v1.2.0
|
github.com/gorilla/sessions v1.2.0
|
||||||
github.com/huandu/go-sqlbuilder v1.4.1
|
github.com/huandu/go-sqlbuilder v1.4.1
|
||||||
github.com/iancoleman/strcase v0.0.0-20190422225806-e506e3ef7365
|
github.com/iancoleman/strcase v0.0.0-20190422225806-e506e3ef7365
|
||||||
|
github.com/ikeikeikeike/go-sitemap-generator/v2 v2.0.2
|
||||||
github.com/jmoiron/sqlx v1.2.0
|
github.com/jmoiron/sqlx v1.2.0
|
||||||
github.com/kelseyhightower/envconfig v1.4.0
|
github.com/kelseyhightower/envconfig v1.4.0
|
||||||
github.com/kr/pty v1.1.8 // indirect
|
github.com/kr/pty v1.1.8 // indirect
|
||||||
|
6
go.sum
6
go.sum
@ -10,7 +10,10 @@ github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751 h1:JYp7IbQjafo
|
|||||||
github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
|
github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
|
||||||
github.com/aws/aws-sdk-go v1.21.8 h1:Lv6hW2twBhC6mGZAuWtqplEpIIqtVctJg02sE7Qn0Zw=
|
github.com/aws/aws-sdk-go v1.21.8 h1:Lv6hW2twBhC6mGZAuWtqplEpIIqtVctJg02sE7Qn0Zw=
|
||||||
github.com/aws/aws-sdk-go v1.21.8/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpiN924inxo=
|
github.com/aws/aws-sdk-go v1.21.8/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpiN924inxo=
|
||||||
|
github.com/beevik/etree v1.1.0 h1:T0xke/WvNtMoCqgzPhkX2r4rjY3GDZFi+FjpRZY2Jbs=
|
||||||
|
github.com/beevik/etree v1.1.0/go.mod h1:r8Aw8JqVegEf0w2fDnATrX9VpkMcyFeM0FhwO62wh+A=
|
||||||
github.com/bobesa/go-domain-util v0.0.0-20180815122459-1d708c097a6a/go.mod h1:/mf0HzRK9xVv+1puqGSMzCo7bhEcQhiisuUXlMkq2p4=
|
github.com/bobesa/go-domain-util v0.0.0-20180815122459-1d708c097a6a/go.mod h1:/mf0HzRK9xVv+1puqGSMzCo7bhEcQhiisuUXlMkq2p4=
|
||||||
|
github.com/clbanning/mxj v1.8.3/go.mod h1:BVjHeAH+rl9rs6f+QIpeRl0tfu10SXn1pUSa5PVGJng=
|
||||||
github.com/creack/pty v1.1.7/go.mod h1:lj5s0c3V2DBrqTV7llrYr5NG6My20zk30Fl46Y7DoTY=
|
github.com/creack/pty v1.1.7/go.mod h1:lj5s0c3V2DBrqTV7llrYr5NG6My20zk30Fl46Y7DoTY=
|
||||||
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
|
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
|
||||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
@ -24,6 +27,7 @@ github.com/dustin/go-humanize v1.0.0 h1:VSnTsYCnlFHaM2/igO1h6X3HA71jcobQuxemgkq4
|
|||||||
github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk=
|
github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk=
|
||||||
github.com/fatih/camelcase v1.0.0 h1:hxNvNX/xYBp0ovncs8WyWZrOrpBNub/JfaMvbURyft8=
|
github.com/fatih/camelcase v1.0.0 h1:hxNvNX/xYBp0ovncs8WyWZrOrpBNub/JfaMvbURyft8=
|
||||||
github.com/fatih/camelcase v1.0.0/go.mod h1:yN2Sb0lFhZJUdVvtELVWefmrXpuZESvPmqwoZc+/fpc=
|
github.com/fatih/camelcase v1.0.0/go.mod h1:yN2Sb0lFhZJUdVvtELVWefmrXpuZESvPmqwoZc+/fpc=
|
||||||
|
github.com/fatih/structs v1.1.0/go.mod h1:9NiDSp5zOcgEDl+j00MP/WkGVPOlPRLejGD8Ga6PJ7M=
|
||||||
github.com/fatih/structtag v1.0.0 h1:pTHj65+u3RKWYPSGaU290FpI/dXxTaHdVwVwbcPKmEc=
|
github.com/fatih/structtag v1.0.0 h1:pTHj65+u3RKWYPSGaU290FpI/dXxTaHdVwVwbcPKmEc=
|
||||||
github.com/fatih/structtag v1.0.0/go.mod h1:IKitwq45uXL/yqi5mYghiD3w9H6eTOvI9vnk8tXMphA=
|
github.com/fatih/structtag v1.0.0/go.mod h1:IKitwq45uXL/yqi5mYghiD3w9H6eTOvI9vnk8tXMphA=
|
||||||
github.com/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV9I=
|
github.com/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV9I=
|
||||||
@ -83,6 +87,8 @@ github.com/huandu/go-sqlbuilder v1.4.1 h1:DYGFGLbOUXhtQ2kwO1uyDIPJbsztmVWdPPDyxi
|
|||||||
github.com/huandu/go-sqlbuilder v1.4.1/go.mod h1:mYfGcZTUS6yJsahUQ3imkYSkGGT3A+owd54+79kkW+U=
|
github.com/huandu/go-sqlbuilder v1.4.1/go.mod h1:mYfGcZTUS6yJsahUQ3imkYSkGGT3A+owd54+79kkW+U=
|
||||||
github.com/iancoleman/strcase v0.0.0-20190422225806-e506e3ef7365 h1:ECW73yc9MY7935nNYXUkK7Dz17YuSUI9yqRqYS8aBww=
|
github.com/iancoleman/strcase v0.0.0-20190422225806-e506e3ef7365 h1:ECW73yc9MY7935nNYXUkK7Dz17YuSUI9yqRqYS8aBww=
|
||||||
github.com/iancoleman/strcase v0.0.0-20190422225806-e506e3ef7365/go.mod h1:SK73tn/9oHe+/Y0h39VT4UCxmurVJkR5NA7kMEAOgSE=
|
github.com/iancoleman/strcase v0.0.0-20190422225806-e506e3ef7365/go.mod h1:SK73tn/9oHe+/Y0h39VT4UCxmurVJkR5NA7kMEAOgSE=
|
||||||
|
github.com/ikeikeikeike/go-sitemap-generator/v2 v2.0.2 h1:wIdDEle9HEy7vBPjC6oKz6ejs3Ut+jmsYvuOoAW2pSM=
|
||||||
|
github.com/ikeikeikeike/go-sitemap-generator/v2 v2.0.2/go.mod h1:WtaVKD9TeruTED9ydiaOJU08qGoEPP/LyzTKiD3jEsw=
|
||||||
github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af h1:pmfjZENx5imkbgOkpRUYLnmbU7UEFbjtDA2hxJ1ichM=
|
github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af h1:pmfjZENx5imkbgOkpRUYLnmbU7UEFbjtDA2hxJ1ichM=
|
||||||
github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k=
|
github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k=
|
||||||
github.com/jmoiron/sqlx v1.2.0 h1:41Ip0zITnmWNR/vHV+S4m+VoUivnWY5E4OJfLZjCJMA=
|
github.com/jmoiron/sqlx v1.2.0 h1:41Ip0zITnmWNR/vHV+S4m+VoUivnWY5E4OJfLZjCJMA=
|
||||||
|
@ -234,9 +234,9 @@ func ServiceBuild(log *log.Logger, req *serviceBuildRequest) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
buildStageName = strings.TrimSpace(strings.Split(lineLower, " as ")[1])
|
buildStageName = strings.TrimSpace(strings.Split(lineLower, " as ")[1])
|
||||||
stageLines = append(stageLines, line )
|
stageLines = append(stageLines, line)
|
||||||
} else if buildStageName != "" {
|
} else if buildStageName != "" {
|
||||||
stageLines = append(stageLines, line )
|
stageLines = append(stageLines, line)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -288,7 +288,7 @@ func ServiceBuild(log *log.Logger, req *serviceBuildRequest) error {
|
|||||||
buildBaseImage = os.Getenv("CI_REGISTRY_IMAGE") + ":" + buildBaseImageTag
|
buildBaseImage = os.Getenv("CI_REGISTRY_IMAGE") + ":" + buildBaseImageTag
|
||||||
pushTargetImg = true
|
pushTargetImg = true
|
||||||
} else {
|
} else {
|
||||||
buildBaseImage = req.ProjectName + ":" + req.Env + "-" +req.ServiceName + "-" + buildBaseImageTag
|
buildBaseImage = req.ProjectName + ":" + req.Env + "-" + req.ServiceName + "-" + buildBaseImageTag
|
||||||
}
|
}
|
||||||
|
|
||||||
cmds = append(cmds, []string{"docker", "pull", buildBaseImageTag})
|
cmds = append(cmds, []string{"docker", "pull", buildBaseImageTag})
|
||||||
@ -341,7 +341,7 @@ func ServiceBuild(log *log.Logger, req *serviceBuildRequest) error {
|
|||||||
err = execCmds(log, req.ProjectRoot, cmd)
|
err = execCmds(log, req.ProjectRoot, cmd)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if len(cmd) > 2 && cmd[1] == "pull" {
|
if len(cmd) > 2 && cmd[1] == "pull" {
|
||||||
log.Printf("\t\t\tSkipping pull - %s\n", err.Error())
|
log.Printf("\t\t\tSkipping pull - %s\n", err.Error())
|
||||||
} else {
|
} else {
|
||||||
return errors.Wrapf(err, "Failed to exec %s", strings.Join(cmd, " "))
|
return errors.Wrapf(err, "Failed to exec %s", strings.Join(cmd, " "))
|
||||||
}
|
}
|
||||||
|
@ -2552,8 +2552,6 @@ func ServiceDeploy(log *log.Logger, req *serviceDeployRequest) error {
|
|||||||
pks = append(pks, k)
|
pks = append(pks, k)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Read the defined json task definition.
|
// Read the defined json task definition.
|
||||||
dat, err := EcsReadTaskDefinition(req.ServiceDir, req.Env)
|
dat, err := EcsReadTaskDefinition(req.ServiceDir, req.Env)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -2602,13 +2600,13 @@ func ServiceDeploy(log *log.Logger, req *serviceDeployRequest) error {
|
|||||||
|
|
||||||
replaced := make(map[string]bool)
|
replaced := make(map[string]bool)
|
||||||
for _, m := range matches {
|
for _, m := range matches {
|
||||||
m = strings.Trim(m, "{}")
|
|
||||||
if replaced[m] {
|
if replaced[m] {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
replaced[m] = true
|
replaced[m] = true
|
||||||
|
|
||||||
newVal := os.Getenv(m)
|
envKey := strings.Trim(m, "{}")
|
||||||
|
newVal := os.Getenv(envKey)
|
||||||
log.Printf("\t\t\t%s -> %s", m, newVal)
|
log.Printf("\t\t\t%s -> %s", m, newVal)
|
||||||
jsonStr = strings.Replace(jsonStr, m, newVal, -1)
|
jsonStr = strings.Replace(jsonStr, m, newVal, -1)
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user