diff --git a/.releaserc b/.releaserc index e782380..78f1e87 100644 --- a/.releaserc +++ b/.releaserc @@ -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}" } ] diff --git a/charts/serial-gateway/.helmignore b/charts/serial-gateway/.helmignore new file mode 100644 index 0000000..0e8a0eb --- /dev/null +++ b/charts/serial-gateway/.helmignore @@ -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/ diff --git a/charts/serial-gateway/Chart.yaml b/charts/serial-gateway/Chart.yaml new file mode 100644 index 0000000..3e5b28e --- /dev/null +++ b/charts/serial-gateway/Chart.yaml @@ -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" diff --git a/deploy/k8s/deployment.yaml b/charts/serial-gateway/templates/deployment.yaml similarity index 92% rename from deploy/k8s/deployment.yaml rename to charts/serial-gateway/templates/deployment.yaml index b8bbcab..1bd31df 100644 --- a/deploy/k8s/deployment.yaml +++ b/charts/serial-gateway/templates/deployment.yaml @@ -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 diff --git a/deploy/k8s/service-monitor.yaml b/charts/serial-gateway/templates/service-monitor.yaml similarity index 100% rename from deploy/k8s/service-monitor.yaml rename to charts/serial-gateway/templates/service-monitor.yaml diff --git a/deploy/k8s/service.yaml b/charts/serial-gateway/templates/service.yaml similarity index 100% rename from deploy/k8s/service.yaml rename to charts/serial-gateway/templates/service.yaml diff --git a/charts/serial-gateway/values.yaml b/charts/serial-gateway/values.yaml new file mode 100644 index 0000000..ab73991 --- /dev/null +++ b/charts/serial-gateway/values.yaml @@ -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" diff --git a/cmd/serial/main.go b/cmd/serial/main.go index df044ff..97461e7 100644 --- a/cmd/serial/main.go +++ b/cmd/serial/main.go @@ -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 @@ -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 { @@ -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")