Skip to content

Commit ba093b1

Browse files
rmedina97andreacv98AleC-IX
authored
Enhancement/liqo v1.0.0 (#135)
* Integration of Liqo v1.0.0-rc.3 (#131) * Update: Liqo version 1.0.0 from Liqo version 1.0.0-rc3 * broker CRD no longer directly embeds secrets, fix liqoctl path in installation.sh, fix for Lint 1.64.2, fix liqoctl version in requirements.sh --------- Co-authored-by: Andrea Colli-Vignarelli <[email protected]> Co-authored-by: AlessandroCarbonelli <[email protected]>
1 parent 16a68c7 commit ba093b1

Some content is hidden

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

51 files changed

+2124
-1317
lines changed

.golangci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ linters-settings:
6868
dupl:
6969
threshold: 300
7070
gocyclo:
71-
min-complexity: 34
71+
min-complexity: 39
7272

7373
linters:
7474
disable-all: true

apis/network/v1alpha1/broker_types.go

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,18 @@
1515
package v1alpha1
1616

1717
import (
18-
corev1 "k8s.io/api/core/v1"
1918
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2019
)
2120

2221
// BrokerSpec defines the desired state of Broker.
2322
type BrokerSpec struct {
2423

2524
// Address of the Broker.
26-
Address string `json:"address"`
27-
Name string `json:"name"`
28-
ClCert *corev1.Secret `json:"clcert"`
29-
CaCert *corev1.Secret `json:"cacert"`
30-
Role string `json:"role"`
25+
Address string `json:"address"`
26+
Name string `json:"name"`
27+
ClCert string `json:"clcert"`
28+
CaCert string `json:"cacert"`
29+
Role string `json:"role"`
3130
}
3231

3332
// BrokerStatus defines the observed state of Broker.

apis/network/v1alpha1/zz_generated.deepcopy.go

Lines changed: 1 addition & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

apis/nodecore/v1alpha1/common.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,8 @@ type Configuration struct {
7878

7979
// LiqoCredentials contains the credentials of a Liqo cluster to enstablish a peering.
8080
type LiqoCredentials struct {
81-
ClusterID string `json:"clusterID"`
82-
ClusterName string `json:"clusterName"`
83-
Token string `json:"token"`
84-
Endpoint string `json:"endpoint"`
81+
ClusterID string `json:"liqoID"`
82+
Kubeconfig string `json:"kubeconfig"`
8583
}
8684

8785
// ParseConfiguration parses the configuration data into the correct type.

apis/nodecore/v1alpha1/flavor_webhook.go

Lines changed: 29 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
package v1alpha1
1616

1717
import (
18+
"context"
19+
1820
"k8s.io/apimachinery/pkg/runtime"
1921
ctrl "sigs.k8s.io/controller-runtime"
2022
logf "sigs.k8s.io/controller-runtime/pkg/log"
@@ -28,34 +30,43 @@ var flavorlog = logf.Log.WithName("flavor-resource")
2830
// SetupWebhookWithManager setups the webhooks for the Flavor resource with the manager.
2931
func (r *Flavor) SetupWebhookWithManager(mgr ctrl.Manager) error {
3032
return ctrl.NewWebhookManagedBy(mgr).
31-
For(r).
33+
For(&Flavor{}).
34+
WithDefaulter(&Flavor{}).
35+
WithValidator(&Flavor{}).
3236
Complete()
3337
}
3438

3539
//nolint:lll // kubebuilder directives are too long, but they must be on the same line
3640
//+kubebuilder:webhook:path=/mutate-nodecore-fluidos-eu-v1alpha1-flavor,mutating=true,failurePolicy=fail,sideEffects=None,groups=nodecore.fluidos.eu,resources=flavors,verbs=create;update,versions=v1alpha1,name=mflavor.kb.io,admissionReviewVersions=v1
3741

38-
var _ webhook.Defaulter = &Flavor{}
42+
var _ webhook.CustomDefaulter = &Flavor{}
3943

4044
// Default implements webhook.Defaulter so a webhook will be registered for the type.
41-
func (r *Flavor) Default() {
45+
func (r *Flavor) Default(ctx context.Context, obj runtime.Object) error {
46+
_ = ctx
47+
// Parse obj to Flavor
48+
flavor := obj.(*Flavor)
4249
flavorlog.Info("DEFAULT WEBHOOK")
43-
flavorlog.Info("default", "name", r.Name)
50+
flavorlog.Info("default", "name", flavor.Name)
51+
52+
return nil
4453
}
4554

4655
// TODO(user): change verbs to "verbs=create;update;delete" if you want to enable deletion validation.
4756
//nolint:lll // kubebuilder directives are too long, but they must be on the same line
4857
//+kubebuilder:webhook:path=/validate-nodecore-fluidos-eu-v1alpha1-flavor,mutating=false,failurePolicy=fail,sideEffects=None,groups=nodecore.fluidos.eu,resources=flavors,verbs=create;update,versions=v1alpha1,name=vflavor.kb.io,admissionReviewVersions=v1
4958

50-
var _ webhook.Validator = &Flavor{}
59+
var _ webhook.CustomValidator = &Flavor{}
5160

5261
// ValidateCreate implements webhook.Validator so a webhook will be registered for the type.
53-
func (r *Flavor) ValidateCreate() (admission.Warnings, error) {
62+
func (r *Flavor) ValidateCreate(ctx context.Context, obj runtime.Object) (admission.Warnings, error) {
63+
_ = ctx
64+
flavor := obj.(*Flavor)
5465
flavorlog.Info("VALIDATE CREATE WEBHOOK")
55-
flavorlog.Info("validate create", "name", r.Name)
66+
flavorlog.Info("validate create", "name", flavor.Name)
5667

5768
// Validate creation of Flavor checking FlavorType->TypeIdenfier matches the struct inside the FlavorType->TypeData
58-
typeIdenfier, _, err := ParseFlavorType(r)
69+
typeIdenfier, _, err := ParseFlavorType(flavor)
5970
if err != nil {
6071
return nil, err
6172
}
@@ -74,14 +85,16 @@ func (r *Flavor) ValidateCreate() (admission.Warnings, error) {
7485
}
7586

7687
// ValidateUpdate implements webhook.Validator so a webhook will be registered for the type.
77-
func (r *Flavor) ValidateUpdate(old runtime.Object) (admission.Warnings, error) {
88+
func (r *Flavor) ValidateUpdate(ctx context.Context, oldObj, newObj runtime.Object) (admission.Warnings, error) {
89+
_ = ctx
90+
flavor := newObj.(*Flavor)
7891
flavorlog.Info("VALIDATE UPDATE WEBHOOK")
79-
flavorlog.Info("validate update", "name", r.Name)
92+
flavorlog.Info("validate update", "name", flavor.Name)
8093

81-
flavorlog.Info("old", "old", old)
94+
flavorlog.Info("old", "old", oldObj)
8295

8396
// Validate creation of Flavor checking FlavorType->TypeIdenfier matches the struct inside the FlavorType->TypeData
84-
typeIdenfier, _, err := ParseFlavorType(r)
97+
typeIdenfier, _, err := ParseFlavorType(flavor)
8598
if err != nil {
8699
return nil, err
87100
}
@@ -100,9 +113,11 @@ func (r *Flavor) ValidateUpdate(old runtime.Object) (admission.Warnings, error)
100113
}
101114

102115
// ValidateDelete implements webhook.Validator so a webhook will be registered for the type.
103-
func (r *Flavor) ValidateDelete() (admission.Warnings, error) {
116+
func (r *Flavor) ValidateDelete(ctx context.Context, obj runtime.Object) (admission.Warnings, error) {
117+
_ = ctx
118+
flavor := obj.(*Flavor)
104119
flavorlog.Info("VALIDATE DELETE WEBHOOK")
105-
flavorlog.Info("validate delete", "name", r.Name)
120+
flavorlog.Info("validate delete", "name", flavor.Name)
106121

107122
// TODO(user): fill in your validation logic upon object deletion.
108123
return nil, nil

apis/nodecore/v1alpha1/service_blueprint_webhook.go

Lines changed: 28 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
package v1alpha1
1616

1717
import (
18+
"context"
19+
1820
"k8s.io/apimachinery/pkg/runtime"
1921
ctrl "sigs.k8s.io/controller-runtime"
2022
logf "sigs.k8s.io/controller-runtime/pkg/log"
@@ -28,34 +30,42 @@ var serviceblueprintlog = logf.Log.WithName("serviceblueprint-resource")
2830
// SetupWebhookWithManager setups the webhooks for the ServiceBlueprint resource with the manager.
2931
func (r *ServiceBlueprint) SetupWebhookWithManager(mgr ctrl.Manager) error {
3032
return ctrl.NewWebhookManagedBy(mgr).
31-
For(r).
33+
For(&ServiceBlueprint{}).
34+
WithDefaulter(&ServiceBlueprint{}).
35+
WithValidator(&ServiceBlueprint{}).
3236
Complete()
3337
}
3438

3539
//nolint:lll // kubebuilder directives are too long, but they must be on the same line
3640
//+kubebuilder:webhook:path=/mutate-nodecore-fluidos-eu-v1alpha1-serviceblueprint,mutating=true,failurePolicy=fail,sideEffects=None,groups=nodecore.fluidos.eu,resources=serviceblueprints,verbs=create;update,versions=v1alpha1,name=mserviceblueprint.kb.io,admissionReviewVersions=v1
3741

38-
var _ webhook.Defaulter = &ServiceBlueprint{}
42+
var _ webhook.CustomDefaulter = &ServiceBlueprint{}
3943

4044
// Default implements webhook.Defaulter so a webhook will be registered for the type.
41-
func (r *ServiceBlueprint) Default() {
45+
func (r *ServiceBlueprint) Default(ctx context.Context, obj runtime.Object) error {
46+
_ = ctx
47+
serviceblueprint := obj.(*ServiceBlueprint)
4248
serviceblueprintlog.Info("DEFAULT WEBHOOK")
43-
serviceblueprintlog.Info("default", "name", r.Name)
49+
serviceblueprintlog.Info("default", "name", serviceblueprint.Name)
50+
51+
return nil
4452
}
4553

4654
// TODO(user): change verbs to "verbs=create;update;delete" if you want to enable deletion validation.
4755
//nolint:lll // kubebuilder directives are too long, but they must be on the same line
4856
//+kubebuilder:webhook:path=/validate-nodecore-fluidos-eu-v1alpha1-serviceblueprint,mutating=false,failurePolicy=fail,sideEffects=None,groups=nodecore.fluidos.eu,resources=serviceblueprints,verbs=create;update,versions=v1alpha1,name=vserviceblueprint.kb.io,admissionReviewVersions=v1
4957

50-
var _ webhook.Validator = &ServiceBlueprint{}
58+
var _ webhook.CustomValidator = &ServiceBlueprint{}
5159

5260
// ValidateCreate implements webhook.Validator so a webhook will be registered for the type.
53-
func (r *ServiceBlueprint) ValidateCreate() (admission.Warnings, error) {
61+
func (r *ServiceBlueprint) ValidateCreate(ctx context.Context, obj runtime.Object) (admission.Warnings, error) {
62+
_ = ctx
63+
serviceblueprint := obj.(*ServiceBlueprint)
5464
serviceblueprintlog.Info("VALIDATE CREATE WEBHOOK")
55-
serviceblueprintlog.Info("validate create", "name", r.Name)
65+
serviceblueprintlog.Info("validate create", "name", serviceblueprint.Name)
5666

5767
// Validate ServiceBlueprint templates
58-
manifests, err := ValidateAndExtractManifests(r.Spec.Templates)
68+
manifests, err := ValidateAndExtractManifests(serviceblueprint.Spec.Templates)
5969
if err != nil {
6070
return nil, err
6171
}
@@ -67,14 +77,16 @@ func (r *ServiceBlueprint) ValidateCreate() (admission.Warnings, error) {
6777
}
6878

6979
// ValidateUpdate implements webhook.Validator so a webhook will be registered for the type.
70-
func (r *ServiceBlueprint) ValidateUpdate(old runtime.Object) (admission.Warnings, error) {
80+
func (r *ServiceBlueprint) ValidateUpdate(ctx context.Context, oldObj, newObj runtime.Object) (admission.Warnings, error) {
81+
_ = ctx
82+
serviceblueprint := newObj.(*ServiceBlueprint)
7183
serviceblueprintlog.Info("VALIDATE UPDATE WEBHOOK")
72-
serviceblueprintlog.Info("validate update", "name", r.Name)
84+
serviceblueprintlog.Info("validate update", "name", serviceblueprint.Name)
7385

74-
serviceblueprintlog.Info("old", "old", old)
86+
serviceblueprintlog.Info("old", "old", oldObj)
7587

7688
// Validate ServiceBlueprint templates
77-
manifests, err := ValidateAndExtractManifests(r.Spec.Templates)
89+
manifests, err := ValidateAndExtractManifests(serviceblueprint.Spec.Templates)
7890
if err != nil {
7991
return nil, err
8092
}
@@ -86,9 +98,11 @@ func (r *ServiceBlueprint) ValidateUpdate(old runtime.Object) (admission.Warning
8698
}
8799

88100
// ValidateDelete implements webhook.Validator so a webhook will be registered for the type.
89-
func (r *ServiceBlueprint) ValidateDelete() (admission.Warnings, error) {
101+
func (r *ServiceBlueprint) ValidateDelete(ctx context.Context, obj runtime.Object) (admission.Warnings, error) {
102+
_ = ctx
103+
serviceblueprint := obj.(*ServiceBlueprint)
90104
serviceblueprintlog.Info("VALIDATE DELETE WEBHOOK")
91-
serviceblueprintlog.Info("validate delete", "name", r.Name)
105+
serviceblueprintlog.Info("validate delete", "name", serviceblueprint.Name)
92106

93107
// TODO(user): fill in your validation logic upon object deletion.
94108
return nil, nil

apis/nodecore/v1alpha1/solver_webhook.go

Lines changed: 28 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
package v1alpha1
1616

1717
import (
18+
"context"
19+
1820
"k8s.io/apimachinery/pkg/runtime"
1921
ctrl "sigs.k8s.io/controller-runtime"
2022
logf "sigs.k8s.io/controller-runtime/pkg/log"
@@ -28,57 +30,69 @@ var solverlog = logf.Log.WithName("solver-resource")
2830
// SetupWebhookWithManager sets up and registers the webhook with the manager.
2931
func (r *Solver) SetupWebhookWithManager(mgr ctrl.Manager) error {
3032
return ctrl.NewWebhookManagedBy(mgr).
31-
For(r).
33+
For(&Solver{}).
34+
WithDefaulter(&Solver{}).
35+
WithValidator(&Solver{}).
3236
Complete()
3337
}
3438

3539
//nolint:lll // kubebuilder directives are too long, but they must be on the same line
3640
//+kubebuilder:webhook:path=/mutate-nodecore-fluidos-eu-v1alpha1-solver,mutating=true,failurePolicy=fail,sideEffects=None,groups=nodecore.fluidos.eu,resources=solvers,verbs=create;update,versions=v1alpha1,name=msolver.kb.io,admissionReviewVersions=v1
3741

38-
var _ webhook.Defaulter = &Solver{}
42+
var _ webhook.CustomDefaulter = &Solver{}
3943

4044
// Default implements webhook.Defaulter so a webhook will be registered for the type.
41-
func (r *Solver) Default() {
45+
func (r *Solver) Default(ctx context.Context, obj runtime.Object) error {
46+
_ = ctx
47+
solver := obj.(*Solver)
4248
solverlog.Info("DEFAULT WEBHOOK")
43-
solverlog.Info("default", "name", r.Name)
49+
solverlog.Info("default", "name", solver.Name)
50+
51+
return nil
4452
}
4553

4654
// TODO(user): change verbs to "verbs=create;update;delete" if you want to enable deletion validation.
4755
//nolint:lll // kubebuilder directives are too long, but they must be on the same line
4856
//+kubebuilder:webhook:path=/validate-nodecore-fluidos-eu-v1alpha1-solver,mutating=false,failurePolicy=fail,sideEffects=None,groups=nodecore.fluidos.eu,resources=solvers,verbs=create;update,versions=v1alpha1,name=vsolver.kb.io,admissionReviewVersions=v1
4957

50-
var _ webhook.Validator = &Solver{}
58+
var _ webhook.CustomValidator = &Solver{}
5159

5260
// ValidateCreate implements webhook.Validator so a webhook will be registered for the type.
53-
func (r *Solver) ValidateCreate() (admission.Warnings, error) {
61+
func (r *Solver) ValidateCreate(ctx context.Context, obj runtime.Object) (admission.Warnings, error) {
62+
_ = ctx
63+
solver := obj.(*Solver)
5464
solverlog.Info("VALIDATE CREATE WEBHOOK")
55-
solverlog.Info("validate create", "name", r.Name)
65+
solverlog.Info("validate create", "name", solver.Name)
5666

57-
if err := validateSelector(r.Spec.Selector); err != nil {
67+
if err := validateSelector(solver.Spec.Selector); err != nil {
5868
return nil, err
5969
}
6070

6171
return nil, nil
6272
}
6373

6474
// ValidateUpdate implements webhook.Validator so a webhook will be registered for the type.
65-
func (r *Solver) ValidateUpdate(old runtime.Object) (admission.Warnings, error) {
75+
func (r *Solver) ValidateUpdate(ctx context.Context, oldObj, newObj runtime.Object) (admission.Warnings, error) {
76+
_ = ctx
77+
solver := newObj.(*Solver)
6678
solverlog.Info("VALIDATE UPDATE WEBHOOK")
67-
solverlog.Info("validate update", "name", r.Name)
79+
solverlog.Info("validate update", "name", solver.Name)
6880

69-
solverlog.Info("old", "old", old)
81+
solverlog.Info("old", "old", oldObj)
7082

71-
if err := validateSelector(r.Spec.Selector); err != nil {
83+
if err := validateSelector(solver.Spec.Selector); err != nil {
7284
return nil, err
7385
}
7486

7587
return nil, nil
7688
}
7789

7890
// ValidateDelete implements webhook.Validator so a webhook will be registered for the type.
79-
func (r *Solver) ValidateDelete() (admission.Warnings, error) {
91+
func (r *Solver) ValidateDelete(ctx context.Context, obj runtime.Object) (admission.Warnings, error) {
92+
_ = ctx
93+
solver := obj.(*Solver)
8094
solverlog.Info("VALIDATE DELETE WEBHOOK")
81-
solverlog.Info("validate delete", "name", r.Name)
95+
solverlog.Info("validate delete", "name", solver.Name)
8296

8397
// TODO(user): fill in your validation logic upon object deletion.
8498
return nil, nil

0 commit comments

Comments
 (0)