From 0e6e97cb96c820c46770dbad4f5e8c18254f6165 Mon Sep 17 00:00:00 2001 From: Jeff Ortel Date: Tue, 7 Nov 2023 07:44:02 -0800 Subject: [PATCH] checkpoint Signed-off-by: Jeff Ortel --- addon/adapter.go | 2 +- docs/binding.txt | 352 +++++------------------------------------------ 2 files changed, 39 insertions(+), 315 deletions(-) diff --git a/addon/adapter.go b/addon/adapter.go index 22cdadb9a..dacd3926e 100644 --- a/addon/adapter.go +++ b/addon/adapter.go @@ -68,7 +68,7 @@ type Filter = binding.Filter type Adapter struct { // Task API. Task - // Log is the addon logger. + // Log API. Log logapi.Logger // Settings API. Setting Setting diff --git a/docs/binding.txt b/docs/binding.txt index c7808f747..2db27ee79 100644 --- a/docs/binding.txt +++ b/docs/binding.txt @@ -1,13 +1,6 @@ package addon // import "github.com/konveyor/tackle2-hub/addon" -CONSTANTS - -const ( - RetryLimit = 60 - RetryDelay = time.Second * 10 -) - VARIABLES var ( @@ -20,7 +13,9 @@ TYPES type Adapter struct { // Task API. Task - // Settings API + // Log is the addon logger. + Log logapi.Logger + // Settings API. Setting Setting // Application API. Application Application @@ -44,288 +39,53 @@ type Adapter struct { var Addon *Adapter Addon An addon adapter configured for a task execution. -func (h *Adapter) Client() *Client - Client provides the REST client. - func (h *Adapter) Run(addon func() error) Run addon. Reports: - - Started - - Succeeded - - Failed (when addon returns error). - -type Analysis struct { - // Has unexported fields. -} - Analysis API. - -func (h *Analysis) Create(r *api.Analysis, encoding string, issues, deps io.Reader) (err error) - Create an analysis report. - -type AppFacts struct { - // Has unexported fields. -} - AppFacts sub-resource API. Provides association management of facts. - -func (h *AppFacts) Delete(key string) (err error) - Delete a fact. - -func (h *AppFacts) Get(key string) (fact *api.Fact, err error) - Get a fact. - -func (h *AppFacts) List() (list []api.Fact, err error) - List facts. - -func (h *AppFacts) Replace(facts []api.Fact) (err error) - Replace facts. - -func (h *AppFacts) Set(key string, value interface{}) (err error) - Set a fact (created as needed). - -func (h *AppFacts) Source(source string) - Source sets the source for other operations on the facts. - -type AppTags struct { - // Has unexported fields. -} - AppTags sub-resource API. Provides association management of tags to - applications by name. - -func (h *AppTags) Add(id uint) (err error) - Add ensures tag is associated with the application. - -func (h *AppTags) Delete(id uint) (err error) - Delete ensures the tag is not associated with the application. - -func (h *AppTags) List() (list []api.TagRef, err error) - List associated tags. Returns a list of tag names. - -func (h *AppTags) Replace(ids []uint) (err error) - Replace the associated tags for the source with a new set. Returns an error - if the source is not set. - -func (h *AppTags) Source(name string) - Source sets the source for other operations on the associated tags. - -type Application struct { - // Has unexported fields. -} - Application API. - -func (h *Application) Analysis(id uint) (a Analysis) - Analysis returns the analysis API. - -func (h *Application) Bucket(id uint) (b *Bucket) - Bucket returns the bucket API. - -func (h *Application) Facts(id uint) (f AppFacts) - Facts returns the tags API. - -func (h *Application) FindIdentity(id uint, kind string) (r *api.Identity, found bool, err error) - FindIdentity by kind. - -func (h *Application) Get(id uint) (r *api.Application, err error) - Get an application by ID. - -func (h *Application) List() (list []api.Application, err error) - List applications. - -func (h *Application) Tags(id uint) (tg AppTags) - Tags returns the tags API. - -func (h *Application) Update(r *api.Application) (err error) - Update an application by ID. - -type Bucket struct { - // Has unexported fields. -} - Bucket API. - -func (h *Bucket) Delete(path string) (err error) - Delete deletes content at the specified path. The path is relative to the - bucket root. - -func (h *Bucket) Get(source, destination string) (err error) - Get reads from the bucket. The source (path) is relative to the bucket root. - -func (h *Bucket) Put(source, destination string) (err error) - Put writes to the bucket. The destination (path) is relative to the bucket - root. - -type Client struct { - - // Retry limit. - Retry int - // Error - Error error - // Has unexported fields. -} - Client provides a REST client. - -func NewClient(url, token string) (client *Client) - NewClient Constructs a new client - -func (r *Client) BucketGet(source, destination string) (err error) - BucketGet downloads a file/directory. The source (path) is relative to the - bucket root. - -func (r *Client) BucketPut(source, destination string) (err error) - BucketPut uploads a file/directory. The destination (path) is relative to - the bucket root. - -func (r *Client) Delete(path string, params ...Param) (err error) - Delete a resource. - -func (r *Client) FileGet(path, destination string) (err error) - FileGet downloads a file. - -func (r *Client) FilePut(path, source string, object interface{}) (err error) - FilePut uploads a file. Returns the created File resource. - -func (r *Client) FileSend(path, method string, fields []Field, object interface{}) (err error) - FileSend sends file upload from. -func (r *Client) Get(path string, object interface{}, params ...Param) (err error) - Get a resource. + - Started + - Succeeded + - Failed (when addon returns error). -func (r *Client) Post(path string, object interface{}) (err error) - Post a resource. +type Application = binding.Application + Handler -func (r *Client) Put(path string, object interface{}, params ...Param) (err error) - Put a resource. +type Bucket = binding.Bucket -func (r *Client) Reset() - Reset the client. +type BucketContent = binding.BucketContent -func (r *Client) SetToken(token string) - SetToken sets hub token on client +type Client = binding.Client + Client -type Conflict struct { - SoftError - Path string -} - Conflict reports 409 error. - -func (e Conflict) Error() string - -func (e *Conflict) Is(err error) (matched bool) - -type Field struct { - Name string - Path string - Reader io.Reader - Encoding string -} - Field file upload form field. - -func (f *Field) Write(writer io.Writer) (err error) - Write the field content. When Reader is not set, the path is opened and - copied. - -type File struct { - // Has unexported fields. -} - File API. - -func (h *File) Delete(id uint) (err error) - Delete a file. - -func (h *File) Get(id uint, destination string) (err error) - Get downloads a file. - -func (h *File) Put(source string) (r *api.File, err error) - Put uploads a file. - -type Identity struct { - // Has unexported fields. -} - Identity API. - -func (h *Identity) Get(id uint) (r *api.Identity, err error) - Get an identity by ID. - -func (h *Identity) List() (list []api.Identity, err error) - List identities. - -type NotFound struct { - SoftError - Path string -} - NotFound reports 404 error. - -func (e NotFound) Error() string - -func (e *NotFound) Is(err error) (matched bool) - -type Param struct { - Key string - Value string -} - Param. - -type Params map[string]interface{} - Params mapping. - -type Path string - Path API path. - -func (s Path) Inject(p Params) (out string) - Inject named parameters. - -type Proxy struct { - // Has unexported fields. -} - Proxy API. - -func (h *Proxy) Find(kind string) (r *api.Proxy, err error) - Find by Kind. Returns nil when not found. - -func (h *Proxy) Get(id uint) (r *api.Proxy, err error) - Get a proxy by ID. +type Conflict = binding.Conflict -func (h *Proxy) List() (list []api.Proxy, err error) - List proxies. +type File = binding.File -func (h *Proxy) Update(r *api.Proxy) (err error) - Update a proxy by ID. - -type RuleSet struct { - // Has unexported fields. -} - RuleSet API. +type Filter = binding.Filter + Filter -func (h *RuleSet) Delete(id uint) (err error) - Delete a ruleset. +type Identity = binding.Identity -func (h *RuleSet) Get(id uint) (r *api.RuleSet, err error) - Get a ruleset by ID. +type NotFound = binding.NotFound -func (h *RuleSet) List() (list []api.RuleSet, err error) - List rulesets. +type Param = binding.Param -func (h *RuleSet) Update(r *api.RuleSet) (err error) - Update a ruleset by ID. +type Params = binding.Params -type Setting struct { - // Has unexported fields. -} - Setting API. +type Path = binding.Path -func (h *Setting) Bool(key string) (b bool, err error) - Bool setting value. +type Proxy = binding.Proxy -func (h *Setting) Get(key string, v interface{}) (err error) - Get a setting by key. +type ResetError = binding.RestError + Error -func (h *Setting) Int(key string) (n int, err error) - Int setting value. +type RuleSet = binding.RuleSet -func (h *Setting) Str(key string) (s string, err error) - Str setting value. +type Setting = binding.Setting type SoftError struct { Reason string } - SoftError A "soft" anticipated error. + SoftError A "soft" anticipated error. Deprecated: func (e *SoftError) Error() (s string) @@ -333,65 +93,23 @@ func (e *SoftError) Is(err error) (matched bool) func (e *SoftError) Soft() *SoftError -type Tag struct { - // Has unexported fields. -} - Tag API. - -func (h *Tag) Create(r *api.Tag) (err error) - Create a tag. - -func (h *Tag) Delete(r *api.Tag) (err error) - Delete a tag. - -func (h *Tag) Ensure(wanted *api.Tag) (err error) - Ensure a tag exists. +type Tag = binding.Tag -func (h *Tag) Find(name string, category uint) (r *api.Tag, found bool, err error) - Find by name and type. - -func (h *Tag) Get(id uint) (r *api.Tag, err error) - Get a tag by ID. - -func (h *Tag) List() (list []api.Tag, err error) - List tags. - -type TagCategory struct { - // Has unexported fields. -} - TagCategory API. - -func (h *TagCategory) Create(m *api.TagCategory) (err error) - Create a tag-type. - -func (h *TagCategory) Delete(r *api.TagCategory) (err error) - Delete a tag-type. - -func (h *TagCategory) Ensure(wanted *api.TagCategory) (err error) - Ensure a tag-type exists. - -func (h *TagCategory) Find(name string) (r *api.TagCategory, found bool, err error) - Find by name. - -func (h *TagCategory) Get(id uint) (r *api.TagCategory, err error) - Get a tag-type by ID. - -func (h *TagCategory) List() (list []api.TagCategory, err error) - List tag-types. +type TagCategory = binding.TagCategory type Task struct { // Has unexported fields. } Task API. -func (h *Task) Activity(entry string, x ...interface{}) +func (h *Task) Activity(entry string, v ...interface{}) Activity report addon activity. The description can be a printf style format. func (h *Task) Application() (r *api.Application, err error) Application returns the application associated with the task. -func (h *Task) Bucket() (b *Bucket) +func (h *Task) Bucket() (b *binding.BucketContent) Bucket returns the bucket API. func (h *Task) Completed(n int) @@ -403,7 +121,13 @@ func (h *Task) Data() (d map[string]interface{}) func (h *Task) DataWith(object interface{}) (err error) DataWith populates the addon data object. -func (h *Task) Failed(reason string, x ...interface{}) +func (h *Task) Error(error ...api.TaskError) + Error report addon error. + +func (h *Task) Errorf(severity, description string, v ...interface{}) + Errorf report addon error. + +func (h *Task) Failed(reason string, v ...interface{}) Failed report addon failed. The reason can be a printf style format. func (h *Task) Increment()