Skip to content

Commit

Permalink
Merge pull request #1074 from hashicorp/main
Browse files Browse the repository at this point in the history
Main to Release 0.7.1
  • Loading branch information
absolutelightning authored Oct 30, 2023
2 parents 705e5cb + 4dba535 commit 0a0ae6f
Show file tree
Hide file tree
Showing 28 changed files with 120 additions and 109 deletions.
5 changes: 1 addition & 4 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,4 @@ updates:
schedule:
interval: "daily"
time: "05:00"
timezone: "UTC"
ignore:
- dependency-name: "*"
update-types: ["version-update:semver-patch"]
timezone: "UTC"
20 changes: 10 additions & 10 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,15 +71,15 @@ jobs:
strategy:
matrix:
include:
- {go: "1.18", goos: "linux", goarch: "386"}
- {go: "1.18", goos: "linux", goarch: "amd64"}
- {go: "1.18", goos: "linux", goarch: "arm"}
- {go: "1.18", goos: "linux", goarch: "arm64"}
- {go: "1.18", goos: "freebsd", goarch: "386"}
- {go: "1.18", goos: "freebsd", goarch: "amd64"}
- {go: "1.18", goos: "windows", goarch: "386"}
- {go: "1.18", goos: "windows", goarch: "amd64"}
- {go: "1.18", goos: "solaris", goarch: "amd64"}
- {go: "1.20.10", goos: "linux", goarch: "386"}
- {go: "1.20.10", goos: "linux", goarch: "amd64"}
- {go: "1.20.10", goos: "linux", goarch: "arm"}
- {go: "1.20.10", goos: "linux", goarch: "arm64"}
- {go: "1.20.10", goos: "freebsd", goarch: "386"}
- {go: "1.20.10", goos: "freebsd", goarch: "amd64"}
- {go: "1.20.10", goos: "windows", goarch: "386"}
- {go: "1.20.10", goos: "windows", goarch: "amd64"}
- {go: "1.20.10", goos: "solaris", goarch: "amd64"}
fail-fast: true

name: Go ${{ matrix.go }} ${{ matrix.goos }} ${{ matrix.goarch }} build
Expand Down Expand Up @@ -147,7 +147,7 @@ jobs:
matrix:
goos: [darwin]
goarch: ["amd64"]
go: ["1.18"]
go: ["1.20.10"]
fail-fast: true

name: Go ${{ matrix.go }} ${{ matrix.goos }} ${{ matrix.goarch }} build
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ concurrency:
cancel-in-progress: true

env:
GO_VERSION: 1.18
GO_VERSION: 1.20.10
CONSUL_VERSION: 1.12.1
TERRAFORM_VERSION: 1.2.2

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/weekly-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ concurrency:
cancel-in-progress: true

env:
GO_VERSION: 1.18
GO_VERSION: 1.20.10
CONSUL_VERSION: 1.12.1
TERRAFORM_VERSION: 1.2.2
VAULT_VERSION: 1.10.3
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
BUG FIXES:
* Fix issue with re registration of services with checks not triggering task [[GH-1067](https://github.com/hashicorp/consul-terraform-sync/pull/1067)]

FEATURES:
* Go version bump to 1.21.10 [[GH-1067](https://github.com/hashicorp/consul-terraform-sync/pull/1067)]
* Support for Terraform v1.6.2 [[GH-1067](https://github.com/hashicorp/consul-terraform-sync/pull/1067)]

## 0.7.0 (September 8, 2022)

BREAKING CHANGES:
Expand Down
8 changes: 4 additions & 4 deletions config/monitor_services.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,10 +131,10 @@ func (c *ServicesMonitorConfig) Merge(o MonitorConfig) MonitorConfig {
// Finalize ensures there no nil pointers.
//
// Exception: `Regexp` is never finalized and can potentially be nil.
// - There is a need to distinguish betweeen nil regex (unconfigured regex) and
// empty string regex ("" regex pattern) at Validate().
// - Setting `Regexp` as an empty string is not idempotent. There is a need to
// call Finalize() and Validate() multiple times.
// - There is a need to distinguish betweeen nil regex (unconfigured regex) and
// empty string regex ("" regex pattern) at Validate().
// - Setting `Regexp` as an empty string is not idempotent. There is a need to
// call Finalize() and Validate() multiple times.
func (c *ServicesMonitorConfig) Finalize() {
if c == nil { // config not required, return early
return
Expand Down
14 changes: 8 additions & 6 deletions config/task.go
Original file line number Diff line number Diff line change
Expand Up @@ -465,9 +465,10 @@ func (c *TaskConfig) Validate() error {

// ValidateForDriver validates all remaining values and required options that were not checked during
// the normal Validate() call. This method is recommended to run after:
// - Finalize()
// - Validate()
// - InheritParentConfig()
// - Finalize()
// - Validate()
// - InheritParentConfig()
//
// It is intended to indicate whether a task is safe to be converted into a driver for execution.
func (c *TaskConfig) ValidateForDriver() error {
if err := c.BufferPeriod.Validate(); err != nil {
Expand Down Expand Up @@ -643,9 +644,10 @@ func FilterTasks(tasks *TaskConfigs, names []string) (*TaskConfigs, error) {
}

// validateCondition validates condition block taking into account services list
// - ensure task is configured with a condition (condition block or services
// list)
// - if services list is configured, condition block's monitored variable type
// - ensure task is configured with a condition (condition block or services
// list)
// - if services list is configured, condition block's monitored variable type
//
// cannot be services
//
// Note: checking that a condition block's monitored variable type is different
Expand Down
9 changes: 6 additions & 3 deletions e2e/condition_schedule_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ const (
condition "schedule" {
cron = "*/10 * * * * * *"
}
module_input "services"{
module_input "services" {
regexp = "^web.*|^api.*"
}
}`
Expand All @@ -69,8 +69,8 @@ func TestCondition_Schedule_Basic(t *testing.T) {
condition "schedule" {
cron = "*/10 * * * * * *"
}
}
`, taskName)
}
`, taskName)
moduleInputServices := fmt.Sprintf(scheduledServices, taskName)
moduleInputConsulKV := fmt.Sprintf(scheduledConsulKV, taskName)

Expand Down Expand Up @@ -157,6 +157,7 @@ func TestCondition_Schedule_Basic(t *testing.T) {
// check scheduled task did not trigger immediately and ran only on schedule
api.WaitForEvent(t, cts, taskName, registerTime, scheduledWait)
checkScheduledRun(t, taskName, registerTime, taskSchedule, port)
time.Sleep(defaultWaitForTestReadiness)

// confirm service resources created
resourcesPath := filepath.Join(tempDir, taskName, resourcesDir)
Expand Down Expand Up @@ -348,6 +349,8 @@ func TestCondition_Schedule_CreateAndDeleteCLI(t *testing.T) {
api.WaitForEvent(t, cts, taskName, registerTime, scheduledWait)
checkScheduledRun(t, taskName, registerTime, taskSchedule, port)

time.Sleep(defaultWaitForTestReadiness)

// confirm resources created
resourcesPath := filepath.Join(tempDir, taskName, resourcesDir)
validateServices(t, true, []string{"api-1", "web-1"}, resourcesPath)
Expand Down
10 changes: 5 additions & 5 deletions e2e/condition_service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ func testServicesCondition(t *testing.T, tc servicesConditionTest) {
now := time.Now()
service = testutil.TestService{ID: "api-web-1", Name: "api-web"}
testutils.RegisterConsulService(t, srv, service, defaultWaitForRegistration)
api.WaitForEvent(t, cts, tc.taskName, now, defaultWaitForEvent)
api.WaitForEvent(t, cts, tc.taskName, now, defaultWaitForTestReadiness)
eventCountNow = eventCount(t, tc.taskName, cts.Port())
eventCountExpected++
require.Equal(t, eventCountExpected, eventCountNow,
Expand All @@ -201,7 +201,7 @@ func testServicesCondition(t *testing.T, tc servicesConditionTest) {
now = time.Now()
service = testutil.TestService{ID: "api-web-2", Name: "api-web"}
testutils.RegisterConsulService(t, srv, service, defaultWaitForRegistration)
api.WaitForEvent(t, cts, tc.taskName, now, defaultWaitForEvent)
api.WaitForEvent(t, cts, tc.taskName, now, defaultWaitForTestReadiness)
eventCountNow = eventCount(t, tc.taskName, cts.Port())
eventCountExpected++
require.Equal(t, eventCountExpected, eventCountNow,
Expand All @@ -212,7 +212,7 @@ func testServicesCondition(t *testing.T, tc servicesConditionTest) {
now = time.Now()
service = testutil.TestService{ID: "api-web-3", Name: "api-web", Tags: []string{"tag_a"}}
testutils.RegisterConsulService(t, srv, service, defaultWaitForRegistration)
time.Sleep(defaultWaitForNoEvent)
time.Sleep(defaultWaitForTestReadiness)
eventCountNow = eventCount(t, tc.taskName, cts.Port())
require.Equal(t, eventCountExpected, eventCountNow,
"change in event count. task was unexpectedly triggered")
Expand Down Expand Up @@ -340,7 +340,7 @@ func TestConditionServices_SuppressTriggers_SharedDependencies(t *testing.T) {
now := time.Now()
service := testutil.TestService{ID: "api-test", Name: "api-test"}
testutils.RegisterConsulService(t, srv, service, defaultWaitForRegistration)
api.WaitForEvent(t, cts, taskName, now, defaultWaitForEvent)
api.WaitForEvent(t, cts, taskName, now, defaultWaitForTestReadiness)
count = eventCount(t, taskName, cts.Port())
expectedCount++
assert.Equal(t, expectedCount, count, "unexpected event count")
Expand All @@ -351,7 +351,7 @@ func TestConditionServices_SuppressTriggers_SharedDependencies(t *testing.T) {
now = time.Now()
service = testutil.TestService{ID: "web", Name: "web"}
testutils.RegisterConsulService(t, srv, service, defaultWaitForRegistration)
api.WaitForEvent(t, cts, initTaskName, now, defaultWaitForEvent)
api.WaitForEvent(t, cts, initTaskName, now, defaultWaitForTestReadiness)
initCount := eventCount(t, initTaskName, cts.Port())
assert.Equal(t, 2, initCount, "unexpected event count")
initResources := filepath.Join(tempDir, initTaskName, resourcesDir)
Expand Down
4 changes: 2 additions & 2 deletions e2e/module_input_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ func testModuleInputBasic(t *testing.T, tc moduleInputTest) {
tc.srv.SetKVString(t, "key", "value")
tc.srv.SetKVString(t, "key/recurse", "value-recurse")

time.Sleep(defaultWaitForNoEvent)
time.Sleep(defaultWaitForTestReadiness)
testutils.CheckDir(t, false, resourcesPath)

// 2. Register "web" service to trigger condition. Confirm that
Expand Down Expand Up @@ -394,7 +394,7 @@ func TestModuleInput_ConsulKVCondition(t *testing.T) {
service := testutil.TestService{ID: "api", Name: "api"}
testutils.RegisterConsulService(t, srv, service, defaultWaitForRegistration)

time.Sleep(defaultWaitForNoEvent)
time.Sleep(defaultWaitForTestReadiness)
testutils.CheckDir(t, false, resourcesPath)

// 2. Register kv pair to trigger condition. Confirm that
Expand Down
2 changes: 1 addition & 1 deletion examples/reference-example/sync-tasks/my-task/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# Description: automate services for website X

terraform {
required_version = ">= 0.13.0, < 1.3.0"
required_version = ">= 0.13.0, <= 1.6.2"
required_providers {
myprovider = {
source = "namespace/myprovider"
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/hashicorp/consul-terraform-sync

go 1.18
go 1.20

require (
github.com/PaloAltoNetworks/pango v0.5.1
Expand Down
5 changes: 3 additions & 2 deletions internal/decode/decode.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ import (
// Aliases must be lowercase, as keys are compared case-insensitive.
//
// Example alias tag:
// MyField []string `alias:"old_field_name,otherfieldname"`
//
// MyField []string `alias:"old_field_name,otherfieldname"`
//
// This hook should ONLY be used to maintain backwards compatibility with
// deprecated keys. For new structures use mapstructure struct tags to set the
Expand Down Expand Up @@ -149,7 +150,7 @@ type mapstructureFieldTags struct {
// the target is a slice. This is necessary because this hook would have converted
// the initial slices into single values on the first pass.
//
// Background
// # Background
//
// HCL allows for repeated blocks which forces it to store structures
// as []map[string]interface{} instead of map[string]interface{}. This is an
Expand Down
6 changes: 3 additions & 3 deletions mocks/api/middleware.go

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

Loading

0 comments on commit 0a0ae6f

Please sign in to comment.