Skip to content

Commit

Permalink
fix(ci): add helm chart
Browse files Browse the repository at this point in the history
  • Loading branch information
tonygilkerson committed Dec 31, 2023
1 parent f127348 commit fb28c46
Show file tree
Hide file tree
Showing 8 changed files with 64 additions and 12 deletions.
4 changes: 2 additions & 2 deletions .releaserc
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@
[
"@semantic-release/exec",
{
"prepareCmd": "img=\"ghcr.io/tonygilkerson/serial-gateway:v${nextRelease.version}\" yq eval '.spec.template.spec.containers[0].image = strenv(img)' ./deploy/k8s/deployment.yaml --inplace"
"prepareCmd": "tag=\"v${nextRelease.version}\" yq eval '.image.tag = strenv(tag)' ./charts/serial-gateway/values.yaml --inplace"
}
],
[
"@semantic-release/git",
{
"assets": [ "./deploy/k8s/deployment.yaml"],
"assets": [ "./charts/serial-gateway/values.yaml" ],
"message": "chore(release): ${nextRelease.version} \n\n${nextRelease.notes}"
}
]
Expand Down
23 changes: 23 additions & 0 deletions charts/serial-gateway/.helmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# 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/
24 changes: 24 additions & 0 deletions charts/serial-gateway/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
apiVersion: v2
name: serial-gateway
description: A Helm chart for Kubernetes

# A chart can be either an 'application' or a 'library' chart.
#
# Application charts are a collection of templates that can be packaged into versioned archives
# to be deployed.
#
# Library charts provide useful utilities or functions for the chart developer. They're included as
# a dependency of application charts to inject those utilities and functions into the rendering
# pipeline. Library charts do not define any templates and therefore cannot be deployed.
type: application

# 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.0

# 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.
# It is recommended to use it with quotes.
appVersion: "1.16.0"
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ spec:
spec:
containers:
- name: serial-gateway
image: ghcr.io/tonygilkerson/serial-gateway:v1.0.15
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
resources:
requests:
cpu: 50m
Expand Down
File renamed without changes.
File renamed without changes.
5 changes: 5 additions & 0 deletions charts/serial-gateway/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
image:
repository: ghcr.io/tonygilkerson/serial-gateway
pullPolicy: IfNotPresent
# Overrides the image tag whose default is the chart appVersion.
tag: "v1.0.15"
18 changes: 9 additions & 9 deletions cmd/serial/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promhttp"
"github.com/tarm/serial"
iotmsg "github.com/tonygilkerson/mbx-iot/pkg/msg"
"github.com/tonygilkerson/mbx-iot/pkg/iot"
)

// Main
Expand Down Expand Up @@ -168,7 +168,7 @@ func serialServer(port *serial.Port) {

switch {

case strings.Contains(msg, string(iotmsg.MbxTemperature)):
case strings.Contains(msg, string(iot.MbxTemperature)):
parts := strings.Split(msg, ":")
f, err := strconv.ParseFloat(parts[1], 64)
if err != nil {
Expand All @@ -178,31 +178,31 @@ func serialServer(port *serial.Port) {
log.Printf("set MailboxTemperature to: %v", f)
}

case msg == iotmsg.MbxMuleAlarm:
case msg == iot.MbxMuleAlarm:
mbxMuleAlarmCount.Inc()
log.Println("increment mbxMuleAlarmCount")

case msg == iotmsg.MbxDoorOpened:
case msg == iot.MbxDoorOpened:
mbxMailboxDoorOpenedCount.Inc()
log.Println("increment mbxMailboxDoorOpenedCount")

case msg == iotmsg.MbxChargerChargeStatusOn:
case msg == iot.MbxChargerChargeStatusOn:
mbxChargerChargeStatus.Set(1)
log.Println("set mbxChargerChargeStatus to ON")

case msg == iotmsg.MbxChargerChargeStatusOff:
case msg == iot.MbxChargerChargeStatusOff:
mbxChargerChargeStatus.Set(0)
log.Println("set mbxChargerChargeStatus to OFF")

case msg == iotmsg.MbxChargerPowerSourceGood:
case msg == iot.MbxChargerPowerSourceGood:
mbxChargerPowerStatus.Set(1)
log.Println("set mbxChargerPowerStatus to GOOD")

case msg == iotmsg.MbxChargerPowerSourceBad:
case msg == iot.MbxChargerPowerSourceBad:
mbxChargerPowerStatus.Set(0)
log.Println("set mbxChargerPowerStatus to BAD")

case msg == iotmsg.MbxRoadMainLoopHeartbeat:
case msg == iot.MbxRoadMainLoopHeartbeat:
mbxRoadMainLoopHeartbeatCount.Inc()
log.Println("increment mbxRoadMainLoopHeartbeatCount")

Expand Down

0 comments on commit fb28c46

Please sign in to comment.