rolebinding

package
v0.84.1-rc7 Latest Latest
Warning

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

Go to latest
Published: Sep 19, 2024 License: MPL-2.0 Imports: 5 Imported by: 1

Documentation

Overview

Package rolebinding defines RoleBinding object definitions.

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Metadata

type Metadata struct {
	Name string `json:"name"`
}

type RoleBinding

type RoleBinding struct {
	APIVersion manifest.Version `json:"apiVersion"`
	Kind       manifest.Kind    `json:"kind"`
	Metadata   Metadata         `json:"metadata"`
	Spec       Spec             `json:"spec"`

	Organization   string `json:"organization,omitempty"`
	ManifestSource string `json:"manifestSrc,omitempty"`
}

RoleBinding represents relation between user and role.

Example
package main

import (
	"context"
	"log"

	"github.com/nobl9/nobl9-go/internal/examples"
	"github.com/nobl9/nobl9-go/manifest"
	"github.com/nobl9/nobl9-go/manifest/v1alpha/rolebinding"
)

func main() {
	// Create the object:
	myBinding := rolebinding.New(
		rolebinding.Metadata{
			Name: "my-binding",
		},
		rolebinding.Spec{
			User:       ptr("some-user-id"),
			RoleRef:    "project-editor",
			ProjectRef: "default",
		},
	)
	// Verify the object:
	if err := myBinding.Validate(); err != nil {
		log.Fatal("role binding validation failed, err: %w", err)
	}
	// Apply the object:
	client := examples.GetOfflineEchoClient()
	if err := client.Objects().V1().Apply(context.Background(), []manifest.Object{myBinding}); err != nil {
		log.Fatal("failed to apply role binding, err: %w", err)
	}
}

func ptr[T any](v T) *T { return &v }
Output:

apiVersion: n9/v1alpha
kind: RoleBinding
metadata:
  name: my-binding
spec:
  user: some-user-id
  roleRef: project-editor
  projectRef: default

func New

func New(metadata Metadata, spec Spec) RoleBinding

func (RoleBinding) GetKind

func (r RoleBinding) GetKind() manifest.Kind

func (RoleBinding) GetManifestSource

func (r RoleBinding) GetManifestSource() string

func (RoleBinding) GetName

func (r RoleBinding) GetName() string

func (RoleBinding) GetOrganization

func (r RoleBinding) GetOrganization() string

func (RoleBinding) GetValidator added in v0.82.0

func (r RoleBinding) GetValidator() govy.Validator[RoleBinding]

func (RoleBinding) GetVersion

func (r RoleBinding) GetVersion() manifest.Version

func (RoleBinding) SetManifestSource

func (r RoleBinding) SetManifestSource(src string) manifest.Object

func (RoleBinding) SetOrganization

func (r RoleBinding) SetOrganization(org string) manifest.Object

func (RoleBinding) Validate

func (r RoleBinding) Validate() error

type Spec

type Spec struct {
	User       *string `json:"user,omitempty"`
	GroupRef   *string `json:"groupRef,omitempty"`
	RoleRef    string  `json:"roleRef"`
	ProjectRef string  `json:"projectRef,omitempty"`
}

Jump to

Keyboard shortcuts

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