Documentation
¶
Index ¶
- Constants
- Variables
- func CheckGitFileIsStagedOrUnmodified(path string, st extgogit.FileStatus) error
- func CheckGitFileStatus(path string, st extgogit.FileStatus) error
- func CheckGitIsStagedOrUnmodified(stmap extgogit.Status) error
- func CheckGitStatus(stmap extgogit.Status) error
- func CollectPartialDeviceConfig(dir, device string) ([]string, error)
- func ConvertMapKeyToString(path string, in io.Reader, out io.Writer) error
- func GetGNMIServiceVersion() (string, error)
- func HttpCapabilities(c echo.Context, path string) error
- func HttpGet(c echo.Context, rootpath string) error
- func HttpSet(c echo.Context, ctx context.Context, gogit *gogit.Git, scfg *ServeCfg) error
- func MakeCommitMessage(stmap extgogit.Status) string
- func MakeSyncCommitMessage(stmap git.Status) string
- func RunCueGet(ctx context.Context, cfg *CueGetCfg) error
- func RunCueGetImpl(ctx context.Context, path string, getter CueGetter) error
- func RunDeviceAggregate(ctx context.Context, cfg *DeviceAggregateCfg) error
- func RunDeviceComposite(ctx context.Context, cfg *DeviceCompositeCfg) error
- func RunGitCommit(ctx context.Context, cfg *GitCommitCfg) error
- func RunServe(ctx context.Context, cfg *ServeCfg) error
- func RunServeHttp(ctx context.Context, cfg *ServeCfg) error
- func RunServiceApply(ctx context.Context, cfg *ServiceApplyCfg) error
- func RunServiceCompile(ctx context.Context, cfg *ServiceCompileCfg) error
- func SetupGitRepoWithRemote(t *testing.T, remote string) (*git.Repository, string, string)
- func WithWriter(parent context.Context, w io.Writer) context.Context
- func WriterFromContext(ctx context.Context) io.Writer
- type CueGetCfg
- type CueGetFunc
- type CueGetter
- type DeviceAggregateCfg
- type DeviceAggregateServer
- func (s *DeviceAggregateServer) GitPushDeviceConfig(ctx context.Context) error
- func (s *DeviceAggregateServer) HandleFunc(w http.ResponseWriter, r *http.Request)
- func (s *DeviceAggregateServer) Run(ctx context.Context)
- func (s *DeviceAggregateServer) SaveConfig(ctx context.Context, r *SaveConfigRequest) error
- type DeviceCompositeCfg
- type DeviceCompositePlan
- type DeviceFunc
- type DevicePathReq
- type ErrConfigValue
- type GitCommitCfg
- type GnmiPathConverter
- type GnmiRequestHandler
- type HttpGetBody
- type HttpSetBody
- type HttpSetRes
- type NorthboundServer
- func (s *NorthboundServer) Capabilities(ctx context.Context, req *pb.CapabilityRequest) (*pb.CapabilityResponse, error)
- func (s *NorthboundServer) Get(ctx context.Context, req *pb.GetRequest) (*pb.GetResponse, error)
- func (s *NorthboundServer) RunConfigSyncLoop(ctx context.Context, dur time.Duration)
- func (s *NorthboundServer) RunStatusSyncLoop(ctx context.Context, dur time.Duration)
- func (s *NorthboundServer) Set(ctx context.Context, req *pb.SetRequest) (*pb.SetResponse, error)
- type NorthboundServerImpl
- func (s *NorthboundServerImpl) Capabilities(ctx context.Context, req *pb.CapabilityRequest) (*pb.CapabilityResponse, error)
- func (s *NorthboundServerImpl) Delete(ctx context.Context, prefix, path *pb.Path) (*pb.UpdateResult, error)
- func (s *NorthboundServerImpl) Get(ctx context.Context, prefix, path *pb.Path) (*pb.Notification, error)
- func (s *NorthboundServerImpl) Replace(ctx context.Context, prefix, path *pb.Path, val *pb.TypedValue) (*pb.UpdateResult, error)
- func (s *NorthboundServerImpl) Update(ctx context.Context, prefix, path *pb.Path, val *pb.TypedValue) (*pb.UpdateResult, error)
- type PathReq
- type PathType
- type RootCfg
- type SaveConfigRequest
- type ServeCfg
- type ServiceApplyCfg
- type ServiceCompileCfg
- type ServiceCompilePlan
- type ServiceFunc
- type ServicePathReq
- type VisitFunc
Constants ¶
const ( NodeService = "service" NodeDevice = "device" KeyServiceKind = "kind" KeyDeviceName = "name" PathTypeService PathType = NodeService PathTypeDevice PathType = NodeDevice )
const ( ServiceKind = "services" DeviceKind = "devices" )
Variables ¶
var UpdateCheckDuration = 5 * time.Second // TODO parameterize
Functions ¶
func CheckGitFileIsStagedOrUnmodified ¶
func CheckGitFileIsStagedOrUnmodified(path string, st extgogit.FileStatus) error
CheckGitFileIsStagedOrUnmodified checks the given file status is modified and staged, or unmodified.
func CheckGitFileStatus ¶
func CheckGitFileStatus(path string, st extgogit.FileStatus) error
CheckGitFileStatus checks the given file status is in the proper status for service apply operation.
func CheckGitIsStagedOrUnmodified ¶
CheckGitIsStagedOrUnmodified checks all tracked files are modified and staged, or unmodified.
func CheckGitStatus ¶
CheckGitStatus checks all git tracked files are in the proper status for service apply operation.
func CollectPartialDeviceConfig ¶
CollectPartialDeviceConfig returns list of partial device configs for the given device.
func ConvertMapKeyToString ¶
ConvertMapKeyToString converts all go structs in the given go file to the structure supported by kuesta. It extracts go structs and converts all map keys to string if the go struct contains maps with non-string key.
func GetGNMIServiceVersion ¶
GetGNMIServiceVersion returns a pointer to the gNMI service version string. The method is non-trivial because of the way it is defined in the proto file.
func HttpCapabilities ¶ added in v0.9.0
Capabilities responds the server capabilities containing the available services.
func HttpSet ¶ added in v0.9.0
Set executes specified Replace/Update/Delete operations and responds what is done by SetRequest.
func MakeCommitMessage ¶
MakeCommitMessage returns the commit message that shows the summary of service and device updates.
func MakeSyncCommitMessage ¶
func MakeSyncCommitMessage(stmap git.Status) string
MakeSyncCommitMessage returns the commit message that shows the device actual config updates.
func RunDeviceAggregate ¶
func RunDeviceAggregate(ctx context.Context, cfg *DeviceAggregateCfg) error
RunDeviceAggregate runs the main process of the `device aggregate` command.
func RunDeviceComposite ¶
func RunDeviceComposite(ctx context.Context, cfg *DeviceCompositeCfg) error
RunDeviceComposite runs the main process of the `device composite` command.
func RunGitCommit ¶
func RunGitCommit(ctx context.Context, cfg *GitCommitCfg) error
RunGitCommit runs the main process of the `git commit` command.
func RunServiceApply ¶
func RunServiceApply(ctx context.Context, cfg *ServiceApplyCfg) error
RunServiceApply runs the main process of the `service apply` command.
func RunServiceCompile ¶
func RunServiceCompile(ctx context.Context, cfg *ServiceCompileCfg) error
RunServiceCompile runs the main process of the `service compile` command.
func SetupGitRepoWithRemote ¶
func WithWriter ¶
WithWriter sets io.Writer to context for outputting message from command.
Types ¶
type CueGetFunc ¶
func (CueGetFunc) Exec ¶
func (fn CueGetFunc) Exec(modPath, outDir string) error
type DeviceAggregateCfg ¶
type DeviceAggregateCfg struct { RootCfg Addr string NoTLS bool Insecure bool TLSCrtPath string TLSKeyPath string TLSCACrtPath string }
func (*DeviceAggregateCfg) Mask ¶
func (c *DeviceAggregateCfg) Mask() *DeviceAggregateCfg
Mask returns the copy whose sensitive data are masked.
func (*DeviceAggregateCfg) TLSServerConfig ¶
func (c *DeviceAggregateCfg) TLSServerConfig() *credentials.TLSServerConfig
func (*DeviceAggregateCfg) Validate ¶
func (c *DeviceAggregateCfg) Validate() error
Validate validates exposed fields according to the `validate` tag.
type DeviceAggregateServer ¶
type DeviceAggregateServer struct {
// contains filtered or unexported fields
}
DeviceAggregateServer runs saver loop and committer loop along with serving commit API to persist device config to git. Device config are written locally and added to git just after commit API call. Updated configs are aggregated and git-pushed as batch commit periodically.
func NewDeviceAggregateServer ¶
func NewDeviceAggregateServer(cfg *DeviceAggregateCfg) *DeviceAggregateServer
NewDeviceAggregateServer creates new DeviceAggregateServer.
func (*DeviceAggregateServer) GitPushDeviceConfig ¶
func (s *DeviceAggregateServer) GitPushDeviceConfig(ctx context.Context) error
GitPushDeviceConfig runs git-commit all unstaged device config updates as batch commit then git-push to remote origin.
func (*DeviceAggregateServer) HandleFunc ¶
func (s *DeviceAggregateServer) HandleFunc(w http.ResponseWriter, r *http.Request)
HandleFunc handles API call to persist actual device config.
func (*DeviceAggregateServer) Run ¶
func (s *DeviceAggregateServer) Run(ctx context.Context)
func (*DeviceAggregateServer) SaveConfig ¶
func (s *DeviceAggregateServer) SaveConfig(ctx context.Context, r *SaveConfigRequest) error
SaveConfig writes device config contained in supplied SaveConfigRequest.
type DeviceCompositeCfg ¶
func (*DeviceCompositeCfg) Mask ¶
func (c *DeviceCompositeCfg) Mask() *DeviceCompositeCfg
Mask returns the copy whose sensitive data are masked.
func (*DeviceCompositeCfg) Validate ¶
func (c *DeviceCompositeCfg) Validate() error
Validate validates exposed fields according to the `validate` tag.
type DeviceCompositePlan ¶
type DeviceCompositePlan struct {
// contains filtered or unexported fields
}
func NewDeviceCompositePlan ¶
func NewDeviceCompositePlan(stmap extgogit.Status, root string) *DeviceCompositePlan
NewDeviceCompositePlan creates new DeviceCompositePlan from the given git file statuses.
func (*DeviceCompositePlan) Do ¶
func (p *DeviceCompositePlan) Do(ctx context.Context, compositeFunc DeviceFunc) error
Do executes given composite DeviceFunc according to its execution plan.
func (*DeviceCompositePlan) IsEmpty ¶
func (p *DeviceCompositePlan) IsEmpty() bool
IsEmpty returns True when there are no planned targets.
type DeviceFunc ¶
type DeviceFunc func(ctx context.Context, sp kuesta.DevicePath) error
type DevicePathReq ¶
type DevicePathReq struct {
// contains filtered or unexported fields
}
func (DevicePathReq) Path ¶
func (s DevicePathReq) Path() *kuesta.DevicePath
func (DevicePathReq) String ¶
func (s DevicePathReq) String() string
func (DevicePathReq) Type ¶
func (DevicePathReq) Type() PathType
type ErrConfigValue ¶
type ErrConfigValue struct {
// contains filtered or unexported fields
}
func (*ErrConfigValue) Error ¶
func (e *ErrConfigValue) Error() string
type GitCommitCfg ¶
type GitCommitCfg struct {
RootCfg
}
func (*GitCommitCfg) Mask ¶
func (c *GitCommitCfg) Mask() *GitCommitCfg
Mask returns the copy whose sensitive data are masked.
func (*GitCommitCfg) Validate ¶
func (c *GitCommitCfg) Validate() error
Validate validates exposed fields according to the `validate` tag.
type GnmiPathConverter ¶
type GnmiPathConverter struct {
// contains filtered or unexported fields
}
func NewGnmiPathConverter ¶
func NewGnmiPathConverter(cfg *ServeCfg) *GnmiPathConverter
type GnmiRequestHandler ¶
type GnmiRequestHandler interface { Capabilities(ctx context.Context, req *pb.CapabilityRequest) (*pb.CapabilityResponse, error) Get(ctx context.Context, prefix, path *pb.Path) (*pb.Notification, error) Delete(ctx context.Context, prefix, path *pb.Path) (*pb.UpdateResult, error) Update(ctx context.Context, prefix, path *pb.Path, val *pb.TypedValue) (*pb.UpdateResult, error) Replace(ctx context.Context, prefix, path *pb.Path, val *pb.TypedValue) (*pb.UpdateResult, error) }
type HttpGetBody ¶ added in v0.9.0
type HttpGetBody struct {
Paths []string `json:"paths"`
}
type HttpSetBody ¶ added in v0.9.0
type HttpSetRes ¶ added in v0.9.0
type NorthboundServer ¶
type NorthboundServer struct { pb.UnimplementedGNMIServer // contains filtered or unexported fields }
func NewNorthboundServer ¶
func NewNorthboundServer(cfg *ServeCfg) (*NorthboundServer, error)
NewNorthboundServer creates new NorthboundServer with supplied ServeCfg.
func NewNorthboundServerWithGit ¶
func NewNorthboundServerWithGit(cfg *ServeCfg, cGit, sGit *gogit.Git) *NorthboundServer
func (*NorthboundServer) Capabilities ¶
func (s *NorthboundServer) Capabilities(ctx context.Context, req *pb.CapabilityRequest) (*pb.CapabilityResponse, error)
Capabilities responds the server capabilities containing the available services.
func (*NorthboundServer) Get ¶
func (s *NorthboundServer) Get(ctx context.Context, req *pb.GetRequest) (*pb.GetResponse, error)
Get responds the multiple service inputs requested by GetRequest.
func (*NorthboundServer) RunConfigSyncLoop ¶
func (s *NorthboundServer) RunConfigSyncLoop(ctx context.Context, dur time.Duration)
func (*NorthboundServer) RunStatusSyncLoop ¶
func (s *NorthboundServer) RunStatusSyncLoop(ctx context.Context, dur time.Duration)
func (*NorthboundServer) Set ¶
func (s *NorthboundServer) Set(ctx context.Context, req *pb.SetRequest) (*pb.SetResponse, error)
Set executes specified Replace/Update/Delete operations and responds what is done by SetRequest.
type NorthboundServerImpl ¶
type NorthboundServerImpl struct {
// contains filtered or unexported fields
}
func NewNorthboundServerImpl ¶
func NewNorthboundServerImpl(cfg *ServeCfg) *NorthboundServerImpl
func (*NorthboundServerImpl) Capabilities ¶
func (s *NorthboundServerImpl) Capabilities(ctx context.Context, req *pb.CapabilityRequest) (*pb.CapabilityResponse, error)
Capabilities responds the server capabilities containing the available services.
func (*NorthboundServerImpl) Delete ¶
func (s *NorthboundServerImpl) Delete(ctx context.Context, prefix, path *pb.Path) (*pb.UpdateResult, error)
Delete deletes the service input stored at the supplied path.
func (*NorthboundServerImpl) Get ¶
func (s *NorthboundServerImpl) Get(ctx context.Context, prefix, path *pb.Path) (*pb.Notification, error)
Get returns the service input stored at the supplied path.
func (*NorthboundServerImpl) Replace ¶
func (s *NorthboundServerImpl) Replace(ctx context.Context, prefix, path *pb.Path, val *pb.TypedValue) (*pb.UpdateResult, error)
Replace replaces the service input stored at the supplied path.
func (*NorthboundServerImpl) Update ¶
func (s *NorthboundServerImpl) Update(ctx context.Context, prefix, path *pb.Path, val *pb.TypedValue) (*pb.UpdateResult, error)
Update updates the service input stored at the supplied path.
type RootCfg ¶
type RootCfg struct { Verbose uint8 `validate:"min=0,max=3"` Devel bool ConfigRootPath string StatusRootPath string ConfigRepoUrl string StatusRepoUrl string GitTrunk string GitRemote string GitToken string GitUser string GitEmail string PushToMain bool }
func (*RootCfg) ConfigGitOptions ¶
func (c *RootCfg) ConfigGitOptions() *gogit.GitOptions
func (*RootCfg) StatusGitOptions ¶
func (c *RootCfg) StatusGitOptions() *gogit.GitOptions
type SaveConfigRequest ¶
type SaveConfigRequest struct { Device string `json:"device" validate:"required"` Config *string `json:"config" validate:"required"` }
func DecodeSaveConfigRequest ¶
func DecodeSaveConfigRequest(r io.Reader) (*SaveConfigRequest, error)
DecodeSaveConfigRequest decodes supplied payload to SaveConfigRequest.
func (*SaveConfigRequest) Validate ¶
func (r *SaveConfigRequest) Validate() error
type ServeCfg ¶
type ServeCfg struct { RootCfg Addr string `validate:"required"` HttpAddr string SyncPeriod int `validate:"required"` PersistGitState bool NoTLS bool Insecure bool TLSCrtPath string TLSKeyPath string TLSCACrtPath string }
func (*ServeCfg) TLSServerConfig ¶
func (c *ServeCfg) TLSServerConfig() *credentials.TLSServerConfig
type ServiceApplyCfg ¶
type ServiceApplyCfg struct {
RootCfg
}
func (*ServiceApplyCfg) Mask ¶
func (c *ServiceApplyCfg) Mask() *ServiceApplyCfg
Mask returns the copy whose sensitive data are masked.
func (*ServiceApplyCfg) Validate ¶
func (c *ServiceApplyCfg) Validate() error
Validate validates exposed fields according to the `validate` tag.
type ServiceCompileCfg ¶
type ServiceCompileCfg struct { RootCfg Service string `validate:"required"` Keys []string `validate:"gt=0,dive,required"` }
func (*ServiceCompileCfg) Mask ¶
func (c *ServiceCompileCfg) Mask() *ServiceCompileCfg
Mask returns the copy whose sensitive data are masked.
func (*ServiceCompileCfg) Validate ¶
func (c *ServiceCompileCfg) Validate() error
Validate validates exposed fields according to the `validate` tag.
type ServiceCompilePlan ¶
type ServiceCompilePlan struct {
// contains filtered or unexported fields
}
func NewServiceCompilePlan ¶
func NewServiceCompilePlan(stmap extgogit.Status, root string) *ServiceCompilePlan
NewServiceCompilePlan creates new ServiceCompilePlan from the given git file statuses.
func (*ServiceCompilePlan) Do ¶
func (p *ServiceCompilePlan) Do(ctx context.Context, deleteFunc ServiceFunc, updateFunc ServiceFunc) error
Do executes given delete ServiceFunc and update ServiceFunc according to its execution plan.
func (*ServiceCompilePlan) IsEmpty ¶
func (p *ServiceCompilePlan) IsEmpty() bool
IsEmpty returns True when there are no planned targets.
type ServiceFunc ¶
type ServiceFunc func(ctx context.Context, sp kuesta.ServicePath) error
type ServicePathReq ¶
type ServicePathReq struct {
// contains filtered or unexported fields
}
func (*ServicePathReq) Keys ¶
func (s *ServicePathReq) Keys() map[string]string
func (*ServicePathReq) Path ¶
func (s *ServicePathReq) Path() *kuesta.ServicePath
func (ServicePathReq) String ¶
func (s ServicePathReq) String() string
func (ServicePathReq) Type ¶
func (ServicePathReq) Type() PathType