Skip to content

Commit

Permalink
Reformatted following linting
Browse files Browse the repository at this point in the history
  • Loading branch information
LorenzoMoro committed Oct 12, 2024
1 parent b09de8b commit 6e1f7ee
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 25 deletions.
2 changes: 1 addition & 1 deletion cmd/network-manager/doc.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2022-2023 FLUIDOS Project
// Copyright 2022-2024 FLUIDOS Project
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down
3 changes: 1 addition & 2 deletions cmd/network-manager/main.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2022-2023 FLUIDOS Project
// Copyright 2022-2024 FLUIDOS Project
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -83,7 +83,6 @@ func main() {
setupLog.Error(err, "Unable to start NetworkManager")
os.Exit(1)
}

}

func healthHandler(w http.ResponseWriter, _ *http.Request) {
Expand Down
2 changes: 1 addition & 1 deletion pkg/network-manager/doc.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2022-2023 FLUIDOS Project
// Copyright 2022-2024 FLUIDOS Project
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down
7 changes: 4 additions & 3 deletions pkg/network-manager/network-controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,12 @@ import (
// +kubebuilder:rbac:groups=network.fluidos.eu,resources=clusters,verbs=get;list;watch;create;update;patch;delete
// +kubebuilder:rbac:groups=core,resources=configmaps,verbs=get;list;watch

// ClusterInfo keeps the address of the discovered cluster

Check failure on line 36 in pkg/network-manager/network-controller.go

View workflow job for this annotation

GitHub Actions / Lint golang files

Comment should end in a period (godot)
type ClusterInfo struct {
Address string `json:"address"`
}

// NetworkManager keeps all the necessary class data

Check failure on line 41 in pkg/network-manager/network-controller.go

View workflow job for this annotation

GitHub Actions / Lint golang files

Comment should end in a period (godot)
type NetworkManager struct {
context context.Context
client client.Client
Expand All @@ -46,7 +48,6 @@ type NetworkManager struct {
}

func (nm *NetworkManager) sendMulticastMessage(multicastAddress string) error {

info := ClusterInfo{
Address: nm.address,
}
Expand Down Expand Up @@ -79,7 +80,6 @@ func (nm *NetworkManager) sendMulticastMessage(multicastAddress string) error {
}

func (nm *NetworkManager) receiveMulticastMessage(multicastAddress string) error {

addr, err := net.ResolveUDPAddr("udp", multicastAddress)
if err != nil {
return err
Expand Down Expand Up @@ -128,6 +128,7 @@ func (nm *NetworkManager) receiveMulticastMessage(multicastAddress string) error
}
}

// This is the entrypoint of the Network Manager

Check failure on line 131 in pkg/network-manager/network-controller.go

View workflow job for this annotation

GitHub Actions / Lint golang files

Comment should end in a period (godot)
func Start(ctx context.Context, cl client.Client) error {
fmt.Println("Starting Kubernetes cluster discovery")

Expand Down Expand Up @@ -179,7 +180,7 @@ func Start(ctx context.Context, cl client.Client) error {
}
}()

// Block until context is cancelled
// Block until context is canceled
<-ctx.Done()
return nil
}
Expand Down
6 changes: 3 additions & 3 deletions pkg/utils/namings/namings.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,9 @@ func RetrieveFlavorNameFromPC(pcName string) string {
}

// ForgeClusterName generates a name for the Cluster.
func ForgeClusterName(IPaddress string) string {
hash := ForgeHashString(IPaddress, 4)
return fmt.Sprintf("cluster-%s-%s", strings.Replace(strings.Replace(IPaddress, ":", "-", -1), ".", "-", -1), hash)
func ForgeClusterName(address string) string {
hash := ForgeHashString(address, 4)
return fmt.Sprintf("cluster-%s-%s", strings.ReplaceAll(strings.ReplaceAll(address, ":", "-"), ".", "-"), hash)
}

// ForgeRandomString generates a random string of 16 bytes.
Expand Down
6 changes: 3 additions & 3 deletions pkg/utils/resourceforge/forge.go
Original file line number Diff line number Diff line change
Expand Up @@ -1433,12 +1433,12 @@ func ForgeSecretForService(contract *reservationv1alpha1.Contract,
}

// ForgeCluster creates a Cluster from a String.
func ForgeCluster(IPaddress string) *networkv1alpha1.Cluster {
func ForgeCluster(address string) *networkv1alpha1.Cluster {
return &networkv1alpha1.Cluster{
ObjectMeta: metav1.ObjectMeta{
Name: namings.ForgeClusterName(IPaddress),
Name: namings.ForgeClusterName(address),
Namespace: flags.FluidosNamespace,
},
Address: IPaddress,
Address: address,
}
}
24 changes: 12 additions & 12 deletions tools/scripts/environment.sh
Original file line number Diff line number Diff line change
Expand Up @@ -74,14 +74,14 @@ create_kind_clusters() {
kind create cluster --name "$name" --config "$SCRIPT_DIR"/../../quickstart/kind/configs/standard.yaml --kubeconfig "$SCRIPT_DIR"/"$name"-config -q
# Install macvlan plugin to enable multicast node discovery, if required
if [ "$6" == "true" ]; then
num_workers=$(kind get nodes --name fluidos-consumer-1 | grep worker | wc -l)
num_workers=$(kind get nodes --name fluidos-consumer-1 | grep worker -c)
for j in $(seq 1 "$num_workers"); do
(
docker exec --workdir /tmp "$name"-worker$([ $j = 1 ] && echo "" || echo $j) mkdir -p cni-plugins
docker exec --workdir /tmp/cni-plugins "$name"-worker$([ $j = 1 ] && echo "" || echo $j) curl -LO https://github.com/containernetworking/plugins/releases/download/v1.5.1/cni-plugins-linux-amd64-v1.5.1.tgz
docker exec --workdir /tmp/cni-plugins "$name"-worker$([ $j = 1 ] && echo "" || echo $j) tar xvfz cni-plugins-linux-amd64-v1.5.1.tgz
docker exec --workdir /tmp/cni-plugins "$name"-worker$([ $j = 1 ] && echo "" || echo $j) cp macvlan /opt/cni/bin
docker exec --workdir /tmp "$name"-worker$([ $j = 1 ] && echo "" || echo $j) rm -r cni-plugins
docker exec --workdir /tmp "$name"-worker"$([ "$j" = 1 ] && echo "" || echo "$j")" mkdir -p cni-plugins
docker exec --workdir /tmp/cni-plugins "$name"-worker"$([ "$j" = 1 ] && echo "" || echo "$j")" curl -LO https://github.com/containernetworking/plugins/releases/download/v1.5.1/cni-plugins-linux-amd64-v1.5.1.tgz
docker exec --workdir /tmp/cni-plugins "$name"-worker"$([ "$j" = 1 ] && echo "" || echo "$j")" tar xvfz cni-plugins-linux-amd64-v1.5.1.tgz
docker exec --workdir /tmp/cni-plugins "$name"-worker"$([ "$j" = 1 ] && echo "" || echo "$j")" cp macvlan /opt/cni/bin
docker exec --workdir /tmp "$name"-worker"$([ $j = 1 ] && echo "" || echo $j)" rm -r cni-plugins
)
done
fi
Expand All @@ -106,14 +106,14 @@ create_kind_clusters() {
kind create cluster --name "$name" --config "$SCRIPT_DIR"/../../quickstart/kind/configs/standard.yaml --kubeconfig "$SCRIPT_DIR"/"$name"-config -q
# Install macvlan plugin to enable multicast node discovery, if required
if [ "$6" == "true" ]; then
num_workers=$(kind get nodes --name fluidos-provider-1 | grep worker | wc -l)
num_workers=$(kind get nodes --name fluidos-provider-1 | grep worker -c)
for j in $(seq 1 "$num_workers"); do
(
docker exec --workdir /tmp "$name"-worker$([ $j = 1 ] && echo "" || echo $j) mkdir -p cni-plugins
docker exec --workdir /tmp/cni-plugins "$name"-worker$([ $j = 1 ] && echo "" || echo $j) curl -LO https://github.com/containernetworking/plugins/releases/download/v1.5.1/cni-plugins-linux-amd64-v1.5.1.tgz
docker exec --workdir /tmp/cni-plugins "$name"-worker$([ $j = 1 ] && echo "" || echo $j) tar xvfz cni-plugins-linux-amd64-v1.5.1.tgz
docker exec --workdir /tmp/cni-plugins "$name"-worker$([ $j = 1 ] && echo "" || echo $j) cp macvlan /opt/cni/bin
docker exec --workdir /tmp "$name"-worker$([ $j = 1 ] && echo "" || echo $j) rm -r cni-plugins
docker exec --workdir /tmp "$name"-worker"$([ "$j" = 1 ] && echo "" || echo "$j")" mkdir -p cni-plugins
docker exec --workdir /tmp/cni-plugins "$name"-worker"$([ "$j" = 1 ] && echo "" || echo "$j")" curl -LO https://github.com/containernetworking/plugins/releases/download/v1.5.1/cni-plugins-linux-amd64-v1.5.1.tgz
docker exec --workdir /tmp/cni-plugins "$name"-worker"$([ "$j" = 1 ] && echo "" || echo "$j")" tar xvfz cni-plugins-linux-amd64-v1.5.1.tgz
docker exec --workdir /tmp/cni-plugins "$name"-worker"$([ "$j" = 1 ] && echo "" || echo "$j")" cp macvlan /opt/cni/bin
docker exec --workdir /tmp "$name"-worker"$([ $j = 1 ] && echo "" || echo $j)" rm -r cni-plugins
)
done
fi
Expand Down

0 comments on commit 6e1f7ee

Please sign in to comment.