Skip to content

Commit

Permalink
SEC-090: Automated trusted workflow pinning (2024-08-19) (#601)
Browse files Browse the repository at this point in the history
* Result of tsccr-helper -log-level=info gha update -latest .

* Resolve linter errors and warnings

---------

Co-authored-by: hashicorp-tsccr[bot] <hashicorp-tsccr[bot]@users.noreply.github.com>
Co-authored-by: Selena Goods <github@simplebox.anonaddy.com>
  • Loading branch information
3 people committed Aug 20, 2024
1 parent b6364da commit 523efdf
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ jobs:
cd .changes
sed -e "1{/# /d;}" -e "2{/^$/d;}" ${{ needs.changelog-version.outputs.version }}.md > release-notes.txt
- uses: actions/upload-artifact@89ef406dd8d7e03cfd12d9e0a4a378f454709029 # v4.3.5
- uses: actions/upload-artifact@834a144ee995460fba8ed112a2fc961b36a5ec5a # v4.3.6
with:
name: release-notes
path: ./.changes/release-notes.txt
Expand Down
2 changes: 1 addition & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ linters:
- unconvert
- unparam
- unused
- vet
- govet

run:
# Prevent false positive timeouts in CI
Expand Down
22 changes: 11 additions & 11 deletions internal/provider/resource_integer.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,26 +101,26 @@ func (r *integerResource) Create(ctx context.Context, req resource.CreateRequest
return
}

max := int(plan.Max.ValueInt64())
min := int(plan.Min.ValueInt64())
maxVal := int(plan.Max.ValueInt64())
minVal := int(plan.Min.ValueInt64())
seed := plan.Seed.ValueString()

if max < min {
if maxVal < minVal {
resp.Diagnostics.AddError(
"Create Random Integer Error",
"The minimum (min) value needs to be smaller than or equal to maximum (max) value.",
"The minimum (minVal) value needs to be smaller than or equal to maximum (maxVal) value.",
)
return
}

rand := random.NewRand(seed)
number := rand.Intn((max+1)-min) + min
number := rand.Intn((maxVal+1)-minVal) + minVal

u := &integerModelV0{
ID: types.StringValue(strconv.Itoa(number)),
Keepers: plan.Keepers,
Min: types.Int64Value(int64(min)),
Max: types.Int64Value(int64(max)),
Min: types.Int64Value(int64(minVal)),
Max: types.Int64Value(int64(maxVal)),
Result: types.Int64Value(int64(number)),
}

Expand Down Expand Up @@ -179,7 +179,7 @@ func (r *integerResource) ImportState(ctx context.Context, req resource.ImportSt
return
}

min, err := strconv.ParseInt(parts[1], 10, 64)
minVal, err := strconv.ParseInt(parts[1], 10, 64)
if err != nil {
resp.Diagnostics.AddError(
"Import Random Integer Error",
Expand All @@ -189,7 +189,7 @@ func (r *integerResource) ImportState(ctx context.Context, req resource.ImportSt
return
}

max, err := strconv.ParseInt(parts[2], 10, 64)
maxVal, err := strconv.ParseInt(parts[2], 10, 64)
if err != nil {
resp.Diagnostics.AddError(
"Import Random Integer Error",
Expand All @@ -204,8 +204,8 @@ func (r *integerResource) ImportState(ctx context.Context, req resource.ImportSt
state.ID = types.StringValue(parts[0])
state.Keepers = types.MapNull(types.StringType)
state.Result = types.Int64Value(result)
state.Min = types.Int64Value(min)
state.Max = types.Int64Value(max)
state.Min = types.Int64Value(minVal)
state.Max = types.Int64Value(maxVal)

if len(parts) == 4 {
state.Seed = types.StringValue(parts[3])
Expand Down

0 comments on commit 523efdf

Please sign in to comment.