packageservice

package
v0.0.0-...-5eadde7 Latest Latest
Warning

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

Go to latest
Published: Jan 8, 2024 License: Apache-2.0 Imports: 17 Imported by: 4

Documentation

Index

Constants

View Source
const (
	KptfileName string = "Kptfile"
)

Variables

This section is empty.

Functions

func NewPorchClient

func NewPorchClient(config *rest.Config) (client.Client, error)

NewPorchClient creates a REST client for Porch server. A successful operation returns Client != nil and err == nil. A unsuccessful operation returns Client == nil and err != nil.

Types

type GetResourceRequest

type GetResourceRequest struct {
	// ID uniquely identifies the request
	ID int
	// ApiVersion is the ApiVersion of the requested resource
	ApiVersion string
	// Kind is the Kind of the requested resource
	Kind string
	// Name is the Name of the requested resource, this is the optional field
	Name string
}

GetResourceRequest is used as the input for fetching NF Profiles

type PackageServiceInterface

type PackageServiceInterface interface {
	// GetNFProfiles fetches the requested Nephio CRs (like UpfType, SmfType) and
	// different profile CRs (like CapacityProfile) and returns these
	// resources in a map with key same as the ID in request and value will be the
	// actual CRs in string format
	GetNFProfiles(ctx context.Context, req []GetResourceRequest, nc util.NamingContext) (map[int][]string, error)

	// CreateDeployPackage creates a package in the deploy repo and returns the package k8s resource name
	CreateDeployPackage(ctx context.Context, contents map[string]string, nc util.NamingContext) (string, error)

	// DeleteDeployPackage deletes packages from the deploy repo
	DeleteDeployPackage(ctx context.Context, nc util.NamingContext) error

	// CreateNFDeployActuators creates the NFDeployActuators in the deploy repo and returns
	// 1. the package k8s resource name.
	// 2. True if the package was newly created or updated else false if the package
	//    was already present with same content.
	// 3. Error if any occurred else nil.
	CreateNFDeployActuators(ctx context.Context, nc util.NamingContext, key VendorNFKey) (string, bool, error)

	// GetVendorExtensionPackage returns the list of k8s object yamls as string in the extension package.
	// Each string represent a single k8s object.
	GetVendorExtensionPackage(ctx context.Context, nc util.NamingContext, key VendorNFKey) ([]string, error)
}

type PorchPackageService

type PorchPackageService struct {
	// Rest client to intract with Porch server.
	Client client.Client
	// PorchPackageService specific logger.
	Log logr.Logger
}

PorchPackageService implements PackageServiceInterface.

func (*PorchPackageService) CreateDeployPackage

func (ps *PorchPackageService) CreateDeployPackage(ctx context.Context, contents map[string]string, nc util.NamingContext) (string, error)

creates the package in the relevant deploy repository and returns the new package name

func (*PorchPackageService) CreateNFDeployActuators

func (ps *PorchPackageService) CreateNFDeployActuators(ctx context.Context,
	nc util.NamingContext,
	key VendorNFKey) (string, bool, error)

Verifies the existing package and creates the actuator package in deploy repo if missing. It pulls the required operators from the private catalogue of the Customer. Returns: a. The name of the package k8s resource that has the actuator manifests b. A bool value representing if the package was newly created c. error if any. If the error is not nil, other values should not be used.

func (*PorchPackageService) DeleteDeployPackage

func (ps *PorchPackageService) DeleteDeployPackage(ctx context.Context, nc util.NamingContext) error

DeleteDeployPackage deletes packages from the deploy repo

func (*PorchPackageService) GetNFProfiles

func (ps *PorchPackageService) GetNFProfiles(ctx context.Context, req []GetResourceRequest, nc util.NamingContext) (map[int][]string, error)

fetches the requested Nephio profiles CRs (like UpfType, SmfType, CapacityProfile) and returns these resources as per the requestID in a map.

func (*PorchPackageService) GetVendorExtensionPackage

func (ps *PorchPackageService) GetVendorExtensionPackage(
	ctx context.Context,
	nc util.NamingContext,
	key VendorNFKey) ([]string, error)

GetVendorExtensionPackage returns the list of valid k8s object yamls as string in the extension package. A valid k8s object is one with valid GVK present along with namespace and name. Each string represent a single k8s object. Returns empty list if no extension package present. All other files and objects will be ignored on the assumption that the package could have non-yaml files too like Readme etc for users. Returns an error if package was present but no valid k8s object was found.

type VendorNFKey

type VendorNFKey struct {
	// The identifier for representing the vendor in our manifests for e.g. Casa.
	Vendor string

	// The version of the vendor's NF type for e.g. 1.0
	Version string

	// NF Type like Upf, Smf etc.
	NFType string
}

VendorNFKey is used to fetch and create the actuators or extension packages. specific to that vendor's NF type. The fields names should exactly match with what is present in the private catalogue of the customer.

Directories

Path Synopsis
Package mock is a generated GoMock package.
Package mock is a generated GoMock package.
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.

Jump to

Keyboard shortcuts

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