Skip to content

Commit 9f5e098

Browse files
authored
Fixes 4825: add template attribute for when env is created (#846)
Fixes 4825: provide template attribute for when env is created
1 parent cc27e68 commit 9f5e098

29 files changed

+145
-51
lines changed

api/docs.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4741,6 +4741,11 @@ const docTemplate = `{
47414741
"type": "string"
47424742
}
47434743
},
4744+
"rhsm_environment_created": {
4745+
"description": "Whether the candlepin environment is created and systems can be added",
4746+
"type": "boolean",
4747+
"readOnly": true
4748+
},
47444749
"rhsm_environment_id": {
47454750
"description": "Environment ID used by subscription-manager and candlepin",
47464751
"type": "string"

api/openapi.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1434,6 +1434,11 @@
14341434
},
14351435
"type": "array"
14361436
},
1437+
"rhsm_environment_created": {
1438+
"description": "Whether the candlepin environment is created and systems can be added",
1439+
"readOnly": true,
1440+
"type": "boolean"
1441+
},
14371442
"rhsm_environment_id": {
14381443
"description": "Environment ID used by subscription-manager and candlepin",
14391444
"type": "string"

db/migrations.latest

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
20240919154238
1+
20241011084507
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
BEGIN;
2+
3+
alter table templates drop column rhsm_environment_created;
4+
5+
COMMIT;
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
BEGIN;
2+
3+
alter table templates add column rhsm_environment_created boolean NOT NULL DEFAULT false;
4+
update templates set rhsm_environment_created = true
5+
where templates.uuid in (select object_uuid from tasks where type = 'update-template-content' and status = 'completed');
6+
7+
COMMIT;

pkg/api/templates.go

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -23,23 +23,24 @@ type TemplateRequest struct {
2323

2424
type TemplateResponse struct {
2525
UUID string `json:"uuid" readonly:"true"`
26-
Name string `json:"name"` // Name of the template
27-
OrgID string `json:"org_id"` // Organization ID of the owner
28-
Description string `json:"description"` // Description of the template
29-
Arch string `json:"arch"` // Architecture of the template
30-
Version string `json:"version"` // Version of the template
31-
Date time.Time `json:"date"` // Latest date to include snapshots for
32-
RepositoryUUIDS []string `json:"repository_uuids"` // Repositories added to the template
33-
RHSMEnvironmentID string `json:"rhsm_environment_id"` // Environment ID used by subscription-manager and candlepin
34-
CreatedBy string `json:"created_by"` // User that created the template
35-
LastUpdatedBy string `json:"last_updated_by"` // User that most recently updated the template
36-
CreatedAt time.Time `json:"created_at"` // Datetime template was created
37-
UpdatedAt time.Time `json:"updated_at"` // Datetime template was last updated
38-
DeletedAt gorm.DeletedAt `json:"-" swaggerignore:"true"` // Datetime template was deleted
39-
UseLatest bool `json:"use_latest"` // Use latest snapshot for all repositories in the template
40-
LastUpdateSnapshotError string `json:"last_update_snapshot_error"` // Error of last update_latest_snapshot task that updated the template
41-
LastUpdateTaskUUID string `json:"last_update_task_uuid,omitempty"` // UUID of the last update_template_content task that updated the template
42-
LastUpdateTask *TaskInfoResponse `json:"last_update_task,omitempty"` // Response of last update_template_content task that updated the template
26+
Name string `json:"name"` // Name of the template
27+
OrgID string `json:"org_id"` // Organization ID of the owner
28+
Description string `json:"description"` // Description of the template
29+
Arch string `json:"arch"` // Architecture of the template
30+
Version string `json:"version"` // Version of the template
31+
Date time.Time `json:"date"` // Latest date to include snapshots for
32+
RepositoryUUIDS []string `json:"repository_uuids"` // Repositories added to the template
33+
RHSMEnvironmentID string `json:"rhsm_environment_id"` // Environment ID used by subscription-manager and candlepin
34+
CreatedBy string `json:"created_by"` // User that created the template
35+
LastUpdatedBy string `json:"last_updated_by"` // User that most recently updated the template
36+
CreatedAt time.Time `json:"created_at"` // Datetime template was created
37+
UpdatedAt time.Time `json:"updated_at"` // Datetime template was last updated
38+
DeletedAt gorm.DeletedAt `json:"-" swaggerignore:"true"` // Datetime template was deleted
39+
UseLatest bool `json:"use_latest"` // Use latest snapshot for all repositories in the template
40+
LastUpdateSnapshotError string `json:"last_update_snapshot_error"` // Error of last update_latest_snapshot task that updated the template
41+
LastUpdateTaskUUID string `json:"last_update_task_uuid,omitempty"` // UUID of the last update_template_content task that updated the template
42+
LastUpdateTask *TaskInfoResponse `json:"last_update_task,omitempty"` // Response of last update_template_content task that updated the template
43+
RHSMEnvironmentCreated bool `json:"rhsm_environment_created" readonly:"true"` // Whether the candlepin environment is created and systems can be added
4344
}
4445

4546
// We use a separate struct because version and arch cannot be updated

pkg/cache/cache_mock.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/candlepin_client/candlepin_client_mock.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/dao/admin_tasks_mock.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/dao/domain_dao_mock.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)