project

package
v0.83.0-rc2 Latest Latest
Warning

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

Go to latest
Published: Jun 27, 2024 License: MPL-2.0 Imports: 4 Imported by: 1

Documentation

Overview

Package project defines Project 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 is used to uniquely identify the Project.
	Name string `json:"name"`
	// DisplayName allows defining a more human-readable name for the Project.
	DisplayName string                      `json:"displayName,omitempty"`
	Labels      v1alpha.Labels              `json:"labels,omitempty"`
	Annotations v1alpha.MetadataAnnotations `json:"annotations,omitempty"`
}

Metadata provides identity information for Project.

type Project

type Project 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"`
}

Project is the primary grouping of resources in Nobl9. Most objects are scoped to a certain Project. For more details, see projects in the Nobl9 platform.

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"
	"github.com/nobl9/nobl9-go/manifest/v1alpha/project"
)

func main() {
	// Create the object:
	myProject := project.New(
		project.Metadata{
			Name:        "my-project",
			DisplayName: "My Project",
			Labels: v1alpha.Labels{
				"team":   []string{"green", "orange"},
				"region": []string{"eu-central-1"},
			},
		},
		project.Spec{
			Description: "Example project",
		},
	)
	// Verify the object:
	if err := myProject.Validate(); err != nil {
		log.Fatalf("project validation failed, err: %v", err)
	}
	// Apply the object:
	client := examples.GetOfflineEchoClient()
	if err := client.Objects().V1().Apply(context.Background(), []manifest.Object{myProject}); err != nil {
		log.Fatalf("failed to apply project, err: %v", err)
	}
}
Output:

apiVersion: n9/v1alpha
kind: Project
metadata:
  name: my-project
  displayName: My Project
  labels:
    region:
    - eu-central-1
    team:
    - green
    - orange
spec:
  description: Example project

func New

func New(metadata Metadata, spec Spec) Project

New creates a new Project based on provided Metadata nad Spec.

func (Project) GetKind

func (p Project) GetKind() manifest.Kind

func (Project) GetManifestSource

func (p Project) GetManifestSource() string

func (Project) GetName

func (p Project) GetName() string

func (Project) GetOrganization

func (p Project) GetOrganization() string

func (Project) GetValidator added in v0.82.0

func (p Project) GetValidator() validation.Validator[Project]

func (Project) GetVersion

func (p Project) GetVersion() manifest.Version

func (Project) SetManifestSource

func (p Project) SetManifestSource(src string) manifest.Object

func (Project) SetOrganization

func (p Project) SetOrganization(org string) manifest.Object

func (Project) Validate

func (p Project) Validate() error

type Spec

type Spec struct {
	CreatedAt string `json:"createdAt,omitempty"`
	CreatedBy string `json:"createdBy,omitempty"`
	// Description allows for a more detailed description of the Project.
	Description string `json:"description" validate:"description" example:"Bleeding edge web app"`
}

Spec holds detailed specification of the Project.

Jump to

Keyboard shortcuts

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