rolebinding

package
v0.61.0 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2023 License: MPL-2.0 Imports: 3 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 string        `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("00uatx49j46yVPKx04x7"),
			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.ApplyObjects(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: 00uatx49j46yVPKx04x7
  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) GetVersion

func (r RoleBinding) GetVersion() string

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