Giter Club home page Giter Club logo

function-cidr's Introduction

function-cidr

A Crossplane Composition Function for calculating Classless Inter-Domain Routing (CIDR) numbers. A CIDR is an IP address allocation method that is used to improve data routing efficiency on the internet.

Overview

This composition function offers 4 HashiCorp compatible IP Network Functions plus one custom wrapper. Follow the function links for detailed explanations of the function semantics.

To use this function, apply the following functions.yaml to your Crossplane management cluster.

cat <<EOF|kubectl apply -f -
apiVersion: pkg.crossplane.io/v1beta1
kind: Function
metadata:
  name: upbound-function-cidr
spec:
  package: xpkg.upbound.io/upbound/function-cidr:v0.1.0
EOF

Call the function from a Crossplane composition as described below.

Terminology

The cidrfunc IP Network Functions have various input parameters. Below are brief descriptions for context.

  • prefix must be given in CIDR notation, as defined in RFC 4632 section 3.1.
  • hostnum is a whole number that can be represented as a binary integer with no more than the number of digits remaining in the address after the given prefix.
  • newbits is the number of additional bits with which to extend the prefix. For example, if given a prefix ending in /16 and a newbits value of 4, the resulting subnet address will have length /20.
  • netnum is a whole number that can be represented as a binary integer with no more than newbits binary digits, which will be used to populate the additional bits added to the prefix.

Usage

Specify the cidrfunc calculation type in the composition function input. Valid values are as follows:

- cidrhost
- cidrnetmask
- cidrsubnet
- cidrsubnets
- cidrsubnetloop

Specify a custom outputfield in the function input parameters when the output should appear at a different path than the respective status.atFunction.cidr sub field default path.

All cidrfunc IP Network Functions require a CIDR prefix as input. Provide the prefix directly in the function input or specify a prefixfield in the XR where the function shall pick up the prefix value.

Function input field names ending in field indicate that the function shall read the field path value from the specified field path in the XR.

cidrhost

The cidrhost cidrfunc requires a hostnum or hostnumfield as function input. hostnum is an integer.

cidrnetmask

The cidrnetmask cidrfunc does not require additional parameters beyond the prefix. The prefix can be read from an XR field when the prefixField path is specified in the function input instead of a prefix value.

cidrsubnet

The cidrhost cidrsubnet reauires a netnum or netnumfield, and a newbits or newbitsfield as function input.

netNum is an integer. newBits is one integer in an array of integers.

cidrsubnets

The cidrhost cidrsubnets reauires a newBits or newBitsField as function input.

newBits is an array of integers.

cidrsubnetloop

The cidrhost cidrsubnetloop reauires the following input fields.

  • newBits (integer array) or newBitsField
  • netNumCount (integer) or netNumCountField
  • netNumItems (string array) or netNumItemsField
  • offset or offsetfield ** netNumCount and netNumItems are mutually exclusive **

The cidrsubnetloop wrapper calculates cidrsubnet CIDRs using the prefix and newBits parameters as input. It performs the calculations in a loop. The netnum is calculated during each iteration from iteration+offset. The iterations are either from 0 to netNumCount -1 or from 0 to number of items in netNumItemsCount or their respective values from their XR field references.

Testing The Function

Clone the repo. Run make debug and in a second terminal run make render and examine the output. Corresponding compositions and XR yaml can be found in the examples folder.

function-cidr's People

Contributors

humoflife avatar renovate[bot] avatar haarchri avatar ytsarev avatar mproffitt avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.