Skip to content

Commit

Permalink
update(serverless-agent): default to non-essential container
Browse files Browse the repository at this point in the history
  • Loading branch information
gnosek committed Feb 29, 2024
1 parent 5897961 commit dc7ff5c
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
19 changes: 18 additions & 1 deletion sysdig/data_source_sysdig_fargate_ECS_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,12 @@ func TestNewPatchOptions(t *testing.T) {
},
},
},
"priority": {
Type: schema.TypeString,
Description: "The priority of the agent. Can be 'security' or 'availability'",
Default: "availability",
Optional: true,
},
},
}
}
Expand Down Expand Up @@ -165,13 +171,24 @@ func TestNewPatchOptions(t *testing.T) {
"stream_prefix": "fried",
"region": "chicken",
},
Essential: true,
Essential: false,
}
actualPatchOptions := newPatchOptions(data)

if !reflect.DeepEqual(expectedPatchOptions, actualPatchOptions) {
t.Errorf("patcConfigurations are not equal. Expected: %v, Actual: %v", expectedPatchOptions, actualPatchOptions)
}

err = data.Set("priority", "security")
if err != nil {
assert.FailNow(t, fmt.Sprintf("Could not set priority, got error: %v", err))
}
expectedPatchOptions.Essential = true
actualPatchOptions = newPatchOptions(data)

if !reflect.DeepEqual(expectedPatchOptions, actualPatchOptions) {
t.Errorf("patcConfigurations are not equal. Expected: %v, Actual: %v", expectedPatchOptions, actualPatchOptions)
}
}

func getSidecarConfig() string {
Expand Down
5 changes: 3 additions & 2 deletions sysdig/data_source_sysdig_fargate_workload_agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ func dataSourceSysdigFargateWorkloadAgent() *schema.Resource {
"instrumentation_essential": {
Type: schema.TypeBool,
Description: "Should the instrumentation container be marked as essential",
Default: true,
Default: false,
Optional: true,
},
"instrumentation_cpu": {
Expand Down Expand Up @@ -411,7 +411,8 @@ func newPatchOptions(d *schema.ResourceData) *patchOptions {
if essential := d.Get("instrumentation_essential"); essential != nil {
opts.Essential = essential.(bool)
} else {
opts.Essential = true
priority := d.Get("priority").(string)
opts.Essential = priority == "security"
}

if cpuShares := d.Get("instrumentation_cpu"); cpuShares != nil {
Expand Down

0 comments on commit dc7ff5c

Please sign in to comment.