Skip to content

feat: Create provisioner abstraction #12

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 14 commits into from
Jan 8, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Check for unstaged file changes
  • Loading branch information
kylecarbs committed Jan 7, 2022
commit 1605445c7886341caee72c6ae76e67030bfc5842
3 changes: 2 additions & 1 deletion .github/workflows/coder.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,9 @@ jobs:
with:
go-version: "^1.17"
- run: go install github.com/kyleconroy/sqlc/cmd/sqlc@latest
- run: go install github.com/storj/drpc/cmd/protoc-gen-go-drpc@v0.0.20
- run: go install storj.io/drpc/cmd/protoc-gen-go-drpc@v0.0.20
- run: "make --output-sync -j gen"
- run: ./scripts/check_unstaged.sh

style:
name: "style/${{ matrix.style }}"
Expand Down
8 changes: 4 additions & 4 deletions provisioner/terraform/parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ import (
"golang.org/x/xerrors"
)

// Parse parses Terraform variables from source-code.
// Parse extracts Terraform variables from source-code.
func (t *terraform) Parse(ctx context.Context, request *proto.Parse_Request) (*proto.Parse_Response, error) {
module, diags := tfconfig.LoadModule(request.Directory)
if diags.HasErrors() {
return nil, xerrors.Errorf("load module: %w", diags.Err())
}
parameters := make([]*proto.ParameterSchema, 0, len(module.Variables))
for _, v := range module.Variables {
schema, err := convertVariable(v)
schema, err := convertVariableToParameter(v)
if err != nil {
return nil, xerrors.Errorf("convert variable %q: %w", v.Name, err)
}
Expand All @@ -31,8 +31,8 @@ func (t *terraform) Parse(ctx context.Context, request *proto.Parse_Request) (*p
}, nil
}

// convertVariable converts a Terraform variable to a provisioner parameter.
func convertVariable(variable *tfconfig.Variable) (*proto.ParameterSchema, error) {
// Converts a Terraform variable to a provisioner parameter.
func convertVariableToParameter(variable *tfconfig.Variable) (*proto.ParameterSchema, error) {
schema := &proto.ParameterSchema{
Name: variable.Name,
Description: variable.Description,
Expand Down
24 changes: 24 additions & 0 deletions scripts/check_unstaged.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/bin/bash

set -euo pipefail

FILES="$(git ls-files --other --modified --exclude-standard)"
if [[ "$FILES" != "" ]]; then
mapfile -t files <<<"$FILES"

echo "The following files contain unstaged changes:"
echo
for file in "${files[@]}"; do
echo " - $file"
done
echo

echo "These are the changes:"
echo
for file in "${files[@]}"; do
git --no-pager diff "$file"
done
exit 1
fi

exit 0