Skip to content
Open
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,4 @@ examples/sidecar/templates/python/__pycache__/*
.settings
CLAUDE.md
.dagger
openapi-gen
40 changes: 0 additions & 40 deletions ci/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,46 +2,6 @@ module dagger/interlink

go 1.24.0

Copy link

Copilot AI Mar 25, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ci/go.mod now has only replace directives and no require block, and ci/go.sum is empty. Since this module depends on generated Dagger Go SDK code (ci/.gitignore ignores internal/dagger, etc.), builds can become non-reproducible or fail under -mod=readonly once the generated code imports external modules. Consider regenerating the Dagger SDK and committing the resulting go.mod/go.sum requirements (or documenting why deps should be unpinned).

Suggested change
require (
go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploggrpc v0.14.0
go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploghttp v0.14.0
go.opentelemetry.io/otel/log v0.14.0
go.opentelemetry.io/otel/sdk/log v0.14.0
)

Copilot uses AI. Check for mistakes.
require (
github.com/99designs/gqlgen v0.17.80
github.com/Khan/genqlient v0.8.1
github.com/vektah/gqlparser/v2 v2.5.30
go.opentelemetry.io/otel v1.38.0
go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploggrpc v0.14.0
go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploghttp v0.14.0
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.38.0
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.38.0
go.opentelemetry.io/otel/log v0.14.0
go.opentelemetry.io/otel/sdk v1.38.0
go.opentelemetry.io/otel/sdk/log v0.14.0
go.opentelemetry.io/otel/trace v1.38.0
go.opentelemetry.io/proto/otlp v1.8.0
golang.org/x/sync v0.17.0
google.golang.org/grpc v1.75.1
)

require (
github.com/cenkalti/backoff/v5 v5.0.3 // indirect
github.com/go-logr/logr v1.4.3 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/grpc-ecosystem/grpc-gateway/v2 v2.27.2 // indirect
github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3 // indirect
github.com/sosodev/duration v1.3.1 // indirect
go.opentelemetry.io/auto/sdk v1.1.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc v1.38.0
go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetrichttp v1.38.0
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.38.0 // indirect
go.opentelemetry.io/otel/metric v1.38.0
go.opentelemetry.io/otel/sdk/metric v1.38.0
golang.org/x/net v0.44.0 // indirect
golang.org/x/sys v0.36.0 // indirect
golang.org/x/text v0.29.0 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20250825161204-c5933d9347a5 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20250825161204-c5933d9347a5 // indirect
google.golang.org/protobuf v1.36.9 // indirect
)

replace go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploggrpc => go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploggrpc v0.14.0

replace go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploghttp => go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploghttp v0.14.0
Expand Down
99 changes: 0 additions & 99 deletions ci/go.sum
Original file line number Diff line number Diff line change
@@ -1,99 +0,0 @@
github.com/99designs/gqlgen v0.17.80 h1:S64VF9SK+q3JjQbilgdrM0o4iFQgB54mVQ3QvXEO4Ek=
github.com/99designs/gqlgen v0.17.80/go.mod h1:vgNcZlLwemsUhYim4dC1pvFP5FX0pr2Y+uYUoHFb1ig=
github.com/Khan/genqlient v0.8.1 h1:wtOCc8N9rNynRLXN3k3CnfzheCUNKBcvXmVv5zt6WCs=
github.com/Khan/genqlient v0.8.1/go.mod h1:R2G6DzjBvCbhjsEajfRjbWdVglSH/73kSivC9TLWVjU=
github.com/andreyvit/diff v0.0.0-20170406064948-c7f18ee00883 h1:bvNMNQO63//z+xNgfBlViaCIJKLlCJ6/fmUseuG0wVQ=
github.com/andreyvit/diff v0.0.0-20170406064948-c7f18ee00883/go.mod h1:rCTlJbsFo29Kk6CurOXKm700vrz8f0KW0JNfpkRJY/8=
github.com/cenkalti/backoff/v5 v5.0.3 h1:ZN+IMa753KfX5hd8vVaMixjnqRZ3y8CuJKRKj1xcsSM=
github.com/cenkalti/backoff/v5 v5.0.3/go.mod h1:rkhZdG3JZukswDf7f0cwqPNk4K0sa+F97BxZthm/crw=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=
github.com/go-logr/logr v1.4.3 h1:CjnDlHq8ikf6E492q6eKboGOC0T8CDaOvkHCIg8idEI=
github.com/go-logr/logr v1.4.3/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag=
github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE=
github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek=
github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps=
github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8=
github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU=
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/grpc-ecosystem/grpc-gateway/v2 v2.27.2 h1:8Tjv8EJ+pM1xP8mK6egEbD1OgnVTyacbefKhmbLhIhU=
github.com/grpc-ecosystem/grpc-gateway/v2 v2.27.2/go.mod h1:pkJQ2tZHJ0aFOVEEot6oZmaVEZcRme73eIFmhiVuRWs=
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3 h1:n661drycOFuPLCN3Uc8sB6B/s6Z4t2xvBgU1htSHuq8=
github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3/go.mod h1:A0bzQcvG0E7Rwjx0REVgAGH58e96+X0MeOfepqsbeW4=
github.com/sosodev/duration v1.3.1 h1:qtHBDMQ6lvMQsL15g4aopM4HEfOaYuhWBw3NPTtlqq4=
github.com/sosodev/duration v1.3.1/go.mod h1:RQIBBX0+fMLc/D9+Jb/fwvVmo0eZvDDEERAikUR6SDg=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U=
github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U=
github.com/vektah/gqlparser/v2 v2.5.30 h1:EqLwGAFLIzt1wpx1IPpY67DwUujF1OfzgEyDsLrN6kE=
github.com/vektah/gqlparser/v2 v2.5.30/go.mod h1:D1/VCZtV3LPnQrcPBeR/q5jkSQIPti0uYCP/RI0gIeo=
go.opentelemetry.io/auto/sdk v1.1.0 h1:cH53jehLUN6UFLY71z+NDOiNJqDdPRaXzTel0sJySYA=
go.opentelemetry.io/auto/sdk v1.1.0/go.mod h1:3wSPjt5PWp2RhlCcmmOial7AvC4DQqZb7a7wCow3W8A=
go.opentelemetry.io/otel v1.38.0 h1:RkfdswUDRimDg0m2Az18RKOsnI8UDzppJAtj01/Ymk8=
go.opentelemetry.io/otel v1.38.0/go.mod h1:zcmtmQ1+YmQM9wrNsTGV/q/uyusom3P8RxwExxkZhjM=
go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploggrpc v0.14.0 h1:OMqPldHt79PqWKOMYIAQs3CxAi7RLgPxwfFSwr4ZxtM=
go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploggrpc v0.14.0/go.mod h1:1biG4qiqTxKiUCtoWDPpL3fB3KxVwCiGw81j3nKMuHE=
go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploghttp v0.14.0 h1:QQqYw3lkrzwVsoEX0w//EhH/TCnpRdEenKBOOEIMjWc=
go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploghttp v0.14.0/go.mod h1:gSVQcr17jk2ig4jqJ2DX30IdWH251JcNAecvrqTxH1s=
go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc v1.38.0 h1:vl9obrcoWVKp/lwl8tRE33853I8Xru9HFbw/skNeLs8=
go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc v1.38.0/go.mod h1:GAXRxmLJcVM3u22IjTg74zWBrRCKq8BnOqUVLodpcpw=
go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetrichttp v1.38.0 h1:Oe2z/BCg5q7k4iXC3cqJxKYg0ieRiOqF0cecFYdPTwk=
go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetrichttp v1.38.0/go.mod h1:ZQM5lAJpOsKnYagGg/zV2krVqTtaVdYdDkhMoX6Oalg=
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.38.0 h1:GqRJVj7UmLjCVyVJ3ZFLdPRmhDUp2zFmQe3RHIOsw24=
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.38.0/go.mod h1:ri3aaHSmCTVYu2AWv44YMauwAQc0aqI9gHKIcSbI1pU=
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.38.0 h1:lwI4Dc5leUqENgGuQImwLo4WnuXFPetmPpkLi2IrX54=
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.38.0/go.mod h1:Kz/oCE7z5wuyhPxsXDuaPteSWqjSBD5YaSdbxZYGbGk=
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.38.0 h1:aTL7F04bJHUlztTsNGJ2l+6he8c+y/b//eR0jjjemT4=
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.38.0/go.mod h1:kldtb7jDTeol0l3ewcmd8SDvx3EmIE7lyvqbasU3QC4=
go.opentelemetry.io/otel/log v0.14.0 h1:2rzJ+pOAZ8qmZ3DDHg73NEKzSZkhkGIua9gXtxNGgrM=
go.opentelemetry.io/otel/log v0.14.0/go.mod h1:5jRG92fEAgx0SU/vFPxmJvhIuDU9E1SUnEQrMlJpOno=
go.opentelemetry.io/otel/metric v1.38.0 h1:Kl6lzIYGAh5M159u9NgiRkmoMKjvbsKtYRwgfrA6WpA=
go.opentelemetry.io/otel/metric v1.38.0/go.mod h1:kB5n/QoRM8YwmUahxvI3bO34eVtQf2i4utNVLr9gEmI=
go.opentelemetry.io/otel/sdk v1.38.0 h1:l48sr5YbNf2hpCUj/FoGhW9yDkl+Ma+LrVl8qaM5b+E=
go.opentelemetry.io/otel/sdk v1.38.0/go.mod h1:ghmNdGlVemJI3+ZB5iDEuk4bWA3GkTpW+DOoZMYBVVg=
go.opentelemetry.io/otel/sdk/log v0.14.0 h1:JU/U3O7N6fsAXj0+CXz21Czg532dW2V4gG1HE/e8Zrg=
go.opentelemetry.io/otel/sdk/log v0.14.0/go.mod h1:imQvII+0ZylXfKU7/wtOND8Hn4OpT3YUoIgqJVksUkM=
go.opentelemetry.io/otel/sdk/log/logtest v0.14.0 h1:Ijbtz+JKXl8T2MngiwqBlPaHqc4YCaP/i13Qrow6gAM=
go.opentelemetry.io/otel/sdk/log/logtest v0.14.0/go.mod h1:dCU8aEL6q+L9cYTqcVOk8rM9Tp8WdnHOPLiBgp0SGOA=
go.opentelemetry.io/otel/sdk/metric v1.38.0 h1:aSH66iL0aZqo//xXzQLYozmWrXxyFkBJ6qT5wthqPoM=
go.opentelemetry.io/otel/sdk/metric v1.38.0/go.mod h1:dg9PBnW9XdQ1Hd6ZnRz689CbtrUp0wMMs9iPcgT9EZA=
go.opentelemetry.io/otel/trace v1.38.0 h1:Fxk5bKrDZJUH+AMyyIXGcFAPah0oRcT+LuNtJrmcNLE=
go.opentelemetry.io/otel/trace v1.38.0/go.mod h1:j1P9ivuFsTceSWe1oY+EeW3sc+Pp42sO++GHkg4wwhs=
go.opentelemetry.io/proto/otlp v1.8.0 h1:fRAZQDcAFHySxpJ1TwlA1cJ4tvcrw7nXl9xWWC8N5CE=
go.opentelemetry.io/proto/otlp v1.8.0/go.mod h1:tIeYOeNBU4cvmPqpaji1P+KbB4Oloai8wN4rWzRrFF0=
go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto=
go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE=
golang.org/x/net v0.44.0 h1:evd8IRDyfNBMBTTY5XRF1vaZlD+EmWx6x8PkhR04H/I=
golang.org/x/net v0.44.0/go.mod h1:ECOoLqd5U3Lhyeyo/QDCEVQ4sNgYsqvCZ722XogGieY=
golang.org/x/sync v0.17.0 h1:l60nONMj9l5drqw6jlhIELNv9I0A4OFgRsG9k2oT9Ug=
golang.org/x/sync v0.17.0/go.mod h1:9KTHXmSnoGruLpwFjVSX0lNNA75CykiMECbovNTZqGI=
golang.org/x/sys v0.36.0 h1:KVRy2GtZBrk1cBYA7MKu5bEZFxQk4NIDV6RLVcC8o0k=
golang.org/x/sys v0.36.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks=
golang.org/x/text v0.29.0 h1:1neNs90w9YzJ9BocxfsQNHKuAT4pkghyXc4nhZ6sJvk=
golang.org/x/text v0.29.0/go.mod h1:7MhJOA9CD2qZyOKYazxdYMF85OwPdEr9jTtBpO7ydH4=
gonum.org/v1/gonum v0.16.0 h1:5+ul4Swaf3ESvrOnidPp4GZbzf0mxVQpDCYUQE7OJfk=
gonum.org/v1/gonum v0.16.0/go.mod h1:fef3am4MQ93R2HHpKnLk4/Tbh/s0+wqD5nfa6Pnwy4E=
google.golang.org/genproto/googleapis/api v0.0.0-20250825161204-c5933d9347a5 h1:BIRfGDEjiHRrk0QKZe3Xv2ieMhtgRGeLcZQ0mIVn4EY=
google.golang.org/genproto/googleapis/api v0.0.0-20250825161204-c5933d9347a5/go.mod h1:j3QtIyytwqGr1JUDtYXwtMXWPKsEa5LtzIFN1Wn5WvE=
google.golang.org/genproto/googleapis/rpc v0.0.0-20250825161204-c5933d9347a5 h1:eaY8u2EuxbRv7c3NiGK0/NedzVsCcV6hDuU5qPX5EGE=
google.golang.org/genproto/googleapis/rpc v0.0.0-20250825161204-c5933d9347a5/go.mod h1:M4/wBTSeyLxupu3W3tJtOgB14jILAS/XWPSSa3TAlJc=
google.golang.org/grpc v1.75.1 h1:/ODCNEuf9VghjgO3rqLcfg8fiOP0nSluljWFlDxELLI=
google.golang.org/grpc v1.75.1/go.mod h1:JtPAzKiq4v1xcAB2hydNlWI2RnF85XXcV0mhKXr2ecQ=
google.golang.org/protobuf v1.36.9 h1:w2gp2mA27hUeUzj9Ex9FBjsBm40zfaDtEWow293U7Iw=
google.golang.org/protobuf v1.36.9/go.mod h1:fuxRtAxBytpl4zzqUh6/eyUujkJdNiuEkXntxiD/uRU=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
134 changes: 101 additions & 33 deletions cmd/openapi-gen/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,41 +14,42 @@
)

func main() {
version := flag.String("version", "0.4.0", "generate API spec for this version")
version := flag.String("version", "0.6.0", "generate API spec for this version")
flag.Parse()

generateInterlinkSpec(*version)
generatePluginSpec(*version)
}

// generateInterlinkSpec generates the OpenAPI spec for the Virtual Kubelet to interLink API
// server communication and writes it to ./docs/openapi/interlink-openapi.json.
func generateInterlinkSpec(version string) {
reflector := openapi3.Reflector{}
reflector.Spec = &openapi3.Spec{Openapi: "3.0.3"}
Copy link

Copilot AI Mar 25, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OpenAPI 3.0.3 is a poor fit for this API because several endpoints use JSON request bodies with GET/DELETE. Many OpenAPI 3.0 consumers omit/ignore request bodies for those methods, and the regenerated specs end up dropping the request schema for /status, /getLogs, and /delete even though the runtime sends/reads JSON bodies. Consider emitting OpenAPI 3.1.0 (or remodeling those endpoints) so the request contracts are actually captured.

Suggested change
reflector.Spec = &openapi3.Spec{Openapi: "3.0.3"}
reflector.Spec = &openapi3.Spec{Openapi: "3.1.0"}

Copilot uses AI. Check for mistakes.
reflector.Spec.Info.
WithTitle("interLink server API").
WithVersion(*version).
WithVersion(version).
WithDescription("This is the API spec for the Virtual Kubelet to interLink API server communication")

// CREATE: VK sends PodCreateRequests; interLink proxies back the plugin's CreateStruct response.
createOp, err := reflector.NewOperationContext(http.MethodPost, "/create")
if err != nil {
panic(err)
}

// CREATE
createOp.AddReqStructure(new(interlink.PodCreateRequests))
createOp.AddRespStructure(new(interlink.RetrievedPodData), func(cu *openapi.ContentUnit) { cu.HTTPStatus = http.StatusOK })

err = reflector.AddOperation(createOp)
if err != nil {
createOp.AddReqStructure(new(interlink.PodCreateRequests), withRequiredBody)
createOp.AddRespStructure(new(interlink.CreateStruct), func(cu *openapi.ContentUnit) { cu.HTTPStatus = http.StatusOK })
if err = reflector.AddOperation(createOp); err != nil {
Comment thread
dciangot marked this conversation as resolved.
panic(err)
}

// DELETE
deleteOp, err := reflector.NewOperationContext(http.MethodPost, "/delete")
// DELETE: VK sends DELETE to interLink.

Check notice on line 45 in cmd/openapi-gen/main.go

View workflow job for this annotation

GitHub Actions / Check duplicated code

Copy/pasted code

see cmd/openapi-gen/main.go (110-116)
deleteOp, err := reflector.NewOperationContext(http.MethodDelete, "/delete")
if err != nil {
panic(err)
}

deleteOp.AddReqStructure(new(corev1.Pod))
deleteOp.AddRespStructure(nil, func(cu *openapi.ContentUnit) { cu.HTTPStatus = http.StatusOK })

err = reflector.AddOperation(deleteOp)
if err != nil {
if err = reflector.AddOperation(deleteOp); err != nil {
panic(err)
}

Expand All @@ -57,60 +58,127 @@
if err != nil {
panic(err)
}

pingOp.AddReqStructure(nil)
pingOp.AddRespStructure(nil, func(cu *openapi.ContentUnit) { cu.HTTPStatus = http.StatusOK })
if err = reflector.AddOperation(pingOp); err != nil {
panic(err)
}

err = reflector.AddOperation(pingOp)
// Status: VK uses GET with a JSON body.
statusOp, err := reflector.NewOperationContext(http.MethodGet, "/status")
if err != nil {
panic(err)
}
statusOp.AddReqStructure(new([]corev1.Pod))
statusOp.AddRespStructure(new([]interlink.PodStatus), func(cu *openapi.ContentUnit) { cu.HTTPStatus = http.StatusOK })
if err = reflector.AddOperation(statusOp); err != nil {
panic(err)
}

// Status
statusOp, err := reflector.NewOperationContext(http.MethodPost, "/status")
// Logs: VK uses GET with a JSON body; response is streamed plain text.

Check notice on line 78 in cmd/openapi-gen/main.go

View workflow job for this annotation

GitHub Actions / Check duplicated code

Copy/pasted code

see cmd/openapi-gen/main.go (128-138)
logsOp, err := reflector.NewOperationContext(http.MethodGet, "/getLogs")
if err != nil {
panic(err)
}
logsOp.AddReqStructure(new(interlink.LogStruct))
logsOp.AddRespStructure(nil, func(cu *openapi.ContentUnit) {
cu.HTTPStatus = http.StatusOK
cu.ContentType = "text/plain"
})
if err = reflector.AddOperation(logsOp); err != nil {
panic(err)
}

statusOp.AddReqStructure(new([]corev1.Pod))
statusOp.AddRespStructure(new([]interlink.PodStatus), func(cu *openapi.ContentUnit) { cu.HTTPStatus = http.StatusOK })
writeSpec(reflector, "./docs/openapi/interlink-openapi.json")

Check notice on line 92 in cmd/openapi-gen/main.go

View workflow job for this annotation

GitHub Actions / Check duplicated code

Copy/pasted code

see cmd/openapi-gen/main.go (139-152)
}

// generatePluginSpec generates the OpenAPI spec for the interLink API server to plugin
// (sidecar) communication and writes it to ./docs/openapi/plugin-openapi.json.
func generatePluginSpec(version string) {
reflector := openapi3.Reflector{}
reflector.Spec = &openapi3.Spec{Openapi: "3.0.3"}
reflector.Spec.Info.
WithTitle("interLink Plugin API").
Comment on lines +98 to +101
Copy link

Copilot AI Mar 25, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same OpenAPI version issue for the plugin spec: with Openapi: "3.0.3", the generated spec currently has no request schema for /status and /getLogs even though interLink sends JSON bodies in those GET requests. Switching to OpenAPI 3.1.0 (or remodeling the endpoints) would allow the spec to represent the actual request payloads.

Copilot uses AI. Check for mistakes.
WithVersion(version).
WithDescription("This is the API spec for the interLink API server to plugin (sidecar) communication")

err = reflector.AddOperation(statusOp)
// CREATE: interLink sends RetrievedPodData (including jobConfig and jobScript); plugin returns CreateStruct.
createOp, err := reflector.NewOperationContext(http.MethodPost, "/create")
if err != nil {
panic(err)
}
createOp.AddReqStructure(new(interlink.RetrievedPodData), withRequiredBody)
createOp.AddRespStructure(new(interlink.CreateStruct), func(cu *openapi.ContentUnit) { cu.HTTPStatus = http.StatusOK })
if err = reflector.AddOperation(createOp); err != nil {
panic(err)
}

// Logs
logsOp, err := reflector.NewOperationContext(http.MethodPost, "/getLogs")
// DELETE

Check notice on line 116 in cmd/openapi-gen/main.go

View workflow job for this annotation

GitHub Actions / Check duplicated code

Copy/pasted code

see cmd/openapi-gen/main.go (39-45)
deleteOp, err := reflector.NewOperationContext(http.MethodPost, "/delete")
if err != nil {
panic(err)
}
deleteOp.AddReqStructure(new(corev1.Pod), withRequiredBody)
deleteOp.AddRespStructure(nil, func(cu *openapi.ContentUnit) { cu.HTTPStatus = http.StatusOK })
if err = reflector.AddOperation(deleteOp); err != nil {
panic(err)
}

logsOp.AddReqStructure(new(interlink.LogStruct))
logsOp.AddRespStructure(new(string), func(cu *openapi.ContentUnit) { cu.HTTPStatus = http.StatusOK })
// Status: interLink calls the plugin with GET and a JSON body.
statusOp, err := reflector.NewOperationContext(http.MethodGet, "/status")
if err != nil {
panic(err)
}
statusOp.AddReqStructure(new([]corev1.Pod))
statusOp.AddRespStructure(new([]interlink.PodStatus), func(cu *openapi.ContentUnit) { cu.HTTPStatus = http.StatusOK })
if err = reflector.AddOperation(statusOp); err != nil {
panic(err)
}

err = reflector.AddOperation(logsOp)
// Logs: interLink calls the plugin with GET; response is streamed plain text.

Check notice on line 138 in cmd/openapi-gen/main.go

View workflow job for this annotation

GitHub Actions / Check duplicated code

Copy/pasted code

see cmd/openapi-gen/main.go (68-78)
logsOp, err := reflector.NewOperationContext(http.MethodGet, "/getLogs")
if err != nil {
panic(err)
}
logsOp.AddReqStructure(new(interlink.LogStruct))
logsOp.AddRespStructure(nil, func(cu *openapi.ContentUnit) {
cu.HTTPStatus = http.StatusOK
cu.ContentType = "text/plain"
})
if err = reflector.AddOperation(logsOp); err != nil {
panic(err)
}

writeSpec(reflector, "./docs/openapi/plugin-openapi.json")

Check notice on line 152 in cmd/openapi-gen/main.go

View workflow job for this annotation

GitHub Actions / Check duplicated code

Copy/pasted code

see cmd/openapi-gen/main.go (79-92)
}

// withRequiredBody is a ContentOption that marks a request body as required in the OpenAPI spec.
// Handlers that unmarshal from the request body will fail on empty bodies, so the spec should
// reflect that the body is mandatory.
func withRequiredBody(cu *openapi.ContentUnit) {
cu.Customize = func(cor openapi.ContentOrReference) {
if rbr, ok := cor.(*openapi3.RequestBodyOrRef); ok {
rbr.RequestBodyEns().WithRequired(true)
}
}
}

// writeSpec marshals the reflector's spec to JSON and writes it to the given file path.
func writeSpec(reflector openapi3.Reflector, path string) {
schema, err := reflector.Spec.MarshalJSON()
if err != nil {
log.Fatal(err)
}
fmt.Println(string(schema))

// Write the JSON data to the file
file, err := os.Create("./docs/openapi/interlink-openapi.json")
file, err := os.Create(path)
if err != nil {
panic(err)
}
defer file.Close()

_, err = file.Write(schema)
if err != nil {
if _, err = file.Write(schema); err != nil {
panic(err)
}

fmt.Println("Successfully wrote to ./docs/openapi/interlink-openapi.json")
fmt.Printf("Successfully wrote to %s\n", path)
}
Loading
Loading