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

New Resource: azurerm_scheduler_job #1172

Merged
merged 22 commits into from
Jul 3, 2018
Merged

Conversation

katbyte
Copy link
Collaborator

@katbyte katbyte commented Apr 27, 2018

No description provided.

@katbyte katbyte added this to the 1.5.0 milestone Apr 27, 2018
@katbyte katbyte force-pushed the f-r-scheduler_job branch 2 times, most recently from 7a07134 to 634f9b4 Compare April 27, 2018 15:56
travis CI fixes
@tombuildsstuff tombuildsstuff modified the milestones: 1.5.0, 1.6.0 May 8, 2018
@tombuildsstuff tombuildsstuff self-assigned this May 23, 2018
@tombuildsstuff tombuildsstuff modified the milestones: 1.6.0, 1.7.0 May 24, 2018
@tombuildsstuff tombuildsstuff changed the title Added new resource scheduler_job New Resource: azurerm_scheduler_job May 25, 2018
Copy link
Contributor

@tombuildsstuff tombuildsstuff left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hey @katbyte

Apologies for the delayed review of this PR - I've taken a look through and left some comments in-line; but I've got questions both about the schema design (I think we should make this more Terraform-y) and how the tests are implemented (to make them easier to read)

Thanks!

@@ -0,0 +1,23 @@
package supress
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

supress -> suppress

"time"

"github.com/hashicorp/terraform/helper/schema"
"strings"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor can we sort these?

Schema: map[string]*schema.Schema{
"day": { // DatOfWeek (sunday monday)
Type: schema.TypeString,
Required: true,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we add some validation here?


for _, tc := range cases {
if CaseDifference("test", tc.StringA, tc.StringB, nil) != tc.Suppress {
t.Fatalf("Expected CaseDifference to return %t for '%s' == '%s'", tc.Suppress, tc.StringA, tc.StringB)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor you can use %q in place of '%s' (or "%s")

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we be using %q everywhere instead of %s?

url, err := url.Parse(v)
if err != nil {
errors = append(errors, fmt.Errorf("%q url is in an invalid format: %q (%+v)", k, i, err))
} else if url.Scheme != "http" && url.Scheme != "https" {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that's a bit of an assumption given the name of the function - perhaps it's worth renaming this to WebUrl?

method = "put"
body = "this is some text"
headers = {
Content-Type = "text"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should quote this, since I think this could break in HCL2?

tenant_id = "%s"
client_id = "%s"
secret = "%s"
audience = "https://management.core.windows.net/"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we template this value? it's available on meta.(*ArmClient).environment..

resource.TestCheckResourceAttr(resourceName, "action_web.0.authentication_active_directory.0.tenant_id", tenantId),
resource.TestCheckResourceAttr(resourceName, "action_web.0.authentication_active_directory.0.client_id", clientId),
resource.TestCheckResourceAttr(resourceName, "action_web.0.authentication_active_directory.0.secret", secret),
resource.TestCheckResourceAttr(resourceName, "action_web.0.authentication_active_directory.0.audience", "https://management.core.windows.net/"),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can either use the full URI depending on the environment being used here or just ensure this is set?

body = "The job failed"

headers = {
Content-Type = "text"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(as above)

return hashcode.String(buf.String())
}

//todo where to put these?
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

azurerm/helpers/set/set.go?

@katbyte katbyte modified the milestones: 1.7.0, Soon Jun 12, 2018
@tombuildsstuff tombuildsstuff modified the milestones: Soon, 1.8.0 Jun 19, 2018
@katbyte katbyte modified the milestones: 1.8.0, 1.9.0 Jun 28, 2018
@tombuildsstuff tombuildsstuff removed their assignment Jul 3, 2018
Copy link
Contributor

@tombuildsstuff tombuildsstuff left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aside from a few minor nits (which I'll push a commit for) this otherwise LGTM 👍

}

for _, s := range validSchemes {
if url.Scheme == s {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO this should be strings.EqualFold(url.Scheme, s) to handle casing - but it's not a blocker

}
}

return
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we be adding a couldn't find it error here?

@@ -0,0 +1 @@
package validate
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we add some basic tests covering the methods in the other file?

@@ -736,6 +736,11 @@
<a href="/docs/providers/azurerm/r/scheduler_job_collection.html">azurerm_scheduler_job_collection</a>
</li>
</ul>
<ul class="nav nav-visible">
<li<%= sidebar_current("docs-azurerm-resource-scheduler_job") %>>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should suffix this to avoid highlight conflicts

Scheduler Job can be imported using a `resource id`, e.g.

```shell
terraform import azurerm_search_service.service1 /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resourceGroup1/providers/Microsoft.Scheduler/jobCollections/jobCollection1/jobs/job1
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

azurerm_search_service.service1 -> azurerm_scheduler_job.job1

Steps: []resource.TestStep{
{
Config: testAccAzureRMSchedulerJob_web_basic(ri, testLocation()),
Check: checkAccAzureRMSchedulerJob_web_basic(resourceName),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should in-line these

@tombuildsstuff
Copy link
Contributor

Tests pass:

screenshot 2018-07-03 at 14 28 32

@tombuildsstuff tombuildsstuff merged commit 3cc5cdb into master Jul 3, 2018
@tombuildsstuff tombuildsstuff deleted the f-r-scheduler_job branch July 3, 2018 12:29
tombuildsstuff added a commit that referenced this pull request Jul 3, 2018
tombuildsstuff added a commit that referenced this pull request Jul 3, 2018
@ghost
Copy link

ghost commented Mar 30, 2020

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. If you feel I made an error 🤖 🙉 , please reach out to my human friends 👉 hashibot-feedback@hashicorp.com. Thanks!

@ghost ghost locked and limited conversation to collaborators Mar 30, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants