Skip to content

Commit 1921309

Browse files
committed
Add bind dev command and updage golang to fix linter
Signed-off-by: Mangirdas Judeikis <mangirdas@judeikis.lt> On-behalf-of: @SAP mangirdas.judeikis@sap.com
1 parent f66ba4f commit 1921309

48 files changed

Lines changed: 2582 additions & 933 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/ci.yaml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ jobs:
3030
- uses: actions/checkout@v4
3131
- uses: actions/setup-go@v5
3232
with:
33-
go-version: v1.24.0
33+
go-version: v1.25.4
3434
- uses: actions/setup-node@v4
3535
with:
3636
node-version: '20'
@@ -45,7 +45,7 @@ jobs:
4545
- uses: actions/checkout@v4
4646
- uses: actions/setup-go@v5
4747
with:
48-
go-version: v1.24.0
48+
go-version: v1.25.4
4949
- uses: actions/setup-node@v4
5050
with:
5151
node-version: '20'
@@ -60,7 +60,7 @@ jobs:
6060
- uses: actions/checkout@v4
6161
- uses: actions/setup-go@v5
6262
with:
63-
go-version: v1.24.0
63+
go-version: v1.25.4
6464
- run: make test
6565

6666
lint:
@@ -70,7 +70,7 @@ jobs:
7070
- uses: actions/checkout@v4
7171
- uses: actions/setup-go@v5
7272
with:
73-
go-version: v1.24.0
73+
go-version: v1.25.4
7474
- run: make lint
7575

7676
verify:
@@ -80,5 +80,5 @@ jobs:
8080
- uses: actions/checkout@v4
8181
- uses: actions/setup-go@v5
8282
with:
83-
go-version: v1.24.0
83+
go-version: v1.25.4
8484
- run: make verify

.github/workflows/docs-gen-and-push.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ jobs:
3434

3535
- uses: actions/setup-go@v5
3636
with:
37-
go-version: v1.24.0
37+
go-version: v1.25.4
3838
cache: true
3939

4040
- uses: actions/setup-python@v5

.github/workflows/goreleaser.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
fetch-depth: 0
2323
- uses: actions/setup-go@v5
2424
with:
25-
go-version: v1.24.0
25+
go-version: v1.25.4
2626
- name: Delete non-semver tags
2727
run: 'git tag -d $(git tag -l | grep -v "^v")'
2828
- name: Run GoReleaser on tag

.github/workflows/image.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
- uses: actions/checkout@v4
2020
- uses: actions/setup-go@v5
2121
with:
22-
go-version: v1.24.0
22+
go-version: v1.25.4
2323
check-latest: true
2424

2525
# We need this to remove local tags that are not semver so goreleaser doesn't get confused.

.ko.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
baseImageOverrides:
2-
github.com/google/ko: golang:1.24.0
2+
github.com/google/ko: golang:1.25.4
33

44
builds:
55
- id: konnector

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ ENV VITE_BUILD_TARGET=docker
3939
RUN npm run build
4040

4141
# Build Go binary with embedded UI assets
42-
FROM golang:1.24.0 AS go-build-env
42+
FROM golang:1.25.4 AS go-build-env
4343
WORKDIR /app
4444

4545
# Accept build arguments for multi-arch support

Dockerfile.konnector

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
FROM golang:1.24.0 AS builder
15+
FROM golang:1.25.4 AS builder
1616
WORKDIR /app
1717

1818
# Accept build arguments for multi-arch support

Makefile

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -171,11 +171,6 @@ fix-lint: $(GOLANGCI_LINT) ## Run golangci-lint with --fix
171171
GOLANGCI_LINT_FLAGS="--fix" $(MAKE) lint
172172
.PHONY: fix-lint
173173

174-
vendor: ## Vendor the dependencies
175-
go mod tidy
176-
go mod vendor
177-
.PHONY: vendor
178-
179174
tools: $(GOLANGCI_LINT) $(CONTROLLER_GEN) $(YAML_PATCH) $(GOTESTSUM) $(CODE_GENERATOR) ## Install tools
180175
.PHONY: tools
181176

@@ -364,7 +359,7 @@ verify-modules: modules # Verify go modules are up to date
364359
done
365360

366361
.PHONY: verify
367-
verify: verify-modules verify-go-versions verify-imports verify-codegen verify-boilerplate ## verify formal properties of the code
362+
verify: verify-go-versions verify-imports verify-codegen verify-boilerplate ## verify formal properties of the code
368363

369364
.PHONY: help
370365
help: ## Show this help

backend/oidc/oidc.go

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ import (
2222
"fmt"
2323
"net"
2424
"os"
25-
"path"
2625
"time"
2726

27+
"github.com/davecgh/go-spew/spew"
2828
"github.com/gorilla/mux"
2929
"github.com/xrstf/mockoidc"
3030
)
@@ -34,7 +34,7 @@ type Server struct {
3434
tlsConfig *tls.Config
3535
}
3636

37-
func New(caBundleFile string, listener net.Listener) (*Server, error) {
37+
func New(caBundleFile string, listener net.Listener, addrOverride string) (*Server, error) {
3838
// Add offline_access to supported scopes for refresh token support
3939
ensureOfflineAccessScope()
4040
var tlsConfig *tls.Config
@@ -49,8 +49,9 @@ func New(caBundleFile string, listener net.Listener) (*Server, error) {
4949
}
5050

5151
server, err := mockoidc.NewServer(&mockoidc.ServerConfig{
52-
TLSConfig: tlsConfig,
53-
Listener: listener,
52+
TLSConfig: tlsConfig,
53+
Listener: listener,
54+
AddrOverride: addrOverride,
5455
})
5556
if err != nil {
5657
return nil, fmt.Errorf("failed to create mock OIDC server: %w", err)
@@ -70,8 +71,9 @@ type Config struct {
7071

7172
CodeChallengeMethodsSupported []string
7273

73-
// CallbackURL is kube-bind specific and must match API server endpoints.
74+
// CallbackURL and IssuerURL are kube-bind specific and must match API server endpoints.
7475
CallbackURL string
76+
IssuerURL string
7577
}
7678

7779
var ErrServerNotRunning = fmt.Errorf("embedded OIDC server is not running")
@@ -85,18 +87,21 @@ func (s *Server) AddRoutes(mux *mux.Router) {
8587
}
8688

8789
// URL returns the base URL of the embedded OIDC server.
88-
func (s *Server) Config() (*Config, error) {
89-
return &Config{
90+
func (s *Server) Config(callbackURL, issuerURL string) (*Config, error) {
91+
c := &Config{
9092
ClientID: s.server.Config().ClientID,
9193
ClientSecret: s.server.Config().ClientSecret,
92-
Issuer: s.server.Config().Issuer,
94+
Issuer: issuerURL, // This overrided default fake OIDC issuer URL. Must match what it is served at.
9395

9496
AccessTTL: s.server.Config().AccessTTL,
9597
RefreshTTL: s.server.Config().RefreshTTL,
9698

9799
CodeChallengeMethodsSupported: s.server.Config().CodeChallengeMethodsSupported,
98-
CallbackURL: path.Join(s.server.Addr(), "api/callback"),
99-
}, nil
100+
CallbackURL: callbackURL,
101+
IssuerURL: issuerURL,
102+
}
103+
spew.Dump(c)
104+
return c, nil
100105
}
101106

102107
func LoadTLSConfig(caFile string) (*tls.Config, error) {

backend/options/oidc.go

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,15 @@ import (
2626
"github.com/kube-bind/kube-bind/backend/oidc"
2727
)
2828

29+
type OIDCType string
30+
31+
const (
32+
OIDCTypeEmbedded OIDCType = "embedded"
33+
OIDCTypeExternal OIDCType = "external"
34+
)
35+
2936
type OIDC struct {
37+
Type string
3038
IssuerClientID string
3139
IssuerClientSecret string
3240
IssuerURL string
@@ -40,7 +48,9 @@ type OIDC struct {
4048
}
4149

4250
func NewOIDC() *OIDC {
43-
return &OIDC{}
51+
return &OIDC{
52+
Type: string(OIDCTypeExternal),
53+
}
4454
}
4555

4656
func (options *OIDC) AddFlags(fs *pflag.FlagSet) {
@@ -50,17 +60,18 @@ func (options *OIDC) AddFlags(fs *pflag.FlagSet) {
5060
fs.StringVar(&options.CallbackURL, "oidc-callback-url", options.CallbackURL, "OpenID callback URL")
5161
fs.StringVar(&options.AuthorizeURL, "oidc-authorize-url", options.AuthorizeURL, "OpenID authorize URL")
5262
fs.StringVar(&options.CAFile, "oidc-ca-file", options.CAFile, "Path to a CA bundle to use when verifying the OIDC provider's TLS certificate.")
63+
fs.StringVar(&options.Type, "oidc-type", options.Type, "Type of OIDC provider (embedded or external)")
5364
}
5465

5566
func (options *OIDC) Complete(listener net.Listener) error {
56-
if options.IssuerURL == "" {
57-
oidcServer, err := oidc.New(options.CAFile, listener)
67+
if options.Type == string(OIDCTypeEmbedded) {
68+
oidcServer, err := oidc.New(options.CAFile, listener, options.IssuerURL)
5869
if err != nil {
5970
return err
6071
}
6172
options.OIDCServer = oidcServer
6273

63-
cfg, err := oidcServer.Config()
74+
cfg, err := oidcServer.Config(options.CallbackURL, options.IssuerURL)
6475
if err != nil {
6576
return err
6677
}

0 commit comments

Comments
 (0)