diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e428cf1..f41c5e7 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,39 +1,22 @@ name: CI -permissions: - contents: read - pull-requests: read - on: + workflow_dispatch: {} + pull_request: {} + release: + types: [published] push: - branches: [master] - pull_request: - branches: [master] + branches: + - master + - develop + - release/* + - feature/* + - hotfix/* jobs: - test: - runs-on: default - steps: - - uses: actions/checkout@v2 - - - name: Set up Go - uses: actions/setup-go@v2 - with: - go-version: 1.19 - - - name: Test - run: go test -v ./... - - lint: - name: lint - runs-on: default - steps: - - name: Checkout Code - uses: actions/checkout@v2 - - - name: golangci-lint - uses: golangci/golangci-lint-action@v2 - with: - version: latest - github-token: ${{secrets.GITHUB_TOKEN}} - only-new-issues: true + golang: + uses: UNIwise/workflows/.github/workflows/golang.yaml@master + secrets: inherit + with: + go-version: 1.19 + golangci-lint-version: v1.61.0 \ No newline at end of file diff --git a/.github/workflows/documentation-lint.yaml b/.github/workflows/documentation-lint.yaml new file mode 100644 index 0000000..9ee3f64 --- /dev/null +++ b/.github/workflows/documentation-lint.yaml @@ -0,0 +1,14 @@ +name: Docs + +on: + workflow_dispatch: {} + pull_request: + paths: + - "wiki/**" + +jobs: + markdown: + uses: UNIwise/workflows/.github/workflows/documentation.yaml@master + secrets: inherit + with: + sync: false # We don't want to sync documentation on pull requests diff --git a/.github/workflows/documentation-sync.yaml b/.github/workflows/documentation-sync.yaml new file mode 100644 index 0000000..54ae59b --- /dev/null +++ b/.github/workflows/documentation-sync.yaml @@ -0,0 +1,14 @@ +name: Docs + +on: + workflow_dispatch: {} + push: + branches: + - master + paths: + - "wiki/**" + +jobs: + markdown: + uses: UNIwise/workflows/.github/workflows/documentation.yaml@master + secrets: inherit diff --git a/.ship-it b/.ship-it deleted file mode 100644 index a44af5d..0000000 --- a/.ship-it +++ /dev/null @@ -1 +0,0 @@ -targetBranch: master diff --git a/Jenkinsfile b/Jenkinsfile deleted file mode 100644 index 0d12033..0000000 --- a/Jenkinsfile +++ /dev/null @@ -1,39 +0,0 @@ -#!groovy -@Library('utils') -import jenkinslib.Utilities -import jenkinslib.PodBuilder -def utils = new Utilities(this, false) -def podbuilder = new PodBuilder(this, false) - -properties([ - parameters([ - string(name: 'docker tags', defaultValue: utils.tagsFromBranch(env.BRANCH_NAME).join(","), description: "Tag the docker image with these tags. (separated by commas)") - ]) -]) - -podbuilder.Golang(){ - def tags = params["docker tags"].tokenize(",") - stage('Checkout'){ - tags.push((checkout(scm)).GIT_COMMIT.substring(0,7)) - } - - container('golang'){ - stage('Test'){ - sh "go test ./..." - } - } - - container('dind'){ - stage('Build'){ - withCredentials([usernamePassword(credentialsId: "jenkins-harbor-registry", usernameVariable: 'USERNAME', passwordVariable: 'PASSWORD')]){ - sh "docker login --username='$USERNAME' --password='$PASSWORD' docker.wiseflow.io" - } - sh "docker build . -t " + utils.dockertags(tags).join(" -t ") - } - stage('Push'){ - utils.dockertags(tags).each { - tag -> sh "docker push $tag" - } - } - } -} \ No newline at end of file diff --git a/README.md b/README.md index 2c081ea..e4e7fe7 100644 --- a/README.md +++ b/README.md @@ -1,14 +1,19 @@ +# Parrot -
-
-
Parrot the POEditor pull-through cache
-
+
+
+
@@ -19,15 +24,15 @@
This cache makes it possible to pull app translations directly from [POEditor](http://poeditor.com/) instead of compiling them into your app. This means no more re-builds every time translations are updated!
-# Features
+## Features
-- **Battle tested**: The software is in active use on the WISEflow platform with high request rates daily.
-- **All the formats**: Parrot can provide all formats supported by POEditor.
-- **Cache choices**: Parrot comes with a Filesystem and Redis cache to facilitate single app deployments and highly distributed deployments.
-- **OpenAPI**: The Parrot API has been documented in OpenAPI specification which can be found in the [doc/](/docs) directory.
-- **Easy deployment**: A docker image and helm chart is provided.
+- **Battle tested**: The software is in active use on the WISEflow platform with high request rates daily.
+- **All the formats**: Parrot can provide all formats supported by POEditor.
+- **Cache choices**: Parrot comes with a Filesystem and Redis cache to facilitate single app deployments and highly distributed deployments.
+- **OpenAPI**: The Parrot API has been documented in OpenAPI specification which can be found in the [doc/](/docs) directory.
+- **Easy deployment**: A docker image and helm chart is provided.
-# Configuration
+## Configuration
The server can be configured with a yaml configuration file specified with the `--config` option. Every configuration can be overridden with an environment variable, where dots are replaced by underscores, such that `API_TOKEN=xxx` will set the `api.token` value
@@ -55,11 +60,11 @@ The server can be configured with a yaml configuration file specified with the `
| prometheus.port | port to expose the prometheus metrics under | int | `9090` |
| api.token | secret token to authenticating against poeditor | string |
-# API specification
+## API specification
The REST API of Parrot is documented in the OpenAPI format. The specification file can be found here [docs/api.yml](docs/api.yml) and a Swagger UI is available here [uniwise.github.io/parrot](https://uniwise.github.io/parrot).
-# License
+## License
Parrot is available under the Apache 2 license.
diff --git a/chart/parrot/.helmignore b/chart/parrot/.helmignore
deleted file mode 100644
index 0e8a0eb..0000000
--- a/chart/parrot/.helmignore
+++ /dev/null
@@ -1,23 +0,0 @@
-# Patterns to ignore when building packages.
-# This supports shell glob matching, relative path matching, and
-# negation (prefixed with !). Only one pattern per line.
-.DS_Store
-# Common VCS dirs
-.git/
-.gitignore
-.bzr/
-.bzrignore
-.hg/
-.hgignore
-.svn/
-# Common backup files
-*.swp
-*.bak
-*.tmp
-*.orig
-*~
-# Various IDEs
-.project
-.idea/
-*.tmproj
-.vscode/
diff --git a/chart/parrot/Chart.yaml b/chart/parrot/Chart.yaml
deleted file mode 100644
index 13f5437..0000000
--- a/chart/parrot/Chart.yaml
+++ /dev/null
@@ -1,15 +0,0 @@
-apiVersion: v1
-name: parrot
-description: A Helm chart for Kubernetes
-
-# This is the chart version. This version number should be incremented each time you make changes
-# to the chart and its templates, including the app version.
-# Versions are expected to follow Semantic Versioning (https://semver.org/)
-version: 0.1.2
-
-# This is the version number of the application being deployed. This version number should be
-# incremented each time you make changes to the application. Versions are not expected to
-# follow Semantic Versioning. They should reflect the version the application is using.
-appVersion: 0.2.0
-
-icon: https://github.com/UNIwise/parrot/raw/master/assets/parrot.svg
diff --git a/chart/parrot/templates/NOTES.txt b/chart/parrot/templates/NOTES.txt
deleted file mode 100644
index 9bf4c3b..0000000
--- a/chart/parrot/templates/NOTES.txt
+++ /dev/null
@@ -1,21 +0,0 @@
-1. Get the application URL by running these commands:
-{{- if .Values.ingress.enabled }}
-{{- range $host := .Values.ingress.hosts }}
- {{- range .paths }}
- http{{ if $.Values.ingress.tls }}s{{ end }}://{{ $host.host }}{{ . }}
- {{- end }}
-{{- end }}
-{{- else if contains "NodePort" .Values.service.type }}
- export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "parrot.fullname" . }})
- export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}")
- echo http://$NODE_IP:$NODE_PORT
-{{- else if contains "LoadBalancer" .Values.service.type }}
- NOTE: It may take a few minutes for the LoadBalancer IP to be available.
- You can watch the status of by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "parrot.fullname" . }}'
- export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "parrot.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}")
- echo http://$SERVICE_IP:{{ .Values.service.port }}
-{{- else if contains "ClusterIP" .Values.service.type }}
- export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "parrot.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}")
- echo "Visit http://127.0.0.1:8080 to use your application"
- kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 8080:80
-{{- end }}
diff --git a/chart/parrot/templates/_helpers.tpl b/chart/parrot/templates/_helpers.tpl
deleted file mode 100644
index f685410..0000000
--- a/chart/parrot/templates/_helpers.tpl
+++ /dev/null
@@ -1,62 +0,0 @@
-{{/*
-Expand the name of the chart.
-*/}}
-{{- define "parrot.name" -}}
-{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
-{{- end }}
-
-{{/*
-Create a default fully qualified app name.
-We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
-If release name contains chart name it will be used as a full name.
-*/}}
-{{- define "parrot.fullname" -}}
-{{- if .Values.fullnameOverride }}
-{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
-{{- else }}
-{{- $name := default .Chart.Name .Values.nameOverride }}
-{{- if contains $name .Release.Name }}
-{{- .Release.Name | trunc 63 | trimSuffix "-" }}
-{{- else }}
-{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
-{{- end }}
-{{- end }}
-{{- end }}
-
-{{/*
-Create chart name and version as used by the chart label.
-*/}}
-{{- define "parrot.chart" -}}
-{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
-{{- end }}
-
-{{/*
-Common labels
-*/}}
-{{- define "parrot.labels" -}}
-helm.sh/chart: {{ include "parrot.chart" . }}
-{{ include "parrot.selectorLabels" . }}
-{{- if .Chart.AppVersion }}
-app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
-{{- end }}
-app.kubernetes.io/managed-by: {{ .Release.Service }}
-{{- end }}
-
-{{/*
-Selector labels
-*/}}
-{{- define "parrot.selectorLabels" -}}
-app.kubernetes.io/name: {{ include "parrot.name" . }}
-app.kubernetes.io/instance: {{ .Release.Name }}
-{{- end }}
-
-{{/*
-Create the name of the service account to use
-*/}}
-{{- define "parrot.serviceAccountName" -}}
-{{- if .Values.serviceAccount.create }}
-{{- default (include "parrot.fullname" .) .Values.serviceAccount.name }}
-{{- else }}
-{{- default "default" .Values.serviceAccount.name }}
-{{- end }}
-{{- end }}
diff --git a/chart/parrot/templates/deployment.yaml b/chart/parrot/templates/deployment.yaml
deleted file mode 100644
index bc58014..0000000
--- a/chart/parrot/templates/deployment.yaml
+++ /dev/null
@@ -1,77 +0,0 @@
-apiVersion: apps/v1
-kind: Deployment
-metadata:
- name: {{ include "parrot.fullname" . }}
- labels:
- {{- include "parrot.labels" . | nindent 4 }}
-spec:
-{{- if not .Values.autoscaling.enabled }}
- replicas: {{ .Values.replicaCount }}
-{{- end }}
- selector:
- matchLabels:
- {{- include "parrot.selectorLabels" . | nindent 6 }}
- template:
- metadata:
- annotations:
- checksum/config: {{ toJson .Values.config | sha256sum }}
- {{- with .Values.podAnnotations }}
- {{- toYaml . | nindent 8 }}
- {{- end }}
- labels:
- {{- include "parrot.selectorLabels" . | nindent 8 }}
- spec:
- volumes:
- - name: config
- secret:
- secretName: {{ include "parrot.fullname" . }}
- {{- with .Values.imagePullSecrets }}
- imagePullSecrets:
- {{- toYaml . | nindent 8 }}
- {{- end }}
- serviceAccountName: {{ include "parrot.serviceAccountName" . }}
- securityContext:
- {{- toYaml .Values.podSecurityContext | nindent 8 }}
- containers:
- - name: {{ .Chart.Name }}
- securityContext:
- {{- toYaml .Values.securityContext | nindent 12 }}
- image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
- imagePullPolicy: {{ .Values.image.pullPolicy }}
- args:
- - --config=/config/config.yaml
- volumeMounts:
- - name: config
- mountPath: /config/config.yaml
- subPath: config.yaml
- ports:
- - name: http
- containerPort: {{ default 80 .Values.config.server.port }}
- protocol: TCP
- {{- if .Values.config.prometheus.enabled }}
- - name: prometheus
- containerPort: {{ default 9090 .Values.config.prometheus.port }}
- protocol: TCP
- {{- end }}
- livenessProbe:
- httpGet:
- path: /health
- port: http
- readinessProbe:
- httpGet:
- path: /health
- port: http
- resources:
- {{- toYaml .Values.resources | nindent 12 }}
- {{- with .Values.nodeSelector }}
- nodeSelector:
- {{- toYaml . | nindent 8 }}
- {{- end }}
- {{- with .Values.affinity }}
- affinity:
- {{- toYaml . | nindent 8 }}
- {{- end }}
- {{- with .Values.tolerations }}
- tolerations:
- {{- toYaml . | nindent 8 }}
- {{- end }}
diff --git a/chart/parrot/templates/hpa.yaml b/chart/parrot/templates/hpa.yaml
deleted file mode 100644
index 1df58a0..0000000
--- a/chart/parrot/templates/hpa.yaml
+++ /dev/null
@@ -1,28 +0,0 @@
-{{- if .Values.autoscaling.enabled }}
-apiVersion: autoscaling/v2beta1
-kind: HorizontalPodAutoscaler
-metadata:
- name: {{ include "parrot.fullname" . }}
- labels:
- {{- include "parrot.labels" . | nindent 4 }}
-spec:
- scaleTargetRef:
- apiVersion: apps/v1
- kind: Deployment
- name: {{ include "parrot.fullname" . }}
- minReplicas: {{ .Values.autoscaling.minReplicas }}
- maxReplicas: {{ .Values.autoscaling.maxReplicas }}
- metrics:
- {{- if .Values.autoscaling.targetCPUUtilizationPercentage }}
- - type: Resource
- resource:
- name: cpu
- targetAverageUtilization: {{ .Values.autoscaling.targetCPUUtilizationPercentage }}
- {{- end }}
- {{- if .Values.autoscaling.targetMemoryUtilizationPercentage }}
- - type: Resource
- resource:
- name: memory
- targetAverageUtilization: {{ .Values.autoscaling.targetMemoryUtilizationPercentage }}
- {{- end }}
-{{- end }}
diff --git a/chart/parrot/templates/ingress.yaml b/chart/parrot/templates/ingress.yaml
deleted file mode 100644
index 775be0c..0000000
--- a/chart/parrot/templates/ingress.yaml
+++ /dev/null
@@ -1,55 +0,0 @@
-{{- if .Values.ingress.enabled -}}
-{{- $fullName := include "parrot.fullname" . -}}
-{{- $svcPort := .Values.service.port -}}
-{{- if semverCompare ">=1.22-0" .Capabilities.KubeVersion.GitVersion -}}
-apiVersion: networking.k8s.io/v1
-{{- else if semverCompare ">=1.14-0" .Capabilities.KubeVersion.GitVersion -}}
-apiVersion: networking.k8s.io/v1beta1
-{{- else -}}
-apiVersion: extensions/v1beta1
-{{- end }}
-kind: Ingress
-metadata:
- name: {{ $fullName }}
- labels:
- {{- include "parrot.labels" . | nindent 4 }}
- {{- with .Values.ingress.annotations }}
- annotations:
- {{- toYaml . | nindent 4 }}
- {{- end }}
-spec:
-{{- if semverCompare ">=1.22-0" .Capabilities.KubeVersion.GitVersion }}
- ingressClassName: {{ .Values.ingress.ingressClassName }}
-{{- end }}
- {{- if .Values.ingress.tls }}
- tls:
- {{- range .Values.ingress.tls }}
- - hosts:
- {{- range .hosts }}
- - {{ . | quote }}
- {{- end }}
- secretName: {{ .secretName }}
- {{- end }}
- {{- end }}
- rules:
- {{- range .Values.ingress.hosts }}
- - host: {{ .host | quote }}
- http:
- paths:
- {{- range .paths }}
- - path: {{ . }}
- {{- if semverCompare ">=1.22-0" $.Capabilities.KubeVersion.GitVersion }}
- pathType: ImplementationSpecific
- backend:
- service:
- name: {{ $fullName }}
- port:
- number: {{ $svcPort }}
- {{- else }}
- backend:
- serviceName: {{ $fullName }}
- servicePort: {{ $svcPort }}
- {{- end }}
- {{- end }}
- {{- end }}
- {{- end }}
diff --git a/chart/parrot/templates/secret.yaml b/chart/parrot/templates/secret.yaml
deleted file mode 100644
index 955236b..0000000
--- a/chart/parrot/templates/secret.yaml
+++ /dev/null
@@ -1,10 +0,0 @@
-apiVersion: v1
-kind: Secret
-metadata:
- name: {{ include "parrot.fullname" . }}
- labels:
- {{- include "parrot.labels" . | nindent 4 }}
-type: Opaque
-data:
- config.yaml: {{ toYaml .Values.config | b64enc }}
-
\ No newline at end of file
diff --git a/chart/parrot/templates/service.yaml b/chart/parrot/templates/service.yaml
deleted file mode 100644
index 78c96da..0000000
--- a/chart/parrot/templates/service.yaml
+++ /dev/null
@@ -1,15 +0,0 @@
-apiVersion: v1
-kind: Service
-metadata:
- name: {{ include "parrot.fullname" . }}
- labels:
- {{- include "parrot.labels" . | nindent 4 }}
-spec:
- type: {{ .Values.service.type }}
- ports:
- - port: {{ .Values.service.port }}
- targetPort: http
- protocol: TCP
- name: http
- selector:
- {{- include "parrot.selectorLabels" . | nindent 4 }}
diff --git a/chart/parrot/templates/serviceaccount.yaml b/chart/parrot/templates/serviceaccount.yaml
deleted file mode 100644
index 9bd16c7..0000000
--- a/chart/parrot/templates/serviceaccount.yaml
+++ /dev/null
@@ -1,12 +0,0 @@
-{{- if .Values.serviceAccount.create -}}
-apiVersion: v1
-kind: ServiceAccount
-metadata:
- name: {{ include "parrot.serviceAccountName" . }}
- labels:
- {{- include "parrot.labels" . | nindent 4 }}
- {{- with .Values.serviceAccount.annotations }}
- annotations:
- {{- toYaml . | nindent 4 }}
- {{- end }}
-{{- end }}
diff --git a/chart/parrot/templates/tests/test-connection.yaml b/chart/parrot/templates/tests/test-connection.yaml
deleted file mode 100644
index 34f36f3..0000000
--- a/chart/parrot/templates/tests/test-connection.yaml
+++ /dev/null
@@ -1,15 +0,0 @@
-apiVersion: v1
-kind: Pod
-metadata:
- name: "{{ include "parrot.fullname" . }}-test-connection"
- labels:
- {{- include "parrot.labels" . | nindent 4 }}
- annotations:
- "helm.sh/hook": test-success
-spec:
- containers:
- - name: wget
- image: busybox
- command: ['wget']
- args: ['{{ include "parrot.fullname" . }}:{{ .Values.service.port }}']
- restartPolicy: Never
diff --git a/chart/parrot/values.yaml b/chart/parrot/values.yaml
deleted file mode 100644
index aac47b3..0000000
--- a/chart/parrot/values.yaml
+++ /dev/null
@@ -1,110 +0,0 @@
-# Default values for parrot.
-# This is a YAML-formatted file.
-# Declare variables to be passed into your templates.
-
-replicaCount: 1
-
-image:
- repository: docker.wiseflow.io/k8s/parrot
- pullPolicy: IfNotPresent
- # Overrides the image tag whose default is the chart appVersion.
- tag: ""
-
-imagePullSecrets: []
-nameOverride: ""
-fullnameOverride: ""
-
-serviceAccount:
- # Specifies whether a service account should be created
- create: true
- # Annotations to add to the service account
- annotations: {}
- # The name of the service account to use.
- # If not set and create is true, a name is generated using the fullname template
- name: ""
-
-podAnnotations: {}
-
-podSecurityContext: {}
- # fsGroup: 2000
-
-securityContext: {}
- # capabilities:
- # drop:
- # - ALL
- # readOnlyRootFilesystem: true
- # runAsNonRoot: true
- # runAsUser: 1000
-
-service:
- type: ClusterIP
- port: 80
-
-ingress:
- enabled: false
- annotations: {}
- # kubernetes.io/ingress.class: nginx
- # kubernetes.io/tls-acme: "true"
- hosts: []
- # - host: chart-example.local
- # paths: []
- tls: []
- # - secretName: chart-example-tls
- # hosts:
- # - chart-example.local
-
-resources: {}
- # We usually recommend not to specify default resources and to leave this as a conscious
- # choice for the user. This also increases chances charts run on environments with little
- # resources, such as Minikube. If you do want to specify resources, uncomment the following
- # lines, adjust them as necessary, and remove the curly braces after 'resources:'.
- # limits:
- # cpu: 100m
- # memory: 128Mi
- # requests:
- # cpu: 100m
- # memory: 128Mi
-
-autoscaling:
- enabled: false
- minReplicas: 1
- maxReplicas: 100
- targetCPUUtilizationPercentage: 80
- # targetMemoryUtilizationPercentage: 80
-
-nodeSelector: {}
-
-tolerations: []
-
-affinity: {}
-
-config:
- server:
- port: 80
- gracePeriod: 10s
- log:
- level: info
- format: json
- cache:
- type: filesystem
- ttl: 1h
- renewalThreshold: 30m
- # filesystem:
- # dir:
- # redis:
- # mode:
- # address:
- # username:
- # password:
- # maxRetries:
- # db:
- # sentinel:
- # master:
- # addresses:
- # password:
- prometheus:
- enabled: true
- path: /metrics
- port: 9090
- api:
- token: REDACTED
diff --git a/jenkinsfile-helm b/jenkinsfile-helm
deleted file mode 100644
index 6226c06..0000000
--- a/jenkinsfile-helm
+++ /dev/null
@@ -1,9 +0,0 @@
-#!groovy
-@Library('utils')
-import jenkinslib.PodBuilder
-import jenkinslib.Utilities
-
-def podbuilder = new PodBuilder(this, false)
-def utils = new Utilities(this, false)
-
-utils.packagePipeline(podbuilder, "chart", "parrot")
diff --git a/jenkinsfile-helm-push b/jenkinsfile-helm-push
deleted file mode 100644
index 165a7f2..0000000
--- a/jenkinsfile-helm-push
+++ /dev/null
@@ -1,9 +0,0 @@
-#!groovy
-@Library('utils')
-import jenkinslib.PodBuilder
-import jenkinslib.Utilities
-
-def podbuilder = new PodBuilder(this, false)
-def utils = new Utilities(this, false)
-
-utils.pushPipeline(podbuilder, "chart", "parrot")