Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions scope/examples/group-1.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ spec:
needs:
- bar
actions:
- description: foo1
- name: action1
description: foo1
check:
paths:
- 'flig/bar/**/*'
Expand All @@ -21,7 +22,8 @@ spec:
There is a good way to fix this, maybe...
helpUrl: https://go.example.com/fixit
required: false
- description: foo2
- name: action2
description: foo2
check:
paths:
- '*/*.txt'
Expand Down
6 changes: 4 additions & 2 deletions scope/examples/v1alpha/DoctorGroup.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ spec:
needs:
- bar
actions:
- description: foo1
- name: action1
description: foo1
check:
paths:
- 'flig/bar/**/*'
Expand All @@ -21,7 +22,8 @@ spec:
There is a good way to fix this, maybe...
helpUrl: https://go.example.com/fixit
required: false
- description: foo2
- name: action2
description: foo2
check:
paths:
- '*/*.txt'
Expand Down
11 changes: 4 additions & 7 deletions scope/schema/merged.json
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,8 @@
"description": "An action is a single step used to check in a group. This is most commonly used to build a series of tasks for a system, like `ruby`, `python`, and databases.",
"type": "object",
"required": [
"check"
"check",
"name"
],
"properties": {
"check": {
Expand Down Expand Up @@ -142,12 +143,8 @@
"nullable": true
},
"name": {
"description": "Name of the \"action\". When not provided, it will be the index of the action within the group. This is used when reporting status to the users.",
"type": [
"string",
"null"
],
"nullable": true
"description": "Name of the \"action\" used when reporting status to the users.",
"type": "string"
},
"required": {
"description": "If false, the action is allowed to fail and let other actions in the group execute. Defaults to `true`.",
Expand Down
11 changes: 4 additions & 7 deletions scope/schema/v1alpha.com.github.scope.ScopeDoctorGroup.json
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,8 @@
"description": "An action is a single step used to check in a group. This is most commonly used to build a series of tasks for a system, like `ruby`, `python`, and databases.",
"type": "object",
"required": [
"check"
"check",
"name"
],
"properties": {
"check": {
Expand Down Expand Up @@ -158,12 +159,8 @@
"nullable": true
},
"name": {
"description": "Name of the \"action\". When not provided, it will be the index of the action within the group. This is used when reporting status to the users.",
"type": [
"string",
"null"
],
"nullable": true
"description": "Name of the \"action\" used when reporting status to the users.",
"type": "string"
},
"required": {
"description": "If false, the action is allowed to fail and let other actions in the group execute. Defaults to `true`.",
Expand Down
11 changes: 4 additions & 7 deletions scope/schema/v1alpha.com.github.scope.ScopeKnownError.json
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,8 @@
"description": "An action is a single step used to check in a group. This is most commonly used to build a series of tasks for a system, like `ruby`, `python`, and databases.",
"type": "object",
"required": [
"check"
"check",
"name"
],
"properties": {
"check": {
Expand Down Expand Up @@ -158,12 +159,8 @@
"nullable": true
},
"name": {
"description": "Name of the \"action\". When not provided, it will be the index of the action within the group. This is used when reporting status to the users.",
"type": [
"string",
"null"
],
"nullable": true
"description": "Name of the \"action\" used when reporting status to the users.",
"type": "string"
},
"required": {
"description": "If false, the action is allowed to fail and let other actions in the group execute. Defaults to `true`.",
Expand Down
11 changes: 4 additions & 7 deletions scope/schema/v1alpha.com.github.scope.ScopeReportLocation.json
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,8 @@
"description": "An action is a single step used to check in a group. This is most commonly used to build a series of tasks for a system, like `ruby`, `python`, and databases.",
"type": "object",
"required": [
"check"
"check",
"name"
],
"properties": {
"check": {
Expand Down Expand Up @@ -158,12 +159,8 @@
"nullable": true
},
"name": {
"description": "Name of the \"action\". When not provided, it will be the index of the action within the group. This is used when reporting status to the users.",
"type": [
"string",
"null"
],
"nullable": true
"description": "Name of the \"action\" used when reporting status to the users.",
"type": "string"
},
"required": {
"description": "If false, the action is allowed to fail and let other actions in the group execute. Defaults to `true`.",
Expand Down
5 changes: 2 additions & 3 deletions scope/src/models/v1alpha/doctor_group.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,8 @@ pub struct DoctorFixPromptSpec {
#[serde(rename_all = "camelCase")]
#[schemars(deny_unknown_fields)]
pub struct DoctorGroupActionSpec {
/// Name of the "action". When not provided, it will be the index of the action within the group.
/// This is used when reporting status to the users.
pub name: Option<String>,
/// Name of the "action" used when reporting status to the users.
pub name: String,

/// A description of this specific action, used for information to the users.
pub description: Option<String>,
Expand Down
11 changes: 5 additions & 6 deletions scope/src/shared/models/internal/doctor_group.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ impl TryFrom<V1AlphaDoctorGroup> for DoctorGroup {

fn try_from(model: V1AlphaDoctorGroup) -> Result<Self, Self::Error> {
let mut actions: Vec<_> = Default::default();
for (count, spec_action) in model.spec.actions.iter().enumerate() {
actions.push(parse_action(count, &model, spec_action)?);
for spec_action in model.spec.actions.iter() {
actions.push(parse_action(&model, spec_action)?);
}

Ok(DoctorGroup {
Expand All @@ -92,7 +92,6 @@ impl TryFrom<V1AlphaDoctorGroup> for DoctorGroup {
}

fn parse_action(
idx: usize,
group_model: &V1AlphaDoctorGroup,
action: &DoctorGroupActionSpec,
) -> Result<DoctorGroupAction> {
Expand Down Expand Up @@ -123,7 +122,7 @@ fn parse_action(
};

Ok(DoctorGroupAction {
name: spec_action.name.unwrap_or_else(|| format!("{}", idx + 1)),
name: spec_action.name,
required: spec_action.required,
description: spec_action
.description
Expand Down Expand Up @@ -174,7 +173,7 @@ mod tests {
assert_eq!(
dg.actions[0],
DoctorGroupAction {
name: "1".to_string(),
name: "action1".to_string(),
required: false,
description: "foo1".to_string(),
fix: DoctorFix {
Expand All @@ -195,7 +194,7 @@ mod tests {
assert_eq!(
dg.actions[1],
DoctorGroupAction {
name: "2".to_string(),
name: "action2".to_string(),
required: true,
description: "foo2".to_string(),
fix: DoctorFix {
Expand Down
6 changes: 3 additions & 3 deletions scope/tests/scope_doctor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ fn test_cache_invalidation() {
result
.success()
.stdout(predicate::str::contains(
"Check initially failed, fix was successful, group: \"setup\", name: \"1\"",
"Check initially failed, fix was successful, group: \"setup\", name: \"install\"",
))
.stdout(predicate::str::contains("Failed to write updated cache to disk").not());

Expand All @@ -109,7 +109,7 @@ fn test_cache_invalidation() {
result
.success()
.stdout(predicate::str::contains(
"Check was successful, group: \"setup\", name: \"1\"",
"Check was successful, group: \"setup\", name: \"install\"",
))
.stdout(predicate::str::contains("Failed to write updated cache to disk").not());

Expand All @@ -124,7 +124,7 @@ fn test_cache_invalidation() {
result
.success()
.stdout(predicate::str::contains(
"Check initially failed, fix was successful, group: \"setup\", name: \"1\"",
"Check initially failed, fix was successful, group: \"setup\", name: \"install\"",
))
.stdout(predicate::str::contains("Failed to write updated cache to disk").not());
}
Expand Down
3 changes: 2 additions & 1 deletion scope/tests/test-cases/file-cache-check/.scope/group.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ metadata:
description: Run dep install
spec:
actions:
- check:
- name: install
check:
paths:
- '**/requirements.txt'
fix:
Expand Down