Skip to content

Commit

Permalink
Add auto publish mode
Browse files Browse the repository at this point in the history
  • Loading branch information
chkp-royl committed Jun 15, 2023
1 parent 9a4e414 commit 9e56a0f
Show file tree
Hide file tree
Showing 1,466 changed files with 228,572 additions and 135,834 deletions.
8 changes: 8 additions & 0 deletions checkpoint/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,12 @@ func Provider() terraform.ResourceProvider {
DefaultFunc: schema.EnvDefaultFunc("CHECKPOINT_CLOUD_MGMT_ID", ""),
Description: "Smart-1 Cloud management UID",
},
"auto_publish_batch_size": {
Type: schema.TypeInt,
Optional: true,
DefaultFunc: schema.EnvDefaultFunc("CHECKPOINT_AUTO_PUBLISH_BATCH_SIZE", -1),
Description: "Number of batch size to automatically run publish",
},
},
ResourcesMap: map[string]*schema.Resource{
"checkpoint_management_host": resourceManagementHost(),
Expand Down Expand Up @@ -411,6 +417,7 @@ func providerConfigure(data *schema.ResourceData) (interface{}, error) {
sessionDescription := data.Get("session_description").(string)
sessionTimeout := data.Get("session_timeout").(int)
cloudMgmtId := data.Get("cloud_mgmt_id").(string)
autoPublishBatchSize := data.Get("auto_publish_batch_size").(int)

if server == "" || ((username == "" || password == "") && apiKey == "") {
return nil, fmt.Errorf("checkpoint-provider missing parameters to initialize (server, (username and password) OR api_key)")
Expand All @@ -432,6 +439,7 @@ func providerConfigure(data *schema.ResourceData) (interface{}, error) {
Sleep: checkpoint.SleepTime,
UserAgent: "Terraform",
CloudMgmtId: cloudMgmtId,
AutoPublishBatchSize: autoPublishBatchSize,
}

switch context {
Expand Down
10 changes: 10 additions & 0 deletions commands/commands_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ func InitClient() (checkpoint.ApiClient, error) {
port := checkpoint.DefaultPort
timeout := checkpoint.TimeOut
proxyPort := checkpoint.DefaultProxyPort
autoPublishBatchSize := -1

// Get credentials from Environment variables
server := os.Getenv("CHECKPOINT_SERVER")
Expand All @@ -70,6 +71,7 @@ func InitClient() (checkpoint.ApiClient, error) {
proxyPortStr := os.Getenv("CHECKPOINT_PROXY_PORT")
apiKey := os.Getenv("CHECKPOINT_API_KEY")
cloudMgmtId := os.Getenv("CHECKPOINT_CLOUD_MGMT_ID")
autoPublishBatchSizeVal := os.Getenv("CHECKPOINT_AUTO_PUBLISH_BATCH_SIZE")

var err error
if portVal != "" {
Expand Down Expand Up @@ -98,6 +100,13 @@ func InitClient() (checkpoint.ApiClient, error) {
sessionFileName = DefaultFilename
}

if autoPublishBatchSizeVal != "" {
autoPublishBatchSize, err = strconv.Atoi(timeoutVal)
if err != nil {
return checkpoint.ApiClient{}, fmt.Errorf("failed to parse CHECKPOINT_AUTO_PUBLISH_BATCH_SIZE to integer")
}
}

if server == "" || ((username == "" || password == "") && apiKey == "") {
return checkpoint.ApiClient{}, fmt.Errorf("missing at least one required parameter to initialize API client (CHECKPOINT_SERVER, (CHECKPOINT_USERNAME and CHECKPOINT_PASSWORD) OR CHECKPOINT_API_KEY)")
}
Expand Down Expand Up @@ -125,6 +134,7 @@ func InitClient() (checkpoint.ApiClient, error) {
Sleep: checkpoint.SleepTime,
UserAgent: "Terraform",
CloudMgmtId: cloudMgmtId,
AutoPublishBatchSize: autoPublishBatchSize,
}

s, err := GetSession(sessionFileName)
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module github.com/CheckPointSW/terraform-provider-checkpoint

require (
github.com/CheckPointSW/cp-mgmt-api-go-sdk v1.6.0
github.com/CheckPointSW/cp-mgmt-api-go-sdk v1.6.1
github.com/hashicorp/terraform-plugin-sdk v1.17.0
)

Expand Down
43 changes: 41 additions & 2 deletions go.sum

Large diffs are not rendered by default.

11 changes: 11 additions & 0 deletions vendor/cloud.google.com/go/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 9e56a0f

Please sign in to comment.