flexera

package module
v1.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 8, 2021 License: Apache-2.0 Imports: 3 Imported by: 0

README

Flexera

GitHub release Go Report Card codecov

Golang 1.16 | cobra , promptui CLI | interactive and non-interactive mode | CircleCI | travis CI

Complexity

Runtime complexity
------------------- 
Indexing: O(n), n-> number of lines in the csv
Calculation: O(1), Amortized value, constant time, as the data is parsed from the index (ideally total user having those application id)

Storage complexity
------------------
O(s), s-> size of the data without comments that is currently being searched

Statistics
----------
Processing large CSV file ~1GB for calculating the licence cost , time taken <15 seconds
Processing large CSV file ~1GB for calculating the licence cost , < 5MB memory
Generating index for all the application id in ~1GB CSV file, ~4GB Memory consumed

Index structure

 map [applicationId] -> [userId] -> Laptop  -> Set(computerId)
                                    Desktop -> Set(computerId)                                                                   

Running Pre-built Image

To Run the pre-built image, the image can be downloaded from the following releases link

  • Download the release corresponding to your Operating System architecture and run the command
    The files need to be copied to the working directory
https://github.com/techievee/flexera/releases/tag/v1.1.0

Building image

There are multiple ways to build an image

  • custom build
git clone https://github.com/techievee/flexera.git
cd flexera
go build -trimpath -ldflags "-X main.Build=v1.1.0" -o ./flexera ./cmd
  • using makefile (linux and mac)
git clone https://github.com/techievee/flexera.git
cd flexera
make all
make bin-darwin
make bin-windows

Program Components

The program consists of the following components

  • console: Helps in invoking the program and to run in either interactive or non-interactive CLI mode
  • cmd: Command processor that helps in executing commands
  • indexed_data: Index processor, which stores and process index for inventory file based on the searched application id(s). Helps in searching data through index
  • data: Data store that reads and process the csv files from disk to memory structures.
  • utilities: Helper functions.

Command reference

Interactive Console
./flexera --help          

flexera is a CLI library that indexes and search csv file for calculating the licencing cost.
This application is a tool that reads the csv files, indexes it and 
calculates the total licences required for the application.

Usage:
  flexera [flags]
  flexera [command]

Available Commands:
  calculate   Flexera CLI Application to Index and Search CSV File Non interactively to find the total number of licence required
  help        Help about any command

Flags:
      --config string   config file (default is $HOME/flexera.yaml)
  -f, --file string     Path of the CSV file, Defaults to currentPath/sample-small.csv 
  -h, --help            help for flexera

Use "flexera [command] --help" for more information about a command.
Non-Interactive Console
Flexera calculate is a CLI library that indexes and search CSV file.
This application is a tool that reads the csv file, indexes it and 
searches them without any user interactions.

Usage:
  flexera calculate [flags]

Flags:
  -a, --application-id string   ID of the application, for which the licences need to be calculated
  -h, --help                    help for calculate

Global Flags:
      --config string   config file (default is $HOME/flexera.yaml)
  -f, --file string     Path of the CSV file, Defaults to currentPath/sample-small.csv

Program Specification

Interactive Console
  1. Running the ./flexera will invoke the Interactive CLI, the inventory input files need to be present in the directory where the command is present or need to overridden using -f or --file flags or FLEXERA_FILE environment variable
    Invoking interactive command without any CLI flags
    alt text
    Invoking interactive command using the short flags
    alt text
    Invoking interactive command using the full flags
    alt text
    Invoking interactive command after setting environment variable
    alt text

  2. Press Enter to pass the entry screen
    alt text

  3. Use arrow keys and select the licence calculation option
    alt text

  4. Enter the application id for which the licences need to be calculated, Multiple applicationId can be provided separated by comma
    alt text

While entering the application id string, it gets validated to passthrough the calculation command, the following rules apply

  • If enter is selected without any value it is considered as empty search, and it won't be validated

  • If calculation is performed providing one value or multiple comma separated value its considered as valid

  • If alphanumeric or text is entered for field, it won't allow to passthroughs, until the input is corrected


    Invalid inputs
    alt text

  1. Result gets displayed after the input is validated, along with runtime statistics
    alt text
Non-Interactive Console
  1. Running the ./flexera calculate command (flexera with additional calculate verb) will invoke the Non-interactive CLI for one time run or calculation, the inventory input files need to be present in the directory where the command is present or need to overridden using -f or --file flags or FLEXERA_FILE environment variable along with the applicationId via -a short flag , --application-id, or env variable FLEXERA_APPLICATION_ID

    Invoking non-interactive command with full flag name
    alt text
    Invoking non-interactive command using the short flags
    alt text
    Invoking non-interactive command after setting environment variable
    alt text

  2. Result gets displayed after the input is validated, along with runtime statistics
    alt text

Assumptions

  1. If the computer type or any other value is empty, then they won’t be considered as any additional licence, that line of CSV is considered as a noisy data
ComputerID UserID ApplicationID ComputerType Comment
1 - 371 DESKTOP Exported from System A
2 8361 - Desktop Exported from System B
- 4380 371 Desktop Exported from System A
4 3312 371 - Exported from System A
  • The first line doesn't have UserID
  • The second line doesn't have ApplicationId
  • The third line doesn't have ComputerId
  • The last line doesn't have Computer Type
    All these data are skipped.
    Result : 0
  1. If the computer with the same ComputerID is assigned to multiple users, then the licence is calculated based on the users
ComputerID UserID ApplicationID ComputerType Comment
1 1 371 DESKTOP Exported from System A
1 2 371 Desktop Exported from System B
2 1 371 Desktop Exported from System A
3 1 371 Laptop Exported from System A
  • Here, the computer with ComputerId = 1 is assigned to the user with UserID 1 and 2, then I would consider them as 2 licences as the calculations are based on the user and the combination of the computer.


Result: 3 licence
- for user 1, 2 licences(combined use for 2,3 and separate use of computer 1)
- for user 2 , 1 licence (computer 1)

  1. If the computer with the same ComputerID is assigned to laptop and desktop and assigned to a single user, it would be treated as invalid and licence for get calculated for that user, for that application.
ComputerID UserID ApplicationID ComputerType Comment
1 1 371 DESKTOP Exported from System A
1 1 371 laptop Exported from System B
2 1 371 Desktop Exported from System A
  • Here, the Computer with ComputerId=1 is both laptop and desktop, hence both the data are considered as invalid and they are not included for the licence calculation for that user for that application
  • the ComputerId=2 is desktop only, which is considerd as valid
    Result: 1

Libraries used

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Main

func Main(inventoryFile, applicationId string, interactive bool)

Main Core application logic that is initiated by the command processors from cmd package

func MainInteractive

func MainInteractive(c *console.Console)

MainInteractive Runs the program in the interactive mode, asks for user input

func MainNonInteractive

func MainNonInteractive(c *console.Console, applicationId string)

MainNonInteractive Runs the program in non-interactive mode, outputs the result and programs dies

Types

This section is empty.

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL