Skip to content

Commit

Permalink
Merge pull request #16 from Spotnana-Tech/version
Browse files Browse the repository at this point in the history
incrementing version for publishing
  • Loading branch information
kgibson-spotnana authored Mar 5, 2024
2 parents c6e9f58 + 1e343dd commit 9f0c81b
Show file tree
Hide file tree
Showing 10 changed files with 88 additions and 66 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,13 @@ jobs:
- uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0
with:
go-version-file: 'go.mod'
cache: true
cache: false
- run: go mod download
- run: go build -v .
- name: Run linters
uses: golangci/golangci-lint-action@3a919529898de77ec3da873e3063ca4b10e7f5cc # v3.7.0
with:
skip-pkg-cache: true
version: latest

generate:
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ These marks are used nominatively to indicate the nature and function of Spotnan
Terraform provider, which is neither sponsored or endorsed by Jumpcloud, Inc., Hashicorp, Inc. or Google._

### Requirements
- [Spotnana Jumpcloud Go Client](https://github.com/Spotnana-Tech/sec-jumpcloud-client-go) >= 1.0.0
- [Spotnana Jumpcloud Go Client](https://github.com/Spotnana-Tech/sec-jumpcloud-client-go) >= 1.0.2
- [Terraform](https://developer.hashicorp.com/terraform/downloads) >= 1.0
- [Go](https://golang.org/doc/install) >= 1.20

Expand Down
28 changes: 14 additions & 14 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,25 @@ go 1.21
toolchain go1.21.5

require (
github.com/Spotnana-Tech/sec-jumpcloud-client-go v1.0.2
github.com/hashicorp/terraform-plugin-docs v0.16.0
github.com/hashicorp/terraform-plugin-framework v1.4.2
github.com/Spotnana-Tech/sec-jumpcloud-client-go v1.0.3
github.com/hashicorp/terraform-plugin-docs v0.17.0
github.com/hashicorp/terraform-plugin-framework v1.5.0
github.com/hashicorp/terraform-plugin-go v0.20.0
github.com/hashicorp/terraform-plugin-log v0.9.0
github.com/hashicorp/terraform-plugin-testing v1.6.0
)

require (
github.com/Masterminds/goutils v1.1.1 // indirect
github.com/Masterminds/semver/v3 v3.1.1 // indirect
github.com/Masterminds/sprig/v3 v3.2.2 // indirect
github.com/Masterminds/semver/v3 v3.2.0 // indirect
github.com/Masterminds/sprig/v3 v3.2.3 // indirect
github.com/ProtonMail/go-crypto v0.0.0-20230828082145-3c4c8a2d2371 // indirect
github.com/agext/levenshtein v1.2.2 // indirect
github.com/apparentlymart/go-textseg/v15 v15.0.0 // indirect
github.com/armon/go-radix v1.0.0 // indirect
github.com/bgentry/speakeasy v0.1.0 // indirect
github.com/cloudflare/circl v1.3.3 // indirect
github.com/fatih/color v1.13.0 // indirect
github.com/cloudflare/circl v1.3.7 // indirect
github.com/fatih/color v1.16.0 // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/google/go-cmp v0.6.0 // indirect
github.com/google/uuid v1.3.1 // indirect
Expand All @@ -36,19 +36,19 @@ require (
github.com/hashicorp/go-plugin v1.6.0 // indirect
github.com/hashicorp/go-uuid v1.0.3 // indirect
github.com/hashicorp/go-version v1.6.0 // indirect
github.com/hashicorp/hc-install v0.6.1 // indirect
github.com/hashicorp/hc-install v0.6.2 // indirect
github.com/hashicorp/hcl/v2 v2.19.1 // indirect
github.com/hashicorp/logutils v1.0.0 // indirect
github.com/hashicorp/terraform-exec v0.19.0 // indirect
github.com/hashicorp/terraform-json v0.18.0 // indirect
github.com/hashicorp/terraform-exec v0.20.0 // indirect
github.com/hashicorp/terraform-json v0.20.0 // indirect
github.com/hashicorp/terraform-plugin-sdk/v2 v2.30.0 // indirect
github.com/hashicorp/terraform-registry-address v0.2.3 // indirect
github.com/hashicorp/terraform-svchost v0.1.1 // indirect
github.com/hashicorp/yamux v0.1.1 // indirect
github.com/huandu/xstrings v1.3.2 // indirect
github.com/huandu/xstrings v1.3.3 // indirect
github.com/imdario/mergo v0.3.15 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.16 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/mitchellh/cli v1.1.5 // indirect
github.com/mitchellh/copystructure v1.2.0 // indirect
github.com/mitchellh/go-testing-interface v1.14.1 // indirect
Expand All @@ -66,8 +66,8 @@ require (
github.com/zclconf/go-cty v1.14.1 // indirect
golang.org/x/crypto v0.17.0 // indirect
golang.org/x/exp v0.0.0-20230809150735-7b3493d9a819 // indirect
golang.org/x/mod v0.13.0 // indirect
golang.org/x/net v0.17.0 // indirect
golang.org/x/mod v0.14.0 // indirect
golang.org/x/net v0.18.0 // indirect
golang.org/x/sys v0.15.0 // indirect
golang.org/x/text v0.14.0 // indirect
google.golang.org/appengine v1.6.8 // indirect
Expand Down
81 changes: 48 additions & 33 deletions go.sum

Large diffs are not rendered by default.

22 changes: 14 additions & 8 deletions internal/provider/app_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,13 @@ func (r *jcAppResource) Read(ctx context.Context, req resource.ReadRequest, resp
// Get the app by ID
tflog.Info(ctx, fmt.Sprintf("Looking Up App ID: %s %s", state.ID.ValueString(), state.Name.ValueString()))
app, err := r.client.GetApplication(state.ID.ValueString())
if err != nil {
resp.Diagnostics.AddError(
"Error Reading Jumpcloud App",
"Could not read Jumpcloud App ID "+state.ID.ValueString()+": "+err.Error(),
)
return
}
tflog.Info(ctx, fmt.Sprintf("Look Up Results: %s %s", app.ID, app.DisplayName))
// Get the app associations
associations, err := r.client.GetAppAssociations(state.ID.ValueString(), "user_group")
Expand Down Expand Up @@ -127,7 +134,7 @@ func (r *jcAppResource) Read(ctx context.Context, req resource.ReadRequest, resp
}

// Set refreshed state
diags = resp.State.Set(ctx, &state)
diags = resp.State.Set(ctx, &state) //nolint:all
resp.Diagnostics.Append(diags...)
if resp.Diagnostics.HasError() {
return
Expand All @@ -138,7 +145,7 @@ func (r *jcAppResource) Read(ctx context.Context, req resource.ReadRequest, resp
func (r *jcAppResource) Update(ctx context.Context, req resource.UpdateRequest, resp *resource.UpdateResponse) {
// Retrieve values from plan and state
var plan, state AppSchemaModel
diags := req.State.Get(ctx, &state)
diags := req.State.Get(ctx, &state) //nolint:all
diags = req.Plan.Get(ctx, &plan)
resp.Diagnostics.Append(diags...)
if resp.Diagnostics.HasError() {
Expand Down Expand Up @@ -170,8 +177,8 @@ func (r *jcAppResource) Update(ctx context.Context, req resource.UpdateRequest,
// Turn oldstate and newstate into []string of group IDs - these are the associations of the app to usergroups
var oldElements []string
var newElements []string
diags = oldstate.ElementsAs(ctx, &oldElements, false)
diags = newstate.ElementsAs(ctx, &newElements, false)
diags = oldstate.ElementsAs(ctx, &oldElements, false) //nolint:all
diags = newstate.ElementsAs(ctx, &newElements, false) //nolint:all
resp.Diagnostics.Append(diags...)
if resp.Diagnostics.HasError() {
return
Expand All @@ -185,7 +192,7 @@ func (r *jcAppResource) Update(ctx context.Context, req resource.UpdateRequest,
tflog.Info(ctx, fmt.Sprintf("ADDING GROUPID %s TO %s \n", group, state.DisplayLabel.ValueString()))

// Associate the group with the app
err = r.client.AssociateGroupWithApp(state.ID.ValueString(), group)
err = r.client.AssociateGroupWithApp(state.ID.ValueString(), group) //nolint:all
}
}

Expand All @@ -197,12 +204,12 @@ func (r *jcAppResource) Update(ctx context.Context, req resource.UpdateRequest,
tflog.Info(ctx, fmt.Sprintf("REMOVING GROUPID %s FROM %s \n", group, state.DisplayLabel.ValueString()))

// Disassociate the group with the app
err = r.client.RemoveGroupFromApp(state.ID.ValueString(), group)
err = r.client.RemoveGroupFromApp(state.ID.ValueString(), group) //nolint:all
}
}

// Get the app associations
associations, err := r.client.GetAppAssociations(state.ID.ValueString(), "user_group")
associations, err := r.client.GetAppAssociations(state.ID.ValueString(), "user_group") //nolint:all

// Temp holder for associations to be added to state
var idAssociations []attr.Value
Expand Down Expand Up @@ -240,7 +247,6 @@ func (r *jcAppResource) Update(ctx context.Context, req resource.UpdateRequest,
// Delete deletes the resource and removes the Terraform state on success.
func (r *jcAppResource) Delete(ctx context.Context, req resource.DeleteRequest, resp *resource.DeleteResponse) {
// We should not be Creating or Deleting Apps via TF provider... yet
return
}

// Configure adds the provider configuration to the resource.
Expand Down
4 changes: 2 additions & 2 deletions internal/provider/apps_data_source.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ type jcAppsModel struct {
}

// jcAppsDataSourceModel maps the data source schema data.
// TODO: Update this struct value to types.ListType or types.SetType
// TODO: Update this struct value to types.ListType or types.SetType if the data source returns a list or set of items.
type jcAppsDataSourceModel struct {
Apps []jcAppsModel `tfsdk:"apps"`
}
Expand All @@ -40,7 +40,7 @@ func NewjcAppsDataSource() datasource.DataSource {
}

// jcAppsDataSource is the data source implementation.
// This struct accepts a client pointer to the JumpCloud Go client so terraform can make its changes to the system
// This struct accepts a client pointer to the JumpCloud Go client so terraform can make its changes to the system.
type jcAppsDataSource struct {
client *jumpcloud.Client
}
Expand Down
2 changes: 1 addition & 1 deletion internal/provider/provider_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
)

const (
// providerConfig is a shared configuration to combine with the actual test configuration
// providerConfig is a shared configuration to combine with the actual test configuration.
providerConfig = `
variable "api_key" {
type = string
Expand Down
4 changes: 2 additions & 2 deletions internal/provider/usergroups_data_source.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ type jcUserGroupsModel struct {
}

// jcUserGroupsDataSourceModel maps the data source schema data.
// TODO: Update this struct value to types.ListType or types.SetType
// TODO: Update this struct value to types.ListType or types.SetType if the data source returns a list or set of items.
type jcUserGroupsDataSourceModel struct {
UserGroups []jcUserGroupsModel `tfsdk:"usergroups"`
}
Expand All @@ -37,7 +37,7 @@ func NewjcUserGroupDataSource() datasource.DataSource {
}

// jcUserGroupDataSource is the data source implementation.
// This struct accepts a client pointer to the JumpCloud Go client so terraform can make its changes to the system
// This struct accepts a client pointer to the JumpCloud Go client so terraform can make its changes to the system.
type jcUserGroupDataSource struct {
client *jumpcloud.Client
}
Expand Down
6 changes: 3 additions & 3 deletions internal/provider/usergroups_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ func (r *jcUserGroupsResource) Read(ctx context.Context, req resource.ReadReques
func (r *jcUserGroupsResource) Update(ctx context.Context, req resource.UpdateRequest, resp *resource.UpdateResponse) {
// Retrieve values from plan and state
var plan, state UserGroupResourceModel
diags := req.Plan.Get(ctx, &plan) // plan
diags := req.Plan.Get(ctx, &plan) //nolint:all
diags = req.State.Get(ctx, &state) // existing resource state as defined in the terraform state file
resp.Diagnostics.Append(diags...)
if resp.Diagnostics.HasError() {
Expand All @@ -198,7 +198,7 @@ func (r *jcUserGroupsResource) Update(ctx context.Context, req resource.UpdateRe
}

// Get the updated group
groupstate, err := r.client.GetUserGroup(state.ID.ValueString())
groupstate, err := r.client.GetUserGroup(state.ID.ValueString()) //nolint:all
tflog.Info(ctx, fmt.Sprintf("Group Name: %s Group ID: %s", group.Name, group.ID))

// Map response body to schema and populate Computed attribute values
Expand Down Expand Up @@ -259,7 +259,7 @@ func (r *jcUserGroupsResource) Configure(_ context.Context, req resource.Configu
r.client = client
}

// ImportState imports the resource state from live resources via their ID attribute
// ImportState imports the resource state from live resources via their ID attribute.
func (r *jcUserGroupsResource) ImportState(ctx context.Context, req resource.ImportStateRequest, resp *resource.ImportStateResponse) {
// Retrieve import ID and save to id attribute
resource.ImportStatePassthroughID(ctx, path.Root("id"), req, resp)
Expand Down
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import (
var (
// these will be set by the goreleaser configuration
// to appropriate values for the compiled binary.
version string = "v1.0.4"
version string = "v1.0.5"

// goreleaser can pass other information to the main package, such as the specific commit
// https://goreleaser.com/cookbooks/using-main.version/
Expand Down

0 comments on commit 9f0c81b

Please sign in to comment.