Skip to content
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
8 changes: 4 additions & 4 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,16 @@ jobs:
packages: write
steps:
- uses: actions/checkout@v6
- uses: docker/login-action@v3
- uses: docker/login-action@v4
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- uses: docker/metadata-action@v5
- uses: docker/metadata-action@v6
id: meta
with:
images: ghcr.io/${{ github.repository }}
- uses: docker/build-push-action@v6
- uses: docker/build-push-action@v7
with:
push: true
file: ./Containerfile
Expand All @@ -45,7 +45,7 @@ jobs:
- run: |
git config user.name "$GITHUB_ACTOR"
git config user.email "$GITHUB_ACTOR@users.noreply.github.com"
- uses: azure/setup-helm@v4
- uses: azure/setup-helm@v5
with:
token: ${{ secrets.GITHUB_TOKEN }}
- run: |
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ permissions:
contents: read

env:
GO_VERSION: ~1.26.0
GO_VERSION: ~1.26.3

jobs:
basic:
Expand Down Expand Up @@ -43,7 +43,7 @@ jobs:
- name: golangci-lint
uses: golangci/golangci-lint-action@v9
with:
version: v2.9.0
version: v2.12.2
ginkgo:
name: unit-test
runs-on: ubuntu-latest
Expand All @@ -53,7 +53,7 @@ jobs:
go-version: ${{ env.GO_VERSION }}
cache: false
- uses: actions/checkout@v6
- run: go run github.com/onsi/ginkgo/v2/ginkgo@v2.28.1 -r --randomize-all --randomize-suites --race --trace --fail-on-pending --keep-going --vet off --cover
- run: go run github.com/onsi/ginkgo/v2/ginkgo@v2.29.0 -r --randomize-all --randomize-suites --race --trace --fail-on-pending --keep-going --vet off --cover
- run: cat coverprofile.out | grep -v "zz_generated." > coverprofile.out.filtered
#- uses: coverallsapp/github-action@v2
# with:
Expand Down
2 changes: 1 addition & 1 deletion Containerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.26.0-bookworm as builder
FROM golang:1.26.3-bookworm as builder

WORKDIR /workspace
COPY . /workspace
Expand Down
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ helm-test:

CONTROLLER_GEN = bin/controller-gen
controller-gen:
$(call go-get-tool,$(CONTROLLER_GEN),sigs.k8s.io/controller-tools/cmd/controller-gen@v0.20.1)
$(call go-get-tool,$(CONTROLLER_GEN),sigs.k8s.io/controller-tools/cmd/controller-gen@v0.21.0)

GOLANGCI_LINT = ./bin/golangci-lint
colanci-lint-bin:
$(call go-get-tool,$(GOLANGCI_LINT),github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.6.2)
$(call go-get-tool,$(GOLANGCI_LINT),github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.12.2)

CRD_DOCS = bin/crd-ref-docs
crd-docs-gen:
Expand All @@ -45,4 +45,4 @@ endef

GINKGO = ./bin/ginkgo
ginkgo-bin:
$(call go-get-tool,$(GINKGO),github.com/onsi/ginkgo/v2/ginkgo@v2.28.1)
$(call go-get-tool,$(GINKGO),github.com/onsi/ginkgo/v2/ginkgo@v2.29.0)
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ This example will guide you through the process of setting up a basic HAProxy in

3. Check the generated `haproxy.cfg` stored in the `Secret` `example-haproxy-config`:
```
defaults unnamed_defaults_1
defaults haproxy_defaults
mode http
timeout connect 5000
timeout client 5000
Expand Down Expand Up @@ -102,7 +102,7 @@ global
log /var/lib/rsyslog/rsyslog.sock local0
log-send-hostname

defaults unnamed_defaults_1
defaults haproxy_defaults
mode tcp
log global
option tcplog
Expand Down
4 changes: 0 additions & 4 deletions apis/config/v1alpha1/backend_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,3 @@ type BackendList struct {
metav1.ListMeta `json:"metadata,omitempty"`
Items []Backend `json:"items"`
}

func init() {
SchemeBuilder.Register(&Backend{}, &BackendList{})
}
4 changes: 2 additions & 2 deletions apis/config/v1alpha1/common_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ func (b *BaseSpec) AddToParser(p parser.Parser, sectionType parser.Section, sect
return err
}

err = p.Insert(sectionType, sectionName, "acl", configuration.SerializeACL(model), idx)
err = p.Insert(sectionType, sectionName, "acl", model, idx)
if err != nil {
return err
}
Expand Down Expand Up @@ -321,8 +321,8 @@ func (b *Bind) Model() (models.Bind, error) {
Address: b.Address,
Port: ptr.To(int64(b.Port)),
PortRangeEnd: b.PortRangeEnd,
Name: b.Name,
BindParams: models.BindParams{
Name: b.Name,
Transparent: b.Transparent,
AcceptProxy: ptr.Deref(b.AcceptProxy, false),
},
Expand Down
4 changes: 0 additions & 4 deletions apis/config/v1alpha1/frontend_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,3 @@ type FrontendList struct {
metav1.ListMeta `json:"metadata,omitempty"`
Items []Frontend `json:"items"`
}

func init() {
SchemeBuilder.Register(&Frontend{}, &FrontendList{})
}
16 changes: 14 additions & 2 deletions apis/config/v1alpha1/groupversion_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,29 @@
package v1alpha1

import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
"sigs.k8s.io/controller-runtime/pkg/scheme"
)

var (
// GroupVersion is group version used to register these objects
GroupVersion = schema.GroupVersion{Group: "config.haproxy.com", Version: "v1alpha1"}

// SchemeBuilder is used to add go types to the GroupVersionKind scheme
SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion}
SchemeBuilder = runtime.NewSchemeBuilder(addKnownTypes)

// AddToScheme adds the types in this group-version to the given scheme.
AddToScheme = SchemeBuilder.AddToScheme
)

func addKnownTypes(scheme *runtime.Scheme) error {
scheme.AddKnownTypes(GroupVersion,
&Backend{}, &BackendList{},
&Frontend{}, &FrontendList{},
&Listen{}, &ListenList{},
&Resolver{}, &ResolverList{},
)
metav1.AddToGroupVersion(scheme, GroupVersion)
return nil
}
4 changes: 0 additions & 4 deletions apis/config/v1alpha1/listen_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,3 @@ type ListenList struct {
metav1.ListMeta `json:"metadata,omitempty"`
Items []Listen `json:"items"`
}

func init() {
SchemeBuilder.Register(&Listen{}, &ListenList{})
}
4 changes: 0 additions & 4 deletions apis/config/v1alpha1/resolver_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,3 @@ type ResolverList struct {
metav1.ListMeta `json:"metadata,omitempty"`
Items []Resolver `json:"items"`
}

func init() {
SchemeBuilder.Register(&Resolver{}, &ResolverList{})
}
2 changes: 1 addition & 1 deletion apis/config/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 11 additions & 2 deletions apis/proxy/v1alpha1/groupversion_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,26 @@
package v1alpha1

import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
runtime "k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
"sigs.k8s.io/controller-runtime/pkg/scheme"
)

var (
// GroupVersion is group version used to register these objects
GroupVersion = schema.GroupVersion{Group: "proxy.haproxy.com", Version: "v1alpha1"}

// SchemeBuilder is used to add go types to the GroupVersionKind scheme
SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion}
SchemeBuilder = runtime.NewSchemeBuilder(addKnownTypes)

// AddToScheme adds the types in this group-version to the given scheme.
AddToScheme = SchemeBuilder.AddToScheme
)

func addKnownTypes(scheme *runtime.Scheme) error {
scheme.AddKnownTypes(GroupVersion,
&Instance{}, &InstanceList{},
)
metav1.AddToGroupVersion(scheme, GroupVersion)
return nil
}
30 changes: 19 additions & 11 deletions apis/proxy/v1alpha1/instance_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ import (
"k8s.io/utils/ptr"
)

// defaultsSectionName is the name of the HAProxy `defaults` section generated by the operator.
const defaultsSectionName = "haproxy_defaults"

// InstanceSpec defines the desired state of Instance
type InstanceSpec struct {
// Replicas is the desired number of replicas of the HAProxy Instance.
Expand Down Expand Up @@ -180,9 +183,7 @@ func (m *Metrics) AddToParser(p parser.Parser) error {
}

bind := models.Bind{
BindParams: models.BindParams{
Name: "metrics",
},
Name: "metrics",
Port: new(int64(m.Port)),
Address: ptr.Deref(m.Address, "0.0.0.0"),
}
Expand Down Expand Up @@ -574,6 +575,11 @@ func (l *GlobalLoggingConfiguration) Model() (models.LogTarget, models.GlobalLog
}

type GlobalOCSPConfiguration struct {
// Disable completely disables OCSP auto-update.
// When true, all ocsp-update settings are ignored; when false, behavior depends on global ocsp-update configuration.
// Its value defaults to 'false'.
// +optional
Disable *bool `json:"disable,omitempty"`
// Mode Enable automatic OCSP response update when set to 'on', disable it otherwise.
// Its value defaults to 'off'.
// +optional
Expand All @@ -597,6 +603,11 @@ func (t *GlobalOCSPConfiguration) Model() (models.OcspUpdateOptions, error) {
Maxdelay: t.MaxDelay,
Mindelay: t.MinDelay,
}
if t.Disable != nil && *t.Disable {
opts.Disable = new(true)
} else {
opts.Disable = new(false)
}
if t.Mode {
opts.Mode = "enabled"
} else {
Expand Down Expand Up @@ -661,11 +672,12 @@ func (d *DefaultsConfiguration) Model() (models.Defaults, error) {
if err != nil {
return defaults, err
}
if err = configuration.ParseSection(&defaults, parser.Defaults, parser.DefaultSectionName, p); err != nil {
if err = configuration.ParseSection(&defaults, parser.Defaults, defaultsSectionName, p); err != nil {
return defaults, err
}
}

defaults.Name = defaultsSectionName
defaults.Mode = d.Mode

for name, timeout := range d.Timeouts {
Expand Down Expand Up @@ -718,12 +730,12 @@ func (d *DefaultsConfiguration) AddToParser(p parser.Parser) error {
return err
}

if err := p.SectionsCreate(parser.Defaults, parser.DefaultSectionName); err != nil {
if err := p.SectionsCreate(parser.Defaults, defaultsSectionName); err != nil {
return err
}

configOpts := &options.ConfigurationOptions{}
if err := configuration.CreateEditSection(defaults.DefaultsBase, parser.Defaults, parser.DefaultSectionName, p, configOpts); err != nil {
if err := configuration.CreateEditSection(defaults.DefaultsBase, parser.Defaults, defaultsSectionName, p, configOpts); err != nil {
return err
}

Expand All @@ -732,7 +744,7 @@ func (d *DefaultsConfiguration) AddToParser(p parser.Parser) error {
if err != nil {
return err
}
if err := p.Insert(parser.Defaults, parser.DefaultSectionName, "log", configuration.SerializeLogTarget(logTarget)); err != nil {
if err := p.Insert(parser.Defaults, defaultsSectionName, "log", configuration.SerializeLogTarget(logTarget)); err != nil {
return err
}
}
Expand Down Expand Up @@ -787,7 +799,3 @@ type InstanceList struct {
metav1.ListMeta `json:"metadata,omitempty"`
Items []Instance `json:"items"`
}

func init() {
SchemeBuilder.Register(&Instance{}, &InstanceList{})
}
7 changes: 6 additions & 1 deletion apis/proxy/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions controllers/instance/instance_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -741,12 +741,13 @@ global
hard-stop-after 30000
log /var/lib/rsyslog/rsyslog.sock local0
log-send-hostname
ocsp-update.disable off
ocsp-update.httpproxy 192.168.0.10:8000
ocsp-update.mindelay 300
ocsp-update.maxdelay 3600
ocsp-update.mode on

defaults unnamed_defaults_1
defaults haproxy_defaults

resolvers bar-foo-res
hold nx 500
Expand Down Expand Up @@ -780,12 +781,13 @@ global
hard-stop-after 30000
log /var/lib/rsyslog/rsyslog.sock local0
log-send-hostname
ocsp-update.disable off
ocsp-update.httpproxy 192.168.0.10:8000
ocsp-update.mindelay 300
ocsp-update.maxdelay 3600
ocsp-update.mode on

defaults unnamed_defaults_1
defaults haproxy_defaults

resolvers bar-foo-res
hold nx 500
Expand Down
1 change: 1 addition & 0 deletions docs/api-reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -1297,6 +1297,7 @@ _Appears in:_

| Field | Description | Default | Validation |
| --- | --- | --- | --- |
| `disable` _boolean_ | Disable completely disables OCSP auto-update.<br />When true, all ocsp-update settings are ignored; when false, behavior depends on global ocsp-update configuration. Default is false. | | Optional: \{\} <br /> |
| `mode` _boolean_ | Mode Enable automatic OCSP response update when set to 'on', disable it otherwise.<br />Its value defaults to 'off'. | | Optional: \{\} <br /> |
| `maxDelay` _integer_ | MaxDelay sets the maximum interval between two automatic updates of the same OCSP<br />response. This time is expressed in seconds and defaults to 3600 (1 hour). | | Optional: \{\} <br /> |
| `minDelay` _integer_ | MinDelay sets the minimum interval between two automatic updates of the same OCSP<br />response. This time is expressed in seconds and defaults to 300 (5 minutes). | | Optional: \{\} <br /> |
Expand Down
Loading