Skip to content

Commit

Permalink
Merge pull request #1 from OpenCHAMI/trcotton/goreleaser
Browse files Browse the repository at this point in the history
Trcotton/goreleaser
  • Loading branch information
travisbcotton authored Jan 8, 2024
2 parents ff29daf + f96039a commit 37ddc07
Show file tree
Hide file tree
Showing 5 changed files with 139 additions and 65 deletions.
72 changes: 72 additions & 0 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
# This is an example .goreleaser.yml file with some sensible defaults.
# Make sure to check the documentation at https://goreleaser.com

project_name: cloud-init-server
before:
hooks:
# You may remove this if you don't use go modules.
- go mod tidy

builds:
- id: cloud-init-server
main: ./cmd/cloud-init-server
binary: cloud-init-server
goos:
- linux
goarch:
- amd64
no_unique_dist_dir: true
tags:
- dynamic

dockers:
-
image_templates:
- ghcr.io/openchami/{{.ProjectName}}:latest
- ghcr.io/openchami/{{.ProjectName}}:{{ .Tag }}
- ghcr.io/openchami/{{.ProjectName}}:{{ .Major }}
- ghcr.io/openchami/{{.ProjectName}}:{{ .Major }}.{{ .Minor }}
build_flag_templates:
- "--pull"
- "--label=org.opencontainers.image.created={{.Date}}"
- "--label=org.opencontainers.image.title={{.ProjectName}}"
- "--label=org.opencontainers.image.revision={{.FullCommit}}"
- "--label=org.opencontainers.image.version={{.Version}}"
extra_files:
- LICENSE
- CHANGELOG.md
- README.md
- .version

archives:
- format: tar.gz
# this name template makes the OS and Arch compatible with the results of uname.
name_template: >-
{{ .ProjectName }}_
{{- title .Os }}_
{{- if eq .Arch "amd64" }}x86_64
{{- else if eq .Arch "386" }}i386
{{- else }}{{ .Arch }}{{ end }}
{{- if .Arm }}v{{ .Arm }}{{ end }}
files:
- LICENSE
- CHANGELOG.md
- README.md


checksum:
name_template: 'checksums.txt'
snapshot:
name_template: "{{ incpatch .Version }}-next"
changelog:
sort: asc
filters:
exclude:
- '^docs:'
- '^test:'


# The lines beneath this are called `modelines`. See `:help modeline`
# Feel free to remove those if you don't want/use them.
# yaml-language-server: $schema=https://goreleaser.com/static/schema.json
# vim: set ts=2 sw=2 tw=0 fo=cnqoj
48 changes: 48 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# MIT License
#
# (C) Copyright [2018-2021] Hewlett Packard Enterprise Development LP
#
# Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files (the "Software"),
# to deal in the Software without restriction, including without limitation
# the rights to use, copy, modify, merge, publish, distribute, sublicense,
# and/or sell copies of the Software, and to permit persons to whom the
# Software is furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included
# in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
# OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
# OTHER DEALINGS IN THE SOFTWARE.

FROM cgr.dev/chainguard/wolfi-base
EXPOSE 27777
STOPSIGNAL SIGTERM

RUN apk add --no-cache tini

# Setup environment variables.

# Include curl in the final image.
RUN set -ex \
&& apk -U upgrade \
&& apk add --no-cache curl

# Get the boot-script-service from the builder stage.
COPY cloud-init-service /usr/local/bin/
COPY .version /

# nobody 65534:65534
USER 65534:65534

# Set up the command to start the service.
CMD /usr/local/bin/cloud-init-service \
--ci-listen ":27777" \
--smd-endpoint "http://localhost:27779"

ENTRYPOINT ["/sbin/tini", "--"]
21 changes: 15 additions & 6 deletions cmd/harbor/main.go → cmd/cloud-init-server/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,28 @@ package main
import (
"fmt"
"net/http"
"flag"
yaml "gopkg.in/yaml.v2"
"github.com/gin-gonic/gin"
"github.com/gosimple/slug"
"github.com/travisbcotton/harbor/internal/memstore"
"github.com/travisbcotton/harbor/pkg/citypes"
"github.com/travisbcotton/harbor/internal/smdclient"
"github.com/OpenCHAMI/cloud-init/internal/memstore"
"github.com/OpenCHAMI/cloud-init/pkg/citypes"
"github.com/OpenCHAMI/cloud-init/internal/smdclient"
)

var (
ciEndpoint = ":27777"
smdEndpoint = "http://localhost:27779"
)

func main() {
router := gin.Default()
flag.StringVar(&ciEndpoint, "ci-listen", ciEndpoint, "Server IP and port for cloud-init-server to listen on")
flag.StringVar(&smdEndpoint, "smd-endpoint", smdEndpoint, "http IP/url and port for running SMD")
flag.Parse()

router := gin.Default()
store := memstore.NewMemStore()
sm := smdclient.NewSMDClient("http://ochami-vm:27779")
sm := smdclient.NewSMDClient(smdEndpoint)
ciHandler := NewCiHandler(store, sm)

router.GET("/harbor", ciHandler.ListEntries)
Expand All @@ -28,7 +37,7 @@ func main() {
router.DELETE("harbor/:id", ciHandler.DeleteEntry)


router.Run()
router.Run(ciEndpoint)
}


Expand Down
59 changes: 2 additions & 57 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,58 +1,3 @@
module github.com/travisbcotton/harbor
module cloud-init-server

go 1.19

require (
github.com/Cray-HPE/hms-base v1.15.1 // indirect
github.com/Cray-HPE/hms-certs v1.4.0 // indirect
github.com/Cray-HPE/hms-securestorage v1.13.0 // indirect
github.com/OpenCHAMI/smd/v2 v2.12.15 // indirect
github.com/bytedance/sonic v1.9.1 // indirect
github.com/cenkalti/backoff/v3 v3.2.2 // indirect
github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311 // indirect
github.com/fsnotify/fsnotify v1.6.0 // indirect
github.com/gabriel-vasile/mimetype v1.4.2 // indirect
github.com/gin-contrib/sse v0.1.0 // indirect
github.com/gin-gonic/gin v1.9.1 // indirect
github.com/go-jose/go-jose/v3 v3.0.0 // indirect
github.com/go-playground/locales v0.14.1 // indirect
github.com/go-playground/universal-translator v0.18.1 // indirect
github.com/go-playground/validator/v10 v10.14.0 // indirect
github.com/goccy/go-json v0.10.2 // indirect
github.com/gosimple/slug v1.13.1 // indirect
github.com/gosimple/unidecode v1.0.1 // indirect
github.com/hashicorp/errwrap v1.1.0 // indirect
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
github.com/hashicorp/go-multierror v1.1.1 // indirect
github.com/hashicorp/go-retryablehttp v0.7.4 // indirect
github.com/hashicorp/go-rootcerts v1.0.2 // indirect
github.com/hashicorp/go-secure-stdlib/parseutil v0.1.7 // indirect
github.com/hashicorp/go-secure-stdlib/strutil v0.1.2 // indirect
github.com/hashicorp/go-sockaddr v1.0.2 // indirect
github.com/hashicorp/hcl v1.0.1-vault-5 // indirect
github.com/hashicorp/vault/api v1.9.2 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/klauspost/cpuid/v2 v2.2.4 // indirect
github.com/leodido/go-urn v1.2.4 // indirect
github.com/mattn/go-isatty v0.0.19 // indirect
github.com/mitchellh/go-homedir v1.1.0 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/pelletier/go-toml/v2 v2.0.8 // indirect
github.com/ryanuber/go-glob v1.0.0 // indirect
github.com/samber/lo v1.39.0 // indirect
github.com/sirupsen/logrus v1.9.3 // indirect
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
github.com/ugorji/go/codec v1.2.11 // indirect
golang.org/x/arch v0.3.0 // indirect
golang.org/x/crypto v0.12.0 // indirect
golang.org/x/exp v0.0.0-20220303212507-bbda1eaf7a17 // indirect
golang.org/x/net v0.14.0 // indirect
golang.org/x/sys v0.11.0 // indirect
golang.org/x/text v0.12.0 // indirect
golang.org/x/time v0.3.0 // indirect
google.golang.org/protobuf v1.30.0 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
go 1.20
4 changes: 2 additions & 2 deletions internal/memstore/ciMemStore.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import (
"reflect"

"github.com/samber/lo"
"github.com/travisbcotton/harbor/pkg/citypes"
"github.com/travisbcotton/harbor/internal/smdclient"
"github.com/OpenCHAMI/cloud-init/pkg/citypes"
"github.com/OpenCHAMI/cloud-init/internal/smdclient"
)

var (
Expand Down

0 comments on commit 37ddc07

Please sign in to comment.