diff --git a/.gitignore b/.gitignore index 4071b56..747a3cc 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ bin/ .vscode cover.out +.codegraph \ No newline at end of file diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md deleted file mode 100755 index 63418fe..0000000 --- a/CONTRIBUTING.md +++ /dev/null @@ -1,3 +0,0 @@ -# Contributing - -Please check out the [contributing section](https://docs.metal-stack.io/stable/development/contributing/) in our [docs](https://docs.metal-stack.io/). \ No newline at end of file diff --git a/api/v2/config/controller.go b/api/v2/config/controller.go index 8a607e3..f3d654c 100644 --- a/api/v2/config/controller.go +++ b/api/v2/config/controller.go @@ -4,9 +4,10 @@ import ( "fmt" "time" + apiv2client "github.com/metal-stack/api/go/client" + v2 "github.com/metal-stack/firewall-controller-manager/api/v2" "github.com/metal-stack/firewall-controller-manager/api/v2/helper" - metalgo "github.com/metal-stack/metal-go" "k8s.io/client-go/rest" "sigs.k8s.io/controller-runtime/pkg/client" ) @@ -47,9 +48,11 @@ type NewControllerConfig struct { SSHKeySecretName string // Metal is the metal client for accessing the metal-api. - Metal metalgo.Client + Metal apiv2client.Client // ClusterTag is the tag used in the metal-api for new firewalls to associate them with the cluster. ClusterTag string + // Project of this cluster + Project string // SafetyBackoff is used for guarding the metal-api when it comes to creating new firewalls. SafetyBackoff time.Duration @@ -83,8 +86,9 @@ type ControllerConfig struct { sshKeySecretNamespace string sshKeySecretName string - metal metalgo.Client + metal apiv2client.Client clusterTag string + project string safetyBackoff time.Duration progressDeadline time.Duration @@ -117,6 +121,7 @@ func New(c *NewControllerConfig) (*ControllerConfig, error) { shootAccessHelper: helper, metal: c.Metal, clusterTag: c.ClusterTag, + project: c.Project, safetyBackoff: c.SafetyBackoff, progressDeadline: c.ProgressDeadline, firewallHealthTimeout: c.FirewallHealthTimeout, @@ -248,14 +253,16 @@ func (c *ControllerConfig) GetSSHKeySecretNamespace() string { return c.sshKeySecretNamespace } -func (c *ControllerConfig) GetMetal() metalgo.Client { +func (c *ControllerConfig) GetMetal() apiv2client.Client { return c.metal } func (c *ControllerConfig) GetClusterTag() string { return c.clusterTag } - +func (c *ControllerConfig) GetProject() string { + return c.project +} func (c *ControllerConfig) GetSafetyBackoff() time.Duration { return c.safetyBackoff } diff --git a/api/v2/types_firewall.go b/api/v2/types_firewall.go index c8cf401..bc0d905 100644 --- a/api/v2/types_firewall.go +++ b/api/v2/types_firewall.go @@ -263,6 +263,8 @@ type FirewallNetwork struct { Prefixes []string `json:"prefixes,omitempty"` // Vrf is vrf id of this network. Vrf *int64 `json:"vrf"` + // Project of this network + Project *string `json:"project,omitempty"` } // FirewallList contains a list of firewalls diff --git a/api/v2/zz_generated.deepcopy.go b/api/v2/zz_generated.deepcopy.go index 393c86c..aa288a2 100644 --- a/api/v2/zz_generated.deepcopy.go +++ b/api/v2/zz_generated.deepcopy.go @@ -495,6 +495,11 @@ func (in *FirewallNetwork) DeepCopyInto(out *FirewallNetwork) { *out = new(int64) **out = **in } + if in.Project != nil { + in, out := &in.Project, &out.Project + *out = new(string) + **out = **in + } } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new FirewallNetwork. diff --git a/config/crds/firewall.metal-stack.io_firewalldeployments.yaml b/config/crds/firewall.metal-stack.io_firewalldeployments.yaml index 411bf6a..1ea1570 100644 --- a/config/crds/firewall.metal-stack.io_firewalldeployments.yaml +++ b/config/crds/firewall.metal-stack.io_firewalldeployments.yaml @@ -3,7 +3,7 @@ apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: annotations: - controller-gen.kubebuilder.io/version: v0.20.0 + controller-gen.kubebuilder.io/version: v0.21.0 name: firewalldeployments.firewall.metal-stack.io spec: group: firewall.metal-stack.io diff --git a/config/crds/firewall.metal-stack.io_firewallmonitors.yaml b/config/crds/firewall.metal-stack.io_firewallmonitors.yaml index 637536b..f94ceb5 100644 --- a/config/crds/firewall.metal-stack.io_firewallmonitors.yaml +++ b/config/crds/firewall.metal-stack.io_firewallmonitors.yaml @@ -3,7 +3,7 @@ apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: annotations: - controller-gen.kubebuilder.io/version: v0.20.0 + controller-gen.kubebuilder.io/version: v0.21.0 name: firewallmonitors.firewall.metal-stack.io spec: group: firewall.metal-stack.io diff --git a/config/crds/firewall.metal-stack.io_firewalls.yaml b/config/crds/firewall.metal-stack.io_firewalls.yaml index 6087ab1..d70055d 100644 --- a/config/crds/firewall.metal-stack.io_firewalls.yaml +++ b/config/crds/firewall.metal-stack.io_firewalls.yaml @@ -3,7 +3,7 @@ apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: annotations: - controller-gen.kubebuilder.io/version: v0.20.0 + controller-gen.kubebuilder.io/version: v0.21.0 name: firewalls.firewall.metal-stack.io spec: group: firewall.metal-stack.io @@ -325,6 +325,9 @@ spec: items: type: string type: array + project: + description: Project of this network + type: string vrf: description: Vrf is vrf id of this network. format: int64 diff --git a/config/crds/firewall.metal-stack.io_firewallsets.yaml b/config/crds/firewall.metal-stack.io_firewallsets.yaml index 1f2b813..263e54e 100644 --- a/config/crds/firewall.metal-stack.io_firewallsets.yaml +++ b/config/crds/firewall.metal-stack.io_firewallsets.yaml @@ -3,7 +3,7 @@ apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: annotations: - controller-gen.kubebuilder.io/version: v0.20.0 + controller-gen.kubebuilder.io/version: v0.21.0 name: firewallsets.firewall.metal-stack.io spec: group: firewall.metal-stack.io diff --git a/controllers/firewall/controller.go b/controllers/firewall/controller.go index 1d1879a..7e8a72f 100644 --- a/controllers/firewall/controller.go +++ b/controllers/firewall/controller.go @@ -2,9 +2,7 @@ package firewall import ( "context" - "errors" "fmt" - "net/http" "time" "github.com/go-logr/logr" @@ -13,14 +11,13 @@ import ( "sigs.k8s.io/controller-runtime/pkg/builder" "sigs.k8s.io/controller-runtime/pkg/predicate" + "github.com/metal-stack/api/go/errorutil" + apiv2 "github.com/metal-stack/api/go/metalstack/api/v2" v2 "github.com/metal-stack/firewall-controller-manager/api/v2" "github.com/metal-stack/firewall-controller-manager/api/v2/config" "github.com/metal-stack/firewall-controller-manager/api/v2/defaults" "github.com/metal-stack/firewall-controller-manager/api/v2/validation" "github.com/metal-stack/firewall-controller-manager/controllers" - "github.com/metal-stack/metal-go/api/client/firewall" - "github.com/metal-stack/metal-go/api/client/network" - "github.com/metal-stack/metal-go/api/models" "github.com/metal-stack/metal-lib/pkg/cache" ) @@ -28,8 +25,8 @@ type controller struct { c *config.ControllerConfig log logr.Logger recorder events.EventRecorder - networkCache *cache.Cache[string, *models.V1NetworkResponse] - firewallCache *cache.Cache[*v2.Firewall, []*models.V1FirewallResponse] + networkCache *cache.Cache[string, *apiv2.Network] + firewallCache *cache.Cache[*v2.Firewall, []*apiv2.Machine] } func SetupWithManager(log logr.Logger, recorder events.EventRecorder, mgr ctrl.Manager, c *config.ControllerConfig) error { @@ -37,26 +34,32 @@ func SetupWithManager(log logr.Logger, recorder events.EventRecorder, mgr ctrl.M log: log, recorder: recorder, c: c, - networkCache: cache.New(5*time.Minute, func(ctx context.Context, id string) (*models.V1NetworkResponse, error) { - resp, err := c.GetMetal().Network().FindNetwork(network.NewFindNetworkParams().WithID(id).WithContext(ctx), nil) + networkCache: cache.New(5*time.Minute, func(ctx context.Context, id string) (*apiv2.Network, error) { + resp, err := c.GetMetal().Apiv2().Network().Get(ctx, &apiv2.NetworkServiceGetRequest{Project: c.GetProject(), Id: id}) if err != nil { return nil, fmt.Errorf("network find error: %w", err) } - return resp.Payload, nil + return resp.Network, nil }), // the cache is only very short but on quickly repeated status updates, this should prevent the metal-api from being flooded - firewallCache: cache.New(5*time.Second, func(ctx context.Context, fw *v2.Firewall) ([]*models.V1FirewallResponse, error) { - searchFirewalls := func() ([]*models.V1FirewallResponse, error) { - resp, err := c.GetMetal().Firewall().FindFirewalls(firewall.NewFindFirewallsParams().WithBody(&models.V1FirewallFindRequest{ - AllocationName: fw.Name, - AllocationProject: fw.Spec.Project, - Tags: []string{c.GetClusterTag()}, - }).WithContext(ctx), nil) + firewallCache: cache.New(5*time.Second, func(ctx context.Context, fw *v2.Firewall) ([]*apiv2.Machine, error) { + searchFirewalls := func() ([]*apiv2.Machine, error) { + resp, err := c.GetMetal().Apiv2().Machine().List(ctx, &apiv2.MachineServiceListRequest{ + Project: c.GetProject(), + Query: &apiv2.MachineQuery{ + Allocation: &apiv2.MachineAllocationQuery{ + Name: &fw.Name, + Labels: &apiv2.Labels{ + Labels: controllers.ToLabels([]string{c.GetClusterTag()}), + }, + }, + }, + }) if err != nil { return nil, fmt.Errorf("firewall search error: %w", err) } - return resp.Payload, nil + return resp.Machines, nil } // First try to find the firewall by machineID but check that allocation, project and hostname still matches @@ -66,20 +69,20 @@ func SetupWithManager(log logr.Logger, recorder events.EventRecorder, mgr ctrl.M // big enough that we agreed to do it. We still need to run the expensive lookup in the metal-api in case deriving // the machine from the status field does not work. if fw.Status.MachineStatus != nil && fw.Status.MachineStatus.MachineID != "" { - resp, err := c.GetMetal().Firewall().FindFirewall(firewall.NewFindFirewallParams().WithContext(ctx).WithID(fw.Status.MachineStatus.MachineID), nil) + resp, err := c.GetMetal().Apiv2().Machine().Get(ctx, &apiv2.MachineServiceGetRequest{Project: c.GetProject(), Uuid: fw.Status.MachineStatus.MachineID}) if err != nil { - var defaultErr *firewall.FindFirewallDefault - if errors.As(err, &defaultErr) && defaultErr.Code() == http.StatusNotFound { + + if errorutil.IsNotFound(err) { return searchFirewalls() } return nil, fmt.Errorf("firewall find error: %w", err) } - if resp.Payload.Allocation != nil && - *resp.Payload.Allocation.Project == fw.Spec.Project && - *resp.Payload.Allocation.Hostname == fw.Name { - return []*models.V1FirewallResponse{resp.Payload}, nil + if resp.Machine.Allocation != nil && + resp.Machine.Allocation.Project == fw.Spec.Project && + resp.Machine.Allocation.Hostname == fw.Name { + return []*apiv2.Machine{resp.Machine}, nil } } diff --git a/controllers/firewall/delete.go b/controllers/firewall/delete.go index 6cdb7ad..b24a184 100644 --- a/controllers/firewall/delete.go +++ b/controllers/firewall/delete.go @@ -5,9 +5,9 @@ import ( "fmt" "time" + apiv2 "github.com/metal-stack/api/go/metalstack/api/v2" v2 "github.com/metal-stack/firewall-controller-manager/api/v2" "github.com/metal-stack/firewall-controller-manager/controllers" - "github.com/metal-stack/metal-go/api/client/machine" apierrors "k8s.io/apimachinery/pkg/api/errors" corev1 "k8s.io/api/core/v1" @@ -34,20 +34,19 @@ func (c *controller) Delete(r *controllers.Ctx[*v2.Firewall]) error { } for _, f := range fws { - if f.ID == nil { - continue - } - - resp, err := c.c.GetMetal().Machine().FreeMachine(machine.NewFreeMachineParams().WithID(*f.ID).WithContext(r.Ctx), nil) + resp, err := c.c.GetMetal().Apiv2().Machine().Delete(r.Ctx, &apiv2.MachineServiceDeleteRequest{ + Uuid: f.Uuid, + Project: c.c.GetProject(), + }) if err != nil { r.Log.Error(err, "firewall deletion failed") return controllers.RequeueAfter(5*time.Second, "firewall deletion failed, retrying") } - r.Log.Info("deleted firewall", "firewall-name", f.Name, "id", *resp.Payload.ID) + r.Log.Info("deleted firewall", "firewall-name", f.Allocation.Name, "id", resp.Machine.Uuid) - c.recorder.Eventf(r.Target, nil, corev1.EventTypeNormal, "Delete", "deleting firewall", "deleted firewall %s id %s", r.Target.Name, *resp.Payload.ID) + c.recorder.Eventf(r.Target, nil, corev1.EventTypeNormal, "Delete", "deleting firewall", "deleted firewall %s id %s", r.Target.Name, resp.Machine.Uuid) } return nil diff --git a/controllers/firewall/reconcile.go b/controllers/firewall/reconcile.go index 74c8c43..ca0084f 100644 --- a/controllers/firewall/reconcile.go +++ b/controllers/firewall/reconcile.go @@ -6,12 +6,12 @@ import ( "strings" "time" + "github.com/metal-stack/api/go/enum" + apiv2 "github.com/metal-stack/api/go/metalstack/api/v2" v2 "github.com/metal-stack/firewall-controller-manager/api/v2" "github.com/metal-stack/firewall-controller-manager/controllers" - "github.com/metal-stack/metal-go/api/client/firewall" - "github.com/metal-stack/metal-go/api/client/machine" - "github.com/metal-stack/metal-go/api/models" "github.com/metal-stack/metal-lib/pkg/pointer" + "google.golang.org/protobuf/reflect/protoreflect" "sigs.k8s.io/controller-runtime/pkg/client" corev1 "k8s.io/api/core/v1" @@ -46,7 +46,7 @@ func (c *controller) Reconcile(r *controllers.Ctx[*v2.Firewall]) error { return controllers.RequeueAfter(0*time.Second, "removed systemd service restart annotation, requeue for regular reconcile") } - var f *models.V1FirewallResponse + var f *apiv2.Machine defer func() { if err := c.setStatus(r, f); err != nil { r.Log.Error(err, "unable to set firewall status") @@ -79,7 +79,7 @@ func (c *controller) Reconcile(r *controllers.Ctx[*v2.Firewall]) error { case 1: f = fws[0] - cond := v2.NewCondition(v2.FirewallCreated, v2.ConditionTrue, "Created", fmt.Sprintf("Firewall %q created successfully.", pointer.SafeDeref(pointer.SafeDeref(f.Allocation).Name))) + cond := v2.NewCondition(v2.FirewallCreated, v2.ConditionTrue, "Created", fmt.Sprintf("Firewall %q created successfully.", pointer.SafeDeref(f.Allocation).Name)) r.Target.Status.Conditions.Set(cond) // this is mainly for tests when the firewall is already present @@ -96,9 +96,9 @@ func (c *controller) Reconcile(r *controllers.Ctx[*v2.Firewall]) error { if isFirewallReady(currentStatus) { - r.Log.Info("firewall reconciled successfully", "id", pointer.SafeDeref(f.ID)) + r.Log.Info("firewall reconciled successfully", "id", f.Uuid) - cond := v2.NewCondition(v2.FirewallReady, v2.ConditionTrue, "Ready", fmt.Sprintf("Firewall %q is phoning home and alive.", pointer.SafeDeref(pointer.SafeDeref(f.Allocation).Name))) + cond := v2.NewCondition(v2.FirewallReady, v2.ConditionTrue, "Ready", fmt.Sprintf("Firewall %q is phoning home and alive.", pointer.SafeDeref(f.Allocation).Name)) r.Target.Status.Conditions.Set(cond) r.Target.Status.Phase = v2.FirewallPhaseRunning @@ -113,27 +113,27 @@ func (c *controller) Reconcile(r *controllers.Ctx[*v2.Firewall]) error { return controllers.RequeueAfter(10*time.Second, "error syncing firewall ssh keys, backing off") } - // to make the controller always sync the status with the metal-api, we requeue + // to make the controller always sync the status with the metal-apiserver, we requeue return controllers.RequeueAfter(2*time.Minute, "firewall is running, continue probing regularly for status sync") } else if isFirewallProgressing(currentStatus) { - r.Log.Info("firewall is progressing", "id", pointer.SafeDeref(f.ID)) + r.Log.Info("firewall is progressing", "id", f.Uuid) - cond := v2.NewCondition(v2.FirewallReady, v2.ConditionFalse, "NotReady", fmt.Sprintf("Firewall %q is not ready.", pointer.SafeDeref(pointer.SafeDeref(f.Allocation).Name))) + cond := v2.NewCondition(v2.FirewallReady, v2.ConditionFalse, "NotReady", fmt.Sprintf("Firewall %q is not ready.", pointer.SafeDeref(f.Allocation).Name)) r.Target.Status.Conditions.Set(cond) return controllers.RequeueAfter(10*time.Second, "firewall creation is progressing") } else { - r.Log.Error(fmt.Errorf("firewall is not finishing the provisioning"), "please investigate", "id", pointer.SafeDeref(f.ID)) + r.Log.Error(fmt.Errorf("firewall is not finishing the provisioning"), "please investigate", "id", f.Uuid) if pointer.SafeDeref(currentStatus).CrashLoop { r.Target.Status.Phase = v2.FirewallPhaseCrashing } - cond := v2.NewCondition(v2.FirewallReady, v2.ConditionFalse, "NotFinishing", fmt.Sprintf("Firewall %q is not finishing the provisioning procedure.", pointer.SafeDeref(pointer.SafeDeref(f.Allocation).Name))) + cond := v2.NewCondition(v2.FirewallReady, v2.ConditionFalse, "NotFinishing", fmt.Sprintf("Firewall %q is not finishing the provisioning procedure.", pointer.SafeDeref(f.Allocation).Name)) r.Target.Status.Conditions.Set(cond) return controllers.RequeueAfter(1*time.Minute, "firewall creation is not finishing, proceed probing") @@ -142,7 +142,7 @@ func (c *controller) Reconcile(r *controllers.Ctx[*v2.Firewall]) error { default: var ids []string for _, fw := range fws { - ids = append(ids, pointer.SafeDeref(fw.ID)) + ids = append(ids, fw.Uuid) } cond := v2.NewCondition(v2.FirewallCreated, v2.ConditionFalse, "MultipleFirewalls", fmt.Sprintf("Found multiple firewalls with the same name: %s", strings.Join(ids, ", "))) @@ -152,18 +152,17 @@ func (c *controller) Reconcile(r *controllers.Ctx[*v2.Firewall]) error { } } -func (c *controller) createFirewall(r *controllers.Ctx[*v2.Firewall]) (*models.V1FirewallResponse, error) { +func (c *controller) createFirewall(r *controllers.Ctx[*v2.Firewall]) (*apiv2.Machine, error) { var ( - networks []*models.V1MachineAllocationNetwork + networks []*apiv2.MachineAllocationNetwork tags = []string{ c.c.GetClusterTag(), v2.FirewallManagedByTag(), } ) for _, n := range r.Target.Spec.Networks { - network := &models.V1MachineAllocationNetwork{ - Networkid: &n, - Autoacquire: new(true), + network := &apiv2.MachineAllocationNetwork{ + Network: n, } networks = append(networks, network) } @@ -173,21 +172,24 @@ func (c *controller) createFirewall(r *controllers.Ctx[*v2.Firewall]) (*models.V tags = append(tags, v2.FirewallSetTag(ref.Name)) } - createRequest := &models.V1FirewallCreateRequest{ - Description: "created by firewall-controller-manager", - Name: r.Target.Name, - Hostname: r.Target.Name, - Sizeid: &r.Target.Spec.Size, - Projectid: &r.Target.Spec.Project, - Partitionid: &r.Target.Spec.Partition, - Imageid: &r.Target.Spec.Image, - SSHPubKeys: r.Target.Spec.SSHPublicKeys, - Networks: networks, - UserData: r.Target.Spec.Userdata, - Tags: tags, + createRequest := &apiv2.MachineServiceCreateRequest{ + Project: r.Target.Spec.Project, + Name: r.Target.Name, + Hostname: &r.Target.Name, + Description: new("created by firewall-controller-manager"), + Size: &r.Target.Spec.Size, + Partition: &r.Target.Spec.Partition, + Image: r.Target.Spec.Image, + SshPublicKeys: r.Target.Spec.SSHPublicKeys, + Networks: networks, + Userdata: &r.Target.Spec.Userdata, + AllocationType: apiv2.MachineAllocationType_MACHINE_ALLOCATION_TYPE_FIREWALL, + Labels: &apiv2.Labels{ + Labels: controllers.ToLabels(tags), + }, } - resp, err := c.c.GetMetal().Firewall().AllocateFirewall(firewall.NewAllocateFirewallParams().WithBody(createRequest).WithContext(r.Ctx), nil) + resp, err := c.c.GetMetal().Apiv2().Machine().Create(r.Ctx, createRequest) if err != nil { r.Log.Error(err, "error creating firewall") @@ -197,14 +199,14 @@ func (c *controller) createFirewall(r *controllers.Ctx[*v2.Firewall]) (*models.V return nil, controllers.RequeueAfter(30*time.Second, "error creating firewall, backing off") } - r.Log.Info("firewall created", "id", pointer.SafeDeref(resp.Payload.ID)) + r.Log.Info("firewall created", "id", resp.Machine.Uuid) - cond := v2.NewCondition(v2.FirewallCreated, v2.ConditionTrue, "Created", fmt.Sprintf("Firewall %q created successfully.", pointer.SafeDeref(pointer.SafeDeref(resp.Payload.Allocation).Name))) + cond := v2.NewCondition(v2.FirewallCreated, v2.ConditionTrue, "Created", fmt.Sprintf("Firewall %q created successfully.", pointer.SafeDeref(resp.Machine.Allocation).Name)) r.Target.Status.Conditions.Set(cond) - c.recorder.Eventf(r.Target, nil, corev1.EventTypeNormal, "Create", "created firewall %s id %s", r.Target.Name, pointer.SafeDeref(resp.Payload.ID)) + c.recorder.Eventf(r.Target, nil, corev1.EventTypeNormal, "Create", "created firewall %s id %s", r.Target.Name, resp.Machine.Uuid) - return resp.Payload, nil + return resp.Machine, nil } func isFirewallProgressing(status *v2.MachineStatus) bool { @@ -214,12 +216,10 @@ func isFirewallProgressing(status *v2.MachineStatus) bool { if status.CrashLoop { return false } - // TODO replace with models.V1LivelinessAlive once merged - if status.Liveliness != "Alive" { + if status.Liveliness != mustStringValue(apiv2.MachineLiveliness_MACHINE_LIVELINESS_ALIVE) { return false } - // TODO replace with models.V1LivelinessPhonedHome once merged - if status.LastEvent.Event != "Phoned Home" { + if status.LastEvent.Event != mustStringValue(apiv2.MachineProvisioningEventType_MACHINE_PROVISIONING_EVENT_TYPE_PHONED_HOME) { return true } @@ -233,37 +233,53 @@ func isFirewallReady(status *v2.MachineStatus) bool { if status.CrashLoop { return false } - // TODO replace with models.V1LivelinessAlive once merged - if status.Liveliness != "Alive" { + if status.Liveliness != mustStringValue(apiv2.MachineLiveliness_MACHINE_LIVELINESS_ALIVE) { return false } - // TODO replace with models.V1LivelinessPhonedHome once merged - if status.LastEvent.Event == "Phoned Home" { + if status.LastEvent.Event == mustStringValue(apiv2.MachineProvisioningEventType_MACHINE_PROVISIONING_EVENT_TYPE_PHONED_HOME) { return true } return false } -func (c *controller) syncTags(r *controllers.Ctx[*v2.Firewall], m *models.V1FirewallResponse) error { +func mustStringValue[E protoreflect.Enum](e E) string { + val, err := enum.GetStringValue(e) + if err != nil { + panic(err) + } + + return *val +} + +func (c *controller) syncTags(r *controllers.Ctx[*v2.Firewall], m *apiv2.Machine) error { + var ( newTags []string ref = metav1.GetControllerOf(r.Target) ) - newTags = ensureTag(m.Tags, v2.FirewallControllerManagedByAnnotation, v2.FirewallControllerManager) + mtags := controllers.ToTags(pointer.SafeDeref(pointer.SafeDeref(m.Meta).Labels).Labels) + + newTags = ensureTag(mtags, v2.FirewallControllerManagedByAnnotation, v2.FirewallControllerManager) if ref != nil { newTags = ensureTag(newTags, v2.FirewallControllerSetAnnotation, ref.Name) } - if sets.NewString(newTags...).Equal(sets.NewString(m.Tags...)) { + if sets.NewString(newTags...).Equal(sets.NewString(mtags...)) { return nil } - _, err := c.c.GetMetal().Machine().UpdateMachine(machine.NewUpdateMachineParams().WithBody(&models.V1MachineUpdateRequest{ - ID: m.ID, - Tags: newTags, - }).WithContext(r.Ctx), nil) + _, err := c.c.GetMetal().Apiv2().Machine().Update(r.Ctx, &apiv2.MachineServiceUpdateRequest{ + Uuid: m.Uuid, + Labels: &apiv2.UpdateLabels{ + Strategy: &apiv2.UpdateLabels_Replace{ + Replace: &apiv2.Labels{ + Labels: controllers.ToLabels(newTags), + }, + }, + }, + }) if err != nil { return err } @@ -301,19 +317,20 @@ func ensureTag(currentTags []string, key, value string) []string { return newTags } -func (c *controller) syncSSHPubKey(r *controllers.Ctx[*v2.Firewall], m *models.V1FirewallResponse) error { +func (c *controller) syncSSHPubKey(r *controllers.Ctx[*v2.Firewall], m *apiv2.Machine) error { if m.Allocation == nil { return fmt.Errorf("firewall has no allocation in metal-api") } - if slices.Equal(m.Allocation.SSHPubKeys, r.Target.Spec.SSHPublicKeys) { + if slices.Equal(m.Allocation.SshPublicKeys, r.Target.Spec.SSHPublicKeys) { return nil } - _, err := c.c.GetMetal().Machine().UpdateMachine(machine.NewUpdateMachineParams().WithBody(&models.V1MachineUpdateRequest{ - ID: m.ID, - SSHPubKeys: r.Target.Spec.SSHPublicKeys, - }).WithContext(r.Ctx), nil) + _, err := c.c.GetMetal().Apiv2().Machine().Update(r.Ctx, &apiv2.MachineServiceUpdateRequest{ + Uuid: m.Uuid, + Project: c.c.GetProject(), + SshPublicKeys: r.Target.Spec.SSHPublicKeys, + }) if err != nil { return fmt.Errorf("unable to update ssh public keys: %w", err) } diff --git a/controllers/firewall/status.go b/controllers/firewall/status.go index 38a1e09..bab76d0 100644 --- a/controllers/firewall/status.go +++ b/controllers/firewall/status.go @@ -5,14 +5,14 @@ import ( "fmt" "time" + "github.com/metal-stack/api/go/enum" + apiv2 "github.com/metal-stack/api/go/metalstack/api/v2" v2 "github.com/metal-stack/firewall-controller-manager/api/v2" "github.com/metal-stack/firewall-controller-manager/controllers" - "github.com/metal-stack/metal-go/api/models" - "github.com/metal-stack/metal-lib/pkg/pointer" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) -func (c *controller) setStatus(r *controllers.Ctx[*v2.Firewall], f *models.V1FirewallResponse) error { +func (c *controller) setStatus(r *controllers.Ctx[*v2.Firewall], f *apiv2.Machine) error { var errs []error err := setMachineStatus(r.Target, f) @@ -30,7 +30,7 @@ func (c *controller) setStatus(r *controllers.Ctx[*v2.Firewall], f *models.V1Fir return errors.Join(errs...) } -func setMachineStatus(fw *v2.Firewall, f *models.V1FirewallResponse) error { +func setMachineStatus(fw *v2.Firewall, f *apiv2.Machine) error { if f == nil { return nil } @@ -45,35 +45,44 @@ func setMachineStatus(fw *v2.Firewall, f *models.V1FirewallResponse) error { return nil } -func getMachineStatus(f *models.V1FirewallResponse) (*v2.MachineStatus, error) { - if f.ID == nil || f.Allocation == nil || f.Allocation.Created == nil || f.Liveliness == nil || f.Allocation.Image == nil { +func getMachineStatus(f *apiv2.Machine) (*v2.MachineStatus, error) { + if f.Allocation == nil || f.Allocation.Meta == nil || f.Allocation.Meta.CreatedAt == nil || f.Allocation.Image == nil || f.Status == nil { return nil, fmt.Errorf("firewall entity from metal-api is missing essential fields") } + liveliness, err := enum.GetStringValue(f.Status.Liveliness) + if err != nil { + return nil, err + } + result := &v2.MachineStatus{ - MachineID: *f.ID, - AllocationTimestamp: metav1.NewTime(time.Time(*f.Allocation.Created)), - Liveliness: *f.Liveliness, - ImageID: pointer.SafeDeref(f.Allocation.Image.ID), + MachineID: f.Uuid, + AllocationTimestamp: metav1.NewTime(f.Allocation.Meta.CreatedAt.AsTime()), + Liveliness: *liveliness, + ImageID: f.Allocation.Image.Id, } - if f.Events != nil && f.Events.CrashLoop != nil { - result.CrashLoop = *f.Events.CrashLoop + if f.RecentProvisioningEvents != nil && f.RecentProvisioningEvents.State == apiv2.MachineProvisioningEventState_MACHINE_PROVISIONING_EVENT_STATE_CRASHLOOP { + result.CrashLoop = true } - if f.Events != nil && len(f.Events.Log) > 0 && f.Events.Log[0].Event != nil { - log := f.Events.Log[0] + if f.RecentProvisioningEvents != nil && len(f.RecentProvisioningEvents.Events) > 0 { + event := f.RecentProvisioningEvents.Events[0] + eventType, err := enum.GetStringValue(event.Event) + if err != nil { + return nil, err + } result.LastEvent = &v2.MachineLastEvent{ - Event: *log.Event, - Timestamp: metav1.NewTime(time.Time(log.Time)), - Message: log.Message, + Event: *eventType, + Timestamp: metav1.NewTime(event.Time.AsTime()), + Message: event.Message, } } return result, nil } -func (c *controller) setFirewallNetworks(r *controllers.Ctx[*v2.Firewall], f *models.V1FirewallResponse) error { +func (c *controller) setFirewallNetworks(r *controllers.Ctx[*v2.Firewall], f *apiv2.Machine) error { // check whether network prefixes were updated in metal-api // prefixes in the firewall machine allocation are just a snapshot when the firewall was created. // -> when changing prefixes in the referenced network the firewall does not know about any prefix changes. @@ -92,24 +101,29 @@ func (c *controller) setFirewallNetworks(r *controllers.Ctx[*v2.Firewall], f *mo var result []v2.FirewallNetwork for _, n := range f.Allocation.Networks { - if n.Networkid == nil { - continue + nw, err := c.networkCache.Get(r.Ctx, n.Network) + if err != nil { + return err } - - nw, err := c.networkCache.Get(r.Ctx, *n.Networkid) + networkType, err := enum.GetStringValue(n.NetworkType) if err != nil { return err } + var nat bool + if n.NatType == apiv2.NATType_NAT_TYPE_IPV4_MASQUERADE { + nat = true + } result = append(result, v2.FirewallNetwork{ - ASN: n.Asn, - DestinationPrefixes: n.Destinationprefixes, + ASN: new(int64(n.Asn)), + DestinationPrefixes: n.DestinationPrefixes, IPs: n.Ips, - Nat: n.Nat, - NetworkID: n.Networkid, - NetworkType: n.Networktype, + Nat: &nat, + NetworkID: &n.Network, + NetworkType: networkType, Prefixes: nw.Prefixes, - Vrf: n.Vrf, + Vrf: new(int64(n.Vrf)), + Project: n.Project, }) } diff --git a/controllers/set/suite_test.go b/controllers/set/suite_test.go index 85971fe..fc12fdf 100644 --- a/controllers/set/suite_test.go +++ b/controllers/set/suite_test.go @@ -13,7 +13,7 @@ import ( "github.com/metal-stack/firewall-controller-manager/controllers" "github.com/metal-stack/firewall-controller-manager/controllers/firewall" "github.com/metal-stack/firewall-controller-manager/controllers/set" - metalclient "github.com/metal-stack/metal-go/test/client" + "github.com/metal-stack/firewall-controller-manager/internal/test" "github.com/metal-stack/metal-lib/pkg/tag" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" @@ -93,7 +93,7 @@ var _ = BeforeSuite(func() { }) Expect(err).ToNot(HaveOccurred()) - _, metalClient := metalclient.NewMetalMockClient(testingT, &metalclient.MetalMockFns{}) + metalClient := test.New(testingT).Client() cc, err := controllerconfig.New(&controllerconfig.NewControllerConfig{ SeedClient: k8sClient, diff --git a/controllers/tags.go b/controllers/tags.go new file mode 100644 index 0000000..16ff582 --- /dev/null +++ b/controllers/tags.go @@ -0,0 +1,25 @@ +package controllers + +import ( + "fmt" + "strings" +) + +// ToLabels constructs a map of a list of labels. +func ToLabels(tags []string) map[string]string { + result := map[string]string{} + for _, l := range tags { + key, value, _ := strings.Cut(l, "=") + result[key] = value + } + return result +} + +// ToLabels constructs a list of labels. +func ToTags(labels map[string]string) []string { + result := []string{} + for k, v := range labels { + result = append(result, fmt.Sprintf("%s=%s", k, v)) + } + return result +} diff --git a/controllers/update/controller.go b/controllers/update/controller.go index 6d78cf5..4f54353 100644 --- a/controllers/update/controller.go +++ b/controllers/update/controller.go @@ -10,12 +10,11 @@ import ( "sigs.k8s.io/controller-runtime/pkg/builder" "sigs.k8s.io/controller-runtime/pkg/predicate" + apiv2client "github.com/metal-stack/api/go/client" + apiv2 "github.com/metal-stack/api/go/metalstack/api/v2" v2 "github.com/metal-stack/firewall-controller-manager/api/v2" "github.com/metal-stack/firewall-controller-manager/api/v2/config" "github.com/metal-stack/firewall-controller-manager/controllers" - metalgo "github.com/metal-stack/metal-go" - "github.com/metal-stack/metal-go/api/client/image" - "github.com/metal-stack/metal-go/api/models" "github.com/metal-stack/metal-lib/pkg/cache" ) @@ -23,7 +22,7 @@ type controller struct { c *config.ControllerConfig log logr.Logger recorder events.EventRecorder - imageCache *cache.Cache[string, *models.V1ImageResponse] + imageCache *cache.Cache[string, *apiv2.Image] } func SetupWithManager(log logr.Logger, recorder events.EventRecorder, mgr ctrl.Manager, c *config.ControllerConfig) error { @@ -56,13 +55,13 @@ func (c *controller) Delete(_ *controllers.Ctx[*v2.FirewallDeployment]) error { return nil } -func newImageCache(m metalgo.Client) *cache.Cache[string, *models.V1ImageResponse] { - return cache.New(5*time.Minute, func(ctx context.Context, id string) (*models.V1ImageResponse, error) { - resp, err := m.Image().FindLatestImage(image.NewFindLatestImageParams().WithID(id).WithContext(ctx), nil) +func newImageCache(m apiv2client.Client) *cache.Cache[string, *apiv2.Image] { + return cache.New(5*time.Minute, func(ctx context.Context, id string) (*apiv2.Image, error) { + resp, err := m.Apiv2().Image().Latest(ctx, &apiv2.ImageServiceLatestRequest{Os: id}) if err != nil { return nil, err } - return resp.Payload, nil + return resp.Image, nil }) } diff --git a/controllers/update/reconcile.go b/controllers/update/reconcile.go index dd08c99..01bff33 100644 --- a/controllers/update/reconcile.go +++ b/controllers/update/reconcile.go @@ -48,7 +48,7 @@ func (c *controller) autoUpdateOS(r *controllers.Ctx[*v2.FirewallDeployment]) er return fmt.Errorf("unable to retrieve latest os image from metal-api: %w", err) } - if image.ID == nil { + if image.Id == "" { return fmt.Errorf("returned image from metal-api contains no id") } @@ -89,7 +89,7 @@ func (c *controller) autoUpdateOS(r *controllers.Ctx[*v2.FirewallDeployment]) er // finally, we can do the image comparison - if *image.ID == fw.Status.MachineStatus.ImageID { + if image.Id == fw.Status.MachineStatus.ImageID { r.Log.Info("no new os version available, not triggering auto-update") return nil } @@ -109,7 +109,7 @@ func (c *controller) autoUpdateOS(r *controllers.Ctx[*v2.FirewallDeployment]) er refetched.Annotations[v2.RollSetAnnotation] = strconv.FormatBool(true) if isFullyQualifiedImageNotation { - refetched.Spec.Template.Spec.Image = *image.ID + refetched.Spec.Template.Spec.Image = image.Id } err = c.c.GetSeedClient().Update(r.Ctx, refetched) diff --git a/controllers/update/reconcile_test.go b/controllers/update/reconcile_test.go index 11c34a3..3879c9d 100644 --- a/controllers/update/reconcile_test.go +++ b/controllers/update/reconcile_test.go @@ -7,15 +7,13 @@ import ( "github.com/go-logr/logr" "github.com/google/go-cmp/cmp" + apiv2 "github.com/metal-stack/api/go/metalstack/api/v2" v2 "github.com/metal-stack/firewall-controller-manager/api/v2" "github.com/metal-stack/firewall-controller-manager/api/v2/config" "github.com/metal-stack/firewall-controller-manager/controllers" - "github.com/metal-stack/metal-go/api/client/image" - "github.com/metal-stack/metal-go/api/models" - metaltestclient "github.com/metal-stack/metal-go/test/client" + "github.com/metal-stack/firewall-controller-manager/internal/test" "github.com/metal-stack/metal-lib/pkg/testcommon" "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" @@ -31,7 +29,7 @@ func Test_controller_autoUpdateOS(t *testing.T) { tests := []struct { name string - metalMocks *metaltestclient.MetalMockFns + latestImage *apiv2.Image fwDeploy *v2.FirewallDeployment existingFws []v2.Firewall postTestFn func(t *testing.T, c client.Client) @@ -107,14 +105,8 @@ func Test_controller_autoUpdateOS(t *testing.T) { }, }, withinMaintenance: true, - metalMocks: &metaltestclient.MetalMockFns{ - Image: func(mock *mock.Mock) { - mock.On("FindLatestImage", image.NewFindLatestImageParams().WithID("firewall-ubuntu-3.0").WithContext(ctx), nil).Return(&image.FindLatestImageOK{ - Payload: &models.V1ImageResponse{ - ID: new("firewall-ubuntu-3.0.20240503"), - }, - }, nil) - }, + latestImage: &apiv2.Image{ + Id: "firewall-ubuntu-3.0.20240503", }, existingFws: []v2.Firewall{ { @@ -157,14 +149,8 @@ func Test_controller_autoUpdateOS(t *testing.T) { }, }, withinMaintenance: true, - metalMocks: &metaltestclient.MetalMockFns{ - Image: func(mock *mock.Mock) { - mock.On("FindLatestImage", image.NewFindLatestImageParams().WithID("firewall-ubuntu-3.0").WithContext(ctx), nil).Return(&image.FindLatestImageOK{ - Payload: &models.V1ImageResponse{ - ID: new("firewall-ubuntu-3.0.20240503"), - }, - }, nil) - }, + latestImage: &apiv2.Image{ + Id: "firewall-ubuntu-3.0.20240503", }, existingFws: []v2.Firewall{ { @@ -193,7 +179,10 @@ func Test_controller_autoUpdateOS(t *testing.T) { } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - _, mc := metaltestclient.NewMetalMockClient(t, tt.metalMocks) + mm := test.New(t) + mm.OnImageLatest = func(_ context.Context, _ *apiv2.ImageServiceLatestRequest) (*apiv2.ImageServiceLatestResponse, error) { + return &apiv2.ImageServiceLatestResponse{Image: tt.latestImage}, nil + } latestSet := v2.FirewallSet{ Namespace: "firewall", @@ -224,7 +213,7 @@ func Test_controller_autoUpdateOS(t *testing.T) { c := &controller{ c: cc, - imageCache: newImageCache(mc), + imageCache: newImageCache(mm.Client()), } r := &controllers.Ctx[*v2.FirewallDeployment]{ diff --git a/go.mod b/go.mod index d387eb1..57b8ae9 100644 --- a/go.mod +++ b/go.mod @@ -3,19 +3,20 @@ module github.com/metal-stack/firewall-controller-manager go 1.27 require ( + connectrpc.com/connect v1.21.0 github.com/Masterminds/semver/v3 v3.5.0 github.com/flatcar/container-linux-config-transpiler v0.9.4 github.com/go-logr/logr v1.4.4 - github.com/go-openapi/strfmt v0.27.3 github.com/google/go-cmp v0.7.0 github.com/google/uuid v1.6.0 - github.com/metal-stack/metal-go v0.45.0 - github.com/metal-stack/metal-lib v0.26.1 + github.com/metal-stack/api v0.8.0 + github.com/metal-stack/metal-lib v0.26.3 github.com/metal-stack/v v1.0.3 github.com/onsi/ginkgo/v2 v2.33.0 github.com/onsi/gomega v1.44.0 github.com/prometheus/client_golang v1.24.1 github.com/stretchr/testify v1.12.1 + google.golang.org/protobuf v1.36.12 k8s.io/api v0.35.0 k8s.io/apimachinery v0.35.0 k8s.io/client-go v0.35.0 @@ -23,22 +24,21 @@ require ( ) require ( - buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go v1.36.6-20250425153114-8976f5be98c1.1 // indirect - buf.build/go/protovalidate v0.11.0 // indirect + buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go v1.36.12-20260825204119-511051f7f437.2 // indirect + buf.build/go/protovalidate v1.4.0 // indirect buf.build/go/protoyaml v0.7.0 // indirect - cel.dev/expr v0.25.1 // indirect + cel.dev/cel-go v0.32.0 // indirect + cel.dev/expr v0.25.3 // indirect github.com/ajeddeloh/go-json v0.0.0-20200220154158-5ae607161559 // indirect github.com/alecthomas/units v0.0.0-20240927000941-0f3dac36c52b // indirect - github.com/antlr4-go/antlr/v4 v4.13.0 // indirect + github.com/antlr4-go/antlr/v4 v4.13.1 // indirect github.com/beorn7/perks v1.0.1 // indirect github.com/cespare/xxhash/v2 v2.3.0 // indirect - github.com/clipperhouse/displaywidth v0.10.0 // indirect - github.com/clipperhouse/uax29/v2 v2.6.0 // indirect - github.com/coreos/go-oidc/v3 v3.21.0 // indirect + github.com/clipperhouse/displaywidth v0.11.0 // indirect + github.com/clipperhouse/uax29/v2 v2.7.0 // indirect github.com/coreos/go-semver v0.3.1 // indirect github.com/coreos/go-systemd v0.0.0-20191104093116-d3cd4ed1dbcf // indirect github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect - github.com/decred/dcrd/dcrec/secp256k1/v4 v4.4.1 // indirect github.com/emicklei/go-restful/v3 v3.13.0 // indirect github.com/evanphx/json-patch v5.6.0+incompatible // indirect github.com/evanphx/json-patch/v5 v5.9.11 // indirect @@ -46,16 +46,10 @@ require ( github.com/flatcar/ignition v0.36.2 // indirect github.com/fsnotify/fsnotify v1.10.1 // indirect github.com/fxamacker/cbor/v2 v2.9.6 // indirect - github.com/go-jose/go-jose/v4 v4.1.5 // indirect - github.com/go-logr/stdr v1.2.2 // indirect - github.com/go-openapi/analysis v1.0.1 // indirect github.com/go-openapi/errors v0.22.9 // indirect github.com/go-openapi/jsonpointer v1.0.2 // indirect github.com/go-openapi/jsonreference v1.0.3 // indirect - github.com/go-openapi/loads v0.25.3 // indirect - github.com/go-openapi/runtime v0.33.3 // indirect - github.com/go-openapi/runtime/server-middleware v0.33.3 // indirect - github.com/go-openapi/spec v1.0.1 // indirect + github.com/go-openapi/strfmt v0.27.3 // indirect github.com/go-openapi/swag v0.29.2 // indirect github.com/go-openapi/swag/cmdutils v0.29.2 // indirect github.com/go-openapi/swag/conv v0.29.2 // indirect @@ -68,65 +62,49 @@ require ( github.com/go-openapi/swag/stringutils v0.29.2 // indirect github.com/go-openapi/swag/typeutils v0.29.2 // indirect github.com/go-openapi/swag/yamlutils v0.29.2 // indirect - github.com/go-openapi/validate v1.0.0 // indirect github.com/go-task/slim-sprig/v3 v3.0.0 // indirect github.com/go-viper/mapstructure/v2 v2.5.0 // indirect - github.com/goccy/go-json v0.11.2 // indirect + github.com/goccy/go-json v0.10.6 // indirect github.com/goccy/go-yaml v1.19.2 // indirect github.com/golang-jwt/jwt/v5 v5.3.1 // indirect github.com/google/btree v1.1.3 // indirect - github.com/google/cel-go v0.26.0 // indirect github.com/google/gnostic-models v0.7.0 // indirect github.com/google/pprof v0.0.0-20260402051712-545e8a4df936 // indirect - github.com/gorilla/mux v1.8.1 // indirect github.com/inconshreveable/mousetrap v1.1.0 // indirect github.com/json-iterator/go v1.1.12 // indirect - github.com/lestrrat-go/blackmagic v1.0.4 // indirect - github.com/lestrrat-go/httpcc v1.0.1 // indirect - github.com/lestrrat-go/httprc/v3 v3.0.6 // indirect - github.com/lestrrat-go/jwx/v3 v3.2.0 // indirect - github.com/lestrrat-go/option/v2 v2.0.0 // indirect + github.com/klauspost/compress v1.20.0 // indirect + github.com/klauspost/connect-compress/v2 v2.1.1 // indirect github.com/mattn/go-colorable v0.1.15 // indirect github.com/mattn/go-isatty v0.0.24 // indirect github.com/mattn/go-runewidth v0.0.19 // indirect - github.com/metal-stack/security v0.9.7 // indirect + github.com/minio/minlz v1.2.0 // indirect github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect github.com/modern-go/reflect2 v1.0.3-0.20250322232337-35a7c28c31ee // indirect github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect github.com/oklog/ulid/v2 v2.1.2 // indirect github.com/olekukonko/cat v0.0.0-20250911104152-50322a0618f6 // indirect github.com/olekukonko/errors v1.3.0 // indirect - github.com/olekukonko/ll v0.1.8 // indirect - github.com/olekukonko/tablewriter v1.1.4 // indirect + github.com/olekukonko/ll v0.1.9 // indirect + github.com/olekukonko/tablewriter v1.1.5 // indirect github.com/pelletier/go-toml/v2 v2.4.3 // indirect github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect - github.com/prometheus/client_model v0.6.2 // indirect - github.com/prometheus/common v0.70.1 // indirect - github.com/prometheus/procfs v0.21.1 // indirect - github.com/sagikazarmark/locafero v0.11.0 // indirect - github.com/segmentio/asm v1.2.1 // indirect - github.com/sourcegraph/conc v0.3.1-0.20240121214520-5f936abd7ae8 // indirect + github.com/prometheus/client_model v0.6.3 // indirect + github.com/prometheus/common v0.72.0 // indirect + github.com/prometheus/procfs v0.22.0 // indirect + github.com/sagikazarmark/locafero v0.12.0 // indirect github.com/spf13/afero v1.15.0 // indirect github.com/spf13/cast v1.10.0 // indirect github.com/spf13/cobra v1.10.2 // indirect github.com/spf13/pflag v1.0.10 // indirect github.com/spf13/viper v1.21.0 // indirect - github.com/stoewer/go-strcase v1.3.0 // indirect github.com/stretchr/objx v0.5.3 // indirect github.com/subosito/gotenv v1.6.0 // indirect - github.com/valyala/fastjson v1.6.10 // indirect github.com/vincent-petithory/dataurl v1.0.0 // indirect github.com/x448/float16 v0.8.4 // indirect - go.opentelemetry.io/auto/sdk v1.2.1 // indirect - go.opentelemetry.io/otel v1.47.0 // indirect - go.opentelemetry.io/otel/log v1.47.0 // indirect - go.opentelemetry.io/otel/metric v1.47.0 // indirect - go.opentelemetry.io/otel/trace v1.47.0 // indirect go.yaml.in/yaml/v2 v2.4.4 // indirect go.yaml.in/yaml/v3 v3.0.5 // indirect go4.org v0.0.0-20260112195520-a5071408f32f // indirect - golang.org/x/crypto v0.57.0 // indirect - golang.org/x/exp v0.0.0-20260410095643-746e56fc9e2f // indirect + golang.org/x/exp v0.0.0-20261005173118-76772065c9b0 // indirect golang.org/x/mod v0.41.0 // indirect golang.org/x/net v0.59.0 // indirect golang.org/x/oauth2 v0.37.0 // indirect @@ -136,10 +114,10 @@ require ( golang.org/x/text v0.42.0 // indirect golang.org/x/time v0.16.0 // indirect golang.org/x/tools v0.51.0 // indirect - gomodules.xyz/jsonpatch/v2 v2.5.0 // indirect - google.golang.org/genproto/googleapis/api v0.0.0-20260526163538-3dc84a4a5aaa // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20260523011958-0a33c5d7ca68 // indirect - google.golang.org/protobuf v1.36.12 // indirect + gomodules.xyz/jsonpatch/v2 v2.4.0 // indirect + google.golang.org/genproto/googleapis/api v0.0.0-20261005182115-fad411399dd8 // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20261005182115-fad411399dd8 // indirect + google.golang.org/grpc v1.84.0 // indirect gopkg.in/evanphx/json-patch.v4 v4.13.0 // indirect gopkg.in/inf.v0 v0.9.1 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect diff --git a/go.sum b/go.sum index 9d5aadf..02d4e28 100644 --- a/go.sum +++ b/go.sum @@ -1,11 +1,13 @@ -buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go v1.36.6-20250425153114-8976f5be98c1.1 h1:YhMSc48s25kr7kv31Z8vf7sPUIq5YJva9z1mn/hAt0M= -buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go v1.36.6-20250425153114-8976f5be98c1.1/go.mod h1:avRlCjnFzl98VPaeCtJ24RrV/wwHFzB8sWXhj26+n/U= -buf.build/go/protovalidate v0.11.0 h1:qmX+1Z/t5lqlxQW6bNHnCGE9kX6yXBNul0jYFjD2r3Q= -buf.build/go/protovalidate v0.11.0/go.mod h1:Ryhm9EyqOxO/jdqEBpH4mI/FUk2ULyYeuhR+QRhOgqc= +buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go v1.36.12-20260825204119-511051f7f437.2 h1:NbnlmV26O7oZ1iM5tsCI+GEx+3ZSdrhvnKQ/eWSrLiY= +buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go v1.36.12-20260825204119-511051f7f437.2/go.mod h1:TCt1lluMFnctISJXvkIQ4x3ABrPuUKCWKyjKdkJNBpw= +buf.build/go/protovalidate v1.4.0 h1:UjLrYbt5VX7+TMOs2+pG5FhZhIG1mSfK4EIopbb4LcM= +buf.build/go/protovalidate v1.4.0/go.mod h1:8vJfzNT6NIG2qm3uFsJDXMlRmG+bQJzbcIn1Aa0vPGs= buf.build/go/protoyaml v0.7.0 h1:z4oVoFicbpPefhT7WAykxUdfp0yEQlhMQ2mCZOY5V38= buf.build/go/protoyaml v0.7.0/go.mod h1:+a0cavd0uMvirb87xdu2ZMMmjlIQoiH/N2Ich5MGSQ0= -cel.dev/expr v0.25.1 h1:1KrZg61W6TWSxuNZ37Xy49ps13NUovb66QLprthtwi4= -cel.dev/expr v0.25.1/go.mod h1:hrXvqGP6G6gyx8UAHSHJ5RGk//1Oj5nXQ2NI02Nrsg4= +cel.dev/cel-go v0.32.0 h1:irvpFKr5EuGPyxeME03ERh0rii1TX+BDAnB9eL3IvNk= +cel.dev/cel-go v0.32.0/go.mod h1:DnVip7tpJSsgZymwfT+m1tnEVy3ivAjSMXPx12YrMkU= +cel.dev/expr v0.25.3 h1:A2jO8jwOugrrovveCWfj0KEZOfqiLgAcwjpHPhzIGw0= +cel.dev/expr v0.25.3/go.mod h1:hrXvqGP6G6gyx8UAHSHJ5RGk//1Oj5nXQ2NI02Nrsg4= cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= cloud.google.com/go v0.38.0/go.mod h1:990N+gfupTy94rShfmMCWGDn0LpTmnzTp2qbd1dvSRU= @@ -22,6 +24,8 @@ cloud.google.com/go/pubsub v1.0.1/go.mod h1:R0Gpsv3s54REJCy4fxDixWD93lHJMoZTyQ2k cloud.google.com/go/pubsub v1.1.0/go.mod h1:EwwdRX2sKPjnvnqCa270oGRyludottCI76h+R3AArQw= cloud.google.com/go/storage v1.0.0/go.mod h1:IhtSnM/ZTZV8YYJWCY8RULGVqBDmpoyjwiyrjsg+URw= cloud.google.com/go/storage v1.5.0/go.mod h1:tpKbwo567HUNpVclU5sGELwQWBDZ8gh0ZeosJ0Rtdos= +connectrpc.com/connect v1.21.0 h1:LhqSJt7jHf5NJBo9Jq/t/9FjcYAideif0mg+qe2jCUs= +connectrpc.com/connect v1.21.0/go.mod h1:A2ygJrukXwWy32vkCAAHNVguZrqZ+jeZ9rGRnGR4dN4= dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= @@ -33,11 +37,13 @@ github.com/ajeddeloh/go-json v0.0.0-20200220154158-5ae607161559/go.mod h1:otnto4 github.com/alecthomas/units v0.0.0-20210208195552-ff826a37aa15/go.mod h1:OMCwj8VM1Kc9e19TLln2VL61YJF0x1XFtfdL4JdbSyE= github.com/alecthomas/units v0.0.0-20240927000941-0f3dac36c52b h1:mimo19zliBX/vSQ6PWWSL9lK8qwHozUj03+zLoEB8O0= github.com/alecthomas/units v0.0.0-20240927000941-0f3dac36c52b/go.mod h1:fvzegU4vN3H1qMT+8wDmzjAcDONcgo2/SZ/TyfdUOFs= -github.com/antlr4-go/antlr/v4 v4.13.0 h1:lxCg3LAv+EUK6t1i0y1V6/SLeUi0eKEKdhQAlS8TVTI= -github.com/antlr4-go/antlr/v4 v4.13.0/go.mod h1:pfChB/xh/Unjila75QW7+VU4TSnWnnk9UTnmpPaOR2g= +github.com/antlr4-go/antlr/v4 v4.13.1 h1:SqQKkuVZ+zWkMMNkjy5FZe5mr5WURWnlpmOuzYWrPrQ= +github.com/antlr4-go/antlr/v4 v4.13.1/go.mod h1:GKmUxMtwp6ZgGwZSva4eWPC5mS6vUAmOABFgjdkM7Nw= github.com/aws/aws-sdk-go v1.8.39/go.mod h1:ZRmQr0FajVIyZ4ZzBYKG5P3ZqPz9IHG41ZoMu1ADI3k= 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/brianvoe/gofakeit/v6 v6.28.0 h1:Xib46XXuQfmlLS2EXRuJpqcw8St6qSZz75OUo0tgAW4= +github.com/brianvoe/gofakeit/v6 v6.28.0/go.mod h1:Xj58BMSnFqcn/fAQeSK+/PLtC5kSb7FJIq4JyGa8vEs= github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs= github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= @@ -45,12 +51,10 @@ github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWR github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI= github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU= github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= -github.com/clipperhouse/displaywidth v0.10.0 h1:GhBG8WuerxjFQQYeuZAeVTuyxuX+UraiZGD4HJQ3Y8g= -github.com/clipperhouse/displaywidth v0.10.0/go.mod h1:XqJajYsaiEwkxOj4bowCTMcT1SgvHo9flfF3jQasdbs= -github.com/clipperhouse/uax29/v2 v2.6.0 h1:z0cDbUV+aPASdFb2/ndFnS9ts/WNXgTNNGFoKXuhpos= -github.com/clipperhouse/uax29/v2 v2.6.0/go.mod h1:Wn1g7MK6OoeDT0vL+Q0SQLDz/KpfsVRgg6W7ihQeh4g= -github.com/coreos/go-oidc/v3 v3.21.0 h1:wZo4Q9Pum8dYEj0eMUPrqR+kvuGkeUplbLpNCkBqoWM= -github.com/coreos/go-oidc/v3 v3.21.0/go.mod h1:DYCf24+ncYi+XkIH97GY1+dqoRlbaSI26KVTCI9SrY4= +github.com/clipperhouse/displaywidth v0.11.0 h1:lBc6kY44VFw+TDx4I8opi/EtL9m20WSEFgwIwO+UVM8= +github.com/clipperhouse/displaywidth v0.11.0/go.mod h1:bkrFNkf81G8HyVqmKGxsPufD3JhNl3dSqnGhOoSD/o0= +github.com/clipperhouse/uax29/v2 v2.7.0 h1:+gs4oBZ2gPfVrKPthwbMzWZDaAFPGYK72F0NJv2v7Vk= +github.com/clipperhouse/uax29/v2 v2.7.0/go.mod h1:EFJ2TJMRUaplDxHKj1qAEhCtQPW2tJSwu5BF98AuoVM= github.com/coreos/go-semver v0.1.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= github.com/coreos/go-semver v0.3.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= github.com/coreos/go-semver v0.3.1 h1:yi21YpKnrx1gt5R+la8n5WgS0kCrsPp33dmEyHReZr4= @@ -63,14 +67,10 @@ github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSs github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM= github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/decred/dcrd/dcrec/secp256k1/v4 v4.4.1 h1:5RVFMOWjMyRy8cARdy79nAmgYw3hK/4HUq48LQ6Wwqo= -github.com/decred/dcrd/dcrec/secp256k1/v4 v4.4.1/go.mod h1:ZXNYxsqcloTdSy/rNShjYzMhyjf0LaoftYK0p+A3h40= github.com/emicklei/go-restful/v3 v3.13.0 h1:C4Bl2xDndpU6nJ4bc1jXd+uTmYPVUwkD6bFY/oTyCes= github.com/emicklei/go-restful/v3 v3.13.0/go.mod h1:6n3XBCmQQb25CM2LCACGz8ukIrRry+4bhvbpWn3mrbc= github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= -github.com/envoyproxy/protoc-gen-validate v1.2.1 h1:DEo3O99U8j4hBFwbJfrz9VtgcDfUKS7KJ7spH3d86P8= -github.com/envoyproxy/protoc-gen-validate v1.2.1/go.mod h1:d/C80l/jxXLdfEIhX1W2TmLfsJ31lvEjwamM4DxlWXU= github.com/evanphx/json-patch v5.6.0+incompatible h1:jBYDEEiFBPxA0v50tFdvOzQQTCvpL6mnFh5mB2/l16U= github.com/evanphx/json-patch v5.6.0+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQLiYLvXMP4fmwYFNcr97nuDLSk= github.com/evanphx/json-patch/v5 v5.9.11 h1:/8HVnzMq13/3x9TPvjG08wUGqBTmZBsCWzjTM0wiaDU= @@ -96,31 +96,16 @@ github.com/gkampitakis/go-snaps v0.5.15/go.mod h1:HNpx/9GoKisdhw9AFOBT1N7DBs9DiH github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= github.com/go-ini/ini v1.25.4/go.mod h1:ByCAeIL28uOIIG0E3PJtZPDL8WnHpFKFOtgjp+3Ies8= -github.com/go-jose/go-jose/v4 v4.1.5 h1:RjgjO2LOtWOJKUC5wpwY9LR3B3vwVAz6JS2YHfYU6eA= -github.com/go-jose/go-jose/v4 v4.1.5/go.mod h1:x4oUasVrzR7071A4TnHLGSPpNOm2a21K9Kf04k1rs08= -github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= github.com/go-logr/logr v1.4.4 h1:tG4xh9yMsRCAiodLVTxyrkzSZ9+o0L1Kg/+cPVcbP/8= github.com/go-logr/logr v1.4.4/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/go-logr/zapr v1.3.0 h1:XGdV8XW8zdwFiwOA2Dryh1gj2KRQyOOoNmBy4EplIcQ= github.com/go-logr/zapr v1.3.0/go.mod h1:YKepepNBd1u/oyhd/yQmtjVXmm9uML4IXUgMOwR8/Gg= -github.com/go-openapi/analysis v1.0.1 h1:JTEyujgl4GyFj8pbMUY2yZx5ak1Ozt/DaqzQjQBnBWM= -github.com/go-openapi/analysis v1.0.1/go.mod h1:f3gYbXmnXSQIZB02DqE4f8JX969PdOEnaY7gDBLeJjI= github.com/go-openapi/errors v0.22.9 h1:HI9+SyVYiRzyeBQGv0CbWbQa+u2S0nny7G7AhY+UMiM= github.com/go-openapi/errors v0.22.9/go.mod h1:R73q66sXP2smzAGgFOI4nqtusRK2xN5pYCjsij+KX58= github.com/go-openapi/jsonpointer v1.0.2 h1:NbW7xT2b+l7x+JefiPGDsZWsrLk1ogrz4AHK1TTzMt8= github.com/go-openapi/jsonpointer v1.0.2/go.mod h1:N0rI4MbNKD7xAFTiHtB+5Nhrg2j/wwYg7m7Fmb4/jk8= github.com/go-openapi/jsonreference v1.0.3 h1:5rDbq+JsjCv6/nUDDJt83nLZoADI4w03uvHXer+4aYQ= github.com/go-openapi/jsonreference v1.0.3/go.mod h1:OJSlMXHysgH272D9z2tiy2MGe5A9vQLHaCPb6KbYdE4= -github.com/go-openapi/loads v0.25.3 h1:V+jKy/thXWdLJUuYC8sZX2dICyAa8M3DokF70jj34P0= -github.com/go-openapi/loads v0.25.3/go.mod h1:LgLyCSOLBL2Qnj0Ps1oo2YH8jZoEKsMeVZCc+ALIxFo= -github.com/go-openapi/runtime v0.33.3 h1:qVgTDaFH+pzO8UqlwYNVmx2DD+nwVK3rB65V29ednD0= -github.com/go-openapi/runtime v0.33.3/go.mod h1:57crQFXXnCtT68LuAd+NOELX5tSF4ZE1GFW3Z+r/KCk= -github.com/go-openapi/runtime/server-middleware v0.33.3 h1:Td5UBla/J/KCjlsD0tmZYWQWxnT4gHpfXbueLQv9Umw= -github.com/go-openapi/runtime/server-middleware v0.33.3/go.mod h1:dopwrwqIqXe4xWtovDZkkXJzYqKw+Ybmy7G/hIDUWKY= -github.com/go-openapi/spec v1.0.1 h1:lj2vdGpNDcVgwRc6qXdw6qt/KQpCtSa9tnUH6vpDPDk= -github.com/go-openapi/spec v1.0.1/go.mod h1:M//GWQGtDUAjnP37gE6fInLgaczB+FatoipV3H1fYw8= github.com/go-openapi/strfmt v0.27.3 h1:cyf4J5Wjpd6bFpAs44MF8PsbWF/mWXhn82Ck/hgQZgw= github.com/go-openapi/strfmt v0.27.3/go.mod h1:Bl+xadPLa3nhBiaCAxNND1vrQfzyEjF0vBrLx96n/4E= github.com/go-openapi/swag v0.29.2 h1:9n8frkcsuQRA0INU31VbxNxt1zBaHxrHYGEf5BUjFi4= @@ -149,18 +134,16 @@ github.com/go-openapi/swag/typeutils v0.29.2 h1:O7aVvkTs3pXwikgtrPLenigEMdQFgONK github.com/go-openapi/swag/typeutils v0.29.2/go.mod h1:7+GDG+uz9Ke+eVt4rClZg7wklSDp8hT/mKNh/pC26TE= github.com/go-openapi/swag/yamlutils v0.29.2 h1:IFKFFeDnuIwzfsuWRQU+rI8iL3g4XyAYjV/RlnlxPLM= github.com/go-openapi/swag/yamlutils v0.29.2/go.mod h1:7MGqtcrK73sxQ4ceiyIf8qiXS/s09JLMdR5esK5euYQ= -github.com/go-openapi/testify/enable/yaml/v2 v2.8.0 h1:dvOQNZ2ovOdogn902NYq7i6jUI9Dma4qyjTXABY5YTY= -github.com/go-openapi/testify/enable/yaml/v2 v2.8.0/go.mod h1:3VwZZUT6nWcAjhIr2RypXxlsxd3mPPtXh3T8z65aRlQ= +github.com/go-openapi/testify/enable/yaml/v2 v2.7.0 h1:wPW6YRgx3+SID1yUy/Xwa17L8kFEaEKod2VRbJDZNUs= +github.com/go-openapi/testify/enable/yaml/v2 v2.7.0/go.mod h1:mI1M88etYbc3PhgHsWQK2kwvNwW5aGFqMPbmib+SGIs= github.com/go-openapi/testify/v2 v2.8.0 h1:19QDx5b57p8KjO2E4sgs/woL4Akp+FGLRlVm2xn0Rho= github.com/go-openapi/testify/v2 v2.8.0/go.mod h1:4gUN8jC+RqOE2qjW/vDmfyTvl5BCht4qL7oca0odrak= -github.com/go-openapi/validate v1.0.0 h1:dFsYCLVUQUL6Vi2lQSexgwmCXDuHe7eWRDhQxkE+xYA= -github.com/go-openapi/validate v1.0.0/go.mod h1:wwXGRqMQzOZ7PCqBcgNk+DD9+Cacnxv7we5T0M/eA3Y= github.com/go-task/slim-sprig/v3 v3.0.0 h1:sUs3vkvUymDpBKi3qH1YSqBQk9+9D/8M2mN1vB6EwHI= github.com/go-task/slim-sprig/v3 v3.0.0/go.mod h1:W848ghGpv3Qj3dhTPRyJypKRiqCdHZiAzKg9hl15HA8= github.com/go-viper/mapstructure/v2 v2.5.0 h1:vM5IJoUAy3d7zRSVtIwQgBj7BiWtMPfmPEgAXnvj1Ro= github.com/go-viper/mapstructure/v2 v2.5.0/go.mod h1:oJDH3BJKyqBA2TXFhDsKDGDTlndYOZ6rGS0BRZIxGhM= -github.com/goccy/go-json v0.11.2 h1:jdZv93Tt4ioR8yW1CoNsvSxrcZlCXAUU1aZXN7gpXUA= -github.com/goccy/go-json v0.11.2/go.mod h1:3NdmfEkZlB7YI5UFw/qdFKq8XN1aiWR0YyRPWZNQltY= +github.com/goccy/go-json v0.10.6 h1:p8HrPJzOakx/mn/bQtjgNjdTcN+/S6FcG2CTtQOrHVU= +github.com/goccy/go-json v0.10.6/go.mod h1:oq7eo15ShAhp70Anwd5lgX2pLfOS3QCiwU/PULtXL6M= github.com/goccy/go-yaml v1.19.2 h1:PmFC1S6h8ljIz6gMRBopkjP1TVT7xuwrButHID66PoM= github.com/goccy/go-yaml v1.19.2/go.mod h1:XBurs7gK8ATbW4ZPGKgcbrY1Br56PdM69F7LkFRi1kA= github.com/godbus/dbus v0.0.0-20181025153459-66d97aec3384/go.mod h1:/YcGZj5zSblfDWMMoOzV4fas9FZnQYTkDnsGvmh2Grw= @@ -178,12 +161,12 @@ github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5y github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.3/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw= +github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek= +github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps= github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= github.com/google/btree v1.1.3 h1:CVpQJjYgC4VbzxeGVHfvZrv1ctoYCAI8vbl07Fcxlyg= github.com/google/btree v1.1.3/go.mod h1:qOPhT0dTNdNzV6Z/lhRX0YXUafgPLFUh+gZMl761Gm4= -github.com/google/cel-go v0.26.0 h1:DPGjXackMpJWH680oGY4lZhYjIameYmR+/6RBdDGmaI= -github.com/google/cel-go v0.26.0/go.mod h1:A9O8OU9rdvrK5MQyrqfIxo1a0u4g3sF8KB6PUIaryMM= github.com/google/gnostic-models v0.7.0 h1:qwTtogB15McXDaNqTZdzPJRHvaVJlAl+HVQnLmJEJxo= github.com/google/gnostic-models v0.7.0/go.mod h1:whL5G0m6dmc5cPxKc5bdKdEN3UjI7OUGxBlw57miDrQ= github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= @@ -207,8 +190,6 @@ github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+ github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg= github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk= github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= -github.com/gorilla/mux v1.8.1 h1:TuBL49tXwgrFYWhqrNgrUNEY92u81SPhu7sTdzQEiWY= -github.com/gorilla/mux v1.8.1/go.mod h1:AKf9I4AEqPTmMytcMc0KkNouC66V3BtZ4qD5fmWSiMQ= github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= @@ -223,8 +204,10 @@ github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1 github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk= github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= -github.com/klauspost/compress v1.19.1 h1:VsB4HPswih7mmZ8WleSFQ75c/Ui1M4trX5oAsJnhSlk= -github.com/klauspost/compress v1.19.1/go.mod h1:cwPg85FWrGar70rWktvGQj8/hthj3wpl0PGDogxkrSQ= +github.com/klauspost/compress v1.20.0 h1:a3C1ke2ohxFymNlb2HWAHjDeKCI90scRskErZkR0ezA= +github.com/klauspost/compress v1.20.0/go.mod h1:LUdAzn7YLVvxLpc7y3V1m40wESHTgc1422pwwBSKYuI= +github.com/klauspost/connect-compress/v2 v2.1.1 h1:ycZNp4rWOZBodVE2Ls5AzK4aHkyK+GteEfzRZgKNs+c= +github.com/klauspost/connect-compress/v2 v2.1.1/go.mod h1:9oilsPHJMzGKkjafSBk9J7iVo4mO+dw0G0KSdVpnlVE= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= @@ -234,20 +217,6 @@ github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc= github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw= -github.com/lestrrat-go/blackmagic v1.0.4 h1:IwQibdnf8l2KoO+qC3uT4OaTWsW7tuRQXy9TRN9QanA= -github.com/lestrrat-go/blackmagic v1.0.4/go.mod h1:6AWFyKNNj0zEXQYfTMPfZrAXUWUfTIZ5ECEUEJaijtw= -github.com/lestrrat-go/dsig v1.3.0 h1:phjMOCXvYzhuIgn7Voe2rex8z166vGfxRxmqM25P9/Q= -github.com/lestrrat-go/dsig v1.3.0/go.mod h1:RD2eOaidyPvpc7IJQoO3Qq52RWdy8ZcJs8lrOnoa1Kc= -github.com/lestrrat-go/dsig-secp256k1 v1.0.0 h1:JpDe4Aybfl0soBvoVwjqDbp+9S1Y2OM7gcrVVMFPOzY= -github.com/lestrrat-go/dsig-secp256k1 v1.0.0/go.mod h1:CxUgAhssb8FToqbL8NjSPoGQlnO4w3LG1P0qPWQm/NU= -github.com/lestrrat-go/httpcc v1.0.1 h1:ydWCStUeJLkpYyjLDHihupbn2tYmZ7m22BGkcvZZrIE= -github.com/lestrrat-go/httpcc v1.0.1/go.mod h1:qiltp3Mt56+55GPVCbTdM9MlqhvzyuL6W/NMDA8vA5E= -github.com/lestrrat-go/httprc/v3 v3.0.6 h1:4FpLQ18KK/ypPbVU3NLWJNRvH3kcYiqKqWfKGqNWxxI= -github.com/lestrrat-go/httprc/v3 v3.0.6/go.mod h1:mSMtkZW92Z98M5YoNNztbRGxbXHql7tSitCvaxvo9l0= -github.com/lestrrat-go/jwx/v3 v3.2.0 h1:Jb3zBASTSZXz7gzzSAfYqxXF8KejvKC4xWoePLQqXCA= -github.com/lestrrat-go/jwx/v3 v3.2.0/go.mod h1:38vQ8iWKq3qRSbilbzvzdQPuywhowwuR03lhkYskyrw= -github.com/lestrrat-go/option/v2 v2.0.0 h1:XxrcaJESE1fokHy3FpaQ/cXW8ZsIdWcdFzzLOcID3Ss= -github.com/lestrrat-go/option/v2 v2.0.0/go.mod h1:oSySsmzMoR0iRzCDCaUfsCzxQHUEuhOViQObyy7S6Vg= github.com/maruel/natural v1.1.1 h1:Hja7XhhmvEFhcByqDoHz9QZbkWey+COd9xWfCfn1ioo= github.com/maruel/natural v1.1.1/go.mod h1:v+Rfd79xlw1AgVBjbO0BEQmptqb5HvL/k9GRHB7ZKEg= github.com/mattn/go-colorable v0.1.15 h1:+u9SLTRGnXv73cEsnsmoZBom+dMU88B2M0aDcWy0/jY= @@ -256,16 +225,16 @@ github.com/mattn/go-isatty v0.0.24 h1:tGZZoVgT/KiqK1c8ocVLeDS8BSWMRd47J3Lbz7vsRe github.com/mattn/go-isatty v0.0.24/go.mod h1:nMCL3Zebbrt45jsMDgnfIwz6ydEQApk5oEI3HqDio6A= github.com/mattn/go-runewidth v0.0.19 h1:v++JhqYnZuu5jSKrk9RbgF5v4CGUjqRfBm05byFGLdw= github.com/mattn/go-runewidth v0.0.19/go.mod h1:XBkDxAl56ILZc9knddidhrOlY5R/pDhgLpndooCuJAs= -github.com/metal-stack/metal-go v0.45.0 h1:X5BCppdE3RYNScfwQxv9JTehyFIv6LhVzhbG25k27KQ= -github.com/metal-stack/metal-go v0.45.0/go.mod h1:GSfXrAj55LGsUSMHWGDsmq5n056NG0yb1JM8bgfvKOw= -github.com/metal-stack/metal-lib v0.26.1 h1:wMrhENm/HPq0t7cjCkhzepGD6dyxmX/4IMsaJZea874= -github.com/metal-stack/metal-lib v0.26.1/go.mod h1:tnx4MM5oml10EMN6Nq6oFSbjOKB9B27WUZQUyZ4MywA= -github.com/metal-stack/security v0.9.7 h1:JAKj/01gIyO4rY7DrrIGBK6X+27uvMX+XPgW15U2d7g= -github.com/metal-stack/security v0.9.7/go.mod h1:6DFjP2KjdwrXF2aboQDrleo6/dZlGXoYtrV/YioKoFY= +github.com/metal-stack/api v0.8.0 h1:olAQtHx7uv3f/jaKKo7aVILhZgO5McQTLeKfS0FkolM= +github.com/metal-stack/api v0.8.0/go.mod h1:rWdj0dTAg2w/WuQhIZ+JVp9b68v6VVCm1k7sLx4U+PQ= +github.com/metal-stack/metal-lib v0.26.3 h1:K5gLoD65m6p3l6qCPrfavIdvNdWfmF2QdXrvU2URaZs= +github.com/metal-stack/metal-lib v0.26.3/go.mod h1:cNXjPBs8SFnjqfBobuSbm5mDk6E/jS8PVeIOrV/7POE= github.com/metal-stack/v v1.0.3 h1:Sh2oBlnxrCUD+mVpzfC8HiqL045YWkxs0gpTvkjppqs= github.com/metal-stack/v v1.0.3/go.mod h1:YTahEu7/ishwpYKnp/VaW/7nf8+PInogkfGwLcGPdXg= github.com/mfridman/tparse v0.18.0 h1:wh6dzOKaIwkUGyKgOntDW4liXSo37qg5AXbIhkMV3vE= github.com/mfridman/tparse v0.18.0/go.mod h1:gEvqZTuCgEhPbYk/2lS3Kcxg1GmTxxU7kTC8DvP0i/A= +github.com/minio/minlz v1.2.0 h1:6IOBuiHg04QxvbFfgFLT/9sMaO/UhL7S+ApW1mK8q5A= +github.com/minio/minlz v1.2.0/go.mod h1:Ls9H7nlkASeCcdl5thjVD5Eraj6z+zGa7xtq57jIKD4= github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= @@ -280,10 +249,10 @@ github.com/olekukonko/cat v0.0.0-20250911104152-50322a0618f6 h1:zrbMGy9YXpIeTnGj github.com/olekukonko/cat v0.0.0-20250911104152-50322a0618f6/go.mod h1:rEKTHC9roVVicUIfZK7DYrdIoM0EOr8mK1Hj5s3JjH0= github.com/olekukonko/errors v1.3.0 h1:teJvgLGUEqMzBUms+Dj3/3szNqCG/Jdw9iDbum8fR6U= github.com/olekukonko/errors v1.3.0/go.mod h1:ppzxA5jBKcO1vIpCXQ9ZqgDh8iwODz6OXIGKU8r5m4Y= -github.com/olekukonko/ll v0.1.8 h1:ysHCJRGHYKzmBSdz9w5AySztx7lG8SQY+naTGYUbsz8= -github.com/olekukonko/ll v0.1.8/go.mod h1:RPRC6UcscfFZgjo1nulkfMH5IM0QAYim0LfnMvUuozw= -github.com/olekukonko/tablewriter v1.1.4 h1:ORUMI3dXbMnRlRggJX3+q7OzQFDdvgbN9nVWj1drm6I= -github.com/olekukonko/tablewriter v1.1.4/go.mod h1:+kedxuyTtgoZLwif3P1Em4hARJs+mVnzKxmsCL/C5RY= +github.com/olekukonko/ll v0.1.9 h1:7twe+xnE6CSlfOlvGj0Finwnvr3CgWt25W33yuWNI6k= +github.com/olekukonko/ll v0.1.9/go.mod h1:RPRC6UcscfFZgjo1nulkfMH5IM0QAYim0LfnMvUuozw= +github.com/olekukonko/tablewriter v1.1.5 h1:4LoZSfMySpMQY3PT8RWJsJeuEuMIoo9xGRgvmqjg6IQ= +github.com/olekukonko/tablewriter v1.1.5/go.mod h1:+kedxuyTtgoZLwif3P1Em4hARJs+mVnzKxmsCL/C5RY= github.com/onsi/ginkgo/v2 v2.33.0 h1:C8gBA6Uc2ZEubiV+SXiu5tZnMTwEmXHgkJwGozKtZf8= github.com/onsi/ginkgo/v2 v2.33.0/go.mod h1:+aXOY+vzZ5mu2iI2HpTZUPmM//oQfsNFX6gU9kNcA44= github.com/onsi/gomega v1.44.0 h1:eAiGl3Pw5jz5GQdDff0BcxYpAX1JxW8xD7mFUuwNfZQ= @@ -301,27 +270,25 @@ github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH github.com/prometheus/client_golang v1.24.1 h1:JnJkREXzWxUdCuPFpIWZiPispT9xVV59uiuyR2bPlnU= github.com/prometheus/client_golang v1.24.1/go.mod h1:F+oSRECHg4sse5ucfYpYDeIv/hu68Zo0uoHKetWnzcE= github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= -github.com/prometheus/client_model v0.6.2 h1:oBsgwpGs7iVziMvrGhE53c/GrLUsZdHnqNwqPLxwZyk= -github.com/prometheus/client_model v0.6.2/go.mod h1:y3m2F6Gdpfy6Ut/GBsUqTWZqCUvMVzSfMLjcu6wAwpE= -github.com/prometheus/common v0.70.1 h1:1HvjP4D5oL3t8RsPlwxA9onvvStjtIHYE5XuuwOi/PY= -github.com/prometheus/common v0.70.1/go.mod h1:VdFUQDMZK3VLkurFUVhia6uys/0suUp86TJz5qbJRhc= -github.com/prometheus/procfs v0.21.1 h1:GljZCt+zSTS+NZq88cyQ1LjZ+RCHp3uVuabBWA5+OJI= -github.com/prometheus/procfs v0.21.1/go.mod h1:aB55Cww9pdSJVHk0hUf0inxWyyjPogFIjmHKYgMKmtY= +github.com/prometheus/client_model v0.6.3 h1:O0jaTVAYNxTHYInEPFJt5I3+sN8zqBtVMPTB1qyxiEo= +github.com/prometheus/client_model v0.6.3/go.mod h1:gpN5P9S7Rr6Yr92PiQ+Ixvhf6JZEkF1dnxsYL2aPBEM= +github.com/prometheus/common v0.72.0 h1:tAYsE+sPJxIncDAobm4H5aQjmox9ZxEIIqPbiffa8G4= +github.com/prometheus/common v0.72.0/go.mod h1:77NWqAQ2tXT7BIK40qjJdw5Acrsrg1TlHAnsQi3i6mk= +github.com/prometheus/procfs v0.22.0 h1:6q9+/JL9IKAPbCmBrv9n5O5Ty3NKnciV5X7YGw0oics= +github.com/prometheus/procfs v0.22.0/go.mod h1:CvmFr/GVhIjIvWJZW3tgkODBQMRIf0EyWMQLHCHab58= +github.com/rodaine/protogofakeit v0.1.1 h1:ZKouljuRM3A+TArppfBqnH8tGZHOwM/pjvtXe9DaXH8= +github.com/rodaine/protogofakeit v0.1.1/go.mod h1:pXn/AstBYMaSfc1/RqH3N82pBuxtWgejz1AlYpY1mI0= github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= github.com/rogpeppe/go-internal v1.14.1 h1:UQB4HGPB6osV0SQTLymcB4TgvyWu6ZyliaW0tI/otEQ= github.com/rogpeppe/go-internal v1.14.1/go.mod h1:MaRKkUm5W0goXpeCfT7UZI6fk/L7L7so1lCWt35ZSgc= github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/rwcarlsen/goexif v0.0.0-20190401172101-9e8deecbddbd/go.mod h1:hPqNNc0+uJM6H+SuU8sEs5K5IQeKccPqeSjfgcKGgPk= -github.com/sagikazarmark/locafero v0.11.0 h1:1iurJgmM9G3PA/I+wWYIOw/5SyBtxapeHDcg+AAIFXc= -github.com/sagikazarmark/locafero v0.11.0/go.mod h1:nVIGvgyzw595SUSUE6tvCp3YYTeHs15MvlmU87WwIik= -github.com/segmentio/asm v1.2.1 h1:DTNbBqs57ioxAD4PrArqftgypG4/qNpXoJx8TVXxPR0= -github.com/segmentio/asm v1.2.1/go.mod h1:BqMnlJP91P8d+4ibuonYZw9mfnzI9HfxselHZr5aAcs= +github.com/sagikazarmark/locafero v0.12.0 h1:/NQhBAkUb4+fH1jivKHWusDYFjMOOKU88eegjfxfHb4= +github.com/sagikazarmark/locafero v0.12.0/go.mod h1:sZh36u/YSZ918v0Io+U9ogLYQJ9tLLBmM4eneO6WwsI= github.com/sigma/bdoor v0.0.0-20160202064022-babf2a4017b0/go.mod h1:WBu7REWbxC/s/J06jsk//d+9DOz9BbsmcIrimuGRFbs= github.com/sigma/vmw-guestinfo v0.0.0-20160204083807-95dd4126d6e8/go.mod h1:JrRFFC0veyh0cibh0DAhriSY7/gV3kDdNaVUOmfx01U= github.com/smartystreets/assertions v1.2.0/go.mod h1:tcbTF8ujkAEcZ8TElKY+i30BzYlVhC/LOxJk7iOWnoo= github.com/smartystreets/goconvey v1.7.2/go.mod h1:Vw0tHAZW6lzCRk3xgdin6fKYcG+G3Pg9vgXWeJpQFMM= -github.com/sourcegraph/conc v0.3.1-0.20240121214520-5f936abd7ae8 h1:+jumHNA0Wrelhe64i8F6HNlS8pkoyMv5sreGx2Ry5Rw= -github.com/sourcegraph/conc v0.3.1-0.20240121214520-5f936abd7ae8/go.mod h1:3n1Cwaq1E1/1lhQhtRK2ts/ZwZEhjcQeJQ1RuC6Q/8U= github.com/spf13/afero v1.15.0 h1:b/YBCLWAJdFWJTN9cLhiXXcD7mzKn9Dm86dNnfyQw1I= github.com/spf13/afero v1.15.0/go.mod h1:NC2ByUVxtQs4b3sIUphxK0NioZnmxgyCrfzeuq8lxMg= github.com/spf13/cast v1.10.0 h1:h2x0u2shc1QuLHfxi+cTJvs30+ZAHOGRic8uyGTDWxY= @@ -333,8 +300,6 @@ github.com/spf13/pflag v1.0.10 h1:4EBh2KAYBwaONj6b2Ye1GiHfwjqyROoF4RwYO+vPwFk= github.com/spf13/pflag v1.0.10/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= github.com/spf13/viper v1.21.0 h1:x5S+0EU27Lbphp4UKm1C+1oQO+rKx36vfCoaVebLFSU= github.com/spf13/viper v1.21.0/go.mod h1:P0lhsswPGWD/1lZJ9ny3fYnVqxiegrlNrEmgLjbTCAY= -github.com/stoewer/go-strcase v1.3.0 h1:g0eASXYtp+yvN9fK8sH94oCIk0fau9uV1/ZdJ0AVEzs= -github.com/stoewer/go-strcase v1.3.0/go.mod h1:fAH5hQ5pehh+j3nZfvwdk2RgEgQjAoM8wodgtPmh1xo= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= @@ -346,7 +311,6 @@ github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81P github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= -github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= github.com/stretchr/testify v1.12.1 h1:EuwCh5fleGS7H32xRwO3wRGT7DxrDhLAT6FF8MpWDWE= @@ -361,8 +325,6 @@ github.com/tidwall/pretty v1.2.1 h1:qjsOFOWWQl+N3RsoF5/ssm1pHmJJwhjlSbZ51I6wMl4= github.com/tidwall/pretty v1.2.1/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU= github.com/tidwall/sjson v1.2.5 h1:kLy8mja+1c9jlljvWTlSazM7cKDRfJuR/bOJhcY5NcY= github.com/tidwall/sjson v1.2.5/go.mod h1:Fvgq9kS/6ociJEDnK0Fk1cpYF4FIW6ZF7LAe+6jwd28= -github.com/valyala/fastjson v1.6.10 h1:/yjJg8jaVQdYR3arGxPE2X5z89xrlhS0eGXdv+ADTh4= -github.com/valyala/fastjson v1.6.10/go.mod h1:e6FubmQouUNP73jtMLmcbxS6ydWIpOfhz34TSfO3JaE= github.com/vincent-petithory/dataurl v1.0.0 h1:cXw+kPto8NLuJtlMsI152irrVw9fRDX8AbShPRpg2CI= github.com/vincent-petithory/dataurl v1.0.0/go.mod h1:FHafX5vmDzyP+1CQATJn7WFKc9CvnvxyvZy6I1MrG/U= github.com/vmware/vmw-guestinfo v0.0.0-20170707015358-25eff159a728/go.mod h1:x9oS4Wk2s2u4tS29nEaDLdzvuHdB19CvSGJjPgkZJNk= @@ -373,18 +335,6 @@ go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU= go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8= go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= go.opencensus.io v0.22.3/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= -go.opentelemetry.io/auto/sdk v1.2.1 h1:jXsnJ4Lmnqd11kwkBV2LgLoFMZKizbCi5fNZ/ipaZ64= -go.opentelemetry.io/auto/sdk v1.2.1/go.mod h1:KRTj+aOaElaLi+wW1kO/DZRXwkF4C5xPbEe3ZiIhN7Y= -go.opentelemetry.io/otel v1.47.0 h1:j7ALJ/zgkS7Z6aeJW09p8VC9804bC+PpeTfCD4XPnOM= -go.opentelemetry.io/otel v1.47.0/go.mod h1:8wS9O2qfXrYrzp6hIF/HOYJJf/wIhFPhR2xLuP+iXQU= -go.opentelemetry.io/otel/log v1.47.0 h1:cOTS1CcLbSQeZKanGJ+0JpF/+t4PELi3O3bbl2lqCcI= -go.opentelemetry.io/otel/log v1.47.0/go.mod h1:9byitSQ5pLC6PpqwGXjqdMKya6ZTswHRZh2vvXT33nw= -go.opentelemetry.io/otel/metric v1.47.0 h1:4PptaldXx3Eat1XjMZ68pPJEs5wrhlemctZE9a3UdWY= -go.opentelemetry.io/otel/metric v1.47.0/go.mod h1:ADGSXxRrXM6bjbvLo535EstVFlPpPYZm4LBKixjDHwU= -go.opentelemetry.io/otel/sdk v1.46.0 h1:h5CNQQjEbuQXY/JfZtgt3i7HVFV3aHPO2OAwO2eTYPI= -go.opentelemetry.io/otel/sdk v1.46.0/go.mod h1:GAERFXFt5SYCEB+YiKUbMBeza6UaDH7GmGOZEfh2gSM= -go.opentelemetry.io/otel/trace v1.47.0 h1:JOjX/Oci8K94QHddo+bbfya/Ai/nf6/dt9ZfrFNWSrM= -go.opentelemetry.io/otel/trace v1.47.0/go.mod h1:jNaSLa2PZEYFG6fRjJABAu+bw4FS08uDmPg28lTghu0= go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto= go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE= go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0= @@ -404,8 +354,6 @@ golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACk golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.57.0 h1:3ZVCjf8Ggz7zneR/EHRVx68Ctf+2pmIMP2UFhh9cC6M= -golang.org/x/crypto v0.57.0/go.mod h1:Fdz0i5U6CoizGwLda9DttjSk6qlZo25zYNtR+ycvuZA= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= @@ -414,8 +362,8 @@ golang.org/x/exp v0.0.0-20191030013958-a1ab85dbe136/go.mod h1:JXzH8nQsPlswgeRAPE golang.org/x/exp v0.0.0-20191129062945-2f5052295587/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= golang.org/x/exp v0.0.0-20191227195350-da58074b4299/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= golang.org/x/exp v0.0.0-20200207192155-f17229e696bd/go.mod h1:J/WKrq2StrnmMY6+EHIKF9dgMWnmCNThgcyBT1FY9mM= -golang.org/x/exp v0.0.0-20260410095643-746e56fc9e2f h1:W3F4c+6OLc6H2lb//N1q4WpJkhzJCK5J6kUi1NTVXfM= -golang.org/x/exp v0.0.0-20260410095643-746e56fc9e2f/go.mod h1:J1xhfL/vlindoeF/aINzNzt2Bket5bjo9sdOYzOsU80= +golang.org/x/exp v0.0.0-20261005173118-76772065c9b0 h1:qUp3i6M39kccSm3OMMIE3tvs7YQWO9rFeCKdk1sSaFk= +golang.org/x/exp v0.0.0-20261005173118-76772065c9b0/go.mod h1:SRjTzy5WcYqRRqquLUvHeeovSwLO0CZ3xcltZNO4Fck= golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js= golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= @@ -525,8 +473,8 @@ golang.org/x/tools v0.51.0/go.mod h1:9eEncMayCV6zRMGhR5eZEC2iBx98qWcF1HZ9Z7wJOoA golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -gomodules.xyz/jsonpatch/v2 v2.5.0 h1:JELs8RLM12qJGXU4u/TO3V25KW8GreMKl9pdkk14RM0= -gomodules.xyz/jsonpatch/v2 v2.5.0/go.mod h1:AH3dM2RI6uoBZxn3LVrfvJ3E0/9dG4cSrbuBJT4moAY= +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/api v0.4.0/go.mod h1:8k5glujaEP+g9n7WNsDg8QP6cUVNI86fCNMcbazEtwE= google.golang.org/api v0.7.0/go.mod h1:WtwebWUNSVBH/HAw79HIFXZNqEvBhG+Ra+ax0hx3E3M= google.golang.org/api v0.8.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg= @@ -553,10 +501,10 @@ google.golang.org/genproto v0.0.0-20191115194625-c23dd37a84c9/go.mod h1:n3cpQtvx google.golang.org/genproto v0.0.0-20191216164720-4f79533eabd1/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= google.golang.org/genproto v0.0.0-20191230161307-f3c370f40bfb/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= google.golang.org/genproto v0.0.0-20200212174721-66ed5ce911ce/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= -google.golang.org/genproto/googleapis/api v0.0.0-20260526163538-3dc84a4a5aaa h1:Kjn0N0tCrDgiAFW+lGO4JZ3ck44CehvJQMAwj9QF0G8= -google.golang.org/genproto/googleapis/api v0.0.0-20260526163538-3dc84a4a5aaa/go.mod h1:q4lMZS6kskjT5HvCPrnnypcDPVJqT/f4nfxmkE7gryY= -google.golang.org/genproto/googleapis/rpc v0.0.0-20260523011958-0a33c5d7ca68 h1:PvEgGJf9C/1u5CHkInMg7UFYYUoiaQmW2LbtH0pjB78= -google.golang.org/genproto/googleapis/rpc v0.0.0-20260523011958-0a33c5d7ca68/go.mod h1:4Hqkh8ycfw05ld/3BWL7rJOSfebL2Q+DVDeRgYgxUU8= +google.golang.org/genproto/googleapis/api v0.0.0-20261005182115-fad411399dd8 h1:cFbkNigDInw+wVTXc+CyhUsoHGJCw0BR6mlNoRVfre0= +google.golang.org/genproto/googleapis/api v0.0.0-20261005182115-fad411399dd8/go.mod h1:QK6p7IgD7IZEZJBhhSUCib5X2vMOzlrGCGUw2XyVDh0= +google.golang.org/genproto/googleapis/rpc v0.0.0-20261005182115-fad411399dd8 h1:0SXBqli5dnuCKMjI/X3FM226zEaEa0GUcSCJtN1vL2o= +google.golang.org/genproto/googleapis/rpc v0.0.0-20261005182115-fad411399dd8/go.mod h1:OaIUM3+LpYcK2GXM4FTmhWoIq371Owdr+Cc7/BsYHHc= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38= google.golang.org/grpc v1.21.1/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM= @@ -564,6 +512,8 @@ google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyac google.golang.org/grpc v1.26.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= google.golang.org/grpc v1.27.1/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= +google.golang.org/grpc v1.84.0 h1:soMyaPJ8pAak5PIQ0DGBUir0XRo2fRoMqhNWMLlLxO0= +google.golang.org/grpc v1.84.0/go.mod h1:ljCht0DrxQrXBDRTZp52Qxh3Ffk8CdYm2sj4O2QN2C0= google.golang.org/protobuf v1.36.12 h1:pJOKDDOyeXErUroCihFAd5LQuwXBSpVnKGrj5o/fwxc= google.golang.org/protobuf v1.36.12/go.mod h1:HTf+CrKn2C3g5S8VImy6tdcUvCska2kB7j23XfzDpco= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= diff --git a/integration/integration_test.go b/integration/integration_test.go index d35bb97..a039aba 100644 --- a/integration/integration_test.go +++ b/integration/integration_test.go @@ -4,12 +4,13 @@ import ( "fmt" "time" + apiv2 "github.com/metal-stack/api/go/metalstack/api/v2" v2 "github.com/metal-stack/firewall-controller-manager/api/v2" "github.com/metal-stack/firewall-controller-manager/api/v2/defaults" + "github.com/metal-stack/firewall-controller-manager/internal/test" "github.com/metal-stack/metal-lib/httperrors" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" - "github.com/stretchr/testify/mock" "sigs.k8s.io/controller-runtime/pkg/client" corev1 "k8s.io/api/core/v1" @@ -17,13 +18,6 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" testcommon "github.com/metal-stack/firewall-controller-manager/integration/common" - - metalfirewall "github.com/metal-stack/metal-go/api/client/firewall" - "github.com/metal-stack/metal-go/api/client/image" - "github.com/metal-stack/metal-go/api/client/machine" - "github.com/metal-stack/metal-go/api/client/network" - "github.com/metal-stack/metal-go/api/models" - metalclient "github.com/metal-stack/metal-go/test/client" ) var ( @@ -151,21 +145,11 @@ var _ = Context("integration test", Ordered, func() { Describe("the rolling update", Ordered, func() { When("creating a firewall deployment", Ordered, func() { It("the creation works", func() { - swapMetalClient(&metalclient.MetalMockFns{ - Firewall: func(m *mock.Mock) { - m.On("AllocateFirewall", mock.Anything, nil).Return(&metalfirewall.AllocateFirewallOK{Payload: firewall1}, nil).Maybe() - m.On("FindFirewall", mock.Anything, nil).Return(&metalfirewall.FindFirewallOK{Payload: firewall1}, nil).Maybe() - m.On("FindFirewalls", mock.Anything, nil).Return(&metalfirewall.FindFirewallsOK{Payload: []*models.V1FirewallResponse{firewall1}}, nil).Maybe() - }, - Network: func(m *mock.Mock) { - m.On("FindNetwork", mock.Anything, nil).Return(&network.FindNetworkOK{Payload: network1}, nil).Maybe() - }, - Machine: func(m *mock.Mock) { - m.On("UpdateMachine", mock.Anything, nil).Return(&machine.UpdateMachineOK{Payload: &models.V1MachineResponse{}}, nil).Maybe() - }, - Image: func(m *mock.Mock) { - m.On("FindLatestImage", mock.Anything, nil).Return(&image.FindLatestImageOK{Payload: image1}, nil).Maybe() - }, + swapMetalClient(func(m *test.Client) { + mockMachine(m, firewall1) + mockMachineUpdate(m) + mockNetwork(m, network1) + mockImage(m, image1) }) Expect(k8sClient.Create(ctx, deployment())).To(Succeed()) @@ -248,7 +232,7 @@ var _ = Context("integration test", Ordered, func() { Expect(cond.LastTransitionTime).NotTo(BeZero()) Expect(cond.LastUpdateTime).NotTo(BeZero()) Expect(cond.Reason).To(Equal("Created")) - Expect(cond.Message).To(Equal(fmt.Sprintf("Firewall %q created successfully.", *firewall1.Allocation.Name))) + Expect(cond.Message).To(Equal(fmt.Sprintf("Firewall %q created successfully.", firewall1.Allocation.Name))) }) It("should populate the machine status", func() { @@ -260,9 +244,9 @@ var _ = Context("integration test", Ordered, func() { return status }, 5*time.Second, interval).Should(Not(BeNil())) - Expect(status.MachineID).To(Equal(*firewall1.ID)) + Expect(status.MachineID).To(Equal(firewall1.Uuid)) Expect(status.CrashLoop).To(Equal(false)) - Expect(status.Liveliness).To(Equal("Alive")) + Expect(status.Liveliness).To(Equal("alive")) Expect(status.LastEvent).NotTo(BeNil()) Expect(status.LastEvent.Event).To(Equal("Phoned Home")) Expect(status.LastEvent.Message).To(Equal("phoning home")) @@ -276,7 +260,7 @@ var _ = Context("integration test", Ordered, func() { Expect(cond.LastTransitionTime).NotTo(BeZero()) Expect(cond.LastUpdateTime).NotTo(BeZero()) Expect(cond.Reason).To(Equal("Ready")) - Expect(cond.Message).To(Equal(fmt.Sprintf("Firewall %q is phoning home and alive.", *firewall1.Allocation.Name))) + Expect(cond.Message).To(Equal(fmt.Sprintf("Firewall %q is phoning home and alive.", firewall1.Allocation.Name))) }) It("should have the monitor condition true", func() { @@ -476,21 +460,11 @@ var _ = Context("integration test", Ordered, func() { Context("the spec is updated", func() { It("the update works", func() { - swapMetalClient(&metalclient.MetalMockFns{ - Firewall: func(m *mock.Mock) { - m.On("AllocateFirewall", mock.Anything, nil).Return(&metalfirewall.AllocateFirewallOK{Payload: installingFirewall}, nil).Maybe() - m.On("FindFirewall", mock.Anything, nil).Return(&metalfirewall.FindFirewallOK{Payload: installingFirewall}, nil).Maybe() - m.On("FindFirewalls", mock.Anything, nil).Return(&metalfirewall.FindFirewallsOK{Payload: []*models.V1FirewallResponse{installingFirewall}}, nil).Maybe() - }, - Network: func(m *mock.Mock) { - m.On("FindNetwork", mock.Anything, nil).Return(&network.FindNetworkOK{Payload: network1}, nil).Maybe() - }, - Machine: func(m *mock.Mock) { - m.On("UpdateMachine", mock.Anything, nil).Return(&machine.UpdateMachineOK{Payload: &models.V1MachineResponse{}}, nil).Maybe() - }, - Image: func(m *mock.Mock) { - m.On("FindLatestImage", mock.Anything, nil).Return(&image.FindLatestImageOK{Payload: image1}, nil).Maybe() - }, + swapMetalClient(func(m *test.Client) { + mockMachine(m, installingFirewall) + mockMachineUpdate(m) + mockNetwork(m, network1) + mockImage(m, image1) }) deploy := deployment() @@ -555,7 +529,7 @@ var _ = Context("integration test", Ordered, func() { Expect(cond.LastTransitionTime).NotTo(BeZero()) Expect(cond.LastUpdateTime).NotTo(BeZero()) Expect(cond.Reason).To(Equal("Created")) - Expect(cond.Message).To(Equal(fmt.Sprintf("Firewall %q created successfully.", *installingFirewall.Allocation.Name))) + Expect(cond.Message).To(Equal(fmt.Sprintf("Firewall %q created successfully.", installingFirewall.Allocation.Name))) }) It("should populate the machine status", func() { @@ -567,9 +541,9 @@ var _ = Context("integration test", Ordered, func() { return status }, 5*time.Second, interval).Should(Not(BeNil())) - Expect(status.MachineID).To(Equal(*installingFirewall.ID)) + Expect(status.MachineID).To(Equal(installingFirewall.Uuid)) Expect(status.CrashLoop).To(Equal(false)) - Expect(status.Liveliness).To(Equal("Alive")) + Expect(status.Liveliness).To(Equal("alive")) Expect(status.LastEvent).NotTo(BeNil()) Expect(status.LastEvent.Event).To(Equal("Installing")) Expect(status.LastEvent.Message).To(Equal("is installing")) @@ -583,7 +557,7 @@ var _ = Context("integration test", Ordered, func() { Expect(cond.LastTransitionTime).NotTo(BeZero()) Expect(cond.LastUpdateTime).NotTo(BeZero()) Expect(cond.Reason).To(Equal("NotReady")) - Expect(cond.Message).To(Equal(fmt.Sprintf("Firewall %q is not ready.", *installingFirewall.Allocation.Name))) + Expect(cond.Message).To(Equal(fmt.Sprintf("Firewall %q is not ready.", installingFirewall.Allocation.Name))) }) It("should not yet have a distance configured", func() { @@ -634,14 +608,14 @@ var _ = Context("integration test", Ordered, func() { Expect(nws).To(BeComparableTo([]v2.FirewallNetwork{ { - ASN: installingFirewall.Allocation.Networks[0].Asn, - DestinationPrefixes: installingFirewall.Allocation.Networks[0].Destinationprefixes, + ASN: new(int64(installingFirewall.Allocation.Networks[0].Asn)), + DestinationPrefixes: installingFirewall.Allocation.Networks[0].DestinationPrefixes, IPs: installingFirewall.Allocation.Networks[0].Ips, - Nat: installingFirewall.Allocation.Networks[0].Nat, - NetworkID: installingFirewall.Allocation.Networks[0].Networkid, - NetworkType: installingFirewall.Allocation.Networks[0].Networktype, + Nat: new(installingFirewall.Allocation.Networks[0].NatType == apiv2.NATType_NAT_TYPE_IPV4_MASQUERADE), + NetworkID: new(installingFirewall.Allocation.Networks[0].Network), + NetworkType: new("child"), Prefixes: network1.Prefixes, - Vrf: installingFirewall.Allocation.Networks[0].Vrf, + Vrf: new(int64(installingFirewall.Allocation.Networks[0].Vrf)), }, })) }) @@ -778,21 +752,12 @@ var _ = Context("integration test", Ordered, func() { When("the firewall gets ready and the firewall-controller connects", Ordered, func() { It("should allow an update of the firewall monitor", func() { - swapMetalClient(&metalclient.MetalMockFns{ - Machine: func(m *mock.Mock) { - m.On("FreeMachine", mock.Anything, nil).Return(&machine.FreeMachineOK{Payload: &models.V1MachineResponse{ID: firewall1.ID}}, nil).Maybe() - m.On("UpdateMachine", mock.Anything, nil).Return(&machine.UpdateMachineOK{Payload: &models.V1MachineResponse{}}, nil).Maybe() - }, - Firewall: func(m *mock.Mock) { - m.On("FindFirewall", mock.Anything, nil).Return(&metalfirewall.FindFirewallOK{Payload: readyFirewall}, nil).Maybe() - m.On("FindFirewalls", mock.Anything, nil).Return(&metalfirewall.FindFirewallsOK{Payload: []*models.V1FirewallResponse{readyFirewall}}, nil).Maybe() - }, - Network: func(m *mock.Mock) { - m.On("FindNetwork", mock.Anything, nil).Return(&network.FindNetworkOK{Payload: network1}, nil).Maybe() - }, - Image: func(m *mock.Mock) { - m.On("FindLatestImage", mock.Anything, nil).Return(&image.FindLatestImageOK{Payload: image1}, nil).Maybe() - }, + swapMetalClient(func(m *test.Client) { + mockMachine(m, readyFirewall) + mockMachineDelete(m, firewall1) + mockMachineUpdate(m) + mockNetwork(m, network1) + mockImage(m, image1) }) Expect(k8sClient.Get(ctx, client.ObjectKeyFromObject(mon), mon)).To(Succeed()) // refetch @@ -827,14 +792,14 @@ var _ = Context("integration test", Ordered, func() { mon := testcommon.WaitForResourceAmount(k8sClient, ctx, namespaceName, 1, &v2.FirewallMonitorList{}, func(l *v2.FirewallMonitorList) []*v2.FirewallMonitor { return l.GetItems() }, 15*time.Second) - Expect(mon.MachineStatus.MachineID).To(Equal(*readyFirewall.ID)) + Expect(mon.MachineStatus.MachineID).To(Equal(readyFirewall.Uuid)) }) It("should delete the firewall", func() { fw = testcommon.WaitForResourceAmount(k8sClient, ctx, namespaceName, 1, &v2.FirewallList{}, func(l *v2.FirewallList) []*v2.Firewall { return l.GetItems() }, 15*time.Second) - Expect(fw.Status.MachineStatus.MachineID).To(Equal(*readyFirewall.ID)) + Expect(fw.Status.MachineStatus.MachineID).To(Equal(readyFirewall.Uuid)) }) It("should delete the firewall set", func() { @@ -868,22 +833,12 @@ var _ = Context("integration test", Ordered, func() { Describe("the deletion flow", Ordered, func() { When("deleting the firewall deployment", func() { It("the deletion finishes", func() { - swapMetalClient(&metalclient.MetalMockFns{ - Firewall: func(m *mock.Mock) { - m.On("AllocateFirewall", mock.Anything, nil).Return(&metalfirewall.AllocateFirewallOK{Payload: firewall1}, nil).Maybe() - m.On("FindFirewall", mock.Anything, nil).Return(&metalfirewall.FindFirewallOK{Payload: firewall1}, nil).Maybe() - m.On("FindFirewalls", mock.Anything, nil).Return(&metalfirewall.FindFirewallsOK{Payload: []*models.V1FirewallResponse{firewall1}}, nil).Maybe() - }, - Network: func(m *mock.Mock) { - m.On("FindNetwork", mock.Anything, nil).Return(&network.FindNetworkOK{Payload: network1}, nil).Maybe() - }, - Machine: func(m *mock.Mock) { - m.On("FreeMachine", mock.Anything, nil).Return(&machine.FreeMachineOK{Payload: &models.V1MachineResponse{ID: firewall1.ID}}, nil).Maybe() - m.On("UpdateMachine", mock.Anything, nil).Return(&machine.UpdateMachineOK{Payload: &models.V1MachineResponse{}}, nil).Maybe() - }, - Image: func(m *mock.Mock) { - m.On("FindLatestImage", mock.Anything, nil).Return(&image.FindLatestImageOK{Payload: image1}, nil).Maybe() - }, + swapMetalClient(func(m *test.Client) { + mockMachine(m, firewall1) + mockMachineDelete(m, firewall1) + mockMachineUpdate(m) + mockNetwork(m, network1) + mockImage(m, image1) }) Expect(k8sClient.Delete(ctx, deployment())).To(Succeed()) @@ -919,21 +874,11 @@ var _ = Context("integration test", Ordered, func() { Describe("the recreate update", Ordered, func() { When("creating a firewall deployment", Ordered, func() { It("the creation works", func() { - swapMetalClient(&metalclient.MetalMockFns{ - Firewall: func(m *mock.Mock) { - m.On("AllocateFirewall", mock.Anything, nil).Return(&metalfirewall.AllocateFirewallOK{Payload: firewall1}, nil).Maybe() - m.On("FindFirewall", mock.Anything, nil).Return(&metalfirewall.FindFirewallOK{Payload: firewall1}, nil).Maybe() - m.On("FindFirewalls", mock.Anything, nil).Return(&metalfirewall.FindFirewallsOK{Payload: []*models.V1FirewallResponse{firewall1}}, nil).Maybe() - }, - Network: func(m *mock.Mock) { - m.On("FindNetwork", mock.Anything, nil).Return(&network.FindNetworkOK{Payload: network1}, nil).Maybe() - }, - Machine: func(m *mock.Mock) { - m.On("UpdateMachine", mock.Anything, nil).Return(&machine.UpdateMachineOK{Payload: &models.V1MachineResponse{}}, nil).Maybe() - }, - Image: func(m *mock.Mock) { - m.On("FindLatestImage", mock.Anything, nil).Return(&image.FindLatestImageOK{Payload: image1}, nil).Maybe() - }, + swapMetalClient(func(m *test.Client) { + mockMachine(m, firewall1) + mockMachineUpdate(m) + mockNetwork(m, network1) + mockImage(m, image1) }) deploy := deployment() @@ -1018,7 +963,7 @@ var _ = Context("integration test", Ordered, func() { Expect(cond.LastTransitionTime).NotTo(BeZero()) Expect(cond.LastUpdateTime).NotTo(BeZero()) Expect(cond.Reason).To(Equal("Created")) - Expect(cond.Message).To(Equal(fmt.Sprintf("Firewall %q created successfully.", *firewall1.Allocation.Name))) + Expect(cond.Message).To(Equal(fmt.Sprintf("Firewall %q created successfully.", firewall1.Allocation.Name))) }) It("should populate the machine status", func() { @@ -1030,9 +975,9 @@ var _ = Context("integration test", Ordered, func() { return status }, 5*time.Second, interval).Should(Not(BeNil())) - Expect(status.MachineID).To(Equal(*firewall1.ID)) + Expect(status.MachineID).To(Equal(firewall1.Uuid)) Expect(status.CrashLoop).To(Equal(false)) - Expect(status.Liveliness).To(Equal("Alive")) + Expect(status.Liveliness).To(Equal("alive")) Expect(status.LastEvent).NotTo(BeNil()) Expect(status.LastEvent.Event).To(Equal("Phoned Home")) Expect(status.LastEvent.Message).To(Equal("phoning home")) @@ -1046,7 +991,7 @@ var _ = Context("integration test", Ordered, func() { Expect(cond.LastTransitionTime).NotTo(BeZero()) Expect(cond.LastUpdateTime).NotTo(BeZero()) Expect(cond.Reason).To(Equal("Ready")) - Expect(cond.Message).To(Equal(fmt.Sprintf("Firewall %q is phoning home and alive.", *firewall1.Allocation.Name))) + Expect(cond.Message).To(Equal(fmt.Sprintf("Firewall %q is phoning home and alive.", firewall1.Allocation.Name))) }) It("should have the provisioned condition true", func() { @@ -1243,21 +1188,12 @@ var _ = Context("integration test", Ordered, func() { Expect(k8sClient.Get(ctx, client.ObjectKeyFromObject(deployment()), deploy)).To(Succeed()) - swapMetalClient(&metalclient.MetalMockFns{ - Firewall: func(m *mock.Mock) { - m.On("FindFirewall", mock.Anything, nil).Return(&metalfirewall.FindFirewallOK{Payload: readyFirewall}, nil).Maybe() - m.On("FindFirewalls", mock.Anything, nil).Return(&metalfirewall.FindFirewallsOK{Payload: []*models.V1FirewallResponse{readyFirewall}}, nil).Maybe() - }, - Network: func(m *mock.Mock) { - m.On("FindNetwork", mock.Anything, nil).Return(&network.FindNetworkOK{Payload: network1}, nil).Maybe() - }, - Machine: func(m *mock.Mock) { - m.On("FreeMachine", mock.Anything, nil).Return(nil, &machine.FreeMachineDefault{Payload: httperrors.Conflict(fmt.Errorf("deletion blocked"))}).Maybe() - m.On("UpdateMachine", mock.Anything, nil).Return(&machine.UpdateMachineOK{Payload: &models.V1MachineResponse{}}, nil).Maybe() - }, - Image: func(m *mock.Mock) { - m.On("FindLatestImage", mock.Anything, nil).Return(&image.FindLatestImageOK{Payload: image1}, nil).Maybe() - }, + swapMetalClient(func(m *test.Client) { + mockMachine(m, readyFirewall) + mockMachineDeleteErr(m, httperrors.Conflict(fmt.Errorf("deletion blocked"))) + mockMachineUpdate(m) + mockNetwork(m, network1) + mockImage(m, image1) }) deploy.Spec.Template.Spec.Networks = []string{"internet", "mpls"} @@ -1281,22 +1217,12 @@ var _ = Context("integration test", Ordered, func() { Context("the old generation disappears", Ordered, func() { It("should delete the firewall set", func() { - swapMetalClient(&metalclient.MetalMockFns{ - Firewall: func(m *mock.Mock) { - m.On("AllocateFirewall", mock.Anything, nil).Return(&metalfirewall.AllocateFirewallOK{Payload: readyFirewall}, nil).Maybe() - m.On("FindFirewall", mock.Anything, nil).Return(&metalfirewall.FindFirewallOK{Payload: readyFirewall}, nil).Maybe() - m.On("FindFirewalls", mock.Anything, nil).Return(&metalfirewall.FindFirewallsOK{Payload: []*models.V1FirewallResponse{readyFirewall}}, nil).Maybe() - }, - Network: func(m *mock.Mock) { - m.On("FindNetwork", mock.Anything, nil).Return(&network.FindNetworkOK{Payload: network1}, nil).Maybe() - }, - Machine: func(m *mock.Mock) { - m.On("FreeMachine", mock.Anything, nil).Return(&machine.FreeMachineOK{Payload: &models.V1MachineResponse{ID: firewall1.ID}}, nil).Maybe() - m.On("UpdateMachine", mock.Anything, nil).Return(&machine.UpdateMachineOK{Payload: &models.V1MachineResponse{}}, nil).Maybe() - }, - Image: func(m *mock.Mock) { - m.On("FindLatestImage", mock.Anything, nil).Return(&image.FindLatestImageOK{Payload: image1}, nil).Maybe() - }, + swapMetalClient(func(m *test.Client) { + mockMachine(m, readyFirewall) + mockMachineDelete(m, firewall1) + mockMachineUpdate(m) + mockNetwork(m, network1) + mockImage(m, image1) }) Eventually(func() bool { @@ -1351,20 +1277,11 @@ var _ = Context("integration test", Ordered, func() { When("the firewall-controller connects", Ordered, func() { It("should allow an update of the firewall monitor", func() { - swapMetalClient(&metalclient.MetalMockFns{ - Machine: func(m *mock.Mock) { - m.On("UpdateMachine", mock.Anything, nil).Return(&machine.UpdateMachineOK{Payload: &models.V1MachineResponse{}}, nil).Maybe() - }, - Firewall: func(m *mock.Mock) { - m.On("FindFirewall", mock.Anything, nil).Return(&metalfirewall.FindFirewallOK{Payload: readyFirewall}, nil).Maybe() - m.On("FindFirewalls", mock.Anything, nil).Return(&metalfirewall.FindFirewallsOK{Payload: []*models.V1FirewallResponse{readyFirewall}}, nil).Maybe() - }, - Network: func(m *mock.Mock) { - m.On("FindNetwork", mock.Anything, nil).Return(&network.FindNetworkOK{Payload: network1}, nil).Maybe() - }, - Image: func(m *mock.Mock) { - m.On("FindLatestImage", mock.Anything, nil).Return(&image.FindLatestImageOK{Payload: image1}, nil).Maybe() - }, + swapMetalClient(func(m *test.Client) { + mockMachine(m, readyFirewall) + mockMachineUpdate(m) + mockNetwork(m, network1) + mockImage(m, image1) }) Expect(k8sClient.Get(ctx, client.ObjectKeyFromObject(newMon), newMon)).To(Succeed()) // refetch @@ -1406,7 +1323,7 @@ var _ = Context("integration test", Ordered, func() { Expect(cond.LastTransitionTime).NotTo(BeZero()) Expect(cond.LastUpdateTime).NotTo(BeZero()) Expect(cond.Reason).To(Equal("Created")) - Expect(cond.Message).To(Equal(fmt.Sprintf("Firewall %q created successfully.", *readyFirewall.Allocation.Name))) + Expect(cond.Message).To(Equal(fmt.Sprintf("Firewall %q created successfully.", readyFirewall.Allocation.Name))) }) It("should populate the machine status", func() { @@ -1418,9 +1335,9 @@ var _ = Context("integration test", Ordered, func() { return status }, 5*time.Second, interval).Should(Not(BeNil())) - Expect(status.MachineID).To(Equal(*readyFirewall.ID)) + Expect(status.MachineID).To(Equal(readyFirewall.Uuid)) Expect(status.CrashLoop).To(Equal(false)) - Expect(status.Liveliness).To(Equal("Alive")) + Expect(status.Liveliness).To(Equal("alive")) Expect(status.LastEvent).NotTo(BeNil()) Expect(status.LastEvent.Event).To(Equal("Phoned Home")) Expect(status.LastEvent.Message).To(Equal("is phoning home")) @@ -1434,7 +1351,7 @@ var _ = Context("integration test", Ordered, func() { Expect(cond.LastTransitionTime).NotTo(BeZero()) Expect(cond.LastUpdateTime).NotTo(BeZero()) Expect(cond.Reason).To(Equal("Ready")) - Expect(cond.Message).To(Equal(fmt.Sprintf("Firewall %q is phoning home and alive.", *readyFirewall.Allocation.Name))) + Expect(cond.Message).To(Equal(fmt.Sprintf("Firewall %q is phoning home and alive.", readyFirewall.Allocation.Name))) }) It("should have the provisioned condition true", func() { @@ -1492,14 +1409,14 @@ var _ = Context("integration test", Ordered, func() { Expect(nws).To(BeComparableTo([]v2.FirewallNetwork{ { - ASN: readyFirewall.Allocation.Networks[0].Asn, - DestinationPrefixes: readyFirewall.Allocation.Networks[0].Destinationprefixes, + ASN: new(int64(readyFirewall.Allocation.Networks[0].Asn)), + DestinationPrefixes: readyFirewall.Allocation.Networks[0].DestinationPrefixes, IPs: readyFirewall.Allocation.Networks[0].Ips, - Nat: readyFirewall.Allocation.Networks[0].Nat, - NetworkID: readyFirewall.Allocation.Networks[0].Networkid, - NetworkType: readyFirewall.Allocation.Networks[0].Networktype, + Nat: new(readyFirewall.Allocation.Networks[0].NatType == apiv2.NATType_NAT_TYPE_IPV4_MASQUERADE), + NetworkID: new(readyFirewall.Allocation.Networks[0].Network), + NetworkType: new("child"), Prefixes: network1.Prefixes, - Vrf: readyFirewall.Allocation.Networks[0].Vrf, + Vrf: new(int64(readyFirewall.Allocation.Networks[0].Vrf)), }, })) }) @@ -1625,22 +1542,12 @@ var _ = Context("integration test", Ordered, func() { Describe("the deletion flow", Ordered, func() { When("deleting the firewall deployment", func() { It("the deletion finishes", func() { - swapMetalClient(&metalclient.MetalMockFns{ - Firewall: func(m *mock.Mock) { - m.On("AllocateFirewall", mock.Anything, nil).Return(&metalfirewall.AllocateFirewallOK{Payload: firewall1}, nil).Maybe() - m.On("FindFirewall", mock.Anything, nil).Return(&metalfirewall.FindFirewallOK{Payload: firewall1}, nil).Maybe() - m.On("FindFirewalls", mock.Anything, nil).Return(&metalfirewall.FindFirewallsOK{Payload: []*models.V1FirewallResponse{firewall1}}, nil).Maybe() - }, - Network: func(m *mock.Mock) { - m.On("FindNetwork", mock.Anything, nil).Return(&network.FindNetworkOK{Payload: network1}, nil).Maybe() - }, - Machine: func(m *mock.Mock) { - m.On("FreeMachine", mock.Anything, nil).Return(&machine.FreeMachineOK{Payload: &models.V1MachineResponse{ID: firewall1.ID}}, nil).Maybe() - m.On("UpdateMachine", mock.Anything, nil).Return(&machine.UpdateMachineOK{Payload: &models.V1MachineResponse{}}, nil).Maybe() - }, - Image: func(m *mock.Mock) { - m.On("FindLatestImage", mock.Anything, nil).Return(&image.FindLatestImageOK{Payload: image1}, nil).Maybe() - }, + swapMetalClient(func(m *test.Client) { + mockMachine(m, firewall1) + mockMachineDelete(m, firewall1) + mockMachineUpdate(m) + mockNetwork(m, network1) + mockImage(m, image1) }) Expect(k8sClient.Delete(ctx, deployment())).To(Succeed()) @@ -1728,20 +1635,11 @@ var _ = Context("integration test", Ordered, func() { When("creating a firewall resource (for an existing firewall)", Ordered, func() { It("the creation works", func() { - swapMetalClient(&metalclient.MetalMockFns{ - Firewall: func(m *mock.Mock) { - m.On("FindFirewall", mock.Anything, nil).Return(&metalfirewall.FindFirewallOK{Payload: firewall1}, nil).Maybe() - m.On("FindFirewalls", mock.Anything, nil).Return(&metalfirewall.FindFirewallsOK{Payload: []*models.V1FirewallResponse{firewall1}}, nil).Maybe() - }, - Network: func(m *mock.Mock) { - m.On("FindNetwork", mock.Anything, nil).Return(&network.FindNetworkOK{Payload: network1}, nil).Maybe() - }, - Machine: func(m *mock.Mock) { - m.On("UpdateMachine", mock.Anything, nil).Return(&machine.UpdateMachineOK{Payload: &models.V1MachineResponse{}}, nil).Maybe() - }, - Image: func(m *mock.Mock) { - m.On("FindLatestImage", mock.Anything, nil).Return(&image.FindLatestImageOK{Payload: image1}, nil).Maybe() - }, + swapMetalClient(func(m *test.Client) { + mockMachine(m, firewall1) + mockMachineUpdate(m) + mockNetwork(m, network1) + mockImage(m, image1) }) Expect(k8sClient.Create(ctx, fw)).To(Succeed()) @@ -1810,7 +1708,7 @@ var _ = Context("integration test", Ordered, func() { Expect(cond.LastTransitionTime).NotTo(BeZero()) Expect(cond.LastUpdateTime).NotTo(BeZero()) Expect(cond.Reason).To(Equal("Created")) - Expect(cond.Message).To(Equal(fmt.Sprintf("Firewall %q created successfully.", *firewall1.Allocation.Name))) + Expect(cond.Message).To(Equal(fmt.Sprintf("Firewall %q created successfully.", firewall1.Allocation.Name))) }) It("should populate the machine status", func() { @@ -1822,9 +1720,9 @@ var _ = Context("integration test", Ordered, func() { return status }, 5*time.Second, interval).Should(Not(BeNil())) - Expect(status.MachineID).To(Equal(*firewall1.ID)) + Expect(status.MachineID).To(Equal(firewall1.Uuid)) Expect(status.CrashLoop).To(Equal(false)) - Expect(status.Liveliness).To(Equal("Alive")) + Expect(status.Liveliness).To(Equal("alive")) Expect(status.LastEvent).NotTo(BeNil()) Expect(status.LastEvent.Event).To(Equal("Phoned Home")) Expect(status.LastEvent.Message).To(Equal("phoning home")) @@ -1838,7 +1736,7 @@ var _ = Context("integration test", Ordered, func() { Expect(cond.LastTransitionTime).NotTo(BeZero()) Expect(cond.LastUpdateTime).NotTo(BeZero()) Expect(cond.Reason).To(Equal("Ready")) - Expect(cond.Message).To(Equal(fmt.Sprintf("Firewall %q is phoning home and alive.", *firewall1.Allocation.Name))) + Expect(cond.Message).To(Equal(fmt.Sprintf("Firewall %q is phoning home and alive.", firewall1.Allocation.Name))) }) It("should have the provisioned condition true", func() { @@ -1956,22 +1854,12 @@ var _ = Context("integration test", Ordered, func() { Describe("the deletion flow", Ordered, func() { When("deleting the firewall deployment", func() { It("the deletion finishes", func() { - swapMetalClient(&metalclient.MetalMockFns{ - Firewall: func(m *mock.Mock) { - m.On("AllocateFirewall", mock.Anything, nil).Return(&metalfirewall.AllocateFirewallOK{Payload: firewall1}, nil).Maybe() - m.On("FindFirewall", mock.Anything, nil).Return(&metalfirewall.FindFirewallOK{Payload: firewall1}, nil).Maybe() - m.On("FindFirewalls", mock.Anything, nil).Return(&metalfirewall.FindFirewallsOK{Payload: []*models.V1FirewallResponse{firewall1}}, nil).Maybe() - }, - Network: func(m *mock.Mock) { - m.On("FindNetwork", mock.Anything, nil).Return(&network.FindNetworkOK{Payload: network1}, nil).Maybe() - }, - Machine: func(m *mock.Mock) { - m.On("FreeMachine", mock.Anything, nil).Return(&machine.FreeMachineOK{Payload: &models.V1MachineResponse{ID: firewall1.ID}}, nil).Maybe() - m.On("UpdateMachine", mock.Anything, nil).Return(&machine.UpdateMachineOK{Payload: &models.V1MachineResponse{}}, nil).Maybe() - }, - Image: func(m *mock.Mock) { - m.On("FindLatestImage", mock.Anything, nil).Return(&image.FindLatestImageOK{Payload: image1}, nil).Maybe() - }, + swapMetalClient(func(m *test.Client) { + mockMachine(m, firewall1) + mockMachineDelete(m, firewall1) + mockMachineUpdate(m) + mockNetwork(m, network1) + mockImage(m, image1) }) Expect(k8sClient.Delete(ctx, deployment())).To(Succeed()) diff --git a/integration/metal_resources_test.go b/integration/metal_resources_test.go index 7756df0..9a75c12 100644 --- a/integration/metal_resources_test.go +++ b/integration/metal_resources_test.go @@ -1,326 +1,335 @@ package controllers_test import ( + "context" "time" - "github.com/go-openapi/strfmt" - metalgo "github.com/metal-stack/metal-go" - "github.com/metal-stack/metal-go/api/models" - metalclient "github.com/metal-stack/metal-go/test/client" - "github.com/metal-stack/metal-lib/pkg/net" + apiv2client "github.com/metal-stack/api/go/client" + apiv2 "github.com/metal-stack/api/go/metalstack/api/v2" + "github.com/metal-stack/firewall-controller-manager/internal/test" + "google.golang.org/protobuf/types/known/timestamppb" ) var ( - metalClient metalgo.Client + metalClient apiv2client.Client + metalMock *test.Client testTime = time.Now() - firewall1 = &models.V1FirewallResponse{ - Allocation: &models.V1MachineAllocation{ - BootInfo: &models.V1BootInfo{ - Bootloaderid: new("bootloaderid"), - Cmdline: new("cmdline"), - ImageID: new("imageid"), - Initrd: new("initrd"), - Kernel: new("kernel"), - OsPartition: new("ospartition"), - PrimaryDisk: new("primarydisk"), + firewall1 = &apiv2.Machine{ + Allocation: &apiv2.MachineAllocation{ + Meta: &apiv2.Meta{ + CreatedAt: timestamppb.New(testTime.Add(-14 * 24 * time.Hour)), }, - Created: new(strfmt.DateTime(testTime.Add(-14 * 24 * time.Hour))), - Creator: new("creator"), + CreatedBy: "creator", Description: "firewall allocation 1", - Filesystemlayout: fsl1, - Hostname: new("firewall-hostname-1"), + FilesystemLayout: fsl1, + Hostname: "firewall-hostname-1", Image: image1, - Name: new("firewall-1"), - Networks: []*models.V1MachineNetwork{ + Name: "firewall-1", + Networks: []*apiv2.MachineNetwork{ { - Asn: new(int64(200)), - Destinationprefixes: []string{"2.2.2.2"}, + Asn: uint32(200), + DestinationPrefixes: []string{"2.2.2.2"}, Ips: []string{"1.1.1.1"}, - Nat: new(false), - Networkid: new("private"), - Networktype: new(net.PrivatePrimaryUnshared), + NatType: apiv2.NATType_NAT_TYPE_NONE, + Network: "private", + NetworkType: apiv2.NetworkType_NETWORK_TYPE_CHILD, Prefixes: []string{"prefixes"}, - Private: new(true), - Underlay: new(false), - Vrf: new(int64(100)), + Vrf: uint64(100), }, }, - Project: new("project-1"), - Reinstall: new(false), - Role: new(models.V1MachineAllocationRoleFirewall), - SSHPubKeys: []string{"sshpubkey"}, - Succeeded: new(true), - UserData: "---userdata---", + Project: "project-1", + AllocationType: apiv2.MachineAllocationType_MACHINE_ALLOCATION_TYPE_FIREWALL, + SshPublicKeys: []string{"sshpubkey"}, + Userdata: "---userdata---", }, - Bios: &models.V1MachineBIOS{ - Date: new("biosdata"), - Vendor: new("biosvendor"), - Version: new("biosversion"), - }, - Description: "firewall 1", - Events: &models.V1MachineRecentProvisioningEvents{ - CrashLoop: new(false), - FailedMachineReclaim: new(false), - LastErrorEvent: &models.V1MachineProvisioningEvent{ - Event: new("Crashed"), - Message: "crash", - Time: strfmt.DateTime(testTime.Add(-10 * 24 * time.Hour)), - }, - LastEventTime: strfmt.DateTime(testTime.Add(-7 * 24 * time.Hour)), - Log: []*models.V1MachineProvisioningEvent{ + RecentProvisioningEvents: &apiv2.MachineRecentProvisioningEvents{ + Events: []*apiv2.MachineProvisioningEvent{ { - Event: new("Phoned Home"), + Time: timestamppb.New(testTime.Add(-7 * 24 * time.Hour)), + Event: apiv2.MachineProvisioningEventType_MACHINE_PROVISIONING_EVENT_TYPE_PHONED_HOME, Message: "phoning home", - Time: strfmt.DateTime(testTime.Add(-7 * 24 * time.Hour)), }, }, + LastErrorEvent: &apiv2.MachineProvisioningEvent{ + Time: timestamppb.New(testTime.Add(-10 * 24 * time.Hour)), + Event: apiv2.MachineProvisioningEventType_MACHINE_PROVISIONING_EVENT_TYPE_CRASHED, + Message: "crash", + }, + LastEventTime: timestamppb.New(testTime.Add(-7 * 24 * time.Hour)), + State: apiv2.MachineProvisioningEventState_MACHINE_PROVISIONING_EVENT_STATE_UNSPECIFIED, }, - Hardware: &models.V1MachineHardware{ - CPUCores: new(int32(16)), - Disks: []*models.V1MachineBlockDevice{}, - Memory: new(int64(32)), - Nics: []*models.V1MachineNic{}, - }, - ID: new("1"), - Ledstate: &models.V1ChassisIdentifyLEDState{ - Description: new(""), - Value: new(""), + Hardware: &apiv2.MachineHardware{ + Cpus: []*apiv2.MetalCPU{ + { + Cores: 16, + }, + }, + Disks: []*apiv2.MachineBlockDevice{}, + Memory: uint64(32), + Nics: []*apiv2.MachineNic{}, }, - Liveliness: new("Alive"), - Name: "firewall-1", - Partition: partition1, - Rackid: "rack-1", - Size: size1, - State: &models.V1MachineState{ - Description: new("state"), - Issuer: "issuer", - MetalHammerVersion: new("version"), - Value: new(""), + Uuid: "1", + Status: &apiv2.MachineStatus{ + Condition: &apiv2.MachineCondition{ + Description: "state", + Issuer: "issuer", + }, + LedState: &apiv2.MachineChassisIdentifyLEDState{}, + Liveliness: apiv2.MachineLiveliness_MACHINE_LIVELINESS_ALIVE, + MetalHammerVersion: "version", }, - Tags: []string{"a"}, + Partition: partition1, + Rack: "rack-1", + Size: size1, } - firewall2 = func(event, message string) *models.V1FirewallResponse { - return &models.V1FirewallResponse{ - Allocation: &models.V1MachineAllocation{ - BootInfo: &models.V1BootInfo{ - Bootloaderid: new("bootloaderid"), - Cmdline: new("cmdline"), - ImageID: new("imageid"), - Initrd: new("initrd"), - Kernel: new("kernel"), - OsPartition: new("ospartition"), - PrimaryDisk: new("primarydisk"), + firewall2 = func(event, message string) *apiv2.Machine { + return &apiv2.Machine{ + Allocation: &apiv2.MachineAllocation{ + Meta: &apiv2.Meta{ + CreatedAt: timestamppb.New(testTime), }, - Created: new(strfmt.DateTime(testTime)), - Creator: new("creator"), + CreatedBy: "creator", Description: "firewall allocation 2", - Filesystemlayout: fsl1, - Hostname: new("firewall-hostname-2"), + FilesystemLayout: fsl1, + Hostname: "firewall-hostname-2", Image: image1, - Name: new("firewall-2"), - Networks: []*models.V1MachineNetwork{ + Name: "firewall-2", + Networks: []*apiv2.MachineNetwork{ { - Asn: new(int64(200)), - Destinationprefixes: []string{"2.2.2.2"}, + Asn: uint32(200), + DestinationPrefixes: []string{"2.2.2.2"}, Ips: []string{"1.1.1.1"}, - Nat: new(false), - Networkid: new("private"), - Networktype: new(net.PrivatePrimaryUnshared), + NatType: apiv2.NATType_NAT_TYPE_NONE, + Network: "private", + NetworkType: apiv2.NetworkType_NETWORK_TYPE_CHILD, Prefixes: []string{"prefixes"}, - Private: new(true), - Underlay: new(false), - Vrf: new(int64(100)), + Vrf: uint64(100), }, }, - Project: new("project-1"), - Reinstall: new(false), - Role: new(models.V1MachineAllocationRoleFirewall), - SSHPubKeys: []string{"sshpubkey"}, - Succeeded: new(true), - UserData: "---userdata---", + Project: "project-1", + AllocationType: apiv2.MachineAllocationType_MACHINE_ALLOCATION_TYPE_FIREWALL, + SshPublicKeys: []string{"sshpubkey"}, + Userdata: "---userdata---", }, - Bios: &models.V1MachineBIOS{ - Date: new("biosdata"), - Vendor: new("biosvendor"), - Version: new("biosversion"), - }, - Description: "firewall 2", - Events: &models.V1MachineRecentProvisioningEvents{ - CrashLoop: new(false), - FailedMachineReclaim: new(false), - LastErrorEvent: &models.V1MachineProvisioningEvent{}, - LastEventTime: strfmt.DateTime(testTime.Add(-1 * time.Minute)), - Log: []*models.V1MachineProvisioningEvent{ + RecentProvisioningEvents: &apiv2.MachineRecentProvisioningEvents{ + Events: []*apiv2.MachineProvisioningEvent{ { - Event: new(event), + Time: timestamppb.New(testTime.Add(-7 * 24 * time.Hour)), + Event: provisioningEventType(event), Message: message, - Time: strfmt.DateTime(testTime.Add(-7 * 24 * time.Hour)), }, }, + LastErrorEvent: &apiv2.MachineProvisioningEvent{}, + LastEventTime: timestamppb.New(testTime.Add(-1 * time.Minute)), + State: apiv2.MachineProvisioningEventState_MACHINE_PROVISIONING_EVENT_STATE_UNSPECIFIED, }, - Hardware: &models.V1MachineHardware{ - CPUCores: new(int32(16)), - Disks: []*models.V1MachineBlockDevice{}, - Memory: new(int64(32)), - Nics: []*models.V1MachineNic{}, - }, - ID: new("2"), - Ledstate: &models.V1ChassisIdentifyLEDState{ - Description: new(""), - Value: new(""), + Hardware: &apiv2.MachineHardware{ + Cpus: []*apiv2.MetalCPU{ + { + Cores: 16, + }, + }, + Disks: []*apiv2.MachineBlockDevice{}, + Memory: uint64(32), + Nics: []*apiv2.MachineNic{}, }, - Liveliness: new("Alive"), - Name: "firewall-2", - Partition: partition1, - Rackid: "rack-1", - Size: size1, - State: &models.V1MachineState{ - Description: new("state"), - Issuer: "issuer", - MetalHammerVersion: new("version"), - Value: new(""), + Uuid: "2", + Status: &apiv2.MachineStatus{ + Condition: &apiv2.MachineCondition{ + Description: "state", + Issuer: "issuer", + }, + LedState: &apiv2.MachineChassisIdentifyLEDState{}, + Liveliness: apiv2.MachineLiveliness_MACHINE_LIVELINESS_ALIVE, + MetalHammerVersion: "version", }, - Tags: []string{"b"}, + Partition: partition1, + Rack: "rack-1", + Size: size1, } } - fsl1 = &models.V1FilesystemLayoutResponse{ - Constraints: &models.V1FilesystemLayoutConstraints{ + fsl1 = &apiv2.FilesystemLayout{ + Constraints: &apiv2.FilesystemLayoutConstraints{ Images: map[string]string{ "os-image": "*", }, Sizes: []string{"size1"}, }, - Description: "fsl 1", - Disks: []*models.V1Disk{ + Description: new("fsl 1"), + Disks: []*apiv2.Disk{ { - Device: new("/dev/sda"), - Partitions: []*models.V1DiskPartition{ + Device: "/dev/sda", + Partitions: []*apiv2.DiskPartition{ { - Gpttype: new("ef00"), - Label: "efi", - Number: new(int64(1)), - Size: new(int64(1000)), + GptType: apiv2.GPTType_GPT_TYPE_BOOT.Enum(), + Label: new("efi"), + Number: uint32(1), + Size: uint64(1000), }, }, - Wipeonreinstall: new(true), }, }, - Filesystems: []*models.V1Filesystem{ + Filesystems: []*apiv2.Filesystem{ { - Createoptions: []string{"-F 32"}, - Device: new("/dev/sda1"), - Format: new("vfat"), - Label: "efi", - Mountoptions: []string{"noexec"}, - Path: "/boot/efi", + CreateOptions: []string{"-F 32"}, + Device: "/dev/sda1", + Format: apiv2.Format_FORMAT_VFAT, + Label: new("efi"), + MountOptions: []string{"noexec"}, + Path: new("/boot/efi"), }, { - Createoptions: []string{}, - Device: new("tmpfs"), - Format: new("tmpfs"), - Label: "", - Mountoptions: []string{"noexec"}, - Path: "/tmp", + CreateOptions: []string{}, + Device: "tmpfs", + Format: apiv2.Format_FORMAT_TMPFS, + Label: new(""), + MountOptions: []string{"noexec"}, + Path: new("/tmp"), }, }, - ID: new("1"), - Logicalvolumes: []*models.V1LogicalVolume{ + Id: "1", + LogicalVolumes: []*apiv2.LogicalVolume{ { - Lvmtype: new("linear"), - Name: new("varlib"), - Size: new(int64(5000)), - Volumegroup: new("lvm"), + LvmType: apiv2.LVMType_LVM_TYPE_LINEAR, + Name: "varlib", + Size: uint64(5000), + VolumeGroup: "lvm", }, }, - Name: "fsl1", - Raid: []*models.V1Raid{}, - Volumegroups: []*models.V1VolumeGroup{ + Name: new("fsl1"), + Raid: []*apiv2.Raid{}, + VolumeGroups: []*apiv2.VolumeGroup{ { Devices: []string{"/dev/nvme0n1"}, - Name: new("lvm"), + Name: "lvm", Tags: []string{}, }, }, } - imageExpiration = new(strfmt.DateTime(testTime.Add(3 * 24 * time.Hour))) - image1 = &models.V1ImageResponse{ - Classification: "supported", - Description: "firewall-image-description", - ExpirationDate: imageExpiration, - Features: []string{"firewall"}, - ID: new("firewall-ubuntu-2.0"), - Name: "firewall-image-name", - URL: "firewall-image-url", + imageExpiration = timestamppb.New(testTime.Add(3 * 24 * time.Hour)) + image1 = &apiv2.Image{ + Classification: apiv2.ImageClassification_IMAGE_CLASSIFICATION_SUPPORTED, + Description: new("firewall-image-description"), + ExpiresAt: imageExpiration, + Features: []apiv2.ImageFeature{apiv2.ImageFeature_IMAGE_FEATURE_FIREWALL}, + Id: "firewall-ubuntu-2.0", + Name: new("firewall-image-name"), + Url: "firewall-image-url", } - partition1 = &models.V1PartitionResponse{ - Bootconfig: &models.V1PartitionBootConfiguration{ + partition1 = &apiv2.Partition{ + BootConfiguration: &apiv2.PartitionBootConfiguration{ Commandline: "commandline", - Imageurl: "imageurl", - Kernelurl: "kernelurl", + ImageUrl: "imageurl", + KernelUrl: "kernelurl", }, - Description: "partition 1", - ID: new("1"), - Mgmtserviceaddress: "mgmt", - Name: "partition-1", + Description: "partition 1", + Id: "1", + MgmtServiceAddresses: []string{"mgmt"}, } - size1 = &models.V1SizeResponse{ - Constraints: []*models.V1SizeConstraint{ + size1 = &apiv2.Size{ + Constraints: []*apiv2.SizeConstraint{ { - Max: int64(2), - Min: int64(1), - Type: new("storage"), + Max: uint64(2), + Min: uint64(1), + Type: apiv2.SizeConstraintType_SIZE_CONSTRAINT_TYPE_STORAGE, }, { - Max: int64(4), - Min: int64(3), - Type: new("memory"), + Max: uint64(4), + Min: uint64(3), + Type: apiv2.SizeConstraintType_SIZE_CONSTRAINT_TYPE_MEMORY, }, { - Max: int64(6), - Min: int64(5), - Type: new("cores"), + Max: uint64(6), + Min: uint64(5), + Type: apiv2.SizeConstraintType_SIZE_CONSTRAINT_TYPE_CORES, }, }, - Description: "size 1", - ID: new("1"), - Name: "size-1", + Description: new("size 1"), + Id: "1", + Name: new("size-1"), } - network1 = &models.V1NetworkResponse{ - Description: "network 1", - Destinationprefixes: []string{"dest"}, - ID: new("nw1"), - Labels: map[string]string{"a": "b"}, - Name: "network-1", - Nat: new(true), - Parentnetworkid: "", - Partitionid: "partition-1", + network1 = &apiv2.Network{ + Description: new("network 1"), + DestinationPrefixes: []string{"dest"}, + Id: "nw1", + Name: new("network-1"), + NatType: apiv2.NATType_NAT_TYPE_IPV4_MASQUERADE, + Partition: new("partition-1"), Prefixes: []string{"prefix"}, - Privatesuper: new(true), - Projectid: "", - Shared: false, - Underlay: new(true), - Usage: &models.V1NetworkUsage{ - AvailableIps: new(int64(100)), - AvailablePrefixes: new(int64(200)), - UsedIps: new(int64(300)), - UsedPrefixes: new(int64(400)), - }, - Vrf: 50, - Vrfshared: true, + Project: new(""), + Type: apiv2.NetworkType_NETWORK_TYPE_UNDERLAY, + Vrf: new(uint32(50)), } ) -// we are sharing a client for the tests, so we need to make sure we do not run contradicting tests in parallel -// we can swap the client with this function -func swapMetalClient(mockFns *metalclient.MetalMockFns) { - newClient, _ := metalclient.NewMetalMockClient(testingT, mockFns) +func provisioningEventType(event string) apiv2.MachineProvisioningEventType { + switch event { + case "Phoned Home": + return apiv2.MachineProvisioningEventType_MACHINE_PROVISIONING_EVENT_TYPE_PHONED_HOME + case "Installing": + return apiv2.MachineProvisioningEventType_MACHINE_PROVISIONING_EVENT_TYPE_INSTALLING + case "Crashed": + return apiv2.MachineProvisioningEventType_MACHINE_PROVISIONING_EVENT_TYPE_CRASHED + default: + return apiv2.MachineProvisioningEventType_MACHINE_PROVISIONING_EVENT_TYPE_UNSPECIFIED + } +} - if metalClient == nil { - metalClient = newClient - return +// we are sharing a metal client for the tests, so we need to make sure we do not run contradicting tests in parallel +// the shared metal mock client is reconfigured with this function +func swapMetalClient(fns func(*test.Client)) { + if metalMock != nil && fns != nil { + fns(metalMock) } +} - metalMockClient := metalClient.(*metalclient.MetalMockClient) - *metalMockClient = *newClient // nolint for testing this is just fine +// mockMachine configures the machine service handlers to return the given firewalls. +func mockMachine(m *test.Client, fws ...*apiv2.Machine) { + machine := fws[0] + + m.OnMachineGet = func(_ context.Context, _ *apiv2.MachineServiceGetRequest) (*apiv2.MachineServiceGetResponse, error) { + return &apiv2.MachineServiceGetResponse{Machine: machine}, nil + } + m.OnMachineCreate = func(_ context.Context, _ *apiv2.MachineServiceCreateRequest) (*apiv2.MachineServiceCreateResponse, error) { + return &apiv2.MachineServiceCreateResponse{Machine: machine}, nil + } + m.OnMachineList = func(_ context.Context, _ *apiv2.MachineServiceListRequest) (*apiv2.MachineServiceListResponse, error) { + return &apiv2.MachineServiceListResponse{Machines: fws}, nil + } +} + +// mockMachineDelete configures the machine delete handler to return the given firewall. +func mockMachineDelete(m *test.Client, machine *apiv2.Machine) { + m.OnMachineDelete = func(_ context.Context, _ *apiv2.MachineServiceDeleteRequest) (*apiv2.MachineServiceDeleteResponse, error) { + return &apiv2.MachineServiceDeleteResponse{Machine: machine}, nil + } +} + +// mockMachineDeleteErr configures the machine delete handler to return the given error. +func mockMachineDeleteErr(m *test.Client, err error) { + m.OnMachineDelete = func(_ context.Context, _ *apiv2.MachineServiceDeleteRequest) (*apiv2.MachineServiceDeleteResponse, error) { + return nil, err + } +} + +// mockMachineUpdate configures the machine update handler to succeed. +func mockMachineUpdate(m *test.Client) { + m.OnMachineUpdate = func(_ context.Context, _ *apiv2.MachineServiceUpdateRequest) (*apiv2.MachineServiceUpdateResponse, error) { + return &apiv2.MachineServiceUpdateResponse{Machine: &apiv2.Machine{}}, nil + } +} + +// mockNetwork configures the network service handler to return the given network. +func mockNetwork(m *test.Client, nw *apiv2.Network) { + m.OnNetworkGet = func(_ context.Context, _ *apiv2.NetworkServiceGetRequest) (*apiv2.NetworkServiceGetResponse, error) { + return &apiv2.NetworkServiceGetResponse{Network: nw}, nil + } +} + +// mockImage configures the image service handler to return the given image. +func mockImage(m *test.Client, img *apiv2.Image) { + m.OnImageLatest = func(_ context.Context, _ *apiv2.ImageServiceLatestRequest) (*apiv2.ImageServiceLatestResponse, error) { + return &apiv2.ImageServiceLatestResponse{Image: img}, nil + } } diff --git a/integration/suite_test.go b/integration/suite_test.go index 8db2fed..b31e717 100644 --- a/integration/suite_test.go +++ b/integration/suite_test.go @@ -18,7 +18,7 @@ import ( "github.com/metal-stack/firewall-controller-manager/controllers/set" "github.com/metal-stack/firewall-controller-manager/controllers/timeout" "github.com/metal-stack/firewall-controller-manager/controllers/update" - metalclient "github.com/metal-stack/metal-go/test/client" + "github.com/metal-stack/firewall-controller-manager/internal/test" "github.com/metal-stack/metal-lib/pkg/tag" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" @@ -110,7 +110,8 @@ var _ = BeforeSuite(func() { }) Expect(err).ToNot(HaveOccurred()) - metalClient, _ = metalclient.NewMetalMockClient(testingT, nil) + metalMock = test.New(testingT) + metalClient = metalMock.Client() cc, err := controllerconfig.New(&controllerconfig.NewControllerConfig{ SeedClient: k8sClient, diff --git a/internal/test/mock.go b/internal/test/mock.go new file mode 100644 index 0000000..810d1e3 --- /dev/null +++ b/internal/test/mock.go @@ -0,0 +1,182 @@ +// Package metalmock provides a configurable mock for the metal-stack apiv2 connect +// client (github.com/metal-stack/api) that can be injected into the controllers via +// the ControllerConfig. It uses a connect client interceptor to serve the machine, +// network and image service calls and delegates each call to a programmable handler. +package test + +import ( + "context" + "sync" + "testing" + + "connectrpc.com/connect" + apiv2client "github.com/metal-stack/api/go/client" + apiv2 "github.com/metal-stack/api/go/metalstack/api/v2" + "github.com/metal-stack/api/go/metalstack/api/v2/apiv2connect" +) + +// Handler signatures for the service methods used by the controllers. + +type ( + MachineGetFn func(context.Context, *apiv2.MachineServiceGetRequest) (*apiv2.MachineServiceGetResponse, error) + MachineCreateFn func(context.Context, *apiv2.MachineServiceCreateRequest) (*apiv2.MachineServiceCreateResponse, error) + MachineUpdateFn func(context.Context, *apiv2.MachineServiceUpdateRequest) (*apiv2.MachineServiceUpdateResponse, error) + MachineListFn func(context.Context, *apiv2.MachineServiceListRequest) (*apiv2.MachineServiceListResponse, error) + MachineDeleteFn func(context.Context, *apiv2.MachineServiceDeleteRequest) (*apiv2.MachineServiceDeleteResponse, error) + + NetworkGetFn func(context.Context, *apiv2.NetworkServiceGetRequest) (*apiv2.NetworkServiceGetResponse, error) + + ImageLatestFn func(context.Context, *apiv2.ImageServiceLatestRequest) (*apiv2.ImageServiceLatestResponse, error) +) + +// Client is a configurable mock apiv2 client implemented as a connect client +// interceptor. Set the various handler fields before using it. Unset handlers +// answer with connect.CodeUnimplemented. The handler fields may be reconfigured +// at any time (e.g. between calls in an integration test). +type Client struct { + t *testing.T + + mu sync.RWMutex + + OnMachineGet MachineGetFn + OnMachineCreate MachineCreateFn + OnMachineUpdate MachineUpdateFn + OnMachineList MachineListFn + OnMachineDelete MachineDeleteFn + + OnNetworkGet NetworkGetFn + + OnImageLatest ImageLatestFn + + apiv2 apiv2client.Client +} + +// New creates a mock apiv2 client backed by a connect client interceptor. +func New(t *testing.T) *Client { + return &Client{t: t} +} + +// Client returns the apiv2 client that can be passed to the ControllerConfig. +// It is constructed lazily so that the returned client is always wired with this +// mock as its interceptor. +func (m *Client) Client() apiv2client.Client { + m.mu.RLock() + c := m.apiv2 + m.mu.RUnlock() + if c != nil { + return c + } + + m.mu.Lock() + defer m.mu.Unlock() + if m.apiv2 != nil { + return m.apiv2 + } + + c, err := apiv2client.New(&apiv2client.DialConfig{ + BaseURL: "http://localhost", + Interceptors: []connect.Interceptor{m}, + }) + if err != nil { + m.t.Fatalf("unable to create mock apiv2 client: %v", err) + } + m.apiv2 = c + return c +} + +// WrapUnary implements connect.UnaryInterceptorClient. It dispatches the call to +// the configured handler based on the connect procedure, or returns +// connect.CodeUnimplemented when no handler is set for the call. +func (m *Client) WrapUnary(next connect.UnaryFunc) connect.UnaryFunc { + return func(ctx context.Context, req connect.AnyRequest) (connect.AnyResponse, error) { + m.mu.RLock() + defer m.mu.RUnlock() + + var ( + resp connect.AnyResponse + err error + ) + switch req.Spec().Procedure { + case apiv2connect.MachineServiceGetProcedure: + var r *apiv2.MachineServiceGetResponse + if m.OnMachineGet != nil { + r, err = m.OnMachineGet(ctx, req.Any().(*apiv2.MachineServiceGetRequest)) + } + if r != nil { + resp = connect.NewResponse(r) + } + case apiv2connect.MachineServiceCreateProcedure: + var r *apiv2.MachineServiceCreateResponse + if m.OnMachineCreate != nil { + r, err = m.OnMachineCreate(ctx, req.Any().(*apiv2.MachineServiceCreateRequest)) + } + if r != nil { + resp = connect.NewResponse(r) + } + case apiv2connect.MachineServiceUpdateProcedure: + var r *apiv2.MachineServiceUpdateResponse + if m.OnMachineUpdate != nil { + r, err = m.OnMachineUpdate(ctx, req.Any().(*apiv2.MachineServiceUpdateRequest)) + } + if r != nil { + resp = connect.NewResponse(r) + } + case apiv2connect.MachineServiceListProcedure: + var r *apiv2.MachineServiceListResponse + if m.OnMachineList != nil { + r, err = m.OnMachineList(ctx, req.Any().(*apiv2.MachineServiceListRequest)) + } + if r != nil { + resp = connect.NewResponse(r) + } + case apiv2connect.MachineServiceDeleteProcedure: + var r *apiv2.MachineServiceDeleteResponse + if m.OnMachineDelete != nil { + r, err = m.OnMachineDelete(ctx, req.Any().(*apiv2.MachineServiceDeleteRequest)) + } + if r != nil { + resp = connect.NewResponse(r) + } + case apiv2connect.NetworkServiceGetProcedure: + var r *apiv2.NetworkServiceGetResponse + if m.OnNetworkGet != nil { + r, err = m.OnNetworkGet(ctx, req.Any().(*apiv2.NetworkServiceGetRequest)) + } + if r != nil { + resp = connect.NewResponse(r) + } + case apiv2connect.ImageServiceLatestProcedure: + var r *apiv2.ImageServiceLatestResponse + if m.OnImageLatest != nil { + r, err = m.OnImageLatest(ctx, req.Any().(*apiv2.ImageServiceLatestRequest)) + } + if r != nil { + resp = connect.NewResponse(r) + } + default: + return nil, connect.NewError(connect.CodeUnimplemented, nil) + } + + if err != nil { + return nil, err + } + if resp == nil { + return nil, connect.NewError(connect.CodeUnimplemented, nil) + } + return resp, nil + } +} + +// WrapStreamingClient implements connect.UnaryInterceptorClient. The controllers +// only use unary calls, so this is not supported. +func (m *Client) WrapStreamingClient(next connect.StreamingClientFunc) connect.StreamingClientFunc { + m.t.Errorf("metalmock does not support streaming client calls") + return nil +} + +// WrapStreamingHandler implements connect.UnaryInterceptorClient. The controllers +// only use unary calls, so this is not supported. +func (m *Client) WrapStreamingHandler(next connect.StreamingHandlerFunc) connect.StreamingHandlerFunc { + m.t.Errorf("metalmock does not support streaming handler calls") + return nil +} diff --git a/main.go b/main.go index 1ebcd11..f6705a2 100644 --- a/main.go +++ b/main.go @@ -11,7 +11,7 @@ import ( "github.com/go-logr/logr" - metalgo "github.com/metal-stack/metal-go" + apiv2client "github.com/metal-stack/api/go/client" "github.com/metal-stack/metal-lib/pkg/tag" "github.com/metal-stack/v" @@ -35,14 +35,12 @@ import ( "github.com/metal-stack/firewall-controller-manager/controllers/update" ) -const ( - metalAuthHMACEnvVar = "METAL_AUTH_HMAC" -) - func main() { var ( - scheme = helper.MustNewFirewallScheme() - metalURL string + scheme = helper.MustNewFirewallScheme() + metalURL string + tokenfile string + project string logLevel string metricsAddr string @@ -80,7 +78,9 @@ func main() { flag.DurationVar(&safetyBackoff, "safety-backoff", 10*time.Second, "duration after which a resource is getting reconciled at minimum") flag.DurationVar(&progressDeadline, "progress-deadline", 15*time.Minute, "time after which a deployment is considered unhealthy instead of progressing (informational)") flag.DurationVar(&gracefulShutdownTimeout, "graceful-shutdown-timeout", -1, "grace period after which the controller shuts down") - flag.StringVar(&metalURL, "metal-api-url", "", "the url of the metal-stack api") + flag.StringVar(&metalURL, "metal-apiv2-url", "", "the url of the metal-stack apiserver") + flag.StringVar(&tokenfile, "token-file", "", "the path to the token file to authenticate against the metal-stack apiserver") + flag.StringVar(&project, "project", "", "project id of this cluster") flag.StringVar(&clusterID, "cluster-id", "", "id of the cluster this controller is responsible for") flag.StringVar(&shootApiURL, "shoot-api-url", "", "url of the shoot api server, if not provided falls back to single-cluster mode") flag.StringVar(&internalShootApiURL, "internal-shoot-api-url", "", "url of the shoot api server used by this controller, not published in the shoot access status") @@ -111,7 +111,7 @@ func main() { stop = ctrl.SetupSignalHandler() ) - mclient, err := getMetalClient(metalURL) + mclient, err := getMetalClient(metalURL, tokenfile) if err != nil { log.Fatalf("unable to create metal client %v", err) } @@ -252,6 +252,7 @@ func main() { ShootAccessHelper: internalShootAccessHelper, Metal: mclient, ClusterTag: fmt.Sprintf("%s=%s", tag.ClusterID, clusterID), + Project: project, SafetyBackoff: safetyBackoff, ProgressDeadline: progressDeadline, FirewallHealthTimeout: firewallHealthTimeout, @@ -303,19 +304,21 @@ func main() { } } -func getMetalClient(url string) (metalgo.Client, error) { - hmac := os.Getenv(metalAuthHMACEnvVar) - +func getMetalClient(url, tokenfile string) (apiv2client.Client, error) { if url == "" { return nil, fmt.Errorf("metal api url is required") } - if hmac == "" { - return nil, fmt.Errorf("environment variable %q is required", metalAuthHMACEnvVar) + if tokenfile == "" { + return nil, fmt.Errorf("tokenfile is required") } - client, err := metalgo.NewDriver(url, "", hmac) + client, err := apiv2client.New(&apiv2client.DialConfig{ + BaseURL: url, + TokenFile: tokenfile, + }) + if err != nil { - return nil, fmt.Errorf("unable to initialize metal ccm:%w", err) + return nil, err } return client, nil