Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
eyalb4doc committed Dec 25, 2024
2 parents f3151d6 + 80a5e1b commit dad1a9c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 16 deletions.
21 changes: 5 additions & 16 deletions artifactory/usage/call_home.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ import (
"github.com/jfrog/jfrog-client-go/utils/io/httputils"
)

const minArtifactoryVersion = "6.9.0"

type ReportUsageAttribute struct {
AttributeName string
AttributeValue string
Expand All @@ -28,7 +26,7 @@ func (rua *ReportUsageAttribute) isEmpty() bool {
return rua.AttributeName == ""
}

func (ach *ArtifactoryCallHome) validateAndGetUsageServerInfo(serviceManager artifactory.ArtifactoryServicesManager) (url string, clientDetails httputils.HttpClientDetails, err error) {
func (ach *ArtifactoryCallHome) getUsageServerInfo(serviceManager artifactory.ArtifactoryServicesManager) (url string, clientDetails httputils.HttpClientDetails, err error) {
config := serviceManager.GetConfig()
if config == nil {
err = errorutils.CheckErrorf("expected full config, but no configuration exists.")
Expand All @@ -39,15 +37,6 @@ func (ach *ArtifactoryCallHome) validateAndGetUsageServerInfo(serviceManager art
err = errorutils.CheckErrorf("Artifactory details not configured.")
return
}
// Check Artifactory version
artifactoryVersion, err := rtDetails.GetVersion()
if err != nil {
err = errors.New("Couldn't get Artifactory version. Error: " + err.Error())
return
}
if err = clientutils.ValidateMinimumVersion(clientutils.Artifactory, artifactoryVersion, minArtifactoryVersion); err != nil {
return
}
url, err = clientutils.BuildUrl(rtDetails.GetUrl(), "api/system/usage", make(map[string]string))
if err != nil {
return
Expand All @@ -69,8 +58,8 @@ func (ach *ArtifactoryCallHome) sendReport(url string, serviceManager artifactor
return nil
}

func (ach *ArtifactoryCallHome) SendUsageToArtifactory(productId string, serviceManager artifactory.ArtifactoryServicesManager, features ...Feature) error {
url, clientDetails, err := ach.validateAndGetUsageServerInfo(serviceManager)
func (ach *ArtifactoryCallHome) SendToArtifactory(productId string, serviceManager artifactory.ArtifactoryServicesManager, features ...Feature) error {
url, clientDetails, err := ach.getUsageServerInfo(serviceManager)
if err != nil || url == "" {
return err
}
Expand All @@ -81,8 +70,8 @@ func (ach *ArtifactoryCallHome) SendUsageToArtifactory(productId string, service
return ach.sendReport(url, serviceManager, clientDetails, bodyContent)
}

func (ach *ArtifactoryCallHome) SendUsage(productId, commandName string, serviceManager artifactory.ArtifactoryServicesManager, attributes ...ReportUsageAttribute) error {
url, clientDetails, err := ach.validateAndGetUsageServerInfo(serviceManager)
func (ach *ArtifactoryCallHome) Send(productId, commandName string, serviceManager artifactory.ArtifactoryServicesManager, attributes ...ReportUsageAttribute) error {
url, clientDetails, err := ach.getUsageServerInfo(serviceManager)
if err != nil || url == "" {
return err
}
Expand Down
1 change: 1 addition & 0 deletions jfconnect/services/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ func (jcs *JfConnectService) PostVisibilityMetric(metric VisibilityMetric) error

type Labels struct {
ProductID string `json:"product_id"`
ProductVersion string `json:"product_version"`
FeatureID string `json:"feature_id"`
OIDCUsed string `json:"oidc_used"`
JobID string `json:"job_id"`
Expand Down

0 comments on commit dad1a9c

Please sign in to comment.