Compare commits

..

3 Commits

Author SHA1 Message Date
mainnika 59feb0c835 Enable multiplatform container build 2023-01-11 15:43:44 +01:00
mainnika c2b58f21c8 Move templates to an internal package 2022-02-09 15:22:14 +01:00
mainnika 992059d17b Merge branch 'main' into develop 2022-02-02 23:16:52 +01:00
21 changed files with 59 additions and 26 deletions
+1
View File
@@ -2,6 +2,7 @@
!cmd
!nginx
!pkg
!templates
!web
!go.mod
!go.sum
+19 -10
View File
@@ -22,22 +22,26 @@ jobs:
steps:
- name: Checkout repository
uses: actions/checkout@v4
uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v5
uses: actions/setup-python@v2
with:
python-version: '3.12'
python-version: '3.8'
- name: Install cosign
if: github.event_name != 'pull_request'
uses: sigstore/cosign-installer@main
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
uses: docker/setup-qemu-action@v2
- name: Setup Docker buildx
uses: docker/setup-buildx-action@v3
uses: docker/setup-buildx-action@v2
- name: Log into registry ${{ env.REGISTRY }}
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
uses: docker/login-action@v1
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
@@ -70,19 +74,24 @@ jobs:
- name: Build and push Docker image
id: build-and-push
uses: docker/build-push-action@v6
uses: docker/build-push-action@v2
with:
platforms: linux/amd64,linux/arm64
context: .
build-args: |
APP_VERSION=${{ steps.calver.outputs.current }}
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
platforms: linux/amd64,linux/arm64
- name: Sign the published Docker image
if: ${{ github.event_name != 'pull_request' && !github.event.repository.private }}
env:
COSIGN_EXPERIMENTAL: "true"
run: cosign sign ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}@${{ steps.build-and-push.outputs.digest }}
- name: Trigger release job
if: false
# if: ${{ success() && github.ref_name == 'main' && github.event_name != 'pull_request' && !github.event.repository.private }}
if: ${{ success() && github.ref_name == 'main' && github.event_name != 'pull_request' && !github.event.repository.private }}
uses: toptal/jenkins-job-trigger-action@master
with:
jenkins_url: ${{ secrets.JENKINS_URL }}
+3 -5
View File
@@ -1,10 +1,10 @@
def HELM_DOWNLOAD_URL = "https://get.helm.sh/helm-v3.14.0-linux-amd64.tar.gz"
def HELM_DOWNLOAD_URL = "https://get.helm.sh/helm-v3.7.2-linux-amd64.tar.gz"
def WS_DIST = ".dist"
def WS_BIN = ".bin"
def WS_SCM = ".scm"
pipeline {
agent { label "kube0" }
agent { label "k8s" }
parameters {
string(
@@ -40,8 +40,7 @@ pipeline {
dir("${WS_DIST}") {
sh """
curl -fsSL -O "${HELM_DOWNLOAD_URL}";
mkdir -p "${env.WORKSPACE}/${WS_BIN}";
tar xfz * -C "${env.WORKSPACE}/${WS_BIN}";
tar xfz -C "${env.WORKSPACE}/${WS_BIN}" *;
ls -lah "${env.WORKSPACE}/${WS_BIN}/linux-amd64/helm";
"""
deleteDir()
@@ -74,7 +73,6 @@ pipeline {
sh """
"${env.WORKSPACE}/${WS_BIN}/linux-amd64/helm" upgrade ${params.RELEASE_NAME} * \
--namespace ${params.RELEASE_NAMESPACE} \
--install \
--create-namespace \
--dependency-update \
--reset-values \
+3
View File
@@ -9,6 +9,8 @@ RUN dnf install -yq golang
COPY go.mod .
COPY go.sum .
COPY templates/go.mod templates/go.mod
COPY templates/go.sum templates/go.sum
RUN --mount=type=cache,id=gopath,target=${GOPATH} \
go mod \
@@ -18,6 +20,7 @@ ARG APP_VERSION=containerized
COPY cmd cmd
COPY pkg pkg
COPY templates templates
RUN --mount=type=cache,id=gopath,target=${GOPATH} \
go build \
+3 -2
View File
@@ -9,10 +9,11 @@ import (
"github.com/spf13/viper"
"github.com/valyala/fasthttp"
"code.tokarch.uk/mainnika/nikita-tokarch-uk/templates"
"code.tokarch.uk/mainnika/nikita-tokarch-uk/pkg/config"
"code.tokarch.uk/mainnika/nikita-tokarch-uk/pkg/ghost/v4api/httpclient"
"code.tokarch.uk/mainnika/nikita-tokarch-uk/pkg/routes"
"code.tokarch.uk/mainnika/nikita-tokarch-uk/pkg/templates"
)
var Version = "nightly"
@@ -52,7 +53,7 @@ func main() {
logrus.Fatal(err)
}
templateFuncs := &templates.Funcs{Version: Version, Site: config.Site}
templateFuncs := &templates.Funcs{Version: Version, YandexKey: config.Site.YandexKey}
err = templates.Load(templateFuncs)
if err != nil {
logrus.Fatal(err)
+3
View File
@@ -2,7 +2,10 @@ module code.tokarch.uk/mainnika/nikita-tokarch-uk
go 1.17
replace code.tokarch.uk/mainnika/nikita-tokarch-uk/templates => ./templates
require (
code.tokarch.uk/mainnika/nikita-tokarch-uk/templates v0.0.0-00010101000000-000000000000
github.com/jackwhelpton/fasthttp-routing/v2 v2.0.0
github.com/mailru/easyjson v0.7.7
github.com/sirupsen/logrus v1.8.1
+2 -1
View File
@@ -6,9 +6,10 @@ import (
routing "github.com/jackwhelpton/fasthttp-routing/v2"
"github.com/valyala/fasthttp"
"code.tokarch.uk/mainnika/nikita-tokarch-uk/templates"
"code.tokarch.uk/mainnika/nikita-tokarch-uk/pkg/content"
"code.tokarch.uk/mainnika/nikita-tokarch-uk/pkg/ghost/params"
"code.tokarch.uk/mainnika/nikita-tokarch-uk/pkg/templates"
)
// relativeRedirectBytes makes a relative redirect by using http Location header
+1 -1
View File
@@ -6,7 +6,7 @@ import (
routing "github.com/jackwhelpton/fasthttp-routing/v2"
"github.com/valyala/fasthttp"
"code.tokarch.uk/mainnika/nikita-tokarch-uk/pkg/templates"
"code.tokarch.uk/mainnika/nikita-tokarch-uk/templates"
)
var _ routing.DataWriter = (*TemplateWriter)(nil)
+2 -1
View File
@@ -6,9 +6,10 @@ import (
routing "github.com/jackwhelpton/fasthttp-routing/v2"
"github.com/valyala/fasthttp"
"code.tokarch.uk/mainnika/nikita-tokarch-uk/templates"
"code.tokarch.uk/mainnika/nikita-tokarch-uk/pkg/config"
"code.tokarch.uk/mainnika/nikita-tokarch-uk/pkg/ghost"
"code.tokarch.uk/mainnika/nikita-tokarch-uk/pkg/templates"
)
// Routes is the main handler that contains all routes handlers
@@ -4,13 +4,12 @@ import (
"html/template"
"net/url"
"sync"
"code.tokarch.uk/mainnika/nikita-tokarch-uk/pkg/config"
)
type Funcs struct {
Version string
Site config.Site
YandexKey string
compiledJSAppURL string
@@ -58,7 +57,7 @@ func (f *Funcs) getBlogURL() string {
}
func (f *Funcs) getYaKey() string {
return f.Site.YandexKey
return f.YandexKey
}
// Use returns a func map with template helpers functions
+7
View File
@@ -0,0 +1,7 @@
module code.tokarch.uk/mainnika/nikita-tokarch-uk/templates
go 1.17
require github.com/sirupsen/logrus v1.8.1
require golang.org/x/sys v0.0.0-20191026070338-33540a1f6037 // indirect
+10
View File
@@ -0,0 +1,10 @@
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/sirupsen/logrus v1.8.1 h1:dJKuHgqk1NNQlqoA6BTlM1Wf9DOH3NBjQyu0h9+AZZE=
github.com/sirupsen/logrus v1.8.1/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0=
github.com/stretchr/testify v1.2.2 h1:bSDNvY7ZPG5RlJ8otE/7V6gMiyenm9RtJ7IUVIAoJ1w=
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
golang.org/x/sys v0.0.0-20191026070338-33540a1f6037 h1:YyJpGZS1sBuBCzLAR1VEpK193GlqGZbnPFnPV/5Rsb4=
golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
@@ -21,10 +21,10 @@ import (
//go:embed analytics.go.tmpl
var content embed.FS
// List of compiled go-templates
// Templates is a container of compiled templates
var Templates *template.Template = template.New("")
// Load embeded templates
// Load embedded templates
func Load(funcs *Funcs) (err error) {
Templates.Funcs(funcs.Use())