Skip to content

cub link create

Create a new link or bulk create links

Synopsis

Create a new link between two units or bulk create multiple links based on filters.

SINGLE LINK CREATION:

Create a single link between two units. Links define relationships between units and can be used to establish dependencies or connections between resources.

A link can be created:

  1. Between units in the same space
  2. Between units across different spaces (by specifying the target space)

BULK LINK CREATION:

When no positional arguments are provided, bulk create mode is activated. This mode creates links between units matching the filters specified.

Single Link Examples:

  # Create a link between a deployment and its namespace in the same space
  cub link create --space my-space --json to-ns my-deployment my-ns --wait

  # Create a link for a complex application to its namespace
  cub link create --space my-space --json headlamp-to-ns headlamp my-ns --wait

  # Create a link between a cloned unit and a namespace
  cub link create --space my-space --json clone-to-ns my-clone my-ns --wait

Bulk Create Examples:

  # Create links between all deployments and a namespace in a space
  cub link create --where-space "Slug = 'my-space'" --where-from "Labels.type = 'deployment'" --where-to "Slug = 'my-ns'"

  # Create links using filter entities to select spaces and units
  cub link create --filter-space deployment-spaces --filter-from frontend-units --filter-to backend-units

  # Combine where and filter expressions for complex selections
  cub link create --where-space "Labels.env = 'prod'" --filter-from prod-deployments --where-to "Slug LIKE 'ns-%'"

  # Create links between units across different spaces
  cub link create --dest-space dev-space,staging-space --where-from "Labels.app = 'frontend'" --where-to "Labels.app = 'backend'" --where-to-space "Slug = 'services-space'"

  # Create links with custom labels via JSON patch
  echo '{"Labels": {"relationship": "dependency"}}' | cub link create --where-space "Slug LIKE 'app-%'" --where-from "Labels.tier = 'web'" --where-to "Labels.tier = 'db'" --from-stdin
cub link create [<link slug> <from unit slug> <to unit slug> [<to space slug>]] [flags]

Options

      --allow-exists             Allow creation of resources that already exist
      --annotation strings       annotations in key=value format; can separate by commas and/or use multiple instances of the flag
      --auto-update              enable automatic downstream unit updates when upstream changes
      --delete-gate strings      delete gates in key[=true] format; can separate by commas and/or use multiple instances of the flag
      --dest-space strings       destination spaces for bulk create (can be repeated or comma-separated)
      --filename string          Read the ConfigHub entity JSON from file, URL (https://), or stdin (-); mutually exclusive with --from-stdin
      --filter-from string       filter entity containing WHERE expression to select from units (slug or UUID)
      --filter-space string      filter entity containing WHERE expression to select spaces for bulk create (slug or UUID)
      --filter-to string         filter entity containing WHERE expression to select to units (slug or UUID)
      --filter-to-space string   filter entity containing WHERE expression to select to spaces (slug or UUID)
      --from-stdin               Read the ConfigHub entity JSON (e.g., retrieved with cub <entity> get --quiet --json) from stdin; merged with command arguments on create, and merged with command arguments and existing entity on update
  -h, --help                     help for create
      --jq string                jq expression, suppressing default output
      --json                     JSON output, suppressing default output
      --label strings            labels in key=value format; can separate by commas and/or use multiple instances of the flag
      --make-current             set link revision numbers to current unit revisions (skips initial merge)
      --no-auto-update           disable automatic downstream unit updates
      --no-use-live-state        use Data of upstream unit instead of LiveState
      --quiet                    No default output.
      --timeout string           completion timeout as a duration with units, such as 10s or 2m (default "10m0s")
      --update-type string       link update type (NeedsProvides or MergeUnits)
      --use-live-state           use LiveState of upstream unit instead of Data
      --verbose                  Detailed output, additive with default output
      --wait                     wait for completion (default true)
      --where-from string        where expression to select from units within each space
      --where-mutation string    where expression to filter mutations during merge
      --where-resource string    where expression to select upstream resources for propagation
      --where-space string       where expression to select spaces for bulk create
      --where-to string          where expression to select to units within each space
      --where-to-space string    where expression to select to spaces for bulk create (optional)
      --yaml                     YAML output, suppressing default output
      --yq string                yq expression, suppressing default output

Options inherited from parent commands

      --context string   The context to use for this command
      --debug            Debug output
      --space string     space ID to perform command on

SEE ALSO