project

package
v0.63.0 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2023 License: MPL-2.0 Imports: 3 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        string         `json:"name" validate:"required,objectName" example:"name"`
	DisplayName string         `json:"displayName,omitempty" validate:"omitempty,min=0,max=63" example:"Shopping App"`
	Labels      v1alpha.Labels `json:"labels,omitempty" validate:"omitempty,labels"`
}

Metadata provides identity information for Project.

type Project

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

Project is the primary grouping primitive for manifest.Object. Most objects are scoped to a certain Project.

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.ApplyObjects(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) GetVersion

func (p Project) GetVersion() string

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 {
	Description string `json:"description" validate:"description" example:"Bleeding edge web app"`
}

Spec holds detailed information specific to Project.

Jump to

Keyboard shortcuts

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