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

Add OSIE files and location customization: #534

Merged
merged 5 commits into from
Oct 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion cmd/smee/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@
if _, err := url.Parse(httpScriptURL.String()); err != nil {
return nil, fmt.Errorf("invalid http ipxe script url: %w", err)
}
ipxeScript := func(d *dhcpv4.DHCPv4) *url.URL {
ipxeScript := func(*dhcpv4.DHCPv4) *url.URL {

Check warning on line 382 in cmd/smee/main.go

View check run for this annotation

Codecov / codecov/patch

cmd/smee/main.go#L382

Added line #L382 was not covered by tests
return httpScriptURL
}
if c.dhcp.httpIpxeScript.injectMacAddress {
Expand Down
17 changes: 9 additions & 8 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,23 @@ go 1.22.0
toolchain go1.22.5

require (
github.com/ccoveille/go-safecast v1.1.0
github.com/fsnotify/fsnotify v1.7.0
github.com/ghodss/yaml v1.0.0
github.com/go-logr/logr v1.4.2
github.com/go-logr/stdr v1.2.2
github.com/go-logr/zapr v1.3.0
github.com/google/go-cmp v0.6.0
github.com/insomniacslk/dhcp v0.0.0-20231206064809-8c70d406f6d2
github.com/insomniacslk/dhcp v0.0.0-20240829085014-a3a4c1f04475
github.com/packethost/xff v0.0.0-20190305172552-d3e9190c41b3
github.com/peterbourgon/ff/v3 v3.4.0
github.com/prometheus/client_golang v1.20.4
github.com/tinkerbell/ipxedust v0.0.0-20240726225714-c9bd1dd89cc3
github.com/tinkerbell/ipxedust v0.0.0-20241012034445-f4626d47a3d8
github.com/tinkerbell/tink v0.10.1
github.com/vishvananda/netlink v1.3.0
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.55.0
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.56.0
go.opentelemetry.io/otel v1.31.0
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.30.0
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.31.0
go.opentelemetry.io/otel/sdk v1.31.0
go.opentelemetry.io/otel/trace v1.31.0
go.uber.org/zap v1.27.0
Expand Down Expand Up @@ -83,7 +84,7 @@ require (
github.com/u-root/uio v0.0.0-20230305220412-3e8cd9d6bf63 // indirect
github.com/vishvananda/netns v0.0.4 // indirect
github.com/x448/float16 v0.8.4 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.30.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.31.0 // indirect
go.opentelemetry.io/otel/metric v1.31.0 // indirect
go.opentelemetry.io/proto/otlp v1.3.1 // indirect
go.uber.org/multierr v1.11.0 // indirect
Expand All @@ -93,9 +94,9 @@ require (
golang.org/x/term v0.25.0 // indirect
golang.org/x/text v0.19.0 // indirect
golang.org/x/time v0.5.0 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20240903143218-8af14fe29dc1 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240903143218-8af14fe29dc1 // indirect
google.golang.org/protobuf v1.34.2 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20241007155032-5fefd90f89a9 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20241007155032-5fefd90f89a9 // indirect
google.golang.org/protobuf v1.35.1 // indirect
gopkg.in/evanphx/json-patch.v4 v4.12.0 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
Expand Down
38 changes: 20 additions & 18 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ dario.cat/mergo v1.0.0 h1:AGCNq9Evsj31mOgNPcLyXc+4PNABt905YmuqPYYpBWk=
dario.cat/mergo v1.0.0/go.mod h1:uNxQE+84aUszobStD9th8a29P2fMDhsBdgRYvZOxGmk=
github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw=
github.com/ccoveille/go-safecast v1.1.0 h1:iHKNWaZm+OznO7Eh6EljXPjGfGQsSfa6/sxPlIEKO+g=
github.com/ccoveille/go-safecast v1.1.0/go.mod h1:QqwNjxQ7DAqY0C721OIO9InMk9zCwcsO7tnRuHytad8=
github.com/cenkalti/backoff/v4 v4.3.0 h1:MyRJ/UdXutAwSAT+s3wNd7MfTIcy71VQueUuFK343L8=
github.com/cenkalti/backoff/v4 v4.3.0/go.mod h1:Y3VNntkOUPxTVeUxJ/G5vcM//AlwfmyYozVcomhLiZE=
github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs=
Expand Down Expand Up @@ -78,8 +80,8 @@ github.com/hugelgupf/socketpair v0.0.0-20190730060125-05d35a94e714 h1:/jC7qQFrv8
github.com/hugelgupf/socketpair v0.0.0-20190730060125-05d35a94e714/go.mod h1:2Goc3h8EklBH5mspfHFxBnEoURQCGzQQH1ga9Myjvis=
github.com/imdario/mergo v0.3.16 h1:wwQJbIsHYGMUyLSPrEq1CT16AhnhNJQ51+4fdHUnCl4=
github.com/imdario/mergo v0.3.16/go.mod h1:WBLT9ZmE3lPoWsEzCh9LPo3TiwVN+ZKEjmz+hD27ysY=
github.com/insomniacslk/dhcp v0.0.0-20231206064809-8c70d406f6d2 h1:9K06NfxkBh25x56yVhWWlKFE8YpicaSfHwoV8SFbueA=
github.com/insomniacslk/dhcp v0.0.0-20231206064809-8c70d406f6d2/go.mod h1:3A9PQ1cunSDF/1rbTq99Ts4pVnycWg+vlPkfeD2NLFI=
github.com/insomniacslk/dhcp v0.0.0-20240829085014-a3a4c1f04475 h1:hxST5pwMBEOWmxpkX20w9oZG+hXdhKmAIPQ3NGGAxas=
github.com/insomniacslk/dhcp v0.0.0-20240829085014-a3a4c1f04475/go.mod h1:KclMyHxX06VrVr0DJmeFSUb1ankt7xTfoOA35pCkoic=
github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY=
github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y=
github.com/josharian/native v1.0.1-0.20221213033349-c1e37c09b531/go.mod h1:7X/raswPFr05uY3HiLlYeyQntB6OO7E/d2Cu7qoaN2w=
Expand Down Expand Up @@ -149,8 +151,8 @@ github.com/prometheus/common v0.55.0 h1:KEi6DK7lXW/m7Ig5i47x0vRzuBsHuvJdi5ee6Y3G
github.com/prometheus/common v0.55.0/go.mod h1:2SECS4xJG1kd8XF9IcM1gMX6510RAEL65zxzNImwdc8=
github.com/prometheus/procfs v0.15.1 h1:YagwOFzUgYfKKHX6Dr+sHT7km/hxC76UB0learggepc=
github.com/prometheus/procfs v0.15.1/go.mod h1:fB45yRUv8NstnjriLhBQLuOUt+WW4BsoGhij/e3PBqk=
github.com/rogpeppe/go-internal v1.12.0 h1:exVL4IDcn6na9z1rAb56Vxr+CgyK3nn3O+epU5NdKM8=
github.com/rogpeppe/go-internal v1.12.0/go.mod h1:E+RYuTGaKKdloAfM02xzb0FW3Paa99yedzYV+kq4uf4=
github.com/rogpeppe/go-internal v1.13.1 h1:KvO1DLK/DRN07sQ1LQKScxyZJuNnedQ5/wKSR38lUII=
github.com/rogpeppe/go-internal v1.13.1/go.mod h1:uMEvuHeurkdAXX61udpOXGD/AzZDWNMNyH2VO9fmH0o=
github.com/rs/xid v1.5.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg=
github.com/rs/zerolog v1.33.0 h1:1cU2KZkvPxNyfgEmhHAz/1A9Bz+llsdYzklWFzgp0r8=
github.com/rs/zerolog v1.33.0/go.mod h1:/7mN4D5sKwJLZQ2b/znpjC3/GQWY/xaDXUM0kKWRHss=
Expand All @@ -165,8 +167,8 @@ github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
github.com/tinkerbell/ipxedust v0.0.0-20240726225714-c9bd1dd89cc3 h1:d3/jj37PdUj/T+Yy43NAYHEK+homSIowJWQkDHQbLWw=
github.com/tinkerbell/ipxedust v0.0.0-20240726225714-c9bd1dd89cc3/go.mod h1:zV3E8AR1kG1PCQPFFV3VftTeYmDf29I2ivUJrdagDFA=
github.com/tinkerbell/ipxedust v0.0.0-20241012034445-f4626d47a3d8 h1:w91nBcdEy6ut5wzwddNCjlXUSc5ipmm7uu9Eu1rXPcQ=
github.com/tinkerbell/ipxedust v0.0.0-20241012034445-f4626d47a3d8/go.mod h1:zV3E8AR1kG1PCQPFFV3VftTeYmDf29I2ivUJrdagDFA=
github.com/tinkerbell/tink v0.10.1 h1:mxdPQf7n4nB/AVdjbqCm5c98vsITU35g7Yw5cdOWmCw=
github.com/tinkerbell/tink v0.10.1/go.mod h1:yULdVrzAfPnA8KdOkjvo8qDn6pw0JD6kBzF94gtXMjA=
github.com/u-root/uio v0.0.0-20230305220412-3e8cd9d6bf63 h1:YcojQL98T/OO+rybuzn2+5KrD5dBwXIvYBvQ2cD3Avg=
Expand All @@ -179,14 +181,14 @@ github.com/x448/float16 v0.8.4 h1:qLwI1I70+NjRFUR3zs1JPUCgaCXSh3SW62uAKT1mSBM=
github.com/x448/float16 v0.8.4/go.mod h1:14CWIYCyZA/cWjXOioeEpHeN/83MdbZDRQHoFcYsOfg=
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.55.0 h1:ZIg3ZT/aQ7AfKqdwp7ECpOK6vHqquXXuyTjIO8ZdmPs=
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.55.0/go.mod h1:DQAwmETtZV00skUwgD6+0U89g80NKsJE3DCKeLLPQMI=
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.56.0 h1:UP6IpuHFkUgOQL9FFQFrZ+5LiwhhYRbi7VZSIx6Nj5s=
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.56.0/go.mod h1:qxuZLtbq5QDtdeSHsS7bcf6EH6uO6jUAgk764zd3rhM=
go.opentelemetry.io/otel v1.31.0 h1:NsJcKPIW0D0H3NgzPDHmo0WW6SptzPdqg/L1zsIm2hY=
go.opentelemetry.io/otel v1.31.0/go.mod h1:O0C14Yl9FgkjqcCZAsE053C13OaddMYr/hz6clDkEJE=
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.30.0 h1:lsInsfvhVIfOI6qHVyysXMNDnjO9Npvl7tlDPJFBVd4=
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.30.0/go.mod h1:KQsVNh4OjgjTG0G6EiNi1jVpnaeeKsKMRwbLN+f1+8M=
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.30.0 h1:m0yTiGDLUvVYaTFbAvCkVYIYcvwKt3G7OLoN77NUs/8=
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.30.0/go.mod h1:wBQbT4UekBfegL2nx0Xk1vBcnzyBPsIVm9hRG4fYcr4=
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.31.0 h1:K0XaT3DwHAcV4nKLzcQvwAgSyisUghWoY20I7huthMk=
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.31.0/go.mod h1:B5Ki776z/MBnVha1Nzwp5arlzBbE3+1jk+pGmaP5HME=
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.31.0 h1:FFeLy03iVTXP6ffeN2iXrxfGsZGCjVx0/4KlizjyBwU=
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.31.0/go.mod h1:TMu73/k1CP8nBUpDLc71Wj/Kf7ZS9FK5b53VapRsP9o=
go.opentelemetry.io/otel/metric v1.31.0 h1:FSErL0ATQAmYHUIzSezZibnyVlft1ybhy4ozRPcF2fE=
go.opentelemetry.io/otel/metric v1.31.0/go.mod h1:C3dEloVbLuYoX41KpmAhOqNriGbA+qqH6PQ5E5mUfnY=
go.opentelemetry.io/otel/sdk v1.31.0 h1:xLY3abVHYZ5HSfOg3l2E5LUj2Cwva5Y7yGxnSW9H5Gk=
Expand Down Expand Up @@ -255,14 +257,14 @@ golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8T
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
gomodules.xyz/jsonpatch/v2 v2.4.0 h1:Ci3iUJyx9UeRx7CeFN8ARgGbkESwJK+KB9lLcWxY/Zw=
gomodules.xyz/jsonpatch/v2 v2.4.0/go.mod h1:AH3dM2RI6uoBZxn3LVrfvJ3E0/9dG4cSrbuBJT4moAY=
google.golang.org/genproto/googleapis/api v0.0.0-20240903143218-8af14fe29dc1 h1:hjSy6tcFQZ171igDaN5QHOw2n6vx40juYbC/x67CEhc=
google.golang.org/genproto/googleapis/api v0.0.0-20240903143218-8af14fe29dc1/go.mod h1:qpvKtACPCQhAdu3PyQgV4l3LMXZEtft7y8QcarRsp9I=
google.golang.org/genproto/googleapis/rpc v0.0.0-20240903143218-8af14fe29dc1 h1:pPJltXNxVzT4pK9yD8vR9X75DaWYYmLGMsEvBfFQZzQ=
google.golang.org/genproto/googleapis/rpc v0.0.0-20240903143218-8af14fe29dc1/go.mod h1:UqMtugtsSgubUsoxbuAoiCXvqvErP7Gf0so0mK9tHxU=
google.golang.org/genproto/googleapis/api v0.0.0-20241007155032-5fefd90f89a9 h1:T6rh4haD3GVYsgEfWExoCZA2o2FmbNyKpTuAxbEFPTg=
google.golang.org/genproto/googleapis/api v0.0.0-20241007155032-5fefd90f89a9/go.mod h1:wp2WsuBYj6j8wUdo3ToZsdxxixbvQNAHqVJrTgi5E5M=
google.golang.org/genproto/googleapis/rpc v0.0.0-20241007155032-5fefd90f89a9 h1:QCqS/PdaHTSWGvupk2F/ehwHtGc0/GYkT+3GAcR1CCc=
google.golang.org/genproto/googleapis/rpc v0.0.0-20241007155032-5fefd90f89a9/go.mod h1:GX3210XPVPUjJbTUbvwI8f2IpZDMZuPJWDzDuebbviI=
google.golang.org/grpc v1.67.1 h1:zWnc1Vrcno+lHZCOofnIMvycFcc0QRGIzm9dhnDX68E=
google.golang.org/grpc v1.67.1/go.mod h1:1gLDyUQU7CTLJI90u3nXZ9ekeghjeM7pTDZlqFNg2AA=
google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg=
google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw=
google.golang.org/protobuf v1.35.1 h1:m3LfL6/Ca+fqnjnlqQXNpFPABW1UD7mjh8KO2mKFytA=
google.golang.org/protobuf v1.35.1/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
Expand Down
7 changes: 6 additions & 1 deletion internal/backend/file/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"strings"
"sync"

"github.com/ccoveille/go-safecast"
"github.com/fsnotify/fsnotify"
"github.com/ghodss/yaml"
"github.com/go-logr/logr"
Expand Down Expand Up @@ -292,7 +293,11 @@ func (w *Watcher) translate(r dhcp) (*data.DHCP, *data.Netboot, error) {
d.VLANID = r.VLANID

// lease time
d.LeaseTime = uint32(r.LeaseTime)
// Default to one week
d.LeaseTime = 604800
if v, err := safecast.ToUint32(r.LeaseTime); err == nil {
d.LeaseTime = v
}

// arch
d.Arch = r.Arch
Expand Down
17 changes: 16 additions & 1 deletion internal/backend/kube/kube.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"net/netip"
"net/url"

"github.com/ccoveille/go-safecast"
"github.com/tinkerbell/smee/internal/dhcp/data"
"github.com/tinkerbell/tink/api/v1alpha1"
"go.opentelemetry.io/otel"
Expand Down Expand Up @@ -255,7 +256,11 @@
d.Hostname = h.Hostname

// lease time required
d.LeaseTime = uint32(h.LeaseTime)
// Default to one week
d.LeaseTime = 604800
if v, err := safecast.ToUint32(h.LeaseTime); err == nil {
d.LeaseTime = v
}

// arch
d.Arch = h.Arch
Expand Down Expand Up @@ -300,5 +305,15 @@
// facility
n.Facility = facility

// OSIE data
n.OSIE = data.OSIE{}
if i.OSIE != nil {
if b, err := url.Parse(i.OSIE.BaseURL); err == nil {
n.OSIE.BaseURL = b

Check warning on line 312 in internal/backend/kube/kube.go

View check run for this annotation

Codecov / codecov/patch

internal/backend/kube/kube.go#L311-L312

Added lines #L311 - L312 were not covered by tests
}
n.OSIE.Kernel = i.OSIE.Kernel
n.OSIE.Initrd = i.OSIE.Initrd

Check warning on line 315 in internal/backend/kube/kube.go

View check run for this annotation

Codecov / codecov/patch

internal/backend/kube/kube.go#L314-L315

Added lines #L314 - L315 were not covered by tests
}

return n, nil
}
20 changes: 10 additions & 10 deletions internal/backend/kube/kube_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ func TestNewBackend(t *testing.T) {
"no config": {shouldErr: true},
"failed index field": {shouldErr: true, conf: new(rest.Config), opt: func(o *cluster.Options) {
cl := fake.NewClientBuilder().Build()
o.NewClient = func(config *rest.Config, options client.Options) (client.Client, error) {
o.NewClient = func(*rest.Config, client.Options) (client.Client, error) {
return cl, nil
}
o.MapperProvider = func(c *rest.Config, httpClient *http.Client) (meta.RESTMapper, error) {
o.MapperProvider = func(*rest.Config, *http.Client) (meta.RESTMapper, error) {
return cl.RESTMapper(), nil
}
}},
Expand Down Expand Up @@ -217,7 +217,7 @@ func TestGetByIP(t *testing.T) {
if !tc.failToList {
ct = ct.WithScheme(rs)
ct = ct.WithRuntimeObjects(&v1alpha1.HardwareList{})
ct = ct.WithIndex(&v1alpha1.Hardware{}, IPAddrIndex, func(obj client.Object) []string {
ct = ct.WithIndex(&v1alpha1.Hardware{}, IPAddrIndex, func(client.Object) []string {
var list []string
for _, elem := range tc.hwObject {
list = append(list, elem.Spec.Interfaces[0].DHCP.IP.Address)
Expand All @@ -233,13 +233,13 @@ func TestGetByIP(t *testing.T) {
cl := ct.Build()

fn := func(o *cluster.Options) {
o.NewClient = func(config *rest.Config, options client.Options) (client.Client, error) {
o.NewClient = func(*rest.Config, client.Options) (client.Client, error) {
return cl, nil
}
o.MapperProvider = func(_ *rest.Config, _ *http.Client) (meta.RESTMapper, error) {
o.MapperProvider = func(*rest.Config, *http.Client) (meta.RESTMapper, error) {
return cl.RESTMapper(), nil
}
o.NewCache = func(config *rest.Config, options cache.Options) (cache.Cache, error) {
o.NewCache = func(*rest.Config, cache.Options) (cache.Cache, error) {
return &informertest.FakeInformers{Scheme: cl.Scheme()}, nil
}
}
Expand Down Expand Up @@ -315,7 +315,7 @@ func TestGetByMac(t *testing.T) {
if !tc.failToList {
ct = ct.WithScheme(rs)
ct = ct.WithRuntimeObjects(&v1alpha1.HardwareList{})
ct = ct.WithIndex(&v1alpha1.Hardware{}, MACAddrIndex, func(obj client.Object) []string {
ct = ct.WithIndex(&v1alpha1.Hardware{}, MACAddrIndex, func(client.Object) []string {
var list []string
for _, elem := range tc.hwObject {
list = append(list, elem.Spec.Interfaces[0].DHCP.MAC)
Expand All @@ -331,13 +331,13 @@ func TestGetByMac(t *testing.T) {
cl := ct.Build()

fn := func(o *cluster.Options) {
o.NewClient = func(config *rest.Config, options client.Options) (client.Client, error) {
o.NewClient = func(*rest.Config, client.Options) (client.Client, error) {
return cl, nil
}
o.MapperProvider = func(c *rest.Config, httpClient *http.Client) (meta.RESTMapper, error) {
o.MapperProvider = func(*rest.Config, *http.Client) (meta.RESTMapper, error) {
return cl.RESTMapper(), nil
}
o.NewCache = func(config *rest.Config, options cache.Options) (cache.Cache, error) {
o.NewCache = func(*rest.Config, cache.Options) (cache.Cache, error) {
return &informertest.FakeInformers{Scheme: cl.Scheme()}, nil
}
}
Expand Down
11 changes: 11 additions & 0 deletions internal/dhcp/data/data.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,17 @@ type Netboot struct {
IPXEScript string // Overrides a default value that is passed into DHCP on startup.
Console string
Facility string
OSIE OSIE
}

// OSIE or OS Installation Environment is the data about where the OSIE parts are located.
type OSIE struct {
// BaseURL is the URL where the OSIE parts are located.
BaseURL *url.URL
// Kernel is the name of the kernel file.
Kernel string
// Initrd is the name of the initrd file.
Initrd string
}

// EncodeToAttributes returns a slice of opentelemetry attributes that can be used to set span.SetAttributes.
Expand Down
3 changes: 2 additions & 1 deletion internal/dhcp/dhcp.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package dhcp
import (
"bytes"
"encoding/hex"
"errors"
"fmt"
"net"
"net/netip"
Expand Down Expand Up @@ -255,7 +256,7 @@ func IsNetbootClient(pkt *dhcpv4.DHCPv4) error {

func wrapNonNil(err error, format string) error {
if err == nil {
return fmt.Errorf(format)
return errors.New(format)
}

return fmt.Errorf("%w: %v", err, format)
Expand Down
2 changes: 1 addition & 1 deletion internal/ipxe/http/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@
}

func (s *Config) serveHealthchecker(rev string, start time.Time) http.HandlerFunc {
return func(w http.ResponseWriter, req *http.Request) {
return func(w http.ResponseWriter, _ *http.Request) {

Check warning on line 93 in internal/ipxe/http/http.go

View check run for this annotation

Codecov / codecov/patch

internal/ipxe/http/http.go#L93

Added line #L93 was not covered by tests
w.Header().Set("Content-Type", "application/json")
res := struct {
GitRev string `json:"git_rev"`
Expand Down
12 changes: 8 additions & 4 deletions internal/ipxe/script/auto_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,19 +34,21 @@ echo Loading the Tinkerbell Hook iPXE script...

set arch x86_64
set download-url http://location:8080/to/kernel/and/initrd
set kernel vmlinuz-${arch}
set initrd initramfs-${arch}
set retries:int32 10
set retry_delay:int32 3

set idx:int32 0
:retry_kernel
kernel ${download-url}/vmlinuz-${arch} tink_worker_image=quay.io/tinkerbell/tink-worker:v0.8.0 tinkerbell=packet \
kernel ${download-url}/${kernel} tink_worker_image=quay.io/tinkerbell/tink-worker:v0.8.0 tinkerbell=packet \
facility=onprem syslog_host=1.2.3.4 grpc_authority=1.2.3.4:42113 tinkerbell_tls=false tinkerbell_insecure_tls=false worker_id=3c:ec:ef:4c:4f:54 hw_addr=3c:ec:ef:4c:4f:54 \
modules=loop,squashfs,sd-mod,usb-storage intel_iommu=on iommu=pt initrd=initramfs-${arch} console=tty0 console=ttyS1,115200 && goto download_initrd || iseq ${idx} ${retries} && goto kernel-error || inc idx && echo retry in ${retry_delay} seconds ; sleep ${retry_delay} ; goto retry_kernel

:download_initrd
set idx:int32 0
:retry_initrd
initrd ${download-url}/initramfs-${arch} && goto boot || iseq ${idx} ${retries} && goto initrd-error || inc idx && echo retry in ${retry_delay} seconds ; sleep ${retry_delay} ; goto retry_initrd
initrd ${download-url}/${initrd} && goto boot || iseq ${idx} ${retries} && goto initrd-error || inc idx && echo retry in ${retry_delay} seconds ; sleep ${retry_delay} ; goto retry_initrd

:boot
set idx:int32 0
Expand Down Expand Up @@ -91,19 +93,21 @@ echo Loading the Tinkerbell Hook iPXE script...

set arch x86_64
set download-url http://location:8080/to/kernel/and/initrd
set kernel vmlinuz-${arch}
set initrd initramfs-${arch}
set retries:int32 10
set retry_delay:int32 3

set idx:int32 0
:retry_kernel
kernel ${download-url}/vmlinuz-${arch} vlan_id=16 tink_worker_image=quay.io/tinkerbell/tink-worker:v0.8.0 tinkerbell=packet \
kernel ${download-url}/${kernel} vlan_id=16 tink_worker_image=quay.io/tinkerbell/tink-worker:v0.8.0 tinkerbell=packet \
facility=onprem syslog_host=1.2.3.4 grpc_authority=1.2.3.4:42113 tinkerbell_tls=false tinkerbell_insecure_tls=false worker_id=3c:ec:ef:4c:4f:54 hw_addr=3c:ec:ef:4c:4f:54 \
modules=loop,squashfs,sd-mod,usb-storage intel_iommu=on iommu=pt initrd=initramfs-${arch} console=tty0 console=ttyS1,115200 && goto download_initrd || iseq ${idx} ${retries} && goto kernel-error || inc idx && echo retry in ${retry_delay} seconds ; sleep ${retry_delay} ; goto retry_kernel

:download_initrd
set idx:int32 0
:retry_initrd
initrd ${download-url}/initramfs-${arch} && goto boot || iseq ${idx} ${retries} && goto initrd-error || inc idx && echo retry in ${retry_delay} seconds ; sleep ${retry_delay} ; goto retry_initrd
initrd ${download-url}/${initrd} && goto boot || iseq ${idx} ${retries} && goto initrd-error || inc idx && echo retry in ${retry_delay} seconds ; sleep ${retry_delay} ; goto retry_initrd

:boot
set idx:int32 0
Expand Down
Loading
Loading