-
Notifications
You must be signed in to change notification settings - Fork 12
feat: Add v2.KeptnInterface
that adds context.Context
support to api.KeptnInterface
#449
Conversation
pkg/api/utils/resourceUtils.go
Outdated
return r.GetStageResourceWithContext(context.TODO(), project, stage, resourceURI) | ||
} | ||
|
||
// GetStageResourceContext retrieves a stage resource from the configuration service. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[golint] reported by reviewdog 🐶
comment on exported method ResourceHandler.GetStageResourceWithContext should be of the form "GetStageResourceWithContext ..."
pkg/api/utils/sequenceUtils.go
Outdated
return s.ControlSequenceWithContext(context.TODO(), params) | ||
} | ||
|
||
func (s *SequenceControlHandler) ControlSequenceWithContext(ctx context.Context, params SequenceControlParams) error { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[golint] reported by reviewdog 🐶
exported method SequenceControlHandler.ControlSequenceWithContext should have comment or be unexported
pkg/api/utils/uniformUtils.go
Outdated
return u.PingWithContext(context.TODO(), integrationID) | ||
} | ||
|
||
func (u *UniformHandler) PingWithContext(ctx context.Context, integrationID string) (*models.Integration, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[golint] reported by reviewdog 🐶
exported method UniformHandler.PingWithContext should have comment or be unexported
pkg/api/utils/uniformUtils.go
Outdated
return u.RegisterIntegrationWithContext(context.TODO(), integration) | ||
} | ||
|
||
func (u *UniformHandler) RegisterIntegrationWithContext(ctx context.Context, integration models.Integration) (string, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[golint] reported by reviewdog 🐶
exported method UniformHandler.RegisterIntegrationWithContext should have comment or be unexported
pkg/api/utils/uniformUtils.go
Outdated
return u.CreateSubscriptionWithContext(context.TODO(), integrationID, subscription) | ||
} | ||
|
||
func (u *UniformHandler) CreateSubscriptionWithContext(ctx context.Context, integrationID string, subscription models.EventSubscription) (string, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[golint] reported by reviewdog 🐶
exported method UniformHandler.CreateSubscriptionWithContext should have comment or be unexported
pkg/api/utils/uniformUtils.go
Outdated
return u.UnregisterIntegrationWithContext(context.TODO(), integrationID) | ||
} | ||
|
||
func (u *UniformHandler) UnregisterIntegrationWithContext(ctx context.Context, integrationID string) error { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[golint] reported by reviewdog 🐶
exported method UniformHandler.UnregisterIntegrationWithContext should have comment or be unexported
pkg/api/utils/uniformUtils.go
Outdated
|
||
req, err := http.NewRequest("GET", url.String(), nil) | ||
func (u *UniformHandler) GetRegistrationsWithContext(ctx context.Context) ([]*models.Integration, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[golint] reported by reviewdog 🐶
exported method UniformHandler.GetRegistrationsWithContext should have comment or be unexported
context.Context
support to interfaces offered by api.KeptnInterface
context.Context
support to interfaces offered by api.KeptnInterface
context.Context
support to Keptn
, KeptnBase
and interfaces offered by api.KeptnInterface
b8b854e
to
0b944d0
Compare
pkg/api/utils/apiUtils.go
Outdated
GetMetadata() (*models.Metadata, *models.Error) | ||
} | ||
|
||
// APIV2SendEventOptions are options for APIV2Interface.SendEvent(). | ||
type APIV2SendEventOptions struct{} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[golint] reported by reviewdog 🐶
type name will be used as api.APIV2SendEventOptions by other packages, and that stutters; consider calling this V2SendEventOptions
pkg/api/utils/apiUtils.go
Outdated
type APIV2SendEventOptions struct{} | ||
|
||
// APIV2TriggerEvaluationOptions are options for APIV2Interface.TriggerEvaluation(). | ||
type APIV2TriggerEvaluationOptions struct{} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[golint] reported by reviewdog 🐶
type name will be used as api.APIV2TriggerEvaluationOptions by other packages, and that stutters; consider calling this V2TriggerEvaluationOptions
pkg/api/utils/apiUtils.go
Outdated
type APIV2TriggerEvaluationOptions struct{} | ||
|
||
// APIV2CreateProjectOptions are options for APIV2Interface.CreateProject(). | ||
type APIV2CreateProjectOptions struct{} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[golint] reported by reviewdog 🐶
type name will be used as api.APIV2CreateProjectOptions by other packages, and that stutters; consider calling this V2CreateProjectOptions
pkg/api/utils/apiUtils.go
Outdated
type APIV2CreateProjectOptions struct{} | ||
|
||
// APIV2UpdateProjectOptions are options for APIV2Interface.UpdateProject(). | ||
type APIV2UpdateProjectOptions struct{} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[golint] reported by reviewdog 🐶
type name will be used as api.APIV2UpdateProjectOptions by other packages, and that stutters; consider calling this V2UpdateProjectOptions
pkg/api/utils/apiUtils.go
Outdated
type APIV2UpdateProjectOptions struct{} | ||
|
||
// APIV2DeleteProjectOptions are options for APIV2Interface.DeleteProject(). | ||
type APIV2DeleteProjectOptions struct{} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[golint] reported by reviewdog 🐶
type name will be used as api.APIV2DeleteProjectOptions by other packages, and that stutters; consider calling this V2DeleteProjectOptions
pkg/api/utils/apiUtils.go
Outdated
type APIV2CreateServiceOptions struct{} | ||
|
||
// APIV2DeleteServiceOptions are options for APIV2Interface.DeleteService(). | ||
type APIV2DeleteServiceOptions struct{} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[golint] reported by reviewdog 🐶
type name will be used as api.APIV2DeleteServiceOptions by other packages, and that stutters; consider calling this V2DeleteServiceOptions
pkg/api/utils/apiUtils.go
Outdated
type APIV2DeleteServiceOptions struct{} | ||
|
||
// APIV2GetMetadataOptions are options for APIV2Interface.GetMetadata(). | ||
type APIV2GetMetadataOptions struct{} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[golint] reported by reviewdog 🐶
type name will be used as api.APIV2GetMetadataOptions by other packages, and that stutters; consider calling this V2GetMetadataOptions
pkg/api/utils/apiUtils.go
Outdated
// APIV2GetMetadataOptions are options for APIV2Interface.GetMetadata(). | ||
type APIV2GetMetadataOptions struct{} | ||
|
||
type APIV2Interface interface { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[golint] reported by reviewdog 🐶
exported type APIV2Interface should have comment or be unexported
pkg/api/utils/apiUtils.go
Outdated
// APIV2GetMetadataOptions are options for APIV2Interface.GetMetadata(). | ||
type APIV2GetMetadataOptions struct{} | ||
|
||
type APIV2Interface interface { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[golint] reported by reviewdog 🐶
type name will be used as api.APIV2Interface by other packages, and that stutters; consider calling this V2Interface
pkg/api/utils/apiUtils.go
Outdated
} | ||
|
||
// APIV2Handler handles projects | ||
type APIV2Handler struct { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[golint] reported by reviewdog 🐶
type name will be used as api.APIV2Handler by other packages, and that stutters; consider calling this V2Handler
677fee8
to
5d35c95
Compare
// APIGetMetadataOptions are options for APIInterface.GetMetadata(). | ||
type APIGetMetadataOptions struct{} | ||
|
||
type APIInterface interface { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[golint] reported by reviewdog 🐶
exported type APIInterface should have comment or be unexported
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remaining comments which cannot be posted as a review comment to avoid GitHub Rate Limit
golint
pkg/api/utils/v2/uniformUtils.go|104 col 1| exported method UniformHandler.Ping should have comment or be unexported
pkg/api/utils/v2/uniformUtils.go|122 col 1| exported method UniformHandler.RegisterIntegration should have comment or be unexported
pkg/api/utils/v2/uniformUtils.go|141 col 1| exported method UniformHandler.CreateSubscription should have comment or be unexported
pkg/api/utils/v2/uniformUtils.go|160 col 1| exported method UniformHandler.UnregisterIntegration should have comment or be unexported
pkg/api/utils/v2/uniformUtils.go|168 col 1| exported method UniformHandler.GetRegistrations should have comment or be unexported
// AuthAuthenticateOptions are options for AuthInterface.Authenticate(). | ||
type AuthAuthenticateOptions struct{} | ||
|
||
type AuthInterface interface { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[golint] reported by reviewdog 🐶
exported type AuthInterface should have comment or be unexported
|
||
var _ KeptnInterface = (*APISet)(nil) | ||
|
||
type KeptnInterface interface { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[golint] reported by reviewdog 🐶
exported type KeptnInterface should have comment or be unexported
// EventsGetEventsWithRetryOptions are options for EventsInterface.GetEventsWithRetry(). | ||
type EventsGetEventsWithRetryOptions struct{} | ||
|
||
type EventsInterface interface { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[golint] reported by reviewdog 🐶
exported type EventsInterface should have comment or be unexported
} | ||
} | ||
|
||
const mongodbDatastoreServiceBaseUrl = "mongodb-datastore" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[golint] reported by reviewdog 🐶
const mongodbDatastoreServiceBaseUrl should be mongodbDatastoreServiceBaseURL
"net/http" | ||
) | ||
|
||
type StatusBody struct { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[golint] reported by reviewdog 🐶
exported type StatusBody should have comment or be unexported
// ShipyardControlGetOpenTriggeredEventsOptions are options for ShipyardControlInterface.GetOpenTriggeredEvents(). | ||
type ShipyardControlGetOpenTriggeredEventsOptions struct{} | ||
|
||
type ShipyardControlInterface interface { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[golint] reported by reviewdog 🐶
exported type ShipyardControlInterface should have comment or be unexported
// StagesGetAllStagesOptions are options for StagesInterface.GetAllStages(). | ||
type StagesGetAllStagesOptions struct{} | ||
|
||
type StagesInterface interface { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[golint] reported by reviewdog 🐶
exported type StagesInterface should have comment or be unexported
// UniformGetRegistrationsOptions are options for UniformInterface.GetRegistrations(). | ||
type UniformGetRegistrationsOptions struct{} | ||
|
||
type UniformInterface interface { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[golint] reported by reviewdog 🐶
exported type UniformInterface should have comment or be unexported
GetRegistrations(ctx context.Context, opts UniformGetRegistrationsOptions) ([]*models.Integration, error) | ||
} | ||
|
||
type UniformHandler struct { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[golint] reported by reviewdog 🐶
exported type UniformHandler should have comment or be unexported
Scheme string | ||
} | ||
|
||
func NewUniformHandler(baseURL string) *UniformHandler { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[golint] reported by reviewdog 🐶
exported function NewUniformHandler should have comment or be unexported
1841665
to
a8d49da
Compare
return u.HTTPClient | ||
} | ||
|
||
func (u *UniformHandler) Ping(ctx context.Context, integrationID string, opts UniformPingOptions) (*models.Integration, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[golint] reported by reviewdog 🐶
exported method UniformHandler.Ping should have comment or be unexported
return response, nil | ||
} | ||
|
||
func (u *UniformHandler) RegisterIntegration(ctx context.Context, integration models.Integration, opts UniformRegisterIntegrationOptions) (string, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[golint] reported by reviewdog 🐶
exported method UniformHandler.RegisterIntegration should have comment or be unexported
return registerIntegrationResponse.ID, nil | ||
} | ||
|
||
func (u *UniformHandler) CreateSubscription(ctx context.Context, integrationID string, subscription models.EventSubscription, opts UniformCreateSubscriptionOptions) (string, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[golint] reported by reviewdog 🐶
exported method UniformHandler.CreateSubscription should have comment or be unexported
return createSubscriptionResponse.ID, nil | ||
} | ||
|
||
func (u *UniformHandler) UnregisterIntegration(ctx context.Context, integrationID string, opts UniformUnregisterIntegrationOptions) error { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[golint] reported by reviewdog 🐶
exported method UniformHandler.UnregisterIntegration should have comment or be unexported
return nil | ||
} | ||
|
||
func (u *UniformHandler) GetRegistrations(ctx context.Context, opts UniformGetRegistrationsOptions) ([]*models.Integration, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[golint] reported by reviewdog 🐶
exported method UniformHandler.GetRegistrations should have comment or be unexported
context.Context
support to Keptn
, KeptnBase
and interfaces offered by api.KeptnInterface
v2.KeptnInterface
that adds context.Context
support to api.KeptnInterface
return r.UpdateResourcesByURI(ctx, r.Scheme+"://"+r.BaseURL+v1ProjectPath+"/"+project+pathToStage+"/"+stage+pathToService+"/"+url.QueryEscape(service)+pathToResource, resources) | ||
} | ||
|
||
func (r *ResourceHandler) CreateResourcesByURI(ctx context.Context, uri string, resources []*models.Resource) (string, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[golint] reported by reviewdog 🐶
exported method ResourceHandler.CreateResourcesByURI should have comment or be unexported
return r.writeResources(ctx, uri, "POST", resources) | ||
} | ||
|
||
func (r *ResourceHandler) UpdateResourcesByURI(ctx context.Context, uri string, resources []*models.Resource) (string, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[golint] reported by reviewdog 🐶
exported method ResourceHandler.UpdateResourcesByURI should have comment or be unexported
return version.Version, nil | ||
} | ||
|
||
func (r *ResourceHandler) UpdateResourceByURI(ctx context.Context, uri string, resource *models.Resource) (string, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[golint] reported by reviewdog 🐶
exported method ResourceHandler.UpdateResourceByURI should have comment or be unexported
return r.CreateResourcesByURI(ctx, r.applyOptions(buildURI, opts.URIOptions), resource) | ||
} | ||
|
||
func (r *ResourceHandler) GetResourceByURI(ctx context.Context, uri string) (*models.Resource, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[golint] reported by reviewdog 🐶
exported method ResourceHandler.GetResourceByURI should have comment or be unexported
return resource, nil | ||
} | ||
|
||
func (r *ResourceHandler) DeleteResourceByURI(ctx context.Context, uri string) error { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[golint] reported by reviewdog 🐶
exported method ResourceHandler.DeleteResourceByURI should have comment or be unexported
3fbb0ed
to
7d9743d
Compare
Signed-off-by: Arthur Pitman <[email protected]>
Signed-off-by: Arthur Pitman <[email protected]>
Signed-off-by: Arthur Pitman <[email protected]>
Signed-off-by: Arthur Pitman <[email protected]>
Signed-off-by: Arthur Pitman <[email protected]>
Signed-off-by: Arthur Pitman <[email protected]>
Signed-off-by: Arthur Pitman <[email protected]>
Signed-off-by: Arthur Pitman <[email protected]>
Signed-off-by: Arthur Pitman <[email protected]>
Signed-off-by: Arthur Pitman <[email protected]>
Signed-off-by: Arthur Pitman <[email protected]>
Signed-off-by: Arthur Pitman <[email protected]>
Signed-off-by: Arthur Pitman <[email protected]>
Signed-off-by: Arthur Pitman <[email protected]>
Signed-off-by: Arthur Pitman <[email protected]>
Signed-off-by: Arthur Pitman <[email protected]>
Signed-off-by: Arthur Pitman <[email protected]>
Signed-off-by: Arthur Pitman <[email protected]>
Signed-off-by: Arthur Pitman <[email protected]>
Signed-off-by: Arthur Pitman <[email protected]>
Signed-off-by: Arthur Pitman <[email protected]>
Signed-off-by: Arthur Pitman <[email protected]>
Signed-off-by: Arthur Pitman <[email protected]>
7d9743d
to
3ea9b5c
Compare
GetMetadata(ctx context.Context, opts APIGetMetadataOptions) (*models.Metadata, *models.Error) | ||
} | ||
|
||
type APIHandler struct { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[golint] reported by reviewdog 🐶
exported type APIHandler should have comment or be unexported
Authenticate(ctx context.Context, opts AuthAuthenticateOptions) (*models.EventContext, *models.Error) | ||
} | ||
|
||
type AuthHandler struct { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[golint] reported by reviewdog 🐶
exported type AuthHandler should have comment or be unexported
GetEventsWithRetry(ctx context.Context, filter *EventFilter, maxRetries int, retrySleepTime time.Duration, opts EventsGetEventsWithRetryOptions) ([]*models.KeptnContextExtendedCE, error) | ||
} | ||
|
||
type EventHandler struct { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[golint] reported by reviewdog 🐶
exported type EventHandler should have comment or be unexported
return createEventHandler(baseURL, "", "", httpClient, "http") | ||
} | ||
|
||
const mongodbDatastoreServiceBaseUrl = "mongodb-datastore" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[golint] reported by reviewdog 🐶
const mongodbDatastoreServiceBaseUrl should be mongodbDatastoreServiceBaseURL
return nil | ||
} | ||
|
||
// NewSequenceControlHandlerWithHTTPClient returns a new SequenceControlHandler |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[golint] reported by reviewdog 🐶
comment on exported function NewSequenceControlHandler should be of the form "NewSequenceControlHandler ..."
GetOpenTriggeredEvents(ctx context.Context, filter EventFilter, opts ShipyardControlGetOpenTriggeredEventsOptions) ([]*models.KeptnContextExtendedCE, error) | ||
} | ||
|
||
type ShipyardControllerHandler struct { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[golint] reported by reviewdog 🐶
exported type ShipyardControllerHandler should have comment or be unexported
Signed-off-by: Arthur Pitman <[email protected]>
Signed-off-by: Arthur Pitman <[email protected]>
Signed-off-by: Arthur Pitman <[email protected]>
pkg/api/utils/v2/apiUtils.go
Outdated
func (a *APIHandler) GetMetadata(ctx context.Context, opts APIGetMetadataOptions) (*models.Metadata, *models.Error) { | ||
baseURL := a.getAPIServicePath() | ||
|
||
body, mErr := getAndExpectSuccess(ctx, a.scheme+"://"+baseURL+v1MetadataPath, nil) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think here we also need to pass the api handler, instead of nil
, otherwise we will get a nil pointer exception later in the addAuthHeader()
function
Signed-off-by: Florian Bacher <[email protected]>
Signed-off-by: Florian Bacher <[email protected]>
) | ||
|
||
const pathToResource = "/resource" | ||
const pathToService = "/service" | ||
const pathToStage = "/stage" | ||
const configurationServiceBaseURL = "configuration-service" | ||
|
||
var ResourceNotFoundError = errors.New("Resource not found") | ||
var ResourceNotFoundError = v2.ResourceNotFoundError |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[golint] reported by reviewdog 🐶
exported var ResourceNotFoundError should have comment or be unexported
… v1 (#479) * debug output Signed-off-by: Florian Bacher <[email protected]> * debug output Signed-off-by: Florian Bacher <[email protected]> * ensure that uniform handler is set Signed-off-by: Florian Bacher <[email protected]> * ensure that uniform handler is set Signed-off-by: Florian Bacher <[email protected]> * ensure that all api handlers are set Signed-off-by: Florian Bacher <[email protected]>
SonarCloud Quality Gate failed. 0 Bugs No Coverage information |
This PR
v2
package with the same functionality as theapi
package, just with addedcontext.Context