diff --git a/.dockerignore b/.dockerignore deleted file mode 100644 index 2d676d3..0000000 --- a/.dockerignore +++ /dev/null @@ -1,3 +0,0 @@ -vendor -__PROJECT__ -conf diff --git a/CHANGELOG.md b/CHANGELOG.md index c4cf331..e82f336 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ## [v0.0.1] - Initial creation +- external configuration +- bootstrapping for the core prometheus objects: Registerer and Gatherer +- bootstrapping for the HTTP environment +- bundled HTTP metrics -[Unreleased]: https://github.com/xmidt-org/__PROJECT__/compare/v0.0.1..HEAD -[v0.0.1]: https://github.com/xmidt-org/__PROJECT__/compare/0.0.0...v0.0.1 +[Unreleased]: https://github.com/xmidt-org/touchstone/compare/v0.0.1..HEAD +[v0.0.1]: https://github.com/xmidt-org/touchstone/compare/0.0.0...v0.0.1 diff --git a/Dockerfile b/Dockerfile deleted file mode 100644 index 514f790..0000000 --- a/Dockerfile +++ /dev/null @@ -1,42 +0,0 @@ -FROM docker.io/library/golang:1.15-alpine as builder - -MAINTAINER Jack Murdock - -WORKDIR /src - -ARG VERSION -ARG GITCOMMIT -ARG BUILDTIME - - -RUN apk add --no-cache --no-progress \ - ca-certificates \ - make \ - git \ - openssh \ - gcc \ - libc-dev \ - upx - -RUN go get github.com/geofffranks/spruce/cmd/spruce && chmod +x /go/bin/spruce -COPY . . -RUN make test release - -FROM alpine:3.12.1 - -COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ -COPY --from=builder /src/__PROJECT__ /src/__PROJECT__.yaml /src/deploy/packaging/entrypoint.sh /go/bin/spruce /src/Dockerfile /src/NOTICE /src/LICENSE /src/CHANGELOG.md / -COPY --from=builder /src/deploy/packaging/__PROJECT__.yaml /tmp/__PROJECT__.yaml - -RUN mkdir /etc/__PROJECT__/ && touch /etc/__PROJECT__/__PROJECT__.yaml && chmod 666 /etc/__PROJECT__/__PROJECT__.yaml - -USER nobody - -ENTRYPOINT ["/entrypoint.sh"] - -EXPOSE 6600 -EXPOSE 6601 -EXPOSE 6602 -EXPOSE 6603 - -CMD ["/__PROJECT__"] diff --git a/Makefile b/Makefile deleted file mode 100644 index c09c734..0000000 --- a/Makefile +++ /dev/null @@ -1,53 +0,0 @@ -.PHONY: default build test style docker binaries clean - - -DOCKER ?= docker -GO ?= go -GOFMT ?= $(GO)fmt -APP := __PROJECT__ -DOCKER_ORG := xmidt - -VERSION ?= $(shell git describe --tag --always --dirty) -PROGVER ?= $(shell git describe --tags `git rev-list --tags --max-count=1` | tail -1 | sed 's/v\(.*\)/\1/') -BUILDTIME = $(shell date -u '+%c') -GITCOMMIT = $(shell git rev-parse --short HEAD) -GOBUILDFLAGS = -a -ldflags "-w -s -X 'main.BuildTime=$(BUILDTIME)' -X main.GitCommit=$(GITCOMMIT) -X main.Version=$(VERSION)" -o $(APP) - -default: build - -generate: - $(GO) generate ./... - $(GO) install ./... - -test: - $(GO) test -v -race -coverprofile=coverage.txt ./... - $(GO) test -v -race -json ./... > report.json - -style: - ! $(GOFMT) -d $$(find . -path ./vendor -prune -o -name '*.go' -print) | grep '^' - -check: - golangci-lint run -n | tee errors.txt - -build: - CGO_ENABLED=0 $(GO) build $(GOBUILDFLAGS) - -release: build - upx $(APP) - -docker: - -$(DOCKER) rmi "$(APP):$(VERSION)" - -$(DOCKER) rmi "$(APP):latest" - $(DOCKER) build -t "$(APP):$(VERSION)" -t "$(APP):latest" . - -binaries: generate - mkdir -p ./.ignore - CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 $(GO) build -o ./.ignore/$(APP)-$(PROGVER).darwin-amd64 -ldflags "-X 'main.BuildTime=$(BUILDTIME)' -X main.GitCommit=$(GITCOMMIT) -X main.Version=$(VERSION)" - CGO_ENABLED=0 GOOS=linux GOARCH=amd64 $(GO) build -o ./.ignore/$(APP)-$(PROGVER).linux-amd64 -ldflags "-X 'main.BuildTime=$(BUILDTIME)' -X main.GitCommit=$(GITCOMMIT) -X main.Version=$(VERSION)" - - upx ./.ignore/$(APP)-$(PROGVER).darwin-amd64 - upx ./.ignore/$(APP)-$(PROGVER).linux-amd64 - -clean: - -rm -r .ignore/ $(APP) errors.txt report.json coverage.txt - diff --git a/NOTICE b/NOTICE index 8036277..115e498 100644 --- a/NOTICE +++ b/NOTICE @@ -1,4 +1,4 @@ -__PROJECT__ +touchstone Copyright 2020 Comcast Cable Communications Management, LLC Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/README.md b/README.md index 0994ace..cc1a81e 100644 --- a/README.md +++ b/README.md @@ -1,38 +1,22 @@ -# __PROJECT__ +# touchstone -__PROJECT__ does something good. +Touchstone is an integration between go.uber.org/fx and prometheus. -[![Build Status](https://travis-ci.com/xmidt-org/__PROJECT__.svg?branch=main)](https://travis-ci.com/xmidt-org/__PROJECT__) -[![codecov.io](http://codecov.io/github/xmidt-org/__PROJECT__/coverage.svg?branch=main)](http://codecov.io/github/xmidt-org/__PROJECT__?branch=main) -[![Go Report Card](https://goreportcard.com/badge/github.com/xmidt-org/__PROJECT__)](https://goreportcard.com/report/github.com/xmidt-org/__PROJECT__) -[![Apache V2 License](http://img.shields.io/badge/license-Apache%20V2-blue.svg)](https://github.com/xmidt-org/__PROJECT__/blob/main/LICENSE) +[![Build Status](https://travis-ci.com/xmidt-org/touchstone.svg?branch=main)](https://travis-ci.com/xmidt-org/touchstone) +[![codecov.io](http://codecov.io/github/xmidt-org/touchstone/coverage.svg?branch=main)](http://codecov.io/github/xmidt-org/touchstone?branch=main) +[![Go Report Card](https://goreportcard.com/badge/github.com/xmidt-org/touchstone)](https://goreportcard.com/report/github.com/xmidt-org/touchstone) +[![Apache V2 License](http://img.shields.io/badge/license-Apache%20V2-blue.svg)](https://github.com/xmidt-org/touchstone/blob/main/LICENSE) [![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=xmidt-org_PROJECT&metric=alert_status)](https://sonarcloud.io/dashboard?id=xmidt-org_PROJECT) -[![GitHub release](https://img.shields.io/github/release/xmidt-org/__PROJECT__.svg)](CHANGELOG.md) -[![PkgGoDev](https://pkg.go.dev/badge/github.com/xmidt-org/__PROJECT__)](https://pkg.go.dev/github.com/xmidt-org/__PROJECT__) - -## Setup - -1. Search and replace __PROJECT__ with your project name. -1. Initialize `go.mod` file: `go mod init github.com/xmidt-org/__PROJECT__` -1. Add org teams to project (Settings > Manage Access): - - xmidt-org/admins with Admin role - - xmidt-org/server-writers with Write role -1. Manually create the first release. After v0.0.1 exists, other releases will be made by automation after the CHANGELOG is updated to reflect a new version header and nothing under the Unreleased header. -1. For libraries: - 1. Add org workflows in dir `.github/workflows`: push, tag, and release. This can be done by going to the Actions tab for the repo on the github site. - 1. Remove the following files/dirs: `.dockerignore`, `Dockerfile`, `Makefile`, `rpkg.macros`, `__PROJECT__.yaml`, `deploy/`, and `conf/`. -1. For applications: - 1. Remove PkgGoDev badge from this file. - 1. Add org workflows in dir `.github/workflows`: push, tag, release, and docker-release. This can be done by going to the Actions tab for the repo on the github site. - 1. Add project name, `.ignore`, and `errors.txt` to `.gitignore` file. - 1. Update `Dockerfile` - choose new ports to expose that no current XMiDT application is using. - 1. Update `deploy/packaging/__PROJECT__.spec` file to have a proper Summary and Description. - 1. Update `conf/__PROJECT__.service` file to have a proper Description. - +[![GitHub release](https://img.shields.io/github/release/xmidt-org/touchstone.svg)](CHANGELOG.md) +[![PkgGoDev](https://pkg.go.dev/badge/github.com/xmidt-org/touchstone)](https://pkg.go.dev/github.com/xmidt-org/touchstone) ## Summary -Summary should be a small paragraph explanation of what this project does. +Touchstone provides easy bootstrapping of a prometheus client environment within a go.uber.org/fx application container. Key features include: + +- External configuration that can drive how the Registry and other components are initialized +- Simple constructors that allow individual metrics to fully participate in dependency injection +- Prebundled HTTP metrics with a simpler and more efficient instrumentation than what promhttp provides ## Table of Contents @@ -46,13 +30,9 @@ Summary should be a small paragraph explanation of what this project does. This project and everyone participating in it are governed by the [XMiDT Code Of Conduct](https://xmidt.io/code_of_conduct/). By participating, you agree to this Code. -## Details - -Add details here. - ## Install -Add details here. +go get -u github.com/xmidt-org/touchstone ## Contributing diff --git a/__PROJECT__.yaml b/__PROJECT__.yaml deleted file mode 100644 index 73b314f..0000000 --- a/__PROJECT__.yaml +++ /dev/null @@ -1 +0,0 @@ ---- \ No newline at end of file diff --git a/conf/__PROJECT__.env.example b/conf/__PROJECT__.env.example deleted file mode 100644 index ea716be..0000000 --- a/conf/__PROJECT__.env.example +++ /dev/null @@ -1,6 +0,0 @@ -#KERNEL_OPEN_FILES=95000 -#ULIMIT_OPEN_FILES=75000 -#NET_CORE_SOMAXCONN=1000 -#NET_IPV4_TCP_MAX_SYN_BACKLOG=1000 -#NET_IPV4_TCP_MEM="100000000 100000000 100000000" -DAEMON_COREFILE_LIMIT=unlimited \ No newline at end of file diff --git a/conf/__PROJECT__.service b/conf/__PROJECT__.service deleted file mode 100644 index 6a09fb1..0000000 --- a/conf/__PROJECT__.service +++ /dev/null @@ -1,17 +0,0 @@ -[Unit] -Description=__PROJECT__ description here -After=network.target remote-fs.target nss-lookup.target - -[Service] -Type=simple -PIDFile=/run/__PROJECT__.pid -ExecStartPre=/usr/bin/rm -f /run/__PROJECT__.pid -ExecStart=/usr/bin/__PROJECT__ -ExecReload=/bin/kill -s HUP $MAINPID -TimeoutStopSec=10 -KillMode=process -PrivateTmp=true -Restart=always - -[Install] -WantedBy=multi-user.target \ No newline at end of file diff --git a/deploy/packaging/__PROJECT__.spec b/deploy/packaging/__PROJECT__.spec deleted file mode 100644 index 0084641..0000000 --- a/deploy/packaging/__PROJECT__.spec +++ /dev/null @@ -1,90 +0,0 @@ -%define __os_install_post %{nil} -%define debug_package %{nil} - -Name: __PROJECT__ -Version: {{{ git_tag_version }}} -Release: 1%{?dist} -Summary: __PROJECT__ summary here. - -Vendor: Comcast -Packager: Comcast -Group: System Environment/Daemons -License: ASL 2.0 -URL: https://github.com/xmidt-org/__PROJECT__ -Source0: %{name}-%{version}.tar.gz - -Prefix: /opt -BuildRoot: %{_tmppath}/%{name} -BuildRequires: systemd -BuildRequires: golang >= 1.15 -BuildRequires: git - -%description -__PROJECT__ description here. - -%prep -%setup -q - -%build -GOPROXY=https://proxy.golang.org go build -ldflags "-linkmode=external -X 'main.BuildTime=`date -u '+%c'`' -X main.GitCommit={{{ git_short_hash }}} -X main.Version=%{version}" -o %{name} . - -%install -echo rm -rf %{buildroot} -%{__install} -d %{buildroot}%{_bindir} -%{__install} -d %{buildroot}%{_initddir} -%{__install} -d %{buildroot}%{_sysconfdir}/%{name} -%{__install} -d %{buildroot}%{_localstatedir}/log/%{name} -%{__install} -d %{buildroot}%{_localstatedir}/run/%{name} -%{__install} -d %{buildroot}%{_unitdir} - -%{__install} -p %{name} %{buildroot}%{_bindir} -%{__install} -p conf/%{name}.service %{buildroot}%{_unitdir}/%{name}.service -%{__install} -p %{name}.yaml %{buildroot}%{_sysconfdir}/%{name}/%{name}.yaml - -%files -%defattr(644, root, root, 755) -%doc LICENSE CHANGELOG.md NOTICE - -%attr(755, root, root) %{_bindir}/%{name} - -%{_unitdir}/%{name}.service - -%dir %{_sysconfdir}/%{name} -%config %{_sysconfdir}/%{name}/%{name}.yaml - -%dir %attr(755, %{name}, %{name}) %{_localstatedir}/log/%{name} -%dir %attr(755, %{name}, %{name}) %{_localstatedir}/run/%{name} - -%pre -id %{name} >/dev/null 2>&1 -if [ $? != 0 ]; then - /usr/sbin/groupadd -r %{name} >/dev/null 2>&1 - /usr/sbin/useradd -d /var/run/%{name} -r -g %{name} %{name} >/dev/null 2>&1 -fi - -%post -if [ $1 = 1 ]; then - systemctl preset %{name}.service >/dev/null 2>&1 || : -fi - -%preun -if [ -e /etc/init.d/%{name} ]; then - systemctl --no-reload disable %{name}.service > /dev/null 2>&1 || : - systemctl stop %{name}.service > /dev/null 2>&1 || : -fi - -# If not an upgrade, then delete -if [ $1 = 0 ]; then - systemctl disable %{name}.service >/dev/null 2>&1 || : -fi - -%postun -# Do not remove anything if this is not an uninstall -if [ $1 = 0 ]; then - /usr/sbin/userdel -r %{name} >/dev/null 2>&1 - /usr/sbin/groupdel %{name} >/dev/null 2>&1 - # Ignore errors from above - true -fi - -%changelog diff --git a/deploy/packaging/__PROJECT___spruce.yaml b/deploy/packaging/__PROJECT___spruce.yaml deleted file mode 100644 index 73b314f..0000000 --- a/deploy/packaging/__PROJECT___spruce.yaml +++ /dev/null @@ -1 +0,0 @@ ---- \ No newline at end of file diff --git a/deploy/packaging/entrypoint.sh b/deploy/packaging/entrypoint.sh deleted file mode 100755 index 478b090..0000000 --- a/deploy/packaging/entrypoint.sh +++ /dev/null @@ -1,49 +0,0 @@ -#!/usr/bin/env sh - - -set -e - -# check to see if this file is being run or sourced from another script -_is_sourced() { - # https://unix.stackexchange.com/a/215279 - [ "${#FUNCNAME[@]}" -ge 2 ] \ - && [ "${FUNCNAME[0]}" = '_is_sourced' ] \ - && [ "${FUNCNAME[1]}" = 'source' ] -} - -# check arguments for an option that would cause /__PROJECT__ to stop -# return true if there is one -_want_help() { - local arg - for arg; do - case "$arg" in - -'?'|--help|-v) - return 0 - ;; - esac - done - return 1 -} - -_main() { - # if command starts with an option, prepend __PROJECT__ - if [ "${1:0:1}" = '-' ]; then - set -- /__PROJECT__ "$@" - fi - # skip setup if they aren't running /__PROJECT__ or want an option that stops /__PROJECT__ - if [ "$1" = '/__PROJECT__' ] && ! _want_help "$@"; then - echo "Entrypoint script for __PROJECT__ Server ${VERSION} started." - - if [ ! -s /etc/__PROJECT__/__PROJECT__.yaml ]; then - echo "Building out template for file" - /spruce merge /__PROJECT__.yaml /tmp/__PROJECT___spruce.yaml > /etc/__PROJECT__/__PROJECT__.yaml - fi - fi - - exec "$@" -} - -# If we are sourced from elsewhere, don't perform any further actions -if ! _is_sourced; then - _main "$@" -fi \ No newline at end of file diff --git a/rpkg.macros b/rpkg.macros deleted file mode 100644 index 45baa75..0000000 --- a/rpkg.macros +++ /dev/null @@ -1,19 +0,0 @@ -function git_short_hash { - short_hash="$(cached git_short_hash)" - - if [ -z "$short_hash" ]; then - short_hash="$(git rev-parse --short HEAD)" - fi - - output "$short_hash" -} - -function git_tag_version { - tag="$(cached git_tag_version)" - - if [ -z "$tag" ]; then - tag="$(git describe --tags --abbrev=0)" - fi - - output "$tag" -} \ No newline at end of file