-
Function `ExtractTarGzToPath` has a Cognitive Complexity of 32 (exceeds 20 allowed). Consider refactoring.
// ExtractTarGzToPath extracts a tar.gz file to a specified path func ExtractTarGzToPath(tarGzFilePath, extractedPath string) error { // Ensure the target directory exists; create it if it doesn't. if err := os.MkdirAll(extractedPath, os.ModePerm); err != nil { return fmt.Errorf("error creating target directory: %v", err) } tarGzFile, err := os.Open(tarGzFilePath) if err != nil { return fmt.Errorf("error opening tar.gz file: %v", err) } defer tarGzFile.Close() gzipReader, err := gzip.NewReader(tarGzFile)
Details
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Found in utils/utils.go by structure -
Avoid deeply nested control flow statements.
_, err := io.CopyN(newFile, tarReader, 1024) if err != nil { if err == io.EOF { break } return err }
Found in utils/utils.go by structure -
Function `ExtractTarGzToPath` has 9 return statements (exceeds 4 allowed).
// ExtractTarGzToPath extracts a tar.gz file to a specified path func ExtractTarGzToPath(tarGzFilePath, extractedPath string) error { // Ensure the target directory exists; create it if it doesn't. if err := os.MkdirAll(extractedPath, os.ModePerm); err != nil { return fmt.Errorf("error creating target directory: %v", err) } tarGzFile, err := os.Open(tarGzFilePath) if err != nil { return fmt.Errorf("error opening tar.gz file: %v", err) } defer tarGzFile.Close() gzipReader, err := gzip.NewReader(tarGzFile)
Found in utils/utils.go by structure -
Function `MakeRequest` has 5 arguments (exceeds 4 allowed). Consider refactoring.
} func MakeRequest(_ *gin.Context, client *http.Client, uri string, body []byte, _ string) error { // set the HTTP method, url, and request body req, err := http.NewRequest(http.MethodPut, uri, bytes.NewBuffer(body))
Found in utils/network.go by structure -
Function `PayToScript` has 6 return statements (exceeds 4 allowed).
// Pay to the current escrow smart contract an amount in NTX func PayToScript(ntx int64, spPubKey string, cpPubKey string) (string, error) { outputs, err := GetUTXOs(SPAddress) if err != nil { return "", err } currentContract, err := BuildPaymentScriptAddress() if err != nil { return "", err } transaction := Transaction{ Inputs: outputs,
Found in utils/cardano/cardano.go by structure -
Function `GPUsComparator` has 5 return statements (exceeds 4 allowed).
) func GPUsComparator(lraw, rraw interface{}, _ ...Preference) types.Comparison { // comparator for GPUs type which is just a slice of GPU types: // left represent machine capabilities; // right represent required capabilities; // we need to check if for ech GPU on the right there exist a matching GPU on the left... // (since given slices are not ordered...) // validate input type _, lrawok := lraw.([]types.GPU) _, rrawok := rraw.([]types.GPU) if !lrawok || !rrawok { return types.Error }
Found in dms/orchestrator/matching/GPUsComparator.go by structure -
Function `ExecutionResourcesComparator` has 5 return statements (exceeds 4 allowed).
) func ExecutionResourcesComparator(l, r interface{}, _ ...Preference) types.Comparison { // comparator for types.ExecutionResources type // Current implementation of the type has four fields: CPU, Memory, Disk, GPUs // we consider that all fields have to be 'Better' or 'Equal' // for the comparison to be 'Better' or 'Equal' // else we return 'Worse' // validate input type _, lok := l.(types.ExecutionResources) _, rok := r.(types.ExecutionResources) if !lok || !rok { return types.Error }
Found in dms/orchestrator/matching/ExecutionResourcesComparator.go by structure -
Function `returnBestMatch` has 5 return statements (exceeds 4 allowed).
} func returnBestMatch(dimension []types.Comparison) (types.Comparison, int) { // while i feel that there could be some weird matrix sorting algorithm that could be used here // i can't think of any right now, so i will just iterate over the matrix and return matches // in somewhat manual way for i, v := range dimension { if v == types.Equal { return v, i // selecting an equal match is the most efficient match } } for i, v := range dimension { if v == types.Better { return v, i // selecting a better is also not bad
Found in dms/orchestrator/matching/utils.go by structure -
Function `LocalitiesComparator` has 5 return statements (exceeds 4 allowed).
) func LocalitiesComparator(lraw interface{}, rraw interface{}, _ ...Preference) types.Comparison { // simplified version of Localities comparator // which is simply a slice of Locality type; // we do not have separate type defined for Localities // it takes preference variable where comparison Preference is defined // this is the first method that is used to take Preference variable into account // left represent machine capabilities; // right represent required capabilities; // validate input type _, lrawok := lraw.([]types.Locality) _, rrawok := rraw.([]types.Locality) if !lrawok || !rrawok {
Found in dms/orchestrator/matching/LocalitiesComparator.go by structure -
Function `LibraryComparator` has 7 return statements (exceeds 4 allowed).
) func LibraryComparator(lraw, rraw interface{}, _ ...Preference) types.Comparison { // comparator for single Library type: // left represent machine capabilities; // right represent required capabilities; // validate input type _, lrawok := lraw.(types.Library) _, rrawok := rraw.(types.Library) if !lrawok || !rrawok { return types.Error } l := lraw.(types.Library)
Found in dms/orchestrator/matching/LibraryComparator.go by structure -
Function `GpuComparator` has 6 return statements (exceeds 4 allowed).
) func GpuComparator(l, r interface{}, _ ...Preference) types.Comparison { // comparator for GPU type // we want to reason about the inner fields of the GPU type and how they compare between left and right // in the future we may want to pass custom preference parameters to the ComplexComparator // for now it is probably best to hardcode them; // validate input type _, lok := l.(types.GPU) _, rok := r.(types.GPU) if !lok || !rok { return types.Error }
Found in dms/orchestrator/matching/GpuComparator.go by structure -
Function `LibrariesComparator` has 5 return statements (exceeds 4 allowed).
) func LibrariesComparator(lraw, rraw interface{}, _ ...Preference) types.Comparison { // comparator for Libraries slices (of different lengths) of Library types: // left represent machine capabilities; // right represent required capabilities; // validate input type _, lrawok := lraw.([]types.Library) _, rrawok := rraw.([]types.Library) if !lrawok || !rrawok { return types.Error } l := lraw.([]types.Library)
Found in dms/orchestrator/matching/LibrariesComparator.go by structure -
Function `Run` has 55 lines of code (exceeds 50 allowed). Consider refactoring.
// QUESTION(dms-initialization): should the db instance be constructed here? func Run() { ctx := context.Background() log.Println("WARNING: Most parts commented out in dms.Run()") config.LoadConfig() // XXX: wait for server to start properly before sending requests below // TODO: should be removed time.Sleep(time.Second * 5) // check if onboarded db, err := gorm.Open(sqlite.Open(fmt.Sprintf("%s/nunet.db", config.GetConfig().General.WorkDir)), &gorm.Config{}) if err != nil { log.Fatalf("Failed to connect to database: %v", err)
Found in dms/dms.go by structure -
Method `BasicActor.SendMessage` has 6 return statements (exceeds 4 allowed).
// SendMessage sends a message to another actor. func (a *BasicActor) SendMessage(ctx context.Context, destination *ActorAddrInfo, m *Message) error { if !destination.Valid() { return errors.New("destination actor addr info is invalid") } if m == nil { return errors.New("message is invalid") } // get the multiaddress of a host by resolving the hostid addresses, err := a.network.ResolveAddress(ctx, destination.HostID) if err != nil { return fmt.Errorf("failed to send message to actor %s: %v", destination.HostID, err)
Found in dms/actor.go by structure -
Function `New` has 5 arguments (exceeds 4 allowed). Consider refactoring.
// New creates a new node, attaches an actor to the node. func New(_ context.Context, id string, net network.Network, benchmark benchmarker, resourceManager resources.Manager) (*Node, error) { if id == "" { return nil, errors.New("id is nil")
Found in dms/node/node.go by structure -
Function `New` has 6 return statements (exceeds 4 allowed).
// New creates a new node, attaches an actor to the node. func New(_ context.Context, id string, net network.Network, benchmark benchmarker, resourceManager resources.Manager) (*Node, error) { if id == "" { return nil, errors.New("id is nil") } if net == nil { return nil, errors.New("network is nil") } if benchmark == nil { return nil, errors.New("benchmarker is nil") }
Found in dms/node/node.go by structure -
Method `defaultManager.UpdateFreeResources` has 5 return statements (exceeds 4 allowed).
// UpdateFreeResources calculates, updates db and returns the free resources of the machine in the database func (d defaultManager) UpdateFreeResources(ctx context.Context) (types.FreeResources, error) { usage, err := d.usageMonitor.GetUsage(ctx) if err != nil { return types.FreeResources{}, fmt.Errorf("getting usage: %w", err) } onboardedResources, err := d.GetOnboardedResources(ctx) if err != nil { return types.FreeResources{}, fmt.Errorf("getting total resources: %w", err) } freeResources, err := onboardedResources.Subtract(usage) if err != nil {
Found in dms/resources/resource_manager.go by structure -
Method `linuxSystemSpecs.GetGPUVendors` has a Cognitive Complexity of 23 (exceeds 20 allowed). Consider refactoring.
// GetGPUVendors returns the GPU vendors for the system func (l linuxSystemSpecs) GetGPUVendors() ([]types.GPUVendor, error) { var vendors []types.GPUVendor gpu, err := ghw.GPU() if err != nil { return nil, err } for _, card := range gpu.GraphicsCards { if card.DeviceInfo != nil { class := card.DeviceInfo.Class if class != nil { className := strings.ToLower(class.Name) if strings.Contains(className, "display controller") ||
Details
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Found in dms/resources/system_specs_linux.go by structure -
Method `linuxSystemSpecs.getIntelGPUInfo` has 62 lines of code (exceeds 50 allowed). Consider refactoring.
// getIntelGPUInfo returns the GPU information for Intel GPUs func (l linuxSystemSpecs) getIntelGPUInfo(metadata []gpuMetadata) ([]types.GPU, error) { // Determine the number of discrete Intel GPUs cmd := exec.Command("xpu-smi", "health", "-l") output, err := cmd.CombinedOutput() if err != nil { return nil, fmt.Errorf("xpu-smi not installed, initialized, or configured: %s", err) } outputStr := string(output) // fmt.Println("xpu-smi health -l output:\n", outputStr) // Print the output for debugging // Use regex to find all instances of Device ID deviceIDRegex := regexp.MustCompile(`(?i)\| Device ID\s+\|\s+(\d+)\s+\|`)
Found in dms/resources/system_specs_linux.go by structure -
Avoid deeply nested control flow statements.
vendor := card.DeviceInfo.Vendor if vendor != nil { switch { case strings.Contains(strings.ToLower(vendor.Name), "nvidia"): vendors = append(vendors, types.GPUVendorNvidia) case strings.Contains(strings.ToLower(vendor.Name), "amd"): vendors = append(vendors, types.GPUVendorAMDATI) case strings.Contains(strings.ToLower(vendor.Name), "intel"): vendors = append(vendors, types.GPUVendorIntel) default: vendors = append(vendors, types.GPUVendorUnknown) } } }
Found in dms/resources/system_specs_linux.go by structure -
Method `linuxSystemSpecs.GetProvisionedResources` has 5 return statements (exceeds 4 allowed).
// GetProvisionedResources returns the total resources available on the system func (l linuxSystemSpecs) GetProvisionedResources() (types.Resources, error) { cpuInfo, err := l.GetCPUInfo() if err != nil { return types.Resources{}, fmt.Errorf("failed to get CPU info: %s", err) } totalMemory, err := l.GetTotalMemory() if err != nil { return types.Resources{}, fmt.Errorf("failed to get total memory: %s", err) } gpus, err := l.GetGPUs() if err != nil {
Found in dms/resources/system_specs_linux.go by structure -
Method `linuxSystemSpecs.getAMDGPUInfo` has 6 return statements (exceeds 4 allowed).
// getAMDGPUInfo returns the GPU information for AMD GPUs func (l linuxSystemSpecs) getAMDGPUInfo(metadata []gpuMetadata) ([]types.GPU, error) { cmd := exec.Command("rocm-smi", "--showid", "--showproductname", "--showmeminfo", "vram") output, err := cmd.CombinedOutput() if err != nil { return nil, fmt.Errorf("AMD ROCm not installed, initialized, or configured (reboot recommended for newly installed AMD GPU Drivers): %s", err) } outputStr := string(output) // fmt.Println("rocm-smi vram output:\n", outputStr) // Print the output for debugging gpuNameRegex := regexp.MustCompile(`GPU\[\d+\]\s+: Card Series:\s+([^\n]+)`) totalRegex := regexp.MustCompile(`GPU\[\d+\]\s+: VRAM Total Memory \(B\):\s+(\d+)`)
Found in dms/resources/system_specs_linux.go by structure -
Method `linuxSystemSpecs.getNVIDIAGPUInfo` has 7 return statements (exceeds 4 allowed).
// getNVIDIAGPUInfo returns the GPU information for NVIDIA GPUs func (l linuxSystemSpecs) getNVIDIAGPUInfo(metadata []gpuMetadata) ([]types.GPU, error) { // Initialize NVML ret := nvml.Init() if !errors.Is(ret, nvml.SUCCESS) { return nil, fmt.Errorf("NVIDIA Management Library not installed, initialized or configured (reboot recommended for newly installed NVIDIA GPU drivers): %s", nvml.ErrorString(ret)) } defer func() { _ = nvml.Shutdown() }() // Get the number of GPU devices deviceCount, ret := nvml.DeviceGetCount()
Found in dms/resources/system_specs_linux.go by structure -
Method `linuxSystemSpecs.getIntelGPUInfo` has 10 return statements (exceeds 4 allowed).
// getIntelGPUInfo returns the GPU information for Intel GPUs func (l linuxSystemSpecs) getIntelGPUInfo(metadata []gpuMetadata) ([]types.GPU, error) { // Determine the number of discrete Intel GPUs cmd := exec.Command("xpu-smi", "health", "-l") output, err := cmd.CombinedOutput() if err != nil { return nil, fmt.Errorf("xpu-smi not installed, initialized, or configured: %s", err) } outputStr := string(output) // fmt.Println("xpu-smi health -l output:\n", outputStr) // Print the output for debugging // Use regex to find all instances of Device ID deviceIDRegex := regexp.MustCompile(`(?i)\| Device ID\s+\|\s+(\d+)\s+\|`)
Found in dms/resources/system_specs_linux.go by structure -
Method `Allocation.Run` has 6 return statements (exceeds 4 allowed).
// Run creates the executor based on the execution engine configuration. func (a *Allocation) Run(ctx context.Context) error { freeResources, err := a.resourceManager.UpdateFreeResources(ctx) if err != nil { return fmt.Errorf("failed to get free resources: %w", err) } if !availableResources(a.Job.Resources, freeResources) { return fmt.Errorf("no available resources for job %s", a.Job.ID) } // if executor is nil create it if a.executor == nil { err = a.createExecutor(ctx, a.Job.Execution)
Found in dms/jobs/allocation.go by structure -
Method `TransformerImpl.transform` has 6 return statements (exceeds 4 allowed).
// transform is a recursive function that applies the transformers to the configuration. func (t TransformerImpl) transform(root *map[string]interface{}, data any, path tree.Path, transformers map[tree.Path]TransformerFunc) (interface{}, error) { var err error // Apply transformers that match the current path. for pattern, transformer := range transformers { if path.Matches(pattern) { data, err = transformer(root, data, path) if err != nil { return nil, err } } } // Recursively apply transformers to children. if result, ok := data.(map[string]interface{}); ok {
Found in dms/jobs/parser/transform/transform.go by structure -
Function `TransformNetwork` has 51 lines of code (exceeds 50 allowed). Consider refactoring.
// TransformNetwork transforms the network configuration func TransformNetwork(_ *map[string]interface{}, data any, _ tree.Path) (any, error) { if data == nil { return nil, nil } config, ok := data.(map[string]any) if !ok { return nil, fmt.Errorf("invalid network configuration: %v", data) } ports, _ := transform.ToAnySlice(config["ports"]) portMap := []map[string]any{} for _, port := range ports { protocol, host, container := "tcp", 0, 0 switch v := port.(type) {
Found in dms/jobs/parser/nunet/transform.go by structure -
Function `matchParts` has a Cognitive Complexity of 26 (exceeds 20 allowed). Consider refactoring.
// matchParts checks if the path parts match the pattern parts func matchParts(pathParts, patternParts []string) bool { // If the pattern is longer than the path, it can't match if len(pathParts) < len(patternParts) { return false } for i, part := range patternParts { switch part { case configPathMatchAnyMultiple: // if it is the last part of the pattern, it matches if i == len(patternParts)-1 { return true } // Otherwise, try to match the rest of the path
Details
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Found in dms/jobs/parser/tree/path.go by structure -
Function `matchParts` has 7 return statements (exceeds 4 allowed).
// matchParts checks if the path parts match the pattern parts func matchParts(pathParts, patternParts []string) bool { // If the pattern is longer than the path, it can't match if len(pathParts) < len(patternParts) { return false } for i, part := range patternParts { switch part { case configPathMatchAnyMultiple: // if it is the last part of the pattern, it matches if i == len(patternParts)-1 { return true } // Otherwise, try to match the rest of the path
Found in dms/jobs/parser/tree/path.go by structure -
Method `Onboarding.Onboard` has 7 return statements (exceeds 4 allowed).
// Onboard validates the onboarding params and onboards the machine to the network // It returns a *types.OnboardingConfig and any error if encountered func (o *Onboarding) Onboard(ctx context.Context, capacity types.CapacityForNunet) (*types.OnboardingConfig, error) { if err := o.validateOnboardingPrerequisites(capacity); err != nil { return nil, err } hostname, err := os.Hostname() if err != nil { return nil, fmt.Errorf("unable to get hostname: %v", err) } provisionedResources, err := resources.ManagerInstance.SystemSpecs().GetProvisionedResources() if err != nil { return nil, fmt.Errorf("cannot get provisioned resources: %w", err)
Found in dms/onboarding/onboarding.go by structure -
Method `Onboarding.ResourceConfig` has 9 return statements (exceeds 4 allowed).
// ResourceConfig allows changing onboarding parameters func (o *Onboarding) ResourceConfig(ctx context.Context, capacity types.CapacityForNunet) (*types.OnboardingConfig, error) { onboarded, err := o.IsOnboarded(ctx) if err != nil { return nil, fmt.Errorf("could not check onboard status: %w", err) } if !onboarded { return nil, ErrMachineNotOnboarded } if err := validateCapacityForNunet(capacity); err != nil { return nil, fmt.Errorf("could not validate capacity data: %w", err) }
Found in dms/onboarding/onboarding.go by structure -
Method `Onboarding.Offboard` has 5 return statements (exceeds 4 allowed).
// Offboard deletes all onboarding information if already set // It returns an error func (o *Onboarding) Offboard(ctx context.Context, force bool) error { onboarded, err := o.IsOnboarded(ctx) if err != nil && !force { return fmt.Errorf("could not retrieve onboard status: %w", err) } else if err != nil && force { zlog.Sugar().Errorf("problem with onboarding state: %w", err) zlog.Info("continuing with offboarding because forced") } if !onboarded { return fmt.Errorf("machine is not onboarded") }
Found in dms/onboarding/onboarding.go by structure -
Method `Onboarding.validateOnboardingPrerequisites` has 6 return statements (exceeds 4 allowed).
} func (o *Onboarding) validateOnboardingPrerequisites(capacity types.CapacityForNunet) error { ok, err := o.config.Fs.DirExists(o.config.WorkDir) if err != nil { return fmt.Errorf("could not check if config directory exists: %w", err) } if !ok { return fmt.Errorf("config directory does not exist") } if err := utils.ValidateAddress(capacity.PaymentAddress); err != nil { return fmt.Errorf("could not validate payment address: %w", err) }
Found in dms/onboarding/onboarding.go by structure -
Method `executionHandler.run` has 75 lines of code (exceeds 50 allowed). Consider refactoring.
// run starts the container and handles its execution lifecycle. func (h *executionHandler) run(ctx context.Context) { h.running.Store(true) defer func() { if err := h.destroy(DestroyTimeout); err != nil { zlog.Sugar().Warnf("failed to destroy container: %v\n", err) } h.running.Store(false) close(h.waitCh) }() if err := h.client.StartContainer(ctx, h.containerID); err != nil { h.result = types.NewFailedExecutionResult(fmt.Errorf("failed to start container: %v", err)) return
Found in executor/docker/handler.go by structure -
Method `executionHandler.run` has 6 return statements (exceeds 4 allowed).
// run starts the container and handles its execution lifecycle. func (h *executionHandler) run(ctx context.Context) { h.running.Store(true) defer func() { if err := h.destroy(DestroyTimeout); err != nil { zlog.Sugar().Warnf("failed to destroy container: %v\n", err) } h.running.Store(false) close(h.waitCh) }() if err := h.client.StartContainer(ctx, h.containerID); err != nil { h.result = types.NewFailedExecutionResult(fmt.Errorf("failed to start container: %v", err)) return
Found in executor/docker/handler.go by structure -
Function `DecodeSpec` has 5 return statements (exceeds 4 allowed).
// DecodeSpec decodes a spec config into a docker engine spec // It converts the params into a docker EngineSpec struct and validates it func DecodeSpec(spec *types.SpecConfig) (EngineSpec, error) { if !spec.IsType(types.ExecutorTypeDocker) { return EngineSpec{}, fmt.Errorf( "invalid docker engine type. expected %s, but received: %s", types.ExecutorTypeDocker, spec.Type, ) } inputParams := spec.Params if inputParams == nil { return EngineSpec{}, fmt.Errorf("invalid docker engine params: params cannot be nil") }
Found in executor/docker/types.go by structure -
Method `Client.CreateContainer` has 6 arguments (exceeds 4 allowed). Consider refactoring.
// CreateContainer creates a new Docker container with the specified configuration. func (c *Client) CreateContainer( ctx context.Context, config *container.Config, hostConfig *container.HostConfig, networkingConfig *network.NetworkingConfig, platform *v1.Platform, name string, ) (string, error) { _, err := c.PullImage(ctx, config.Image)
Found in executor/docker/client.go by structure -
Function `DecodeSpec` has 5 return statements (exceeds 4 allowed).
// DecodeSpec decodes a spec config into a firecracker engine spec // It converts the params into a firecracker EngineSpec struct and validates it func DecodeSpec(spec *types.SpecConfig) (EngineSpec, error) { if !spec.IsType(types.ExecutorTypeFirecracker) { return EngineSpec{}, fmt.Errorf( "invalid firecracker engine type. expected %s, but received: %s", types.ExecutorTypeFirecracker, spec.Type, ) } inputParams := spec.Params if inputParams == nil { return EngineSpec{}, fmt.Errorf("invalid firecracker engine params: params cannot be nil") }
Found in executor/firecracker/types.go by structure -
Method `Client.DestroyVM` has 6 return statements (exceeds 4 allowed).
// DestroyVM destroys the Firecracker VM. func (c *Client) DestroyVM( ctx context.Context, m *firecracker.Machine, timeout time.Duration, ) error { // Get the PID of the Firecracker process and shut down the VM. // If the process is still running after the timeout, kill it. err := c.ShutdownVM(ctx, m) if err != nil { return fmt.Errorf("failed to shutdown vm: %w", err) } pid, _ := m.PID()
Found in executor/firecracker/client.go by structure -
Method `Client.FindVM` has 5 return statements (exceeds 4 allowed).
// FindVM finds a Firecracker VM by its socket path. // This implementation checks if the VM is running by sending a request to the Firecracker API. func (c *Client) FindVM(ctx context.Context, socketPath string) (*firecracker.Machine, error) { // Check if the socket file exists. if _, err := os.Stat(socketPath); err != nil { return nil, fmt.Errorf("VM with socket path %v not found", socketPath) } // Create a new Firecracker machine instance. cmd := firecracker.VMCommandBuilder{}.WithSocketPath(socketPath).Build(ctx) machine, err := firecracker.NewMachine( ctx, firecracker.Config{SocketPath: socketPath}, firecracker.WithProcessRunner(cmd), )
Found in executor/firecracker/client.go by structure -
Function `NewChatStartCmd` has 58 lines of code (exceeds 50 allowed). Consider refactoring.
var chatStartCmd = NewChatStartCmd(p2pService, utilsService, webSocketClient) func NewChatStartCmd(p2pService backend.PeerManager, _ backend.Utility, wsClient backend.WebSocketClient) *cobra.Command { return &cobra.Command{ Use: "start", Short: "Start chat with a peer", Example: "nunet chat start <peerID>", RunE: func(cmd *cobra.Command, args []string) error { log.SetOutput(cmd.OutOrStderr()) err := validateStartChatInput(p2pService, args) if err != nil { return fmt.Errorf("start chat failed: %w", err) }
Found in cmd/chat_start.go by structure -
Function `runDockerContainer` has 59 lines of code (exceeds 50 allowed). Consider refactoring.
} func runDockerContainer(ctx context.Context, cli *client.Client, options ContainerOptions) error { if options.Image == "" { return fmt.Errorf("image name cannot be empty") } config := &container.Config{ Image: options.Image, Entrypoint: options.Entrypoint, Cmd: options.Command, Tty: true, } hostConfig := &container.HostConfig{}
Found in cmd/gpu_capacity.go by structure -
Function `runDockerContainer` has 9 return statements (exceeds 4 allowed).
} func runDockerContainer(ctx context.Context, cli *client.Client, options ContainerOptions) error { if options.Image == "" { return fmt.Errorf("image name cannot be empty") } config := &container.Config{ Image: options.Image, Entrypoint: options.Entrypoint, Cmd: options.Command, Tty: true, } hostConfig := &container.HostConfig{}
Found in cmd/gpu_capacity.go by structure -
Function `setOnboardData` has 5 arguments (exceeds 4 allowed). Consider refactoring.
// setOnboardData takes all onboarding parameters and marshal them into JSON func setOnboardData(memory int64, cpu int64, ntxPrice float64, channel, address string, cardano, serverMode, isAvailable bool) ([]byte, error) { reserved := types.CapacityForNunet{ Memory: memory,
Found in cmd/utils.go by structure -
Function `validateJoinChatInput` has 6 return statements (exceeds 4 allowed).
// END func validateJoinChatInput(args []string, chatList []byte) error { var chatID int var err error if len(args) == 0 || args[0] == "" { return fmt.Errorf("no chat ID specified") } else if len(args) > 1 { return fmt.Errorf("unable to join multiple chats") } chatID, err = strconv.Atoi(args[0]) if err != nil { return fmt.Errorf("argument is not integer")
Found in cmd/utils.go by structure -
Function `getDHTPeers` has 6 return statements (exceeds 4 allowed).
// getDHTPeers fetches API to retrieve info from DHT peers func getDHTPeers(utilsService backend.Utility) ([]string, error) { var dhtSlice []string bodyDht, err := utilsService.ResponseBody(nil, "GET", "/api/v1/peers/dht", "", nil) if err != nil { return nil, fmt.Errorf("cannot get response body: %w", err) } errMsg, err := jsonparser.GetString(bodyDht, "error") if err == nil { return nil, errors.New(errMsg) } msg, err := jsonparser.GetString(bodyDht, "message")
Found in cmd/utils.go by structure -
Function `getBootstrapPeers` has 7 return statements (exceeds 4 allowed).
// getBootstrapPeers fetches API to retrieve data from bootstrap peers func getBootstrapPeers(writer io.Writer, utilsService backend.Utility) ([]string, error) { var bootSlice []string bodyBoot, err := utilsService.ResponseBody(nil, "GET", "/api/v1/peers", "", nil) if err != nil { return nil, fmt.Errorf("unable to get response body: %w", err) } errMsg, err := jsonparser.GetString(bodyBoot, "error") if err == nil { return nil, errors.New(errMsg) } msg, err := jsonparser.GetString(bodyBoot, "message")
Found in cmd/utils.go by structure -
Function `NewChatJoinCmd` has 63 lines of code (exceeds 50 allowed). Consider refactoring.
// XXX NewChatJoinCmd and NewChatStartCmd are similar, consider refactoring func NewChatJoinCmd(utilsService backend.Utility, wsClient backend.WebSocketClient) *cobra.Command { return &cobra.Command{ Use: "join", Short: "Join open chat stream", Example: "nunet chat join <chatID>", Long: "", RunE: func(cmd *cobra.Command, args []string) error { chatList, err := utilsService.ResponseBody(nil, "GET", "/api/v1/peers/chat", "", nil) if err != nil { return fmt.Errorf("could not obtain incoming chats list: %w", err) } err = validateJoinChatInput(args, chatList)
Found in cmd/chat_join.go by structure -
Function `NewOnboardCmd` has a Cognitive Complexity of 23 (exceeds 20 allowed). Consider refactoring.
) func NewOnboardCmd(net backend.NetworkManager, utilsService backend.Utility) *cobra.Command { cmd := &cobra.Command{ Use: "onboard", Short: "Onboard current machine to NuNet", PreRunE: isDMSRunning(net), RunE: func(cmd *cobra.Command, _ []string) error { memory, _ := cmd.Flags().GetInt64("memory") cpu, _ := cmd.Flags().GetInt64("cpu") channel, _ := cmd.Flags().GetString("nunet-channel") address, _ := cmd.Flags().GetString("address") ntxPrice, _ := cmd.Flags().GetFloat64("ntx-price") local, _ := cmd.Flags().GetBool("local-enable") cardano, _ := cmd.Flags().GetBool("cardano")
Details
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Found in cmd/onboard.go by structure -
Function `NewOnboardCmd` has 65 lines of code (exceeds 50 allowed). Consider refactoring.
) func NewOnboardCmd(net backend.NetworkManager, utilsService backend.Utility) *cobra.Command { cmd := &cobra.Command{ Use: "onboard", Short: "Onboard current machine to NuNet", PreRunE: isDMSRunning(net), RunE: func(cmd *cobra.Command, _ []string) error { memory, _ := cmd.Flags().GetInt64("memory") cpu, _ := cmd.Flags().GetInt64("cpu") channel, _ := cmd.Flags().GetString("nunet-channel") address, _ := cmd.Flags().GetString("address") ntxPrice, _ := cmd.Flags().GetFloat64("ntx-price") local, _ := cmd.Flags().GetBool("local-enable") cardano, _ := cmd.Flags().GetBool("cardano")
Found in cmd/onboard.go by structure -
Function `NewOnboardCmd` has 12 return statements (exceeds 4 allowed).
) func NewOnboardCmd(net backend.NetworkManager, utilsService backend.Utility) *cobra.Command { cmd := &cobra.Command{ Use: "onboard", Short: "Onboard current machine to NuNet", PreRunE: isDMSRunning(net), RunE: func(cmd *cobra.Command, _ []string) error { memory, _ := cmd.Flags().GetInt64("memory") cpu, _ := cmd.Flags().GetInt64("cpu") channel, _ := cmd.Flags().GetString("nunet-channel") address, _ := cmd.Flags().GetString("address") ntxPrice, _ := cmd.Flags().GetFloat64("ntx-price") local, _ := cmd.Flags().GetBool("local-enable") cardano, _ := cmd.Flags().GetBool("cardano")
Found in cmd/onboard.go by structure -
Function `NewPeerListCmd` has 5 return statements (exceeds 4 allowed).
) func NewPeerListCmd(utilsService backend.Utility) *cobra.Command { cmd := &cobra.Command{ Use: "list", Short: "Display list of peers in the network", Long: ``, RunE: func(cmd *cobra.Command, _ []string) error { err := checkOnboarded(utilsService) if err != nil { return err } dhtFlag, _ := cmd.Flags().GetBool("dht")
Found in cmd/peer_list.go by structure -
Function `NewLogCmd` has a Cognitive Complexity of 29 (exceeds 20 allowed). Consider refactoring.
var logCmd *cobra.Command func NewLogCmd(net backend.NetworkManager, fs backend.FileSystem, journal backend.Logger) *cobra.Command { return &cobra.Command{ Use: "log", Short: "Gather all logs into a tarball. COMMAND MUST RUN AS ROOT WITH SUDO", PreRunE: isDMSRunning(net), RunE: func(cmd *cobra.Command, _ []string) error { dmsLogDir := filepath.Join(logDir, "dms-log") fmt.Fprintln(cmd.OutOrStdout(), "Collecting logs...") // nolint:gofumpt err := fs.MkdirAll(dmsLogDir, 0777) if err != nil {
Details
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Found in cmd/log_linux.go by structure -
Function `NewLogCmd` has 64 lines of code (exceeds 50 allowed). Consider refactoring.
var logCmd *cobra.Command func NewLogCmd(net backend.NetworkManager, fs backend.FileSystem, journal backend.Logger) *cobra.Command { return &cobra.Command{ Use: "log", Short: "Gather all logs into a tarball. COMMAND MUST RUN AS ROOT WITH SUDO", PreRunE: isDMSRunning(net), RunE: func(cmd *cobra.Command, _ []string) error { dmsLogDir := filepath.Join(logDir, "dms-log") fmt.Fprintln(cmd.OutOrStdout(), "Collecting logs...") // nolint:gofumpt err := fs.MkdirAll(dmsLogDir, 0777) if err != nil {
Found in cmd/log_linux.go by structure -
Function `NewResourceConfigCmd` has 7 return statements (exceeds 4 allowed).
var resourceConfigCmd = NewResourceConfigCmd(networkService, utilsService) func NewResourceConfigCmd(net backend.NetworkManager, utilsService backend.Utility) *cobra.Command { cmd := &cobra.Command{ Use: "resource-config", Short: "Update configuration of onboarded device", PreRunE: isDMSRunning(net), RunE: func(cmd *cobra.Command, _ []string) error { memory, _ := cmd.Flags().GetInt64("memory") cpu, _ := cmd.Flags().GetInt64("cpu") ntxPrice, _ := cmd.Flags().GetFloat64("ntx-price") // check for both flags values if memory == 0 || cpu == 0 || ntxPrice < 0 { _ = cmd.Help()
Found in cmd/resource-config.go by structure -
Function `NewCapacityCmd` has a Cognitive Complexity of 25 (exceeds 20 allowed). Consider refactoring.
) func NewCapacityCmd(net backend.NetworkManager, resources backend.ResourceManager, utilsService backend.Utility) *cobra.Command { cmd := &cobra.Command{ Use: "capacity", Short: "Display capacity of device resources", Long: `Retrieve capacity of the machine, onboarded or available amount of resources`, PreRunE: isDMSRunning(net), RunE: func(cmd *cobra.Command, _ []string) error { onboarded, _ := cmd.Flags().GetBool("onboarded") full, _ := cmd.Flags().GetBool("full") available, _ := cmd.Flags().GetBool("available") // flagCombination stores the bitwise value of combined flags var flagCombination int
Details
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Found in cmd/capacity.go by structure -
Function `NewCapacityCmd` has 51 lines of code (exceeds 50 allowed). Consider refactoring.
) func NewCapacityCmd(net backend.NetworkManager, resources backend.ResourceManager, utilsService backend.Utility) *cobra.Command { cmd := &cobra.Command{ Use: "capacity", Short: "Display capacity of device resources", Long: `Retrieve capacity of the machine, onboarded or available amount of resources`, PreRunE: isDMSRunning(net), RunE: func(cmd *cobra.Command, _ []string) error { onboarded, _ := cmd.Flags().GetBool("onboarded") full, _ := cmd.Flags().GetBool("full") available, _ := cmd.Flags().GetBool("available") // flagCombination stores the bitwise value of combined flags var flagCombination int
Found in cmd/capacity.go by structure -
Function `NewCapacityCmd` has 5 return statements (exceeds 4 allowed).
) func NewCapacityCmd(net backend.NetworkManager, resources backend.ResourceManager, utilsService backend.Utility) *cobra.Command { cmd := &cobra.Command{ Use: "capacity", Short: "Display capacity of device resources", Long: `Retrieve capacity of the machine, onboarded or available amount of resources`, PreRunE: isDMSRunning(net), RunE: func(cmd *cobra.Command, _ []string) error { onboarded, _ := cmd.Flags().GetBool("onboarded") full, _ := cmd.Flags().GetBool("full") available, _ := cmd.Flags().GetBool("available") // flagCombination stores the bitwise value of combined flags var flagCombination int
Found in cmd/capacity.go by structure -
Function `makeAddrsFactory` has a Cognitive Complexity of 22 (exceeds 20 allowed). Consider refactoring.
} func makeAddrsFactory(announce []string, appendAnnouce []string, noAnnounce []string) func([]multiaddr.Multiaddr) []multiaddr.Multiaddr { var err error // To assign to the slice in the for loop existing := make(map[string]bool) // To avoid duplicates annAddrs := make([]multiaddr.Multiaddr, len(announce)) for i, addr := range announce { annAddrs[i], err = multiaddr.NewMultiaddr(addr) if err != nil { return nil } existing[addr] = true }
Details
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Found in network/libp2p/filter.go by structure -
Function `makeAddrsFactory` has 52 lines of code (exceeds 50 allowed). Consider refactoring.
} func makeAddrsFactory(announce []string, appendAnnouce []string, noAnnounce []string) func([]multiaddr.Multiaddr) []multiaddr.Multiaddr { var err error // To assign to the slice in the for loop existing := make(map[string]bool) // To avoid duplicates annAddrs := make([]multiaddr.Multiaddr, len(announce)) for i, addr := range announce { annAddrs[i], err = multiaddr.NewMultiaddr(addr) if err != nil { return nil } existing[addr] = true }
Found in network/libp2p/filter.go by structure -
Function `NewHost` has a Cognitive Complexity of 25 (exceeds 20 allowed). Consider refactoring.
// NewHost returns a new libp2p host with dht and other related settings. func NewHost(ctx context.Context, config *types.Libp2pConfig, fs afero.Fs) (host.Host, *dht.IpfsDHT, *pubsub.PubSub, error) { var idht *dht.IpfsDHT connmgr, err := connmgr.NewConnManager( 100, 400, connmgr.WithGracePeriod(time.Duration(config.GracePeriodMs)*time.Millisecond), ) if err != nil { return nil, nil, nil, err } filter := multiaddr.NewFilters() for _, s := range defaultServerFilters {
Details
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Found in network/libp2p/host.go by structure -
Function `NewHost` has 112 lines of code (exceeds 50 allowed). Consider refactoring.
// NewHost returns a new libp2p host with dht and other related settings. func NewHost(ctx context.Context, config *types.Libp2pConfig, fs afero.Fs) (host.Host, *dht.IpfsDHT, *pubsub.PubSub, error) { var idht *dht.IpfsDHT connmgr, err := connmgr.NewConnManager( 100, 400, connmgr.WithGracePeriod(time.Duration(config.GracePeriodMs)*time.Millisecond), ) if err != nil { return nil, nil, nil, err } filter := multiaddr.NewFilters() for _, s := range defaultServerFilters {
Found in network/libp2p/host.go by structure -
Function `NewHost` has 10 return statements (exceeds 4 allowed).
// NewHost returns a new libp2p host with dht and other related settings. func NewHost(ctx context.Context, config *types.Libp2pConfig, fs afero.Fs) (host.Host, *dht.IpfsDHT, *pubsub.PubSub, error) { var idht *dht.IpfsDHT connmgr, err := connmgr.NewConnManager( 100, 400, connmgr.WithGracePeriod(time.Duration(config.GracePeriodMs)*time.Millisecond), ) if err != nil { return nil, nil, nil, err } filter := multiaddr.NewFilters() for _, s := range defaultServerFilters {
Found in network/libp2p/host.go by structure -
Function `generateSwarmKey` has 6 return statements (exceeds 4 allowed).
// generateSwarmKey generates a new swarm key, storing it within // `<nunet_config_dir>/swarm.key`. func generateSwarmKey(fs afero.Fs) (pnet.PSK, error) { priv, _, err := crypto.GenerateKeyPair(crypto.Secp256k1, 256) if err != nil { return nil, err } privBytes, err := crypto.MarshalPrivateKey(priv) if err != nil { return nil, err } encodedKey := base64.StdEncoding.EncodeToString(privBytes) swarmKeyWithCodec := fmt.Sprintf("/key/swarm/psk/1.0.0/\n/base64/\n%s\n", encodedKey)
Found in network/libp2p/pnet.go by structure -
File `libp2p.go` has 534 lines of code (exceeds 500 allowed). Consider refactoring.
package libp2p import ( "bufio" "bytes" "context" "crypto/sha256" "encoding/binary" "errors" "fmt" "io" "strings" "sync"
Found in network/libp2p/libp2p.go by structure -
`Libp2p` has 28 methods (exceeds 20 allowed). Consider refactoring.
// TODO-suggestion: maybe we should call it something else like Libp2pPeer, // Libp2pHost or just Peer (callers would use libp2p.Peer...) type Libp2p struct { Host host.Host DHT *dht.IpfsDHT PS peerstore.Peerstore pubsub *pubsub.PubSub pubsubTopics map[string]*pubsub.Topic topicSubscription map[string]*pubsub.Subscription topicMux sync.RWMutex // a list of peers discovered by discovery discoveredPeers []peer.AddrInfo discovery libp2pdiscovery.Discovery
Found in network/libp2p/libp2p.go by structure -
Method `Libp2p.OpenStream` has 5 return statements (exceeds 4 allowed).
// OpenStream opens a stream to a remote address and returns the stream for the caller to handle. func (l *Libp2p) OpenStream(ctx context.Context, addr string, messageType types.MessageType) (network.Stream, error) { maddr, err := multiaddr.NewMultiaddr(addr) if err != nil { return nil, fmt.Errorf("invalid multiaddress: %w", err) } peerInfo, err := peer.AddrInfoFromP2pAddr(maddr) if err != nil { return nil, fmt.Errorf("could not resolve peer info: %w", err) } if err := l.Host.Connect(ctx, *peerInfo); err != nil { return nil, fmt.Errorf("failed to connect to peer: %w", err)
Found in network/libp2p/libp2p.go by structure -
Method `Libp2p.Ping` has 5 return statements (exceeds 4 allowed).
// TODO (Return error once): something that was confusing me when using this method is that the error is // returned twice if any. Once as a field of PingResult and one as a return value. func (l *Libp2p) Ping(ctx context.Context, peerIDAddress string, timeout time.Duration) (types.PingResult, error) { // avoid dial to self attempt if peerIDAddress == l.Host.ID().String() { err := errors.New("can't ping self") return types.PingResult{Success: false, Error: err}, err } pingCtx, cancel := context.WithTimeout(ctx, timeout) defer cancel() remotePeer, err := peer.Decode(peerIDAddress) if err != nil { return types.PingResult{}, err
Found in network/libp2p/libp2p.go by structure -
Method `Libp2p.ResolveAddress` has 6 return statements (exceeds 4 allowed).
// ResolveAddress resolves the address by given a peer id. func (l *Libp2p) ResolveAddress(ctx context.Context, id string) ([]string, error) { pid, err := peer.Decode(id) if err != nil { return nil, fmt.Errorf("failed to resolve invalid peer: %w", err) } // resolve ourself if l.Host.ID().String() == id { multiAddrs, err := l.GetMultiaddr() if err != nil { return nil, fmt.Errorf("failed to resolve self: %w", err) } resolved := make([]string, len(multiAddrs))
Found in network/libp2p/libp2p.go by structure -
Method `Libp2p.Query` has 5 return statements (exceeds 4 allowed).
// Query return all the advertisements in the network related to a key. // The network is queried to find providers for the given key, and peers which we aren't connected to can be retrieved. func (l *Libp2p) Query(ctx context.Context, key string) ([]*commonproto.Advertisement, error) { if key == "" { return nil, errors.New("advertisement key is empty") } customCID, err := createCIDFromKey(key) if err != nil { return nil, fmt.Errorf("failed to create cid for key %s: %w", key, err) } addrInfo, err := l.DHT.FindProviders(ctx, customCID) if err != nil { return nil, fmt.Errorf("failed to find providers for key %s: %w", key, err)
Found in network/libp2p/libp2p.go by structure -
Method `Libp2p.Advertise` has 8 return statements (exceeds 4 allowed).
// Advertise given data and a key pushes the data to the dht. func (l *Libp2p) Advertise(ctx context.Context, key string, data []byte) error { if key == "" { return errors.New("advertisement key is empty") } pubKeyBytes, err := l.getPublicKey() if err != nil { return fmt.Errorf("failed to get public key: %w", err) } envelope := &commonproto.Advertisement{ PeerId: l.Host.ID().String(), Timestamp: time.Now().Unix(),
Found in network/libp2p/libp2p.go by structure -
Method `Libp2p.sendMessage` has 8 return statements (exceeds 4 allowed).
} func (l *Libp2p) sendMessage(ctx context.Context, addr string, msg types.MessageEnvelope) error { peerAddr, err := multiaddr.NewMultiaddr(addr) if err != nil { return fmt.Errorf("invalid multiaddr %s: %v", addr, err) } peerInfo, err := peer.AddrInfoFromP2pAddr(peerAddr) if err != nil { return fmt.Errorf("failed to get peer info %s: %v", addr, err) } // we are delivering a message to ourself // we should use the handler to send the message to the handler directly which has been previously registered.
Found in network/libp2p/libp2p.go by structure -
Method `dhtValidator.Validate` has 7 return statements (exceeds 4 allowed).
// Validate validates an item placed into the dht. func (d dhtValidator) Validate(key string, value []byte) error { // empty value is considered deleting an item from the dht if len(value) == 0 { return nil } if !strings.HasPrefix(key, d.customNamespace) { return errors.New("invalid key namespace") } // verify signature var envelope commonproto.Advertisement err := proto.Unmarshal(value, &envelope)
Found in network/libp2p/dht.go by structure -
File `docs.go` has 888 lines of code (exceeds 500 allowed). Consider refactoring.
// Package docs Code generated by swaggo/swag. DO NOT EDIT package docs import "github.com/swaggo/swag" const docTemplate = `{ "schemes": {{ marshal .Schemes }}, "swagger": "2.0", "info": { "description": "{{escape .Description}}", "title": "{{.Title}}", "termsOfService": "https://nunet.io/tos", "contact": {
Found in api/docs/docs.go by structure -
Method `Storage.Upload` has 9 return statements (exceeds 4 allowed).
// be careful if managing files with `os` (the volume controller might be // using an in-memory one) func (s *Storage) Upload(ctx context.Context, vol types.StorageVolume, destinationSpecs *types.SpecConfig) error { target, err := DecodeInputSpec(destinationSpecs) if err != nil { return fmt.Errorf("failed to decode input spec: %v", err) } sanitizedKey := sanitizeKey(target.Key) // set file system to act upon based on the volume controller implementation var fs afero.Fs if basicVolController, ok := s.volController.(*basiccontroller.BasicVolumeController); ok { fs = basicVolController.FS }
Found in storage/s3/upload.go by structure -
Method `Storage.Download` has 6 return statements (exceeds 4 allowed).
// be careful if managing files with `os` (the volume controller might be // using an in-memory one) func (s *Storage) Download(ctx context.Context, sourceSpecs *types.SpecConfig) (types.StorageVolume, error) { var storageVol types.StorageVolume source, err := DecodeInputSpec(sourceSpecs) if err != nil { return types.StorageVolume{}, err } storageVol, err = s.volController.CreateVolume(storage.VolumeSourceS3) if err != nil { return types.StorageVolume{}, fmt.Errorf("failed to create storage volume: %v", err) }
Found in storage/s3/download.go by structure -
Method `Storage.downloadObject` has 5 return statements (exceeds 4 allowed).
} func (s *Storage) downloadObject(ctx context.Context, source *InputSource, object s3Object, volPath string) error { outputPath := filepath.Join(volPath, *object.key) // use the same file system instance used by the Volume Controller var fs afero.Fs if basicVolController, ok := s.volController.(*basiccontroller.BasicVolumeController); ok { fs = basicVolController.FS } // nolint:gofumpt err := fs.MkdirAll(outputPath, 0755) if err != nil { return fmt.Errorf("failed to create directory: %v", err)
Found in storage/s3/download.go by structure -
Function `SetupVolControllerTestSuite` has 7 return statements (exceeds 4 allowed).
// SetupVolControllerTestSuite sets up a volume controller with 0-n volumes given a base path. // If volumes are inputed, directories will be created and volumes will be stored in the database func SetupVolControllerTestSuite(t *testing.T, basePath string, volumes map[string]*types.StorageVolume) (*VolControllerTestSuiteHelper, error) { tempDir, err := os.MkdirTemp("", "clover-test-*") if err != nil { return nil, fmt.Errorf("failed to create temp directory: %w", err) } db, err := rclover.NewDB(tempDir, []string{"storage_volume"}) if err != nil { os.RemoveAll(tempDir) return nil, fmt.Errorf("failed to open clover db: %w", err) } fs := afero.NewMemMapFs()
Found in storage/basic_controller/test_suite.go by structure -
TODO found
} // TODO(skylar): See if inline datum is present if input.DatumFile != "" { args = append(args, "--tx-in-inline-datum-present")
Found in utils/cardano/cardano.go by fixme -
TODO found
func CapabilityComparator(_, _ interface{}, _ ...Preference) types.Comparison { // TODO: implement the comparison logic for the Capability type // after all the fields are implemented return types.Error
Found in dms/orchestrator/matching/CapabilityComparator.go by fixme -
TODO found
result = types.Worse // TODO: this comparator does not take into account options when several job types are available and several job types are required // in the same data structure; this is why the test fails; }
Found in dms/orchestrator/matching/JobTypesComparator.go by fixme -
TODO found
func Compare(l, r interface{}, _ ...Preference) types.Comparison { // TODO: it would be better to pass a pointer as this is a global structure comparatorMap := initComparatorMap()
Found in dms/orchestrator/matching/comparator.go by fixme -
XXX found
config.LoadConfig() // XXX: wait for server to start properly before sending requests below // TODO: should be removed time.Sleep(time.Second * 5)
Found in dms/dms.go by fixme -
TODO found
// XXX: wait for server to start properly before sending requests below // TODO: should be removed time.Sleep(time.Second * 5)
Found in dms/dms.go by fixme -
TODO found
} // TODO: convert to proto message and marshal with protobuf actorMessge, err := json.Marshal(m) if err != nil {
Found in dms/actor.go by fixme -
TODO found
) // TODO: remove after resource manager MR is merged type benchmarker interface { Benchmark(ctx context.Context) (*types.Capability, error)
Found in dms/node/node.go by fixme -
TODO found
actorFactory *dms.ActorFactory // TODO: fix when resource manager is merged to develop resourceManager resources.Manager
Found in dms/node/node.go by fixme -
TODO found
// GetSpecInfo returns the detailed specifications of the system // TODO: implement the method // https://gitlab.com/nunet/device-management-service/-/issues/537 func (d darwinSystemSpecs) GetSpecInfo() (types.SpecInfo, error) {
Found in dms/resources/system_specs_arm64_darwin.go by fixme -
TODO found
// https://gitlab.com/nunet/device-management-service/-/issues/537 func (d darwinSystemSpecs) GetSpecInfo() (types.SpecInfo, error) { // TODO implement me panic("implement me") }
Found in dms/resources/system_specs_arm64_darwin.go by fixme -
TODO found
) // TODO: This needs to be initialized in `dms` package and removed from here // https://gitlab.com/nunet/device-management-service/-/issues/536 func init() {
Found in dms/resources/init.go by fixme -
TODO found
// defaultManager implements the Manager interface // TODO: do we want to have an in-memory cache for the resources instead of querying the DB every time? // TODO: Add telemetry for the methods https://gitlab.com/nunet/device-management-service/-/issues/535 type defaultManager struct {
Found in dms/resources/resource_manager.go by fixme -
TODO found
// defaultManager implements the Manager interface // TODO: do we want to have an in-memory cache for the resources instead of querying the DB every time? // TODO: Add telemetry for the methods https://gitlab.com/nunet/device-management-service/-/issues/535 type defaultManager struct { usageMonitor UsageMonitor
Found in dms/resources/resource_manager.go by fixme -
TODO found
// GetSpecInfo returns the detailed specifications of the system // TODO: implement the method // https://gitlab.com/nunet/device-management-service/-/issues/537 func (d darwinSystemSpecs) GetSpecInfo() (types.SpecInfo, error) {
Found in dms/resources/system_specs_amd64_darwin.go by fixme -
TODO found
// https://gitlab.com/nunet/device-management-service/-/issues/537 func (d darwinSystemSpecs) GetSpecInfo() (types.SpecInfo, error) { // TODO implement me panic("implement me") }
Found in dms/resources/system_specs_amd64_darwin.go by fixme -
TODO found
// GetSpecInfo returns the detailed specifications of the system // TODO: implement the method // https://gitlab.com/nunet/device-management-service/-/issues/537 func (l linuxSystemSpecs) GetSpecInfo() (types.SpecInfo, error) {
Found in dms/resources/system_specs_linux.go by fixme -
TODO found
// https://gitlab.com/nunet/device-management-service/-/issues/537 func (l linuxSystemSpecs) GetSpecInfo() (types.SpecInfo, error) { // TODO implement me panic("implement me") }
Found in dms/resources/system_specs_linux.go by fixme -
TODO found
// fetchGPUMetadata fetches the GPU metadata for the system using `ghw.GPU()` // TODO: Use one single library to fetch GPU information or improve the match criteria // https://gitlab.com/nunet/device-management-service/-/issues/548 // TODO: write tests by mocking the gpu snapshot
Found in dms/resources/system_specs_linux.go by fixme -
TODO found
// TODO: Use one single library to fetch GPU information or improve the match criteria // https://gitlab.com/nunet/device-management-service/-/issues/548 // TODO: write tests by mocking the gpu snapshot // https://gitlab.com/nunet/device-management-service/-/issues/534 func (l linuxSystemSpecs) fetchGPUMetadata() (map[types.GPUVendor][]gpuMetadata, error) {
Found in dms/resources/system_specs_linux.go by fixme -
TODO found
} // TODO: disk usage var totalVCPU, totalMemSizeMib uint for _, vm := range vms {
Found in dms/resources/usage_monitor.go by fixme -
TODO found
} // TODO: disk usage for _, service := range services { resourcesReq := requirements[service.ResourceRequirements]
Found in dms/resources/usage_monitor.go by fixme -
TODO found
EngineSpec: &a.Job.Execution, Resources: &a.Job.Resources, // TODO add the following Inputs: []*types.StorageVolumeExecutor{}, Outputs: []*types.StorageVolumeExecutor{},
Found in dms/jobs/allocation.go by fixme -
TODO found
} // TODO: ExecutionResources and FreeResources should be compatible func availableResources(jobResources types.ExecutionResources, fr types.FreeResources) bool { return fr.RAM >= uint64(jobResources.Memory.Size) && fr.Disk >= jobResources.Disk.Size && fr.CPU > float64(jobResources.CPU.Cores)
Found in dms/jobs/allocation.go by fixme -
TODO found
// Deleted now because dependencies such as the docker package have been replaced with executor/docker func SanityCheck(_ *gorm.DB) { // TODO: sanity check of DMS last exit and correction of invalid states // resources.CalcFreeResAndUpdateDB()
Found in dms/sanity_check.go by fixme -
TODO found
return false, nil } // TODO: validate onbaording params return true, nil }
Found in dms/onboarding/onboarding.go by fixme -
TODO found
oConf.Name = hostname oConf.UpdateTimestamp = time.Now().Unix() // nolint TODO: 553 oConf.Resource.MemoryMax = int64(provisionedResources.RAM) oConf.Resource.TotalCore = int64(provisionedResources.NumCores)
Found in dms/onboarding/onboarding.go by fixme -
TODO found
oConf.Reserved.Memory = capacity.Memory oConf.Reserved.CPU = capacity.CPU // nolint TODO: 553 oConf.Available.Memory = int64(provisionedResources.RAM) - capacity.Memory oConf.Available.CPU = int64(provisionedResources.CPU) - capacity.CPU
Found in dms/onboarding/onboarding.go by fixme -
TODO found
} // TODO: START NETWORKING AND OTHER WORKERS FOR THE NODE return &savedOConf, errors.New("NOT YET IMPLEMENTED") }
Found in dms/onboarding/onboarding.go by fixme -
TODO found
} // TODO: shutdown routine to stop networking etc... here err = o.config.OnboardingRepo.Clear(ctx)
Found in dms/onboarding/onboarding.go by fixme -
TODO found
} // nolint TODO: 553 if capacity.Memory > int64(provisionedResources.RAM*9/10) || capacity.Memory < int64(provisionedResources.RAM/10) { return fmt.Errorf("memory should be between 10%% and 90%% of the available memory (%d and %d)", int64(provisionedResources.RAM/10), int64(provisionedResources.RAM*9/10))
Found in dms/onboarding/onboarding.go by fixme -
TODO found
CPUNo: totalProvisioned.NumCores, CPUHz: cpuInfo.MHzPerCore, PriceCPU: 0, // TODO: Get price of CPU RAM: int(capacity.Memory), PriceRAM: 0, // TODO: Get price of RAM
Found in dms/onboarding/onboarding.go by fixme -
TODO found
PriceCPU: 0, // TODO: Get price of CPU RAM: int(capacity.Memory), PriceRAM: 0, // TODO: Get price of RAM Vcpu: int(math.Floor((float64(capacity.CPU)) / cpuInfo.MHzPerCore)), Disk: 0,
Found in dms/onboarding/onboarding.go by fixme -
TODO found
// CreatePaymentAddress generates a keypair based on the wallet type. Currently supported types: ethereum, cardano. // TODO: This should be moved to utils-related package. It's a utility function independent of onboarding func CreatePaymentAddress(wallet string) (*types.BlockchainAddressPrivKey, error) { var (
Found in dms/onboarding/onboarding.go by fixme -
TODO found
} // TODO: Move this code block ( L263-272) to the allocator in future // Select the GPU with the highest available free VRAM and choose the GPU vendor for container's host config gpus, err := resources.ManagerInstance.SystemSpecs().GetGPUs()
Found in executor/docker/executor.go by fixme -
TODO found
func (p *P2P) ClearIncomingChatRequests() error { log.Println("WARNING: Bypassing ClearIncomingChatRequests() in libp2p.go") // TODO: Uncomment after refactoring // return libp2p.ClearIncomingChatRequests() // END
Found in cmd/backend/libp2p.go by fixme -
TODO found
} // TODO: Handle this after refactor // getIncomingChatList unmarshal response body from API request into // libp2p.OpenStream slice and return list of chats
Found in cmd/utils.go by fixme -
XXX found
} // XXX: don't leave me like this db, err := gorm.Open(sqlite.Open(fmt.Sprintf("%s/nunet.db", config.GetConfig().General.WorkDir)), &gorm.Config{}) if err != nil {
Found in cmd/utils.go by fixme -
XXX found
} // XXX: don't leave me like this db, err := gorm.Open(sqlite.Open(fmt.Sprintf("%s/nunet.db", config.GetConfig().General.WorkDir)), &gorm.Config{}) if err != nil {
Found in cmd/utils.go by fixme -
XXX found
var chatJoinCmd = NewChatJoinCmd(utilsService, webSocketClient) // XXX NewChatJoinCmd and NewChatStartCmd are similar, consider refactoring func NewChatJoinCmd(utilsService backend.Utility, wsClient backend.WebSocketClient) *cobra.Command { return &cobra.Command{
Found in cmd/chat_join.go by fixme -
XXX found
} // XXX: don't leave me like this db, err := gorm.Open(sqlite.Open(fmt.Sprintf("%s/nunet.db", config.GetConfig().General.WorkDir)), &gorm.Config{}) if err != nil {
Found in cmd/info.go by fixme -
TODO found
MessageHashAction string Action string // TODO: Add ContainerType field }
Found in types/README.md by fixme -
TODO found
// Warning: this is just a draft. And it might be moved to an Encryption package // // TODO: it must support encryption of files/directories, otherwise we have to // create another interface for the usecase type Encryptor interface {
Found in types/encryption.go by fixme -
TODO found
// Warning: this is just a draft. And it might be moved to an Encryption package // // TODO: it must support decryption of files/directories, otherwise we have to // create another interface for the usecase type Decryptor interface {
Found in types/encryption.go by fixme -
TODO found
// ResourceOps defines the operations on resources // TODO: Check how to handle GPU resources type ResourceOps interface { // Add returns the sum of the resources
Found in types/resource.go by fixme -
TODO found
// Add returns the sum of the resources func (r Resources) Add(r2 Resources) Resources { // TODO: GPU addition return Resources{ CPU: r.CPU + r2.CPU,
Found in types/resource.go by fixme -
TODO found
} // TODO: GPU subtraction if r.RAM < r2.RAM {
Found in types/resource.go by fixme -
TODO found
// RequiredResources represents the resources required by the jobs running on the machine // TODO: this is a replacement for ServiceResourceRequirements. Check with the team on this. type RequiredResources struct { BaseDBModel
Found in types/resource.go by fixme -
TODO found
// SpecInfo represents the machine specifications // TODO: Finalise the fields required in this struct // https://gitlab.com/nunet/device-management-service/-/issues/533 type SpecInfo struct {
Found in types/resource.go by fixme -
TODO found
type Disk struct { // Model represents the disk model, e.g., "Samsung 970 EVO Plus", "Western Digital Blue SN550" // TODO: may be removed as Disk models will be usually irrelevant, right? Model string
Found in types/resource.go by fixme -
TODO found
// Vendor represents the disk manufacturer, e.g., "Samsung", "Western Digital" // TODO: may be removed as Disk vendors will be usually irrelevant, right? Vendor string
Found in types/resource.go by fixme -
TODO found
// Read speed in bytes per second // TODO: may be removed as it may be too specific for our case ReadSpeed uint64 // Write speed in bytes per second
Found in types/resource.go by fixme -
TODO found
ReadSpeed uint64 // Write speed in bytes per second // TODO: may be removed as it may be too specific for our case WriteSpeed uint64 }
Found in types/resource.go by fixme -
TODO found
MessageHashAction string Action string // TODO: Add ContainerType field }
Found in types/machine.go by fixme -
TODO found
// created using the VolumeController, there will be no data in it by default. // // TODO-maybe [job]: should volumes be related to a job or []job? // // TODO-maybe: most of the fields should be private, callers shouldn't be able to altere
Found in types/storage.go by fixme -
TODO found
// TODO-maybe [job]: should volumes be related to a job or []job? // // TODO-maybe: most of the fields should be private, callers shouldn't be able to altere // the state of the volume except when using certain methods type StorageVolume struct {
Found in types/storage.go by fixme -
TODO found
// EncryptionType might be checked first if needed) // // TODO-maybe [type]: maybe it should be of type cid.CID CID string
Found in types/storage.go by fixme -
TODO found
// Size is the size of the storage volume // // TODO-maybe: if relying on a size field, we would have to be more careful // how state is being mutated (and they shouldn't be by the caller) // - Size might be calculated only when locking the volume also
Found in types/storage.go by fixme -
TODO found
) // TODO: Consider comments in this thread: https://gitlab.com/nunet/device-management-service/-/merge_requests/356#note_1997854443 // TODO: Consider comments in this thread: https://gitlab.com/nunet/device-management-service/-/merge_requests/356#note_1997875361
Found in types/comparison.go by fixme -
TODO found
// TODO: Consider comments in this thread: https://gitlab.com/nunet/device-management-service/-/merge_requests/356#note_1997854443 // TODO: Consider comments in this thread: https://gitlab.com/nunet/device-management-service/-/merge_requests/356#note_1997875361 // 'left' means 'this object' and 'right' means 'the supplied other object';
Found in types/comparison.go by fixme -
TODO found
) // TODO: pass the logger to the constructor and remove from here var ( zlog *otelzap.Logger
Found in network/libp2p/init.go by fixme -
TODO found
*/ // TODO-pnet-1: we shouldn't handle configuration paths here, a general configuration path // should be provided by /internal/config.go func getBasePath(_ afero.Fs) (string, error) {
Found in network/libp2p/pnet.go by fixme -
TODO found
// If a swarm key is not found, generate a new one. // // TODO-ask: should we continue to generate a new swarm key if one is not found? // Or we should enforce the user to use some cmd/API rpc to generate a new one? func configureSwarmKey(fs afero.Fs) (pnet.PSK, error) {
Found in network/libp2p/pnet.go by fixme -
TODO found
} // TODO-ask: should we return psk fingerprint? return psk, nil }
Found in network/libp2p/pnet.go by fixme -
TODO found
swarmKeyWithCodec := fmt.Sprintf("/key/swarm/psk/1.0.0/\n/base64/\n%s\n", encodedKey) // TODO-pnet-1 nunetDir, err := getBasePath(fs) if err != nil {
Found in network/libp2p/pnet.go by fixme -
TODO found
// Libp2p contains the configuration for a Libp2p instance. // // TODO-suggestion: maybe we should call it something else like Libp2pPeer, // Libp2pHost or just Peer (callers would use libp2p.Peer...) type Libp2p struct {
Found in network/libp2p/libp2p.go by fixme -
TODO found
// New creates a libp2p instance. // // TODO-Suggestion: move types.Libp2pConfig to here for better readability. // Unless there is a reason to keep within types. func New(config *types.Libp2pConfig, fs afero.Fs) (*Libp2p, error) {
Found in network/libp2p/libp2p.go by fixme -
TODO found
err = l.advertiseForRendezvousDiscovery(context) if err != nil { // TODO: the error might be misleading as a peer can normally work well if an error // is returned here (e.g.: the error is yielded in tests even though all tests pass). zlog.Sugar().Errorf("failed to start network with randevouz discovery: %v", err)
Found in network/libp2p/libp2p.go by fixme -
TODO found
// Ping the remote address. The remote address is the encoded peer id which will be decoded and used here. // // TODO (Return error once): something that was confusing me when using this method is that the error is // returned twice if any. Once as a field of PingResult and one as a return value. func (l *Libp2p) Ping(ctx context.Context, peerIDAddress string, timeout time.Duration) (types.PingResult, error) {
Found in network/libp2p/libp2p.go by fixme -
TODO found
advertisements := make([]*commonproto.Advertisement, 0) for _, v := range addrInfo { // TODO: use go routines to get the values in parallel. bytesAdvertisement, err := l.DHT.GetValue(ctx, l.getCustomNamespace(key, v.ID.String())) if err != nil {
Found in network/libp2p/libp2p.go by fixme -
TODO found
func (dhtValidator) Select(_ string, _ [][]byte) (int, error) { return 0, nil } // TODO remove the below when network package is fully implemented // UpdateKadDHT is a stub func (l *Libp2p) UpdateKadDHT() {
Found in network/libp2p/dht.go by fixme -
TODO found
// NewNetwork returns a new network given the configuration. func NewNetwork(netConfig *types.NetworkConfig, fs afero.Fs) (Network, error) { // TODO: probable additional params to receive: DB, FileSystem if netConfig == nil { return nil, errors.New("network configuration is nil")
Found in network/network.go by fixme -
TODO found
// P2PHandler is a controller for /peers endpoint functionalities // TODO: Create a service type for these functionalities // and embed inside the handler type P2PHandler struct {
Found in api/peers.go by fixme -
FIXME found
func getCustomCorsConfig() cors.Config { config := defaultConfig() // FIXME: This is a security concern. config.AllowOrigins = []string{"http://localhost:9991", "http://localhost:9992"} return config
Found in api/api.go by fixme -
TODO found
// DeviceHandler is a controller for /device endpoint functionalities // TODO: Create a service type for these functionalities // and embed inside the handler type DeviceHandler struct{}
Found in api/device.go by fixme -
TODO found
// @Router /device/status [get] func (h *DeviceHandler) DeviceStatus(c *gin.Context) { // TODO: handle this after refactor // status, err := libp2p.DeviceStatus() // if err != nil {
Found in api/device.go by fixme -
TODO found
} // TODO: handle this after refactor // err = libp2p.ChangeDeviceStatus(status.IsAvailable) // if err != nil {
Found in api/device.go by fixme -
TODO found
// VMHandler is a controller for /vm endpoint functionalities // TODO: Create a service type for these functionalities // and embed inside the handler type VMHandler struct{}
Found in api/vm.go by fixme -
XXX found
type Job struct { LogUpdateInterval int `mapstructure:"log_update_interval"` // in minutes TargetPeer string `mapstructure:"target_peer"` // specific peer to send deployment requests to - XXX probably not a good idea. Remove after testing stage. CleanupInterval int `mapstructure:"cleanup_interval"` // docker container and images clean up interval in days }
Found in internal/config/README.md by fixme -
XXX found
type Job struct { LogUpdateInterval int `mapstructure:"log_update_interval"` // in minutes TargetPeer string `mapstructure:"target_peer"` // specific peer to send deployment requests to - XXX probably not a good idea. Remove after testing stage. CleanupInterval int `mapstructure:"cleanup_interval"` // docker container and images clean up interval in days }
Found in internal/config/config.go by fixme -
TODO found
return []s3Object{}, fmt.Errorf("failed to retrieve object metadata: %v", err) } // TODO-minor: validate checksum if provided if strings.HasPrefix(*headObjectOut.ContentType, "application/x-directory") {
Found in storage/s3/download.go by fixme -
TODO found
// NewDefaultVolumeController returns a new instance of BasicVolumeController // // TODO-BugFix [path]: volBasePath might not end with `/`, causing errors when calling methods. // We need to validate it using the `path` library or just verifying the string. func NewDefaultVolumeController(repo repositories.StorageVolume, volBasePath string, fs afero.Fs) (*BasicVolumeController, error) {
Found in storage/basic_controller/basic_controller.go by fixme -
TODO found
// where `name` is random. // // TODO-maybe [withName]: allow callers to specify custom name for path func (vc *BasicVolumeController) CreateVolume(volSource storage.VolumeSource, opts ...storage.CreateVolOpt) (types.StorageVolume, error) { vol := types.StorageVolume{
Found in storage/basic_controller/basic_controller.go by fixme -
TODO found
// It optionally can also set the CID and mark the volume as private. // // TODO-maybe [CID]: maybe calculate CID of every volume in case WithCID opt is not provided func (vc *BasicVolumeController) LockVolume(pathToVol string, opts ...storage.LockVolOpt) error { query := vc.repo.GetQuery()
Found in storage/basic_controller/basic_controller.go by fixme -
TODO found
// WithCID sets the CID of a given volume if already calculated // // TODO [validate]: check if CID provided is valid func WithCID(cid string) storage.LockVolOpt { return func(v *types.StorageVolume) {
Found in storage/basic_controller/basic_controller.go by fixme -
TODO found
// ListVolumes returns a list of all storage volumes stored on the database // // TODO [filter]: maybe add opts to filter results by certain values func (vc *BasicVolumeController) ListVolumes() ([]types.StorageVolume, error) { volumes, err := vc.repo.FindAll(context.Background(), vc.repo.GetQuery())
Found in storage/basic_controller/basic_controller.go by fixme -
TODO found
// GetSize returns the size of a volume // TODO-minor: identify which measurement type will be used func (vc *BasicVolumeController) GetSize(identifier string, idType storage.IDType) (int64, error) { query := vc.repo.GetQuery()
Found in storage/basic_controller/basic_controller.go by fixme -
TODO found
// VolumeController is used to manage storage volumes. // // TODO-maybe: is the interface too big? We may have to split it? type VolumeController interface { // CreateVolume creates a directory where data can be stored, and returns a StorageVolume
Found in storage/volumes.go by fixme -
TODO found
// One of the opts may be a CID. Or the implementation might handle the CID calculation // // TODO-maybe: after volume is locked, callers should not be able to write data to it. LockVolume(pathToVol string, opts ...LockVolOpt) error
Found in storage/volumes.go by fixme -
TODO found
// GetSize returns the size of a volume // TODO-minor: identify which measurement type will be used GetSize(identifier string, idType IDType) (int64, error)
Found in storage/volumes.go by fixme -
TODO found
GetSize(identifier string, idType IDType) (int64, error) // TODO-maybe: encrypt/decrypt method might move to an unique EncryptVolume/DecryptVolume interfaces // or something else. // - Warning: if moved, EncryptionType field of StorageVolume must be updated somehow by the new interface
Found in storage/volumes.go by fixme -
XXX found
echo "Looking for old versions of nunet-dms ..." # XXX this can be removed once the new "nunet" binary has been in use for sometime if [ -f "/usr/bin/nunet-dms" ];then rm -f /usr/bin/nunet-dms
Found in maint-scripts/nunet-dms/DEBIAN/preinst by fixme