Skip to content
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

Adding osconfigv2 project level terraform script #21223

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
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
1 change: 1 addition & 0 deletions google/fwmodels/provider_model.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ type ProviderModel struct {
OracleDatabaseCustomEndpoint types.String `tfsdk:"oracle_database_custom_endpoint"`
OrgPolicyCustomEndpoint types.String `tfsdk:"org_policy_custom_endpoint"`
OSConfigCustomEndpoint types.String `tfsdk:"os_config_custom_endpoint"`
OSConfigV2CustomEndpoint types.String `tfsdk:"os_config_v2_custom_endpoint"`
OSLoginCustomEndpoint types.String `tfsdk:"os_login_custom_endpoint"`
ParallelstoreCustomEndpoint types.String `tfsdk:"parallelstore_custom_endpoint"`
PrivatecaCustomEndpoint types.String `tfsdk:"privateca_custom_endpoint"`
Expand Down
6 changes: 6 additions & 0 deletions google/fwprovider/framework_provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -754,6 +754,12 @@ func (p *FrameworkProvider) Schema(_ context.Context, _ provider.SchemaRequest,
transport_tpg.CustomEndpointValidator(),
},
},
"os_config_v2_custom_endpoint": &schema.StringAttribute{
Optional: true,
Validators: []validator.String{
transport_tpg.CustomEndpointValidator(),
},
},
"os_login_custom_endpoint": &schema.StringAttribute{
Optional: true,
Validators: []validator.String{
Expand Down
6 changes: 6 additions & 0 deletions google/provider/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -643,6 +643,11 @@ func Provider() *schema.Provider {
Optional: true,
ValidateFunc: transport_tpg.ValidateCustomEndpoint,
},
"os_config_v2_custom_endpoint": {
Type: schema.TypeString,
Optional: true,
ValidateFunc: transport_tpg.ValidateCustomEndpoint,
},
"os_login_custom_endpoint": {
Type: schema.TypeString,
Optional: true,
Expand Down Expand Up @@ -1103,6 +1108,7 @@ func ProviderConfigure(ctx context.Context, d *schema.ResourceData, p *schema.Pr
config.OracleDatabaseBasePath = d.Get("oracle_database_custom_endpoint").(string)
config.OrgPolicyBasePath = d.Get("org_policy_custom_endpoint").(string)
config.OSConfigBasePath = d.Get("os_config_custom_endpoint").(string)
config.OSConfigV2BasePath = d.Get("os_config_v2_custom_endpoint").(string)
config.OSLoginBasePath = d.Get("os_login_custom_endpoint").(string)
config.ParallelstoreBasePath = d.Get("parallelstore_custom_endpoint").(string)
config.PrivatecaBasePath = d.Get("privateca_custom_endpoint").(string)
Expand Down
2 changes: 2 additions & 0 deletions google/provider/provider_mmv1_resources.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ import (
"github.com/hashicorp/terraform-provider-google/google/services/oracledatabase"
"github.com/hashicorp/terraform-provider-google/google/services/orgpolicy"
"github.com/hashicorp/terraform-provider-google/google/services/osconfig"
"github.com/hashicorp/terraform-provider-google/google/services/osconfigv2"
"github.com/hashicorp/terraform-provider-google/google/services/oslogin"
"github.com/hashicorp/terraform-provider-google/google/services/parallelstore"
"github.com/hashicorp/terraform-provider-google/google/services/privateca"
Expand Down Expand Up @@ -1098,6 +1099,7 @@ var generatedResources = map[string]*schema.Resource{
"google_org_policy_custom_constraint": orgpolicy.ResourceOrgPolicyCustomConstraint(),
"google_org_policy_policy": orgpolicy.ResourceOrgPolicyPolicy(),
"google_os_config_patch_deployment": osconfig.ResourceOSConfigPatchDeployment(),
"google_os_config_v2_policy_orchestrator": osconfigv2.ResourceOSConfigV2PolicyOrchestrator(),
"google_os_login_ssh_public_key": oslogin.ResourceOSLoginSSHPublicKey(),
"google_parallelstore_instance": parallelstore.ResourceParallelstoreInstance(),
"google_privateca_ca_pool": privateca.ResourcePrivatecaCaPool(),
Expand Down
92 changes: 92 additions & 0 deletions google/services/osconfigv2/os_config_v2_operation.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0

// ----------------------------------------------------------------------------
//
// *** AUTO GENERATED CODE *** Type: MMv1 ***
//
// ----------------------------------------------------------------------------
//
// This file is automatically generated by Magic Modules and manual
// changes will be clobbered when the file is regenerated.
//
// Please read more about how to change this file in
// .github/CONTRIBUTING.md.
//
// ----------------------------------------------------------------------------

package osconfigv2

import (
"encoding/json"
"errors"
"fmt"
"time"

"github.com/hashicorp/terraform-provider-google/google/tpgresource"
transport_tpg "github.com/hashicorp/terraform-provider-google/google/transport"
)

type OSConfigV2OperationWaiter struct {
Config *transport_tpg.Config
UserAgent string
Project string
tpgresource.CommonOperationWaiter
}

func (w *OSConfigV2OperationWaiter) QueryOp() (interface{}, error) {
if w == nil {
return nil, fmt.Errorf("Cannot query operation, it's unset or nil.")
}
// Returns the proper get.
url := fmt.Sprintf("%s%s", w.Config.OSConfigV2BasePath, w.CommonOperationWaiter.Op.Name)

return transport_tpg.SendRequest(transport_tpg.SendRequestOptions{
Config: w.Config,
Method: "GET",
Project: w.Project,
RawURL: url,
UserAgent: w.UserAgent,
})
}

func createOSConfigV2Waiter(config *transport_tpg.Config, op map[string]interface{}, project, activity, userAgent string) (*OSConfigV2OperationWaiter, error) {
w := &OSConfigV2OperationWaiter{
Config: config,
UserAgent: userAgent,
Project: project,
}
if err := w.CommonOperationWaiter.SetOp(op); err != nil {
return nil, err
}
return w, nil
}

// nolint: deadcode,unused
func OSConfigV2OperationWaitTimeWithResponse(config *transport_tpg.Config, op map[string]interface{}, response *map[string]interface{}, project, activity, userAgent string, timeout time.Duration) error {
w, err := createOSConfigV2Waiter(config, op, project, activity, userAgent)
if err != nil {
return err
}
if err := tpgresource.OperationWait(w, activity, timeout, config.PollInterval); err != nil {
return err
}
rawResponse := []byte(w.CommonOperationWaiter.Op.Response)
if len(rawResponse) == 0 {
return errors.New("`resource` not set in operation response")
}
return json.Unmarshal(rawResponse, response)
}

func OSConfigV2OperationWaitTime(config *transport_tpg.Config, op map[string]interface{}, project, activity, userAgent string, timeout time.Duration) error {
if val, ok := op["name"]; !ok || val == "" {
// This was a synchronous call - there is no operation to wait for.
return nil
}
w, err := createOSConfigV2Waiter(config, op, project, activity, userAgent)
if err != nil {
// If w is nil, the op was synchronous.
return err
}
return tpgresource.OperationWait(w, activity, timeout, config.PollInterval)
}
Loading