Documentation
¶
Index ¶
- Constants
- func NewInstrumentedClient(client argocd.Requester, metrics *observability.ComponentMetrics, ...) argocd.Requester
- type ApplicationService
- func (s *ApplicationService) BuildAllApplicationsURL() (string, error)
- func (s *ApplicationService) BuildStatusRequest(endpoint string) (*http.Request, error)
- func (s *ApplicationService) BuildStatusURL(name Name) (string, error)
- func (s *ApplicationService) DecodeAllApplicationsStatus(body io.Reader) ([]applicationResponse, error)
- func (s *ApplicationService) DecodeStatus(body io.Reader) (*applicationResponse, error)
- func (s *ApplicationService) ExecuteRequest(ctx context.Context, req *http.Request) (*http.Response, error)
- func (s *ApplicationService) GetAllApplicationsStatus(ctx context.Context) ([]ApplicationStatus, error)
- func (s *ApplicationService) GetStatus(ctx context.Context, name Name) (*ApplicationStatus, error)
- func (s *ApplicationService) MapToAppStatus(raw *applicationResponse) *ApplicationStatus
- func (s *ApplicationService) ValidateStatus(resp *http.Response) error
- type ApplicationStatus
- type HealthStatus
- type InstrumentedClient
- type InstrumentedService
- type MockService
- type MockService_Expecter
- type MockService_GetAllApplicationsStatus_Call
- func (_c *MockService_GetAllApplicationsStatus_Call) Return(_a0 []ApplicationStatus, _a1 error) *MockService_GetAllApplicationsStatus_Call
- func (_c *MockService_GetAllApplicationsStatus_Call) Run(run func(ctx context.Context)) *MockService_GetAllApplicationsStatus_Call
- func (_c *MockService_GetAllApplicationsStatus_Call) RunAndReturn(run func(context.Context) ([]ApplicationStatus, error)) *MockService_GetAllApplicationsStatus_Call
- type MockService_GetStatus_Call
- func (_c *MockService_GetStatus_Call) Return(_a0 *ApplicationStatus, _a1 error) *MockService_GetStatus_Call
- func (_c *MockService_GetStatus_Call) Run(run func(ctx context.Context, name Name)) *MockService_GetStatus_Call
- func (_c *MockService_GetStatus_Call) RunAndReturn(run func(context.Context, Name) (*ApplicationStatus, error)) *MockService_GetStatus_Call
- type Name
- type Phase
- type Revision
- type Service
- type SyncStatus
- type Version
Constants ¶
const ApiPath = "applications"
ApiPath is the base path for ArgoCD Application API endpoints.
Variables ¶
This section is empty.
Functions ¶
func NewInstrumentedClient ¶
func NewInstrumentedClient(client argocd.Requester, metrics *observability.ComponentMetrics, cluster string) argocd.Requester
NewInstrumentedClient creates a new ArgoCD client wrapper with metrics instrumentation.
This instruments at the HTTP client layer, so all API calls (applications, projects, etc.) will be recorded in metrics.
Example:
client := argocd.New(opts) instrumentedClient := applications.NewInstrumentedClient(client, metrics, "prod-cluster") service := applications.NewService(instrumentedClient)
Types ¶
type ApplicationService ¶
type ApplicationService struct {
// contains filtered or unexported fields
}
ApplicationService performs HTTP calls to ArgoCD's `/api/v1/applications` API.
This service depends exclusively on the high-level argocd.Client, which already embeds all HTTP logic (token, retry, backoff, transports).
func (*ApplicationService) BuildAllApplicationsURL ¶
func (s *ApplicationService) BuildAllApplicationsURL() (string, error)
BuildAllApplicationsURL constructs:
https://host/api/v1/applications
func (*ApplicationService) BuildStatusRequest ¶
func (s *ApplicationService) BuildStatusRequest(endpoint string) (*http.Request, error)
BuildStatusRequest builds a simple GET request.
func (*ApplicationService) BuildStatusURL ¶
func (s *ApplicationService) BuildStatusURL(name Name) (string, error)
BuildStatusURL constructs:
https://host/api/v1/applications/{name}
func (*ApplicationService) DecodeAllApplicationsStatus ¶
func (s *ApplicationService) DecodeAllApplicationsStatus(body io.Reader) ([]applicationResponse, error)
DecodeAllApplicationsStatus decodes the raw JSON array into internal DTOs.
func (*ApplicationService) DecodeStatus ¶
func (s *ApplicationService) DecodeStatus(body io.Reader) (*applicationResponse, error)
DecodeStatus decodes the raw JSON into the internal DTO.
func (*ApplicationService) ExecuteRequest ¶
func (s *ApplicationService) ExecuteRequest(ctx context.Context, req *http.Request) (*http.Response, error)
ExecuteRequest delegates the HTTP execution to the ArgoCD client, which itself delegates to the fully-configured httpclient package.
func (*ApplicationService) GetAllApplicationsStatus ¶
func (s *ApplicationService) GetAllApplicationsStatus(ctx context.Context) ([]ApplicationStatus, error)
GetAllApplicationsStatus fetches the domain-level status for all ArgoCD applications.
func (*ApplicationService) GetStatus ¶
func (s *ApplicationService) GetStatus(ctx context.Context, name Name) (*ApplicationStatus, error)
GetStatus fetches the domain-level status for an ArgoCD application.
func (*ApplicationService) MapToAppStatus ¶
func (s *ApplicationService) MapToAppStatus(raw *applicationResponse) *ApplicationStatus
MapToAppStatus transforms the raw API response into the domain aggregate.
func (*ApplicationService) ValidateStatus ¶
func (s *ApplicationService) ValidateStatus(resp *http.Response) error
ValidateStatus ensures we only accept 200 responses.
type ApplicationStatus ¶
type ApplicationStatus struct {
Name Name // Name is the ArgoCD Application name
HealthStatus HealthStatus // HealthStatus of the application
SyncStatus SyncStatus // SyncStatus of the application
Revision Revision // Revision of the application
Phase Phase // Phase of the application
Version Version // Version computed from labels
}
ApplicationStatus is the aggregation representing the current observed state of an ArgoCD Application, using typed value objects.
type HealthStatus ¶
type HealthStatus struct{ Value string }
HealthStatus is the typed representation of an ArgoCD Application health status.
type InstrumentedClient ¶
type InstrumentedClient struct {
// contains filtered or unexported fields
}
InstrumentedClient wraps an ArgoCD Client with metrics instrumentation at the HTTP layer. This provides metrics for all HTTP calls made to ArgoCD, regardless of which service is used.
func (*InstrumentedClient) Host ¶
func (ic *InstrumentedClient) Host() argocd.Host
Host returns the configured ArgoCD host.
func (*InstrumentedClient) HttpClient ¶
func (ic *InstrumentedClient) HttpClient() *httpclient.Client
HttpClient returns the underlying HTTP client.
type InstrumentedService ¶
type InstrumentedService struct {
// contains filtered or unexported fields
}
InstrumentedService wraps an ApplicationService with Prometheus metrics instrumentation. All operations are recorded with timing and success/failure counts.
This follows the decorator pattern to add observability without modifying the core service.
func (*InstrumentedService) GetAllApplicationsStatus ¶
func (is *InstrumentedService) GetAllApplicationsStatus(ctx context.Context) ([]ApplicationStatus, error)
GetAllApplicationsStatus retrieves all application statuses with metrics recording.
func (*InstrumentedService) GetStatus ¶
func (is *InstrumentedService) GetStatus(ctx context.Context, name Name) (*ApplicationStatus, error)
GetStatus retrieves application status with metrics recording.
type MockService ¶
MockService is an autogenerated mock type for the Service type
func NewMockService ¶
func NewMockService(t interface {
mock.TestingT
Cleanup(func())
}) *MockService
NewMockService creates a new instance of MockService. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. The first argument is typically a *testing.T value.
func (*MockService) EXPECT ¶
func (_m *MockService) EXPECT() *MockService_Expecter
func (*MockService) GetAllApplicationsStatus ¶
func (_m *MockService) GetAllApplicationsStatus(ctx context.Context) ([]ApplicationStatus, error)
GetAllApplicationsStatus provides a mock function with given fields: ctx
func (*MockService) GetStatus ¶
func (_m *MockService) GetStatus(ctx context.Context, name Name) (*ApplicationStatus, error)
GetStatus provides a mock function with given fields: ctx, name
type MockService_Expecter ¶
type MockService_Expecter struct {
// contains filtered or unexported fields
}
func (*MockService_Expecter) GetAllApplicationsStatus ¶
func (_e *MockService_Expecter) GetAllApplicationsStatus(ctx interface{}) *MockService_GetAllApplicationsStatus_Call
GetAllApplicationsStatus is a helper method to define mock.On call
- ctx context.Context
func (*MockService_Expecter) GetStatus ¶
func (_e *MockService_Expecter) GetStatus(ctx interface{}, name interface{}) *MockService_GetStatus_Call
GetStatus is a helper method to define mock.On call
- ctx context.Context
- name Name
type MockService_GetAllApplicationsStatus_Call ¶
MockService_GetAllApplicationsStatus_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetAllApplicationsStatus'
func (*MockService_GetAllApplicationsStatus_Call) Return ¶
func (_c *MockService_GetAllApplicationsStatus_Call) Return(_a0 []ApplicationStatus, _a1 error) *MockService_GetAllApplicationsStatus_Call
func (*MockService_GetAllApplicationsStatus_Call) Run ¶
func (_c *MockService_GetAllApplicationsStatus_Call) Run(run func(ctx context.Context)) *MockService_GetAllApplicationsStatus_Call
func (*MockService_GetAllApplicationsStatus_Call) RunAndReturn ¶
func (_c *MockService_GetAllApplicationsStatus_Call) RunAndReturn(run func(context.Context) ([]ApplicationStatus, error)) *MockService_GetAllApplicationsStatus_Call
type MockService_GetStatus_Call ¶
MockService_GetStatus_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetStatus'
func (*MockService_GetStatus_Call) Return ¶
func (_c *MockService_GetStatus_Call) Return(_a0 *ApplicationStatus, _a1 error) *MockService_GetStatus_Call
func (*MockService_GetStatus_Call) Run ¶
func (_c *MockService_GetStatus_Call) Run(run func(ctx context.Context, name Name)) *MockService_GetStatus_Call
func (*MockService_GetStatus_Call) RunAndReturn ¶
func (_c *MockService_GetStatus_Call) RunAndReturn(run func(context.Context, Name) (*ApplicationStatus, error)) *MockService_GetStatus_Call
type Name ¶
type Name struct{ Value string }
Name is the typed representation of an ArgoCD Application name.
type Phase ¶
type Phase struct{ Value string }
Phase is the typed representation of an ArgoCD Application phase.
type Revision ¶
type Revision struct{ Value string }
Revision is the typed representation of an ArgoCD Application revision.
type Service ¶
type Service interface {
GetStatus(ctx context.Context, name Name) (*ApplicationStatus, error)
GetAllApplicationsStatus(ctx context.Context) ([]ApplicationStatus, error)
}
Service defines the interface for ArgoCD application operations. This interface includes all public methods of ApplicationService.
func NewInstrumentedService ¶
func NewInstrumentedService(service Service, metrics *observability.ComponentMetrics, cluster string) Service
NewInstrumentedService creates a new ArgoCD application service with metrics instrumentation.
The cluster parameter is used to label all metrics from this service instance, allowing differentiation between multiple ArgoCD clusters.
Example:
service := applications.NewService(client) instrumentedService := applications.NewInstrumentedService(service, metrics, "prod-cluster")
func NewService ¶
NewService constructs a new instance and returns the interface.
func WrapClientWithMetrics ¶
func WrapClientWithMetrics(service Service, metrics *observability.ComponentMetrics, cluster string) Service
WrapClientWithMetrics creates an instrumented ArgoCD client for a specific cluster. This is a convenience function that wraps the client with metrics collection.
Example:
client := argocd.New(opts) service := applications.NewService(client) instrumentedService := applications.WrapClientWithMetrics(service, metrics, "prod-cluster")
type SyncStatus ¶
type SyncStatus struct{ Value string }
SyncStatus is the typed representation of an ArgoCD Application sync status.