Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Spring cleaning #258

Merged
merged 31 commits into from
May 4, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
557bbd7
Update codecov settings and move file location
mmlb Apr 25, 2022
f40064e
Get rid of code to bring up the full tinkerbell stack
mmlb Apr 22, 2022
a988da7
ci: Misc updates to ci.yaml
mmlb Apr 23, 2022
b868e3d
nix: Update nixpkgs pin and pkgs installed
mmlb Apr 18, 2022
23c9b66
ci: Run ci steps from Makefile
mmlb Apr 23, 2022
f1c956a
ci: Do not install go using actions/setup-go
mmlb Apr 23, 2022
f918559
ci: Use a tweaked version of tink's ci-checks.sh
mmlb Apr 23, 2022
8d09f50
make: Don't mark the generated files as PHONY
mmlb Apr 22, 2022
135c06a
installers: Get rid of nixos support
mmlb Apr 22, 2022
4d724c9
installers: Get rid of rancheros support
mmlb Apr 22, 2022
628b438
installers: Get rid of most of the conf/mirror env options
mmlb Apr 21, 2022
edd4ca2
tests: Use t.Setenv instead of os.Setenv
mmlb Apr 20, 2022
6be43b8
tests: Stop setting unnecessary env vars in TestMain
mmlb Apr 21, 2022
6c7b9e5
tests: Minimize ipxe script test combinations
mmlb Apr 21, 2022
4f08a76
coreos: Drop coreos from dynamic checks
mmlb Apr 22, 2022
2b59a7e
coreos: Drop oem tarball support
mmlb Apr 22, 2022
a907a20
coreos: Get rid of coreos distro from tests
mmlb Apr 22, 2022
ee0d386
coreos: Update plan types in installer tests to be more relevant.
mmlb Apr 22, 2022
2ab9392
coreos: Move files/ into installers/coreos
mmlb Apr 22, 2022
f9a2b2c
coreos: rename to flatcar
mmlb Apr 22, 2022
f4aaf1f
vmware: Test ipxe scripts for all supported vmware versions
mmlb Apr 21, 2022
61ed82a
ipxe: Always do the `echo Tinkerbell Boots iPXE`
mmlb Apr 22, 2022
443c387
tests: Make the ipxe scripts in the ipxe_script_test files more accurate
mmlb Apr 22, 2022
173d384
Always use ipxe.Script as a pointer
mmlb Apr 21, 2022
087ceb6
job: Add BootScripter interface
mmlb Feb 14, 2022
000e10b
Change installer registration to be based off job.BootScripter
mmlb Apr 21, 2022
74ea185
osie: Figure out tinkerbell connection params only once, at startup
mmlb Feb 14, 2022
1be6a1e
osie: Avoid repeated string concatenation for effectively static tink…
mmlb Feb 14, 2022
383ae2c
osie: Pass TINKERBELL_TLS env var down via kernel command line
mmlb May 3, 2022
f5e5729
osie: Drop support for the /cert url
mmlb May 3, 2022
05cfeab
osie: Avoid env lookups and memoize static values
mmlb May 3, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 1 addition & 7 deletions codecov.yml → .github/codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,14 @@
coverage:
precision: 0 # xx%
round: down # round down
range: 39..75 # red -> yellow (this range) -> green
range: 30..40 # red < yellow (this range) < green

status:
project:
default:
against: auto # auto compares coverage to the previous base commit
target: auto # automatically calculate coverage target - should increase
threshold: 2% # allow for 2% reduction without failing
patch:
default:
against: parent
target: auto
changes: false

ignore:
- "vendor"
- "ipxe/"
38 changes: 38 additions & 0 deletions .github/workflows/ci-checks.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#!/usr/bin/env nix-shell
#!nix-shell -i bash ../../shell.nix
# shellcheck shell=bash

set -eux

failed=0

# --check doesn't show what line number fails, so write the result to disk for the diff to catch
if ! git ls-files '*.json' '*.md' '*.yaml' '*.yml' | xargs prettier --list-different --write; then
failed=1
fi

if ! shfmt -f . | xargs shfmt -l -d; then
failed=1
fi

if ! shfmt -f . | xargs shellcheck; then
failed=1
fi

if ! nixfmt shell.nix; then
failed=1
fi

if ! git ls-files '*.go' | xargs -I% sh -c 'sed "/^import (/,/^)/ { /^\s*$/ d }" % >%.tmp && goimports -w %.tmp && (if cmp -s % %.tmp; then rm %.tmp; else mv %.tmp %; fi)'; then
failed=1
fi

if ! go mod tidy; then
failed=true
fi

if ! git diff | (! grep .); then
failed=1
fi

exit "$failed"
29 changes: 0 additions & 29 deletions .github/workflows/ci-non-go.sh

This file was deleted.

43 changes: 20 additions & 23 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,59 +9,56 @@ on:

jobs:
validation:
runs-on: [self-hosted, X64]
runs-on: ubuntu-latest
env:
CGO_ENABLED: 0
steps:
- name: Setup Dynamic Env
run: |
echo "MAKEFLAGS=-j$(nproc)" | tee $GITHUB_ENV

- name: Checkout code
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
lfs: true

- name: Install nix
uses: cachix/install-nix-action@018abf956a0a15673dae4932ae26f0f071ac0944
uses: cachix/install-nix-action@v17
with:
nix_path: nixpkgs=channel:nixpkgs-unstable

- name: Fetch Deps
run: nix-shell --run 'go get -t ./... && go mod tidy'

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Non Go formatters and linters
run: ./.github/workflows/ci-non-go.sh
- name: Install Go
uses: actions/setup-go@v2
with:
go-version: "1.18"

- name: Generate all files
run: nix-shell --run 'make gen'
- name: goimports
run: go get golang.org/x/tools/cmd/goimports && goimports -d . | (! grep .)
- name: go vet
run: go mod tidy && go vet ./...
- name: golangci-lint
uses: golangci/golangci-lint-action@v2
with:
args: -v
- name: go test
run: go test -v ./... -gcflags=-l
- name: go test coverage
run: go test -coverprofile=coverage.txt ./... -gcflags=-l
run: nix-shell --run 'make -j1 gen'

- name: Run all the tests
run: nix-shell --run 'make ci'

- name: upload codecov
run: bash <(curl -s https://codecov.io/bash)

- name: compile binaries
run: nix-shell --run 'make crosscompile'

- name: Docker Image Tag for Sha
id: docker-image-tag
run: |
echo ::set-output name=tags::quay.io/tinkerbell/boots:latest,quay.io/tinkerbell/boots:sha-${GITHUB_SHA::8}

- name: Login to quay.io
uses: docker/login-action@v1
if: ${{ startsWith(github.ref, 'refs/heads/main') }}
with:
registry: quay.io
username: ${{ secrets.QUAY_USERNAME }}
password: ${{ secrets.QUAY_PASSWORD }}
- name: quay.io/tinkerbell/boots

- name: Build Docker Images
uses: docker/build-push-action@v2
with:
context: ./
Expand Down
8 changes: 0 additions & 8 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,3 @@
/cmd/boots/boots
/cmd/boots/boots-*-*
coverage.txt
!deploy/stack/.env
.vagrant
deploy/stack/state/webroot/misc/osie/current/*
deploy/stack/state/webroot/workflow/*
!deploy/stack/state/webroot/misc/osie/current/.keep
!deploy/stack/state/webroot/workflow/.keep
deploy/stack/state/webroot/*.gz
workflow_id.txt
15 changes: 9 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@ all: help
boots: cmd/boots/boots ## Compile boots for host OS and Architecture

crosscompile: $(crossbinaries) ## Compile boots for all architectures

gen: $(generated_go_files) ## Generate go generate'd files

tools: $(toolsBins) ## Builds cli tools defined in tools.go

IMAGE_TAG ?= boots:latest
image: cmd/boots/boots-linux-amd64 ## Build docker image
docker build -t $(IMAGE_TAG) .
Expand All @@ -27,15 +29,16 @@ coverage: test ## Show test coverage
vet: ## Run go vet
go vet ./...

goimports: ## Run goimports
@echo be sure goimports is installed
goimports: bin/goimports gen ## Run goimports
goimports -w .

golangci-lint: ## Run golangci-lint
@echo be sure golangci-lint is installed: https://golangci-lint.run/usage/install/
golangci-lint: bin/golangci-lint gen ## Run golangci-lint
golangci-lint run -v

validate-local: vet coverage goimports golangci-lint ## Runs all the same validations and tests that run in CI
ci-checks: bin/goimports .github/workflows/ci-checks.sh shell.nix gen
./.github/workflows/ci-checks.sh

ci: ci-checks coverage goimports golangci-lint vet ## Runs all the same validations and tests that run in CI

help: ## Print this help
@grep --no-filename -E '^[a-zA-Z0-9_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sed 's/:.*##/·/' | sort | column -ts '·' -c 120
8 changes: 3 additions & 5 deletions cmd/boots/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import (
"github.com/tinkerbell/boots/client"
"github.com/tinkerbell/boots/conf"
"github.com/tinkerbell/boots/httplog"
"github.com/tinkerbell/boots/installers/coreos"
"github.com/tinkerbell/boots/installers/flatcar"
"github.com/tinkerbell/boots/installers/vmware"
"github.com/tinkerbell/boots/job"
"github.com/tinkerbell/boots/metrics"
Expand Down Expand Up @@ -99,10 +99,8 @@ func (s *BootsHTTPServer) ServeHTTP(i job.Installers, addr string, ipxePattern s
}))

var httpHandlers = make(map[string]http.HandlerFunc)
// register coreos/flatcar endpoints
httpHandlers[coreos.IgnitionPathCoreos] = coreos.ServeIgnitionConfig("coreos", s.jobManager)
httpHandlers[coreos.IgnitionPathFlatcar] = coreos.ServeIgnitionConfig("flatcar", s.jobManager)
httpHandlers[coreos.OEMPath] = coreos.ServeOEM(s.jobManager)
// register flatcar endpoints
httpHandlers[flatcar.IgnitionPathFlatcar] = flatcar.ServeIgnitionConfig(s.jobManager)
// register vmware endpoints
httpHandlers[vmware.KickstartPath] = vmware.ServeKickstart(s.jobManager)

Expand Down
84 changes: 48 additions & 36 deletions cmd/boots/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,9 @@ import (
"github.com/tinkerbell/boots/dhcp"
"github.com/tinkerbell/boots/httplog"
"github.com/tinkerbell/boots/installers"
"github.com/tinkerbell/boots/installers/coreos"
"github.com/tinkerbell/boots/installers/custom_ipxe"
"github.com/tinkerbell/boots/installers/nixos"
"github.com/tinkerbell/boots/installers/flatcar"
"github.com/tinkerbell/boots/installers/osie"
"github.com/tinkerbell/boots/installers/rancher"
"github.com/tinkerbell/boots/installers/vmware"
"github.com/tinkerbell/boots/job"
"github.com/tinkerbell/boots/metrics"
Expand Down Expand Up @@ -206,8 +204,13 @@ func main() {

mainlog.With("addr", cfg.dhcpAddr).Info("serving dhcp")
go dhcpServer.ServeDHCP(cfg.dhcpAddr, nextServer, ipxeBaseURL, bootsBaseURL)

installers, err := cfg.registerInstallers()
if err != nil {
mainlog.Fatal(err)
}
mainlog.With("addr", cfg.httpAddr).Info("serving http")
go httpServer.ServeHTTP(cfg.registerInstallers(), cfg.httpAddr, ipxePattern, ipxeHandler)
go httpServer.ServeHTTP(installers, cfg.httpAddr, ipxePattern, ipxeHandler)

<-ctx.Done()
mainlog.Info("boots shutting down")
Expand Down Expand Up @@ -360,41 +363,50 @@ func newCLI(cfg *config, fs *flag.FlagSet) *ffcli.Command {
}
}

func (cf *config) registerInstallers() job.Installers {
func (cf *config) registerInstallers() (job.Installers, error) {
// register installers
i := job.NewInstallers()
// register coreos/flatcar
c := coreos.Installer{}
i.RegisterDistro("coreos", c.BootScript())
i.RegisterDistro("flatcar", c.BootScript())

// register flatcar
o := flatcar.Installer()
i.RegisterDistro("flatcar", o.BootScript("flatcar"))

// register custom ipxe
ci := custom_ipxe.Installer{}
i.RegisterDistro("custom_ipxe", ci.BootScript())
i.RegisterInstaller("custom_ipxe", ci.BootScript())
// register nixos
n := nixos.Installer{Paths: nixos.BuildInitPaths()}
i.RegisterDistro("nixos", n.BootScript())
o = custom_ipxe.Installer()
i.RegisterDistro("custom_ipxe", o.BootScript("custom_ipxe"))
i.RegisterInstaller("custom_ipxe", o.BootScript("custom_ipxe"))

dataModelVersion := env.Get("DATA_MODEL_VERSION")
auth := env.Get("TINKERBELL_GRPC_AUTHORITY")
if dataModelVersion == "1" && auth == "" {
return job.Installers{}, errors.New("TINKERBELL_GRPC_AUTHORITY is required when in tinkerbell mode")
}

// register osie
o := osie.Installer{}
i.RegisterDistro("discovery", o.Discover())
// register osie as default
d := osie.Installer{ExtraKernelArgs: cf.extraKernelArgs}
i.RegisterDefaultInstaller(d.DefaultHandler())
// register rancher
r := rancher.Installer{}
i.RegisterDistro("rancher", r.BootScript())
o = osie.Installer(
dataModelVersion,
auth,
cf.extraKernelArgs,
env.Get("DOCKER_REGISTRY"),
env.Get("REGISTRY_USERNAME"),
env.Get("REGISTRY_PASSWORD"),
env.Bool("TINKERBELL_TLS", true),
)
i.RegisterDistro("discovery", o.BootScript("discover"))
i.RegisterDefaultInstaller(o.BootScript("default"))

// register vmware
v := vmware.Installer{}
i.RegisterSlug("vmware_esxi_5_5", v.BootScriptVmwareEsxi55())
i.RegisterSlug("vmware_esxi_6_0", v.BootScriptVmwareEsxi60())
i.RegisterSlug("vmware_esxi_6_5", v.BootScriptVmwareEsxi65())
i.RegisterSlug("vmware_esxi_6_7", v.BootScriptVmwareEsxi67())
i.RegisterSlug("vmware_esxi_7_0", v.BootScriptVmwareEsxi70())
i.RegisterSlug("vmware_esxi_7_0U2a", v.BootScriptVmwareEsxi70U2a())
i.RegisterSlug("vmware_esxi_6_5_vcf", v.BootScriptVmwareEsxi65())
i.RegisterSlug("vmware_esxi_6_7_vcf", v.BootScriptVmwareEsxi67())
i.RegisterSlug("vmware_esxi_7_0_vcf", v.BootScriptVmwareEsxi70())
i.RegisterDistro("vmware", v.BootScriptDefault())

return i
v := vmware.Installer()
i.RegisterSlug("vmware_esxi_5_5", v.BootScript("vmware_esxi_5_5"))
i.RegisterSlug("vmware_esxi_6_0", v.BootScript("vmware_esxi_6_0"))
i.RegisterSlug("vmware_esxi_6_5", v.BootScript("vmware_esxi_6_5"))
i.RegisterSlug("vmware_esxi_6_7", v.BootScript("vmware_esxi_6_7"))
i.RegisterSlug("vmware_esxi_7_0", v.BootScript("vmware_esxi_7_0"))
i.RegisterSlug("vmware_esxi_7_0U2a", v.BootScript("vmware_esxi_7_0U2a"))
i.RegisterSlug("vmware_esxi_6_5_vcf", v.BootScript("vmware_esxi_6_5_vcf"))
i.RegisterSlug("vmware_esxi_6_7_vcf", v.BootScript("vmware_esxi_6_7_vcf"))
i.RegisterSlug("vmware_esxi_7_0_vcf", v.BootScript("vmware_esxi_7_0_vcf"))
i.RegisterDistro("vmware", v.BootScript("vmware"))

return i, nil
}
Loading