Documentation ¶
Overview ¶
Package service defines Service object definitions.
Index ¶
- type Metadata
- type Service
- func (s Service) GetKind() manifest.Kind
- func (s Service) GetManifestSource() string
- func (s Service) GetName() string
- func (s Service) GetOrganization() string
- func (s Service) GetProject() string
- func (s Service) GetVersion() string
- func (s Service) SetManifestSource(src string) manifest.Object
- func (s Service) SetOrganization(org string) manifest.Object
- func (s Service) SetProject(project string) manifest.Object
- func (s Service) Validate() error
- type Spec
- type Status
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"` DisplayName string `json:"displayName,omitempty" validate:"omitempty,min=0,max=63"` Project string `json:"project,omitempty" validate:"objectName"` Labels v1alpha.Labels `json:"labels,omitempty" validate:"omitempty,labels"` }
Metadata provides identity information for Service.
type Service ¶
type Service struct { APIVersion string `json:"apiVersion"` Kind manifest.Kind `json:"kind"` Metadata Metadata `json:"metadata"` Spec Spec `json:"spec"` Status *Status `json:"status,omitempty"` Organization string `json:"organization,omitempty"` ManifestSource string `json:"manifestSrc,omitempty"` }
Service struct which mapped one to one with kind: service yaml definition
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/service" ) func main() { // Create the object: myService := service.New( service.Metadata{ Name: "my-service", DisplayName: "My Service", Project: "default", Labels: v1alpha.Labels{ "team": []string{"green", "orange"}, "region": []string{"eu-central-1"}, }, }, service.Spec{ Description: "Example service", }, ) // Verify the object: if err := myService.Validate(); err != nil { log.Fatalf("service validation failed, err: %v", err) } // Apply the object: client := examples.GetOfflineEchoClient() if err := client.ApplyObjects(context.Background(), []manifest.Object{myService}); err != nil { log.Fatalf("failed to apply service, err: %v", err) } }
Output: apiVersion: n9/v1alpha kind: Service metadata: name: my-service displayName: My Service project: default labels: region: - eu-central-1 team: - green - orange spec: description: Example service
func (Service) GetManifestSource ¶
func (Service) GetOrganization ¶
func (Service) GetProject ¶
func (Service) GetVersion ¶
Click to show internal directories.
Click to hide internal directories.