Skip to content

Commit

Permalink
set introspection status for upload repos
Browse files Browse the repository at this point in the history
  • Loading branch information
jlsherrill committed Jul 12, 2024
1 parent 610fdc9 commit 2209358
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 4 deletions.
2 changes: 1 addition & 1 deletion api/docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@ const docTemplate = `{
},
{
"type": "string",
"description": "A comma separated list of statuses to control api response. Statuses can include ` + "`" + `pending` + "`" + `, ` + "`" + `valid` + "`" + `, ` + "`" + `invalid` + "`" + `, ` + "`" + `unavailable` + "`" + `.",
"description": "A comma separated list of statuses to control api response. Statuses can include ` + "`" + `Pending` + "`" + `, ` + "`" + `Valid` + "`" + `, ` + "`" + `Invalid` + "`" + `, ` + "`" + `Unavailable` + "`" + `.",
"name": "status",
"in": "query"
},
Expand Down
2 changes: 1 addition & 1 deletion api/openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -1782,7 +1782,7 @@
}
},
{
"description": "A comma separated list of statuses to control api response. Statuses can include `pending`, `valid`, `invalid`, `unavailable`.",
"description": "A comma separated list of statuses to control api response. Statuses can include `Pending`, `Valid`, `Invalid`, `Unavailable`.",
"in": "query",
"name": "status",
"schema": {
Expand Down
2 changes: 2 additions & 0 deletions pkg/dao/repository_configs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,8 @@ func (suite *RepositoryConfigSuite) TestCreateUpload() {
assert.NoError(suite.T(), err)
assert.True(suite.T(), repo.UUID != "")
assert.NotEqual(suite.T(), repo.UUID, repo2.UUID)
assert.NotEmpty(suite.T(), repo.LastIntrospectionTime)
assert.NotEmpty(suite.T(), repo.LastIntrospectionStatus)
}

func (suite *RepositoryConfigSuite) TestCreateUploadNoSnap() {
Expand Down
4 changes: 2 additions & 2 deletions pkg/handler/repositories.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ func getAccountIdOrgId(c echo.Context) (string, string) {
// @Param url query string false "A comma separated list of URLs to control api response."
// @Param uuid query string false "A comma separated list of UUIDs to control api response."
// @Param sort_by query string false "Sort the response data based on specific repository parameters. Sort criteria can include `name`, `url`, `status`, and `package_count`."
// @Param status query string false "A comma separated list of statuses to control api response. Statuses can include `pending`, `valid`, `invalid`, `unavailable`."
// @Param status query string false "A comma separated list of statuses to control api response. Statuses can include `Pending`, `Valid`, `Invalid`, `Unavailable`."
// @Param origin query string false "A comma separated list of origins to filter api response. Origins can include `red_hat` and `external`."
// @Param content_type query string false "content type of a repository to filter on (rpm)"
// @Accept json
Expand Down Expand Up @@ -529,7 +529,7 @@ func (rh *RepositoryHandler) introspect(c echo.Context) error {

var repoUpdate dao.RepositoryUpdate
count := 0
lastIntrospectionStatus := "Pending"
lastIntrospectionStatus := config.StatusPending
if req.ResetCount {
repoUpdate = dao.RepositoryUpdate{
UUID: repo.UUID,
Expand Down
7 changes: 7 additions & 0 deletions pkg/models/repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,13 @@ func (r *Repository) BeforeCreate(tx *gorm.DB) (err error) {
return err
}
r.URL = CleanupURL(r.URL)
if r.Origin == config.OriginUpload {
r.LastIntrospectionStatus = config.StatusValid
time := time.Now()
r.LastIntrospectionTime = &time
r.LastIntrospectionSuccessTime = &time
r.LastIntrospectionUpdateTime = &time
}
return nil
}

Expand Down

0 comments on commit 2209358

Please sign in to comment.