You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@trafficcontrol.apache.org by GitBox <gi...@apache.org> on 2020/10/08 15:53:35 UTC

[GitHub] [trafficcontrol] jpappa200 opened a new pull request #5122: Dnssec refresh

jpappa200 opened a new pull request #5122:
URL: https://github.com/apache/trafficcontrol/pull/5122


   <!--
   ************ STOP!! ************
   If this Pull Request is intended to fix a security vulnerability, DO NOT submit it! Instead, contact
   the Apache Software Foundation Security Team at security@trafficcontrol.apache.org and follow the
   guidelines at https://www.apache.org/security/ regarding vulnerability disclosure.
   -->
   ## What does this PR (Pull Request) do?
   <!-- Explain the changes you made here. If this fixes an Issue, identify it by
   replacing the text in the checkbox item with the Issue number e.g.
   
   - [x] This PR fixes #9001 OR is not related to any Issue
   
   ^ This will automatically close Issue number 9001 when the Pull Request is
   merged (The '#' is important).
   
   Be sure you check the box properly, see the "The following criteria are ALL
   met by this PR" section for details.
   -->
   
   - [x] This PR is not related to any Issue, it is a rewrite of an existing Perl script to go. <!-- You can check for an issue here: https://github.com/apache/trafficcontrol/issues -->
   
   
   ## Which Traffic Control components are affected by this PR?
   <!-- Please delete all components from this list that are NOT affected by this
   Pull Request. Also, feel free to add the name of a tool or script that is
   affected but not on the list.
   
   Additionally, if this Pull Request does NOT affect documentation, please
   explain why documentation is not required. -->
   This is a conversion of ToDnssecRefresh.pl to go. No documentation updates are needed.
   - Traffic Ops
   
   
   ## What is the best way to verify this PR?
   <!-- Please include here ALL the steps necessary to test your Pull Request. If
   it includes tests (and most should), outline here the steps needed to run the
   tests. If not, lay out the manual testing procedure and please explain why
   tests are unnecessary for this Pull Request. -->
   Run in DEBUG mode against a non prod traffic portal and insure you get the proper response from the API endpoint "Checking DNSSEC keys for refresh in the background"
   
   ## If this is a bug fix, what versions of Traffic Control are affected?
   <!-- If this PR fixes a bug, please list here all of the affected versions - to
   the best of your knowledge. It's also pretty helpful to include a commit hash
   of where 'master' is at the time this PR is opened (if it affects master),
   because what 'master' means will change over time. For example, if this PR
   fixes a bug that's present in master (at commit hash '1df853c8'), in v4.0.0,
   and in the current 4.0.1 Release candidate (e.g. RC1), then this list would
   look like:
   
   - master (1df853c8)
   - 4.0.0
   - 4.0.1 (RC1)
   
   If you don't know what other versions might have this bug, AND don't know how
   to find the commit hash of 'master', then feel free to leave this section
   blank (or, preferably, delete it entirely).
    -->
   This is not a bug fix. 
   
   ## The following criteria are ALL met by this PR
   <!-- Check the boxes to signify that the associated statement is true. To
   "check a box", replace the space inside of the square brackets with an 'x'.
   e.g.
   
   - [ x] <- Wrong
   - [x ] <- Wrong
   - [] <- Wrong
   - [*] <- Wrong
   - [x] <- Correct!
   
   -->
   
   - [x] This PR includes tests OR I have explained why tests are unnecessary
   - [x] This PR includes documentation OR I have explained why documentation is unnecessary
   - [x] This PR includes an update to CHANGELOG.md OR such an update is not necessary
   - [x] This PR includes any and all required license headers
   - [x] This PR ensures that database migration sequence is correct OR this PR does not include a database migration
   - [x] This PR **DOES NOT FIX A SERIOUS SECURITY VULNERABILITY** (see [the Apache Software Foundation's security guidelines](https://www.apache.org/security/) for details)
   
   
   <!--
   Licensed to the Apache Software Foundation (ASF) under one
   or more contributor license agreements.  See the NOTICE file
   distributed with this work for additional information
   regarding copyright ownership.  The ASF licenses this file
   to you under the Apache License, Version 2.0 (the
   "License"); you may not use this file except in compliance
   with the License.  You may obtain a copy of the License at
   
       http://www.apache.org/licenses/LICENSE-2.0
   
   Unless required by applicable law or agreed to in writing,
   software distributed under the License is distributed on an
   "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
   KIND, either express or implied.  See the License for the
   specific language governing permissions and limitations
   under the License.
   -->
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [trafficcontrol] jpappa200 commented on a change in pull request #5122: Dnssec refresh

Posted by GitBox <gi...@apache.org>.
jpappa200 commented on a change in pull request #5122:
URL: https://github.com/apache/trafficcontrol/pull/5122#discussion_r513004721



##########
File path: traffic_ops/app/bin/checks/DnssecRefresh/ToDnssecRefresh.go
##########
@@ -0,0 +1,71 @@
+package main
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import (
+	"bytes"
+	"encoding/json"
+	"fmt"
+	"github.com/apache/trafficcontrol/lib/go-log"

Review comment:
       Moved those to bottom of import with a blank line. 




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [trafficcontrol] jpappa200 commented on a change in pull request #5122: Dnssec refresh

Posted by GitBox <gi...@apache.org>.
jpappa200 commented on a change in pull request #5122:
URL: https://github.com/apache/trafficcontrol/pull/5122#discussion_r513011370



##########
File path: traffic_ops/app/bin/checks/DnssecRefresh/config/config.go
##########
@@ -0,0 +1,153 @@
+package config
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import (
+	"crypto/tls"
+	"errors"
+	"fmt"
+	"github.com/apache/trafficcontrol/lib/go-log"
+	"github.com/pborman/getopt/v2"
+	"io"
+	"net/http"
+	"os"
+	"strings"
+)
+
+type Creds struct {
+	User     string `json:"u"`
+	Password string `json:"p"`
+}
+
+type Cfg struct {
+	LogLocationErr   string
+	LogLocationInfo  string
+	LogLocationWarn  string
+	LogLocationDebug string
+	TOInsecure       bool
+	TOUser           string
+	TOPass           string
+	TOUrl            string
+	Transport        *http.Transport
+}
+
+type ToResponse struct {
+	Response string `json:"response"`
+}
+
+func Dclose(c io.Closer) {
+	if err := c.Close(); err != nil {

Review comment:
       yes it does log an error now (as noted above). 




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [trafficcontrol] jpappa200 commented on a change in pull request #5122: Dnssec refresh

Posted by GitBox <gi...@apache.org>.
jpappa200 commented on a change in pull request #5122:
URL: https://github.com/apache/trafficcontrol/pull/5122#discussion_r513010771



##########
File path: traffic_ops/app/bin/checks/DnssecRefresh/ToDnssecRefresh.go
##########
@@ -0,0 +1,71 @@
+package main
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import (
+	"bytes"
+	"encoding/json"
+	"fmt"
+	"github.com/apache/trafficcontrol/lib/go-log"
+	"github.com/apache/trafficcontrol/traffic_ops/app/bin/checks/DnssecRefresh/config"
+	"io/ioutil"
+	"net/http"
+	"net/http/cookiejar"
+	"os"
+)
+
+func main() {
+	cfg, err := config.GetCfg()
+	config.ErrCheck(err)
+	log.Debugln("Including DEBUG messages in output. Config is:")
+	config.PrintConfig(cfg) // only if DEBUG logging is set.
+	body := &config.Creds{
+		User:     cfg.TOUser,
+		Password: cfg.TOPass,
+	}
+	loginUrl := fmt.Sprintf("%s%s", cfg.TOUrl, "/api/2.0/user/login")
+	buf := new(bytes.Buffer)
+	err = json.NewEncoder(buf).Encode(body)
+	config.ErrCheck(err)
+	req, _ := http.NewRequest("POST", loginUrl, buf)
+	jar, _ := cookiejar.New(nil)
+	client := &http.Client{Jar: jar, Transport: cfg.Transport}
+
+	log.Debugf("Posting to: %s", loginUrl)
+
+	res, err := client.Do(req)
+	config.ErrCheck(err)
+	defer config.Dclose(res.Body)
+	refreshUrl := fmt.Sprintf("%s%s", cfg.TOUrl, "/api/2.0/cdns/dnsseckeys/refresh")
+	resp, _ := http.NewRequest("GET", refreshUrl, buf)

Review comment:
       Checks and handles the error.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [trafficcontrol] jpappa200 commented on a change in pull request #5122: Dnssec refresh

Posted by GitBox <gi...@apache.org>.
jpappa200 commented on a change in pull request #5122:
URL: https://github.com/apache/trafficcontrol/pull/5122#discussion_r513002534



##########
File path: traffic_ops/app/bin/checks/DnssecRefresh/config/config.go
##########
@@ -0,0 +1,153 @@
+package config
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import (
+	"crypto/tls"
+	"errors"
+	"fmt"
+	"github.com/apache/trafficcontrol/lib/go-log"
+	"github.com/pborman/getopt/v2"
+	"io"
+	"net/http"
+	"os"
+	"strings"
+)
+
+type Creds struct {
+	User     string `json:"u"`
+	Password string `json:"p"`
+}
+
+type Cfg struct {
+	LogLocationErr   string
+	LogLocationInfo  string
+	LogLocationWarn  string
+	LogLocationDebug string
+	TOInsecure       bool
+	TOUser           string
+	TOPass           string
+	TOUrl            string
+	Transport        *http.Transport
+}
+
+type ToResponse struct {
+	Response string `json:"response"`
+}
+
+func Dclose(c io.Closer) {
+	if err := c.Close(); err != nil {
+	}
+}
+
+func ErrCheck(err error) {
+	if err != nil {
+		log.Errorln(err)
+		os.Exit(1)
+	}
+}
+
+func (cfg Cfg) ErrorLog() log.LogLocation   { return log.LogLocation(cfg.LogLocationErr) }
+func (cfg Cfg) WarningLog() log.LogLocation { return log.LogLocation(cfg.LogLocationWarn) }
+func (cfg Cfg) InfoLog() log.LogLocation    { return log.LogLocation(cfg.LogLocationInfo) }
+func (cfg Cfg) DebugLog() log.LogLocation   { return log.LogLocation(cfg.LogLocationDebug) }
+func (cfg Cfg) EventLog() log.LogLocation   { return log.LogLocation(log.LogLocationNull) } // event logging not used.
+
+func GetCfg() (Cfg, error) {
+	var err error
+	logLocationDebugPtr := getopt.StringLong("log-location-debug", 'd', "", "Where to log debugs. May be a file path, stdout, stderr, or null, default ''")
+	logLocationErrorPtr := getopt.StringLong("log-location-error", 'e', "stderr", "Where to log errors. May be a file path, stdout, stderr, or null, default stderr")
+	logLocationInfoPtr := getopt.StringLong("log-location-info", 'i', "stderr", "Where to log info. May be a file path, stdout, stderr, or null, default stderr")
+	logLocationWarnPtr := getopt.StringLong("log-location-warning", 'w', "stderr", "Where to log warnings. May be a file path, stdout, stderr, or null, default stderr")
+	toInsecurePtr := getopt.BoolLong("traffic-ops-insecure", 'I', "[true | false] ignore certificate errors from Traffic Ops")
+	toUserPtr := getopt.StringLong("traffic-ops-user", 'u', "", "Traffic Ops username. Required.")
+	toPassPtr := getopt.StringLong("traffic-ops-passowrd", 'p', "", "Traffic Ops Password. Required")
+	toUrlPtr := getopt.StringLong("traffic-ops-url", 'U', "", "Traffic ops base URL. Required.")
+	helpPtr := getopt.BoolLong("help", 'h', "Print usage information and exit")
+	getopt.ParseV2()
+
+	logLocationDebug := *logLocationDebugPtr
+	logLocationError := *logLocationErrorPtr
+	logLocationInfo := *logLocationInfoPtr
+	logLocationWarn := *logLocationWarnPtr
+	toInsecure := *toInsecurePtr
+	toURL := *toUrlPtr
+	toUser := *toUserPtr
+	toPass := *toPassPtr
+	transport := &http.Transport{TLSClientConfig: &tls.Config{InsecureSkipVerify: toInsecure}}
+	help := *helpPtr
+
+	if help {
+		Usage()
+		return Cfg{}, nil

Review comment:
       Added `os.exit(0)` 
   https://github.com/jpappa200/trafficcontrol/blob/10f6c5a3084543f2e1568274dfc7ba7157c55e41/traffic_ops/app/bin/checks/DnssecRefresh/ToDnssecRefresh.go#L39-L41




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [trafficcontrol] jpappa200 commented on a change in pull request #5122: Dnssec refresh

Posted by GitBox <gi...@apache.org>.
jpappa200 commented on a change in pull request #5122:
URL: https://github.com/apache/trafficcontrol/pull/5122#discussion_r513008966



##########
File path: traffic_ops/app/bin/checks/DnssecRefresh/ToDnssecRefresh.go
##########
@@ -0,0 +1,71 @@
+package main
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import (
+	"bytes"
+	"encoding/json"
+	"fmt"
+	"github.com/apache/trafficcontrol/lib/go-log"
+	"github.com/apache/trafficcontrol/traffic_ops/app/bin/checks/DnssecRefresh/config"
+	"io/ioutil"
+	"net/http"
+	"net/http/cookiejar"
+	"os"
+)
+
+func main() {
+	cfg, err := config.GetCfg()
+	config.ErrCheck(err)
+	log.Debugln("Including DEBUG messages in output. Config is:")
+	config.PrintConfig(cfg) // only if DEBUG logging is set.
+	body := &config.Creds{
+		User:     cfg.TOUser,
+		Password: cfg.TOPass,
+	}
+	loginUrl := fmt.Sprintf("%s%s", cfg.TOUrl, "/api/2.0/user/login")
+	buf := new(bytes.Buffer)
+	err = json.NewEncoder(buf).Encode(body)
+	config.ErrCheck(err)
+	req, _ := http.NewRequest("POST", loginUrl, buf)
+	jar, _ := cookiejar.New(nil)
+	client := &http.Client{Jar: jar, Transport: cfg.Transport}
+
+	log.Debugf("Posting to: %s", loginUrl)
+
+	res, err := client.Do(req)
+	config.ErrCheck(err)
+	defer config.Dclose(res.Body)
+	refreshUrl := fmt.Sprintf("%s%s", cfg.TOUrl, "/api/2.0/cdns/dnsseckeys/refresh")
+	resp, _ := http.NewRequest("GET", refreshUrl, buf)
+
+	log.Debugf("Get req to: %s", refreshUrl)
+
+	refresh, _ := client.Do(resp)
+	respData, _ := ioutil.ReadAll(refresh.Body)
+	defer config.Dclose(refresh.Body)

Review comment:
       `Dclose` was a func I came up with to satisfy goland. It complained about unhandled errors with just `defer refresh.Body.Close()`, and I couldn't make it go away. Since I use it more than once I put it in a func so didn't have to type `if err != nil {}`. I guess it kind of my Nitpic. If you think it troublesome I'm happy to remove it. I did make it log and error now if called. seem to have left that out. 




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [trafficcontrol] jpappa200 commented on a change in pull request #5122: Dnssec refresh

Posted by GitBox <gi...@apache.org>.
jpappa200 commented on a change in pull request #5122:
URL: https://github.com/apache/trafficcontrol/pull/5122#discussion_r513010164



##########
File path: traffic_ops/app/bin/checks/DnssecRefresh/ToDnssecRefresh.go
##########
@@ -0,0 +1,71 @@
+package main
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import (
+	"bytes"
+	"encoding/json"
+	"fmt"
+	"github.com/apache/trafficcontrol/lib/go-log"
+	"github.com/apache/trafficcontrol/traffic_ops/app/bin/checks/DnssecRefresh/config"
+	"io/ioutil"
+	"net/http"
+	"net/http/cookiejar"
+	"os"
+)
+
+func main() {
+	cfg, err := config.GetCfg()
+	config.ErrCheck(err)
+	log.Debugln("Including DEBUG messages in output. Config is:")
+	config.PrintConfig(cfg) // only if DEBUG logging is set.
+	body := &config.Creds{
+		User:     cfg.TOUser,
+		Password: cfg.TOPass,
+	}
+	loginUrl := fmt.Sprintf("%s%s", cfg.TOUrl, "/api/2.0/user/login")
+	buf := new(bytes.Buffer)
+	err = json.NewEncoder(buf).Encode(body)
+	config.ErrCheck(err)
+	req, _ := http.NewRequest("POST", loginUrl, buf)

Review comment:
       Checks and handles the error.
   
   




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [trafficcontrol] jpappa200 commented on pull request #5122: Dnssec refresh

Posted by GitBox <gi...@apache.org>.
jpappa200 commented on pull request #5122:
URL: https://github.com/apache/trafficcontrol/pull/5122#issuecomment-717524334


   also added a timeout for http transactions. A typo in the URL took several seconds to timeout before. 
   `client := &http.Client{Jar: jar, Transport: cfg.Transport, Timeout: 5 * time.Second}` 


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [trafficcontrol] jpappa200 commented on a change in pull request #5122: Dnssec refresh

Posted by GitBox <gi...@apache.org>.
jpappa200 commented on a change in pull request #5122:
URL: https://github.com/apache/trafficcontrol/pull/5122#discussion_r513003850



##########
File path: traffic_ops/app/bin/checks/DnssecRefresh/config/config.go
##########
@@ -0,0 +1,153 @@
+package config
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import (
+	"crypto/tls"
+	"errors"
+	"fmt"
+	"github.com/apache/trafficcontrol/lib/go-log"
+	"github.com/pborman/getopt/v2"
+	"io"
+	"net/http"
+	"os"
+	"strings"
+)
+
+type Creds struct {
+	User     string `json:"u"`
+	Password string `json:"p"`
+}
+
+type Cfg struct {
+	LogLocationErr   string
+	LogLocationInfo  string
+	LogLocationWarn  string
+	LogLocationDebug string
+	TOInsecure       bool
+	TOUser           string
+	TOPass           string
+	TOUrl            string
+	Transport        *http.Transport
+}
+
+type ToResponse struct {
+	Response string `json:"response"`
+}
+
+func Dclose(c io.Closer) {
+	if err := c.Close(); err != nil {
+	}
+}
+
+func ErrCheck(err error) {
+	if err != nil {
+		log.Errorln(err)
+		os.Exit(1)
+	}
+}
+
+func (cfg Cfg) ErrorLog() log.LogLocation   { return log.LogLocation(cfg.LogLocationErr) }
+func (cfg Cfg) WarningLog() log.LogLocation { return log.LogLocation(cfg.LogLocationWarn) }
+func (cfg Cfg) InfoLog() log.LogLocation    { return log.LogLocation(cfg.LogLocationInfo) }
+func (cfg Cfg) DebugLog() log.LogLocation   { return log.LogLocation(cfg.LogLocationDebug) }
+func (cfg Cfg) EventLog() log.LogLocation   { return log.LogLocation(log.LogLocationNull) } // event logging not used.
+
+func GetCfg() (Cfg, error) {
+	var err error
+	logLocationDebugPtr := getopt.StringLong("log-location-debug", 'd', "", "Where to log debugs. May be a file path, stdout, stderr, or null, default ''")
+	logLocationErrorPtr := getopt.StringLong("log-location-error", 'e', "stderr", "Where to log errors. May be a file path, stdout, stderr, or null, default stderr")
+	logLocationInfoPtr := getopt.StringLong("log-location-info", 'i', "stderr", "Where to log info. May be a file path, stdout, stderr, or null, default stderr")
+	logLocationWarnPtr := getopt.StringLong("log-location-warning", 'w', "stderr", "Where to log warnings. May be a file path, stdout, stderr, or null, default stderr")
+	toInsecurePtr := getopt.BoolLong("traffic-ops-insecure", 'I', "[true | false] ignore certificate errors from Traffic Ops")
+	toUserPtr := getopt.StringLong("traffic-ops-user", 'u', "", "Traffic Ops username. Required.")
+	toPassPtr := getopt.StringLong("traffic-ops-passowrd", 'p', "", "Traffic Ops Password. Required")

Review comment:
       Fixed typo. 




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [trafficcontrol] jpappa200 commented on a change in pull request #5122: Dnssec refresh

Posted by GitBox <gi...@apache.org>.
jpappa200 commented on a change in pull request #5122:
URL: https://github.com/apache/trafficcontrol/pull/5122#discussion_r513009959



##########
File path: traffic_ops/app/bin/checks/DnssecRefresh/ToDnssecRefresh.go
##########
@@ -0,0 +1,71 @@
+package main
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import (
+	"bytes"
+	"encoding/json"
+	"fmt"
+	"github.com/apache/trafficcontrol/lib/go-log"
+	"github.com/apache/trafficcontrol/traffic_ops/app/bin/checks/DnssecRefresh/config"
+	"io/ioutil"
+	"net/http"
+	"net/http/cookiejar"
+	"os"
+)
+
+func main() {
+	cfg, err := config.GetCfg()
+	config.ErrCheck(err)
+	log.Debugln("Including DEBUG messages in output. Config is:")
+	config.PrintConfig(cfg) // only if DEBUG logging is set.
+	body := &config.Creds{
+		User:     cfg.TOUser,
+		Password: cfg.TOPass,
+	}
+	loginUrl := fmt.Sprintf("%s%s", cfg.TOUrl, "/api/2.0/user/login")
+	buf := new(bytes.Buffer)
+	err = json.NewEncoder(buf).Encode(body)
+	config.ErrCheck(err)
+	req, _ := http.NewRequest("POST", loginUrl, buf)
+	jar, _ := cookiejar.New(nil)

Review comment:
       These both check and handle the error now.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [trafficcontrol] rob05c merged pull request #5122: Dnssec refresh

Posted by GitBox <gi...@apache.org>.
rob05c merged pull request #5122:
URL: https://github.com/apache/trafficcontrol/pull/5122


   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [trafficcontrol] jpappa200 commented on a change in pull request #5122: Dnssec refresh

Posted by GitBox <gi...@apache.org>.
jpappa200 commented on a change in pull request #5122:
URL: https://github.com/apache/trafficcontrol/pull/5122#discussion_r513009528



##########
File path: traffic_ops/app/bin/checks/DnssecRefresh/ToDnssecRefresh.go
##########
@@ -0,0 +1,71 @@
+package main
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import (
+	"bytes"
+	"encoding/json"
+	"fmt"
+	"github.com/apache/trafficcontrol/lib/go-log"
+	"github.com/apache/trafficcontrol/traffic_ops/app/bin/checks/DnssecRefresh/config"
+	"io/ioutil"
+	"net/http"
+	"net/http/cookiejar"
+	"os"
+)
+
+func main() {
+	cfg, err := config.GetCfg()
+	config.ErrCheck(err)
+	log.Debugln("Including DEBUG messages in output. Config is:")
+	config.PrintConfig(cfg) // only if DEBUG logging is set.
+	body := &config.Creds{
+		User:     cfg.TOUser,
+		Password: cfg.TOPass,
+	}
+	loginUrl := fmt.Sprintf("%s%s", cfg.TOUrl, "/api/2.0/user/login")
+	buf := new(bytes.Buffer)
+	err = json.NewEncoder(buf).Encode(body)
+	config.ErrCheck(err)
+	req, _ := http.NewRequest("POST", loginUrl, buf)
+	jar, _ := cookiejar.New(nil)
+	client := &http.Client{Jar: jar, Transport: cfg.Transport}
+
+	log.Debugf("Posting to: %s", loginUrl)
+
+	res, err := client.Do(req)
+	config.ErrCheck(err)
+	defer config.Dclose(res.Body)
+	refreshUrl := fmt.Sprintf("%s%s", cfg.TOUrl, "/api/2.0/cdns/dnsseckeys/refresh")
+	resp, _ := http.NewRequest("GET", refreshUrl, buf)
+
+	log.Debugf("Get req to: %s", refreshUrl)
+
+	refresh, _ := client.Do(resp)

Review comment:
       Checks and handles the error. 




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [trafficcontrol] jpappa200 commented on a change in pull request #5122: Dnssec refresh

Posted by GitBox <gi...@apache.org>.
jpappa200 commented on a change in pull request #5122:
URL: https://github.com/apache/trafficcontrol/pull/5122#discussion_r513010913



##########
File path: traffic_ops/app/bin/checks/DnssecRefresh/config/config.go
##########
@@ -0,0 +1,153 @@
+package config
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import (
+	"crypto/tls"
+	"errors"
+	"fmt"
+	"github.com/apache/trafficcontrol/lib/go-log"
+	"github.com/pborman/getopt/v2"
+	"io"
+	"net/http"
+	"os"
+	"strings"
+)
+
+type Creds struct {
+	User     string `json:"u"`
+	Password string `json:"p"`
+}
+
+type Cfg struct {
+	LogLocationErr   string
+	LogLocationInfo  string
+	LogLocationWarn  string
+	LogLocationDebug string
+	TOInsecure       bool
+	TOUser           string
+	TOPass           string
+	TOUrl            string
+	Transport        *http.Transport
+}
+
+type ToResponse struct {
+	Response string `json:"response"`
+}
+
+func Dclose(c io.Closer) {
+	if err := c.Close(); err != nil {
+	}
+}
+
+func ErrCheck(err error) {
+	if err != nil {
+		log.Errorln(err)
+		os.Exit(1)
+	}
+}
+
+func (cfg Cfg) ErrorLog() log.LogLocation   { return log.LogLocation(cfg.LogLocationErr) }
+func (cfg Cfg) WarningLog() log.LogLocation { return log.LogLocation(cfg.LogLocationWarn) }
+func (cfg Cfg) InfoLog() log.LogLocation    { return log.LogLocation(cfg.LogLocationInfo) }
+func (cfg Cfg) DebugLog() log.LogLocation   { return log.LogLocation(cfg.LogLocationDebug) }
+func (cfg Cfg) EventLog() log.LogLocation   { return log.LogLocation(log.LogLocationNull) } // event logging not used.
+
+func GetCfg() (Cfg, error) {
+	var err error
+	logLocationDebugPtr := getopt.StringLong("log-location-debug", 'd', "", "Where to log debugs. May be a file path, stdout, stderr, or null, default ''")
+	logLocationErrorPtr := getopt.StringLong("log-location-error", 'e', "stderr", "Where to log errors. May be a file path, stdout, stderr, or null, default stderr")
+	logLocationInfoPtr := getopt.StringLong("log-location-info", 'i', "stderr", "Where to log info. May be a file path, stdout, stderr, or null, default stderr")
+	logLocationWarnPtr := getopt.StringLong("log-location-warning", 'w', "stderr", "Where to log warnings. May be a file path, stdout, stderr, or null, default stderr")
+	toInsecurePtr := getopt.BoolLong("traffic-ops-insecure", 'I', "[true | false] ignore certificate errors from Traffic Ops")
+	toUserPtr := getopt.StringLong("traffic-ops-user", 'u', "", "Traffic Ops username. Required.")
+	toPassPtr := getopt.StringLong("traffic-ops-passowrd", 'p', "", "Traffic Ops Password. Required")
+	toUrlPtr := getopt.StringLong("traffic-ops-url", 'U', "", "Traffic ops base URL. Required.")
+	helpPtr := getopt.BoolLong("help", 'h', "Print usage information and exit")
+	getopt.ParseV2()
+
+	logLocationDebug := *logLocationDebugPtr
+	logLocationError := *logLocationErrorPtr
+	logLocationInfo := *logLocationInfoPtr
+	logLocationWarn := *logLocationWarnPtr
+	toInsecure := *toInsecurePtr
+	toURL := *toUrlPtr
+	toUser := *toUserPtr
+	toPass := *toPassPtr
+	transport := &http.Transport{TLSClientConfig: &tls.Config{InsecureSkipVerify: toInsecure}}
+	help := *helpPtr
+
+	if help {
+		Usage()
+		return Cfg{}, nil
+	}
+
+	missingArgStr := "Missing required argument"
+	usageStr := "\nBasic usage: ToDnssecRefresh --traffic-ops-url=myurl --traffic-ops-user=myuser --traffic-ops-password=mypass"
+	if strings.TrimSpace(toURL) == "" {
+		return Cfg{}, errors.New(missingArgStr + " --traffic-ops-url" + usageStr)
+	}
+	if strings.TrimSpace(toUser) == "" {
+		return Cfg{}, errors.New(missingArgStr + " --traffic-ops-user" + usageStr)
+	}
+	if strings.TrimSpace(toPass) == "" {
+		return Cfg{}, errors.New(missingArgStr + " --traffic-ops-password" + usageStr)
+	}
+
+	cfg := Cfg{
+		LogLocationDebug: logLocationDebug,
+		LogLocationErr:   logLocationError,
+		LogLocationInfo:  logLocationInfo,
+		LogLocationWarn:  logLocationWarn,
+		TOInsecure:       toInsecure,
+		Transport:        transport,
+		TOUrl:            toURL,
+		TOUser:           toUser,
+		TOPass:           toPass,
+	}
+
+	if err = log.InitCfg(cfg); err != nil {
+		return Cfg{}, errors.New("Initializing loggers: " + err.Error() + "\n")
+	}
+
+	return cfg, nil
+}
+
+func PrintConfig(cfg Cfg) {
+	log.Debugf("TOUrl: %s\n", cfg.TOUrl)
+	log.Debugf("TOUser: %s\n", cfg.TOUser)
+	log.Debugf("TOPass: Pass len: %d\n", len(cfg.TOPass))
+	log.Debugf("TOInsecure: %t\n", cfg.TOInsecure)
+	log.Debugf("LogLocationDebug: %s\n", cfg.LogLocationDebug)
+	log.Debugf("LogLocationErr: %s\n", cfg.LogLocationErr)
+	log.Debugf("LogLocationInfo: %s\n", cfg.LogLocationInfo)
+	log.Debugf("LogLocationWarn: %s\n", cfg.LogLocationWarn)
+}
+
+func Usage() {
+	fmt.Println("\t  --log-location-debug=[value] | -d [value], Where to log debugs. May be a file path, stdout, stderr, or null, default stderr")

Review comment:
       Changed to raw string literal




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [trafficcontrol] jpappa200 commented on a change in pull request #5122: Dnssec refresh

Posted by GitBox <gi...@apache.org>.
jpappa200 commented on a change in pull request #5122:
URL: https://github.com/apache/trafficcontrol/pull/5122#discussion_r513005122



##########
File path: traffic_ops/app/bin/checks/DnssecRefresh/ToDnssecRefresh.go
##########
@@ -0,0 +1,71 @@
+package main
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import (
+	"bytes"
+	"encoding/json"
+	"fmt"
+	"github.com/apache/trafficcontrol/lib/go-log"
+	"github.com/apache/trafficcontrol/traffic_ops/app/bin/checks/DnssecRefresh/config"
+	"io/ioutil"
+	"net/http"
+	"net/http/cookiejar"
+	"os"
+)
+
+func main() {
+	cfg, err := config.GetCfg()
+	config.ErrCheck(err)
+	log.Debugln("Including DEBUG messages in output. Config is:")
+	config.PrintConfig(cfg) // only if DEBUG logging is set.
+	body := &config.Creds{
+		User:     cfg.TOUser,
+		Password: cfg.TOPass,
+	}
+	loginUrl := fmt.Sprintf("%s%s", cfg.TOUrl, "/api/2.0/user/login")
+	buf := new(bytes.Buffer)
+	err = json.NewEncoder(buf).Encode(body)
+	config.ErrCheck(err)
+	req, _ := http.NewRequest("POST", loginUrl, buf)

Review comment:
       Changed to use constant. 




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [trafficcontrol] jpappa200 commented on a change in pull request #5122: Dnssec refresh

Posted by GitBox <gi...@apache.org>.
jpappa200 commented on a change in pull request #5122:
URL: https://github.com/apache/trafficcontrol/pull/5122#discussion_r513009783



##########
File path: traffic_ops/app/bin/checks/DnssecRefresh/ToDnssecRefresh.go
##########
@@ -0,0 +1,71 @@
+package main
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import (
+	"bytes"
+	"encoding/json"
+	"fmt"
+	"github.com/apache/trafficcontrol/lib/go-log"
+	"github.com/apache/trafficcontrol/traffic_ops/app/bin/checks/DnssecRefresh/config"
+	"io/ioutil"
+	"net/http"
+	"net/http/cookiejar"
+	"os"
+)
+
+func main() {
+	cfg, err := config.GetCfg()
+	config.ErrCheck(err)
+	log.Debugln("Including DEBUG messages in output. Config is:")
+	config.PrintConfig(cfg) // only if DEBUG logging is set.
+	body := &config.Creds{
+		User:     cfg.TOUser,
+		Password: cfg.TOPass,
+	}
+	loginUrl := fmt.Sprintf("%s%s", cfg.TOUrl, "/api/2.0/user/login")
+	buf := new(bytes.Buffer)
+	err = json.NewEncoder(buf).Encode(body)
+	config.ErrCheck(err)
+	req, _ := http.NewRequest("POST", loginUrl, buf)
+	jar, _ := cookiejar.New(nil)
+	client := &http.Client{Jar: jar, Transport: cfg.Transport}
+
+	log.Debugf("Posting to: %s", loginUrl)
+
+	res, err := client.Do(req)
+	config.ErrCheck(err)
+	defer config.Dclose(res.Body)
+	refreshUrl := fmt.Sprintf("%s%s", cfg.TOUrl, "/api/2.0/cdns/dnsseckeys/refresh")
+	resp, _ := http.NewRequest("GET", refreshUrl, buf)
+
+	log.Debugf("Get req to: %s", refreshUrl)
+
+	refresh, _ := client.Do(resp)
+	respData, _ := ioutil.ReadAll(refresh.Body)

Review comment:
       These both check and handle the error now. 




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [trafficcontrol] jpappa200 commented on a change in pull request #5122: Dnssec refresh

Posted by GitBox <gi...@apache.org>.
jpappa200 commented on a change in pull request #5122:
URL: https://github.com/apache/trafficcontrol/pull/5122#discussion_r513011898



##########
File path: traffic_ops/app/bin/checks/DnssecRefresh/ToDnssecRefresh.go
##########
@@ -0,0 +1,71 @@
+package main
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import (
+	"bytes"
+	"encoding/json"
+	"fmt"
+	"github.com/apache/trafficcontrol/lib/go-log"
+	"github.com/apache/trafficcontrol/traffic_ops/app/bin/checks/DnssecRefresh/config"
+	"io/ioutil"
+	"net/http"
+	"net/http/cookiejar"
+	"os"
+)
+
+func main() {
+	cfg, err := config.GetCfg()
+	config.ErrCheck(err)
+	log.Debugln("Including DEBUG messages in output. Config is:")
+	config.PrintConfig(cfg) // only if DEBUG logging is set.
+	body := &config.Creds{
+		User:     cfg.TOUser,
+		Password: cfg.TOPass,
+	}
+	loginUrl := fmt.Sprintf("%s%s", cfg.TOUrl, "/api/2.0/user/login")
+	buf := new(bytes.Buffer)
+	err = json.NewEncoder(buf).Encode(body)
+	config.ErrCheck(err)
+	req, _ := http.NewRequest("POST", loginUrl, buf)
+	jar, _ := cookiejar.New(nil)
+	client := &http.Client{Jar: jar, Transport: cfg.Transport}
+
+	log.Debugf("Posting to: %s", loginUrl)
+
+	res, err := client.Do(req)
+	config.ErrCheck(err)
+	defer config.Dclose(res.Body)
+	refreshUrl := fmt.Sprintf("%s%s", cfg.TOUrl, "/api/2.0/cdns/dnsseckeys/refresh")
+	resp, _ := http.NewRequest("GET", refreshUrl, buf)
+
+	log.Debugf("Get req to: %s", refreshUrl)
+
+	refresh, _ := client.Do(resp)
+	respData, _ := ioutil.ReadAll(refresh.Body)
+	defer config.Dclose(refresh.Body)
+	if refresh.StatusCode != 200 {
+		log.Debugln(string(respData))
+		os.Exit(1)
+	}
+	var response config.ToResponse

Review comment:
       Changed as requested.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [trafficcontrol] jpappa200 commented on a change in pull request #5122: Dnssec refresh

Posted by GitBox <gi...@apache.org>.
jpappa200 commented on a change in pull request #5122:
URL: https://github.com/apache/trafficcontrol/pull/5122#discussion_r513004215



##########
File path: traffic_ops/app/bin/checks/DnssecRefresh/ToDnssecRefresh.go
##########
@@ -0,0 +1,71 @@
+package main
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import (
+	"bytes"
+	"encoding/json"
+	"fmt"
+	"github.com/apache/trafficcontrol/lib/go-log"
+	"github.com/apache/trafficcontrol/traffic_ops/app/bin/checks/DnssecRefresh/config"
+	"io/ioutil"
+	"net/http"
+	"net/http/cookiejar"
+	"os"
+)
+
+func main() {
+	cfg, err := config.GetCfg()
+	config.ErrCheck(err)
+	log.Debugln("Including DEBUG messages in output. Config is:")
+	config.PrintConfig(cfg) // only if DEBUG logging is set.
+	body := &config.Creds{
+		User:     cfg.TOUser,
+		Password: cfg.TOPass,
+	}
+	loginUrl := fmt.Sprintf("%s%s", cfg.TOUrl, "/api/2.0/user/login")
+	buf := new(bytes.Buffer)
+	err = json.NewEncoder(buf).Encode(body)
+	config.ErrCheck(err)
+	req, _ := http.NewRequest("POST", loginUrl, buf)
+	jar, _ := cookiejar.New(nil)
+	client := &http.Client{Jar: jar, Transport: cfg.Transport}
+
+	log.Debugf("Posting to: %s", loginUrl)
+
+	res, err := client.Do(req)
+	config.ErrCheck(err)
+	defer config.Dclose(res.Body)
+	refreshUrl := fmt.Sprintf("%s%s", cfg.TOUrl, "/api/2.0/cdns/dnsseckeys/refresh")
+	resp, _ := http.NewRequest("GET", refreshUrl, buf)
+
+	log.Debugf("Get req to: %s", refreshUrl)
+
+	refresh, _ := client.Do(resp)
+	respData, _ := ioutil.ReadAll(refresh.Body)
+	defer config.Dclose(refresh.Body)
+	if refresh.StatusCode != 200 {
+		log.Debugln(string(respData))

Review comment:
       Changed to `log.Errorln`




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [trafficcontrol] jpappa200 commented on a change in pull request #5122: Dnssec refresh

Posted by GitBox <gi...@apache.org>.
jpappa200 commented on a change in pull request #5122:
URL: https://github.com/apache/trafficcontrol/pull/5122#discussion_r513003712



##########
File path: traffic_ops/app/bin/checks/DnssecRefresh/ToDnssecRefresh.go
##########
@@ -0,0 +1,71 @@
+package main
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import (
+	"bytes"
+	"encoding/json"
+	"fmt"
+	"github.com/apache/trafficcontrol/lib/go-log"
+	"github.com/apache/trafficcontrol/traffic_ops/app/bin/checks/DnssecRefresh/config"
+	"io/ioutil"
+	"net/http"
+	"net/http/cookiejar"
+	"os"
+)
+
+func main() {
+	cfg, err := config.GetCfg()
+	config.ErrCheck(err)

Review comment:
       Moved code around so that logging is enabled sooner. now if you run with no arguments it logs the basic usage message to stdout. 




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [trafficcontrol] jpappa200 commented on a change in pull request #5122: Dnssec refresh

Posted by GitBox <gi...@apache.org>.
jpappa200 commented on a change in pull request #5122:
URL: https://github.com/apache/trafficcontrol/pull/5122#discussion_r513010674



##########
File path: traffic_ops/app/bin/checks/DnssecRefresh/ToDnssecRefresh.go
##########
@@ -0,0 +1,71 @@
+package main
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import (
+	"bytes"
+	"encoding/json"
+	"fmt"
+	"github.com/apache/trafficcontrol/lib/go-log"
+	"github.com/apache/trafficcontrol/traffic_ops/app/bin/checks/DnssecRefresh/config"
+	"io/ioutil"
+	"net/http"
+	"net/http/cookiejar"
+	"os"
+)
+
+func main() {
+	cfg, err := config.GetCfg()
+	config.ErrCheck(err)
+	log.Debugln("Including DEBUG messages in output. Config is:")
+	config.PrintConfig(cfg) // only if DEBUG logging is set.
+	body := &config.Creds{
+		User:     cfg.TOUser,
+		Password: cfg.TOPass,
+	}
+	loginUrl := fmt.Sprintf("%s%s", cfg.TOUrl, "/api/2.0/user/login")
+	buf := new(bytes.Buffer)

Review comment:
       I changed this as requested. 




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [trafficcontrol] rob05c commented on a change in pull request #5122: Dnssec refresh

Posted by GitBox <gi...@apache.org>.
rob05c commented on a change in pull request #5122:
URL: https://github.com/apache/trafficcontrol/pull/5122#discussion_r508886356



##########
File path: traffic_ops/app/bin/checks/DnssecRefresh/config/config.go
##########
@@ -0,0 +1,153 @@
+package config
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import (
+	"crypto/tls"
+	"errors"
+	"fmt"
+	"github.com/apache/trafficcontrol/lib/go-log"
+	"github.com/pborman/getopt/v2"
+	"io"
+	"net/http"
+	"os"
+	"strings"
+)
+
+type Creds struct {
+	User     string `json:"u"`
+	Password string `json:"p"`
+}
+
+type Cfg struct {
+	LogLocationErr   string
+	LogLocationInfo  string
+	LogLocationWarn  string
+	LogLocationDebug string
+	TOInsecure       bool
+	TOUser           string
+	TOPass           string
+	TOUrl            string
+	Transport        *http.Transport
+}
+
+type ToResponse struct {
+	Response string `json:"response"`
+}
+
+func Dclose(c io.Closer) {
+	if err := c.Close(); err != nil {
+	}
+}
+
+func ErrCheck(err error) {
+	if err != nil {
+		log.Errorln(err)
+		os.Exit(1)
+	}
+}
+
+func (cfg Cfg) ErrorLog() log.LogLocation   { return log.LogLocation(cfg.LogLocationErr) }
+func (cfg Cfg) WarningLog() log.LogLocation { return log.LogLocation(cfg.LogLocationWarn) }
+func (cfg Cfg) InfoLog() log.LogLocation    { return log.LogLocation(cfg.LogLocationInfo) }
+func (cfg Cfg) DebugLog() log.LogLocation   { return log.LogLocation(cfg.LogLocationDebug) }
+func (cfg Cfg) EventLog() log.LogLocation   { return log.LogLocation(log.LogLocationNull) } // event logging not used.
+
+func GetCfg() (Cfg, error) {
+	var err error
+	logLocationDebugPtr := getopt.StringLong("log-location-debug", 'd', "", "Where to log debugs. May be a file path, stdout, stderr, or null, default ''")
+	logLocationErrorPtr := getopt.StringLong("log-location-error", 'e', "stderr", "Where to log errors. May be a file path, stdout, stderr, or null, default stderr")
+	logLocationInfoPtr := getopt.StringLong("log-location-info", 'i', "stderr", "Where to log info. May be a file path, stdout, stderr, or null, default stderr")
+	logLocationWarnPtr := getopt.StringLong("log-location-warning", 'w', "stderr", "Where to log warnings. May be a file path, stdout, stderr, or null, default stderr")
+	toInsecurePtr := getopt.BoolLong("traffic-ops-insecure", 'I', "[true | false] ignore certificate errors from Traffic Ops")
+	toUserPtr := getopt.StringLong("traffic-ops-user", 'u', "", "Traffic Ops username. Required.")
+	toPassPtr := getopt.StringLong("traffic-ops-passowrd", 'p', "", "Traffic Ops Password. Required")
+	toUrlPtr := getopt.StringLong("traffic-ops-url", 'U', "", "Traffic ops base URL. Required.")
+	helpPtr := getopt.BoolLong("help", 'h', "Print usage information and exit")
+	getopt.ParseV2()
+
+	logLocationDebug := *logLocationDebugPtr
+	logLocationError := *logLocationErrorPtr
+	logLocationInfo := *logLocationInfoPtr
+	logLocationWarn := *logLocationWarnPtr
+	toInsecure := *toInsecurePtr
+	toURL := *toUrlPtr
+	toUser := *toUserPtr
+	toPass := *toPassPtr
+	transport := &http.Transport{TLSClientConfig: &tls.Config{InsecureSkipVerify: toInsecure}}
+	help := *helpPtr
+
+	if help {
+		Usage()
+		return Cfg{}, nil

Review comment:
       If I run `DnssecRefresh -h`, it prints the help, but then segfaults.
   
   Looks like this somehow needs to either convey to the caller that Help was called, and it should immediately return, or just `os.Exit(0)` right here, either would be fine.

##########
File path: traffic_ops/app/bin/checks/DnssecRefresh/ToDnssecRefresh.go
##########
@@ -0,0 +1,71 @@
+package main
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import (
+	"bytes"
+	"encoding/json"
+	"fmt"
+	"github.com/apache/trafficcontrol/lib/go-log"
+	"github.com/apache/trafficcontrol/traffic_ops/app/bin/checks/DnssecRefresh/config"
+	"io/ioutil"
+	"net/http"
+	"net/http/cookiejar"
+	"os"
+)
+
+func main() {
+	cfg, err := config.GetCfg()
+	config.ErrCheck(err)

Review comment:
       If you call `./DnssecRefresh` with no argument, it seems like this should print the no-argument messages below, but it doesn't, because `ErrCheck` writes to the log, but that doesn't exist.
   
   So `./DnssecRefresh` just returns an error code, with no message.
   
   Something (either here, or in `config`) should probably write to `stdout` that no Error log location exists.
   
   Since it's possible to tell the logger to not log anything with the string `null`, you could just default to stdout with 
   ```
   λ (cfg Cfg) ErrorLog() log.LogLocation   { 
     if stringUtils.TrimSpace(cfg.LogLocationErr) == "" {
       return log.LogLocation(log.LogLocationStdout) 
     }
     return log.LogLocation(cfg.LogLocationErr) 
   }
   ```

##########
File path: traffic_ops/app/bin/checks/DnssecRefresh/config/config.go
##########
@@ -0,0 +1,153 @@
+package config
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import (
+	"crypto/tls"
+	"errors"
+	"fmt"
+	"github.com/apache/trafficcontrol/lib/go-log"
+	"github.com/pborman/getopt/v2"
+	"io"
+	"net/http"
+	"os"
+	"strings"
+)
+
+type Creds struct {
+	User     string `json:"u"`
+	Password string `json:"p"`
+}
+
+type Cfg struct {
+	LogLocationErr   string
+	LogLocationInfo  string
+	LogLocationWarn  string
+	LogLocationDebug string
+	TOInsecure       bool
+	TOUser           string
+	TOPass           string
+	TOUrl            string
+	Transport        *http.Transport
+}
+
+type ToResponse struct {
+	Response string `json:"response"`
+}
+
+func Dclose(c io.Closer) {
+	if err := c.Close(); err != nil {

Review comment:
       Should this log the error? That'd be a reason to keep it (vs as above, `defer body.Close()`)

##########
File path: traffic_ops/app/bin/checks/DnssecRefresh/config/config.go
##########
@@ -0,0 +1,153 @@
+package config
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import (
+	"crypto/tls"
+	"errors"
+	"fmt"
+	"github.com/apache/trafficcontrol/lib/go-log"
+	"github.com/pborman/getopt/v2"
+	"io"
+	"net/http"
+	"os"
+	"strings"
+)
+
+type Creds struct {
+	User     string `json:"u"`
+	Password string `json:"p"`
+}
+
+type Cfg struct {
+	LogLocationErr   string
+	LogLocationInfo  string
+	LogLocationWarn  string
+	LogLocationDebug string
+	TOInsecure       bool
+	TOUser           string
+	TOPass           string
+	TOUrl            string
+	Transport        *http.Transport
+}
+
+type ToResponse struct {
+	Response string `json:"response"`
+}
+
+func Dclose(c io.Closer) {
+	if err := c.Close(); err != nil {
+	}
+}
+
+func ErrCheck(err error) {
+	if err != nil {
+		log.Errorln(err)
+		os.Exit(1)
+	}
+}
+
+func (cfg Cfg) ErrorLog() log.LogLocation   { return log.LogLocation(cfg.LogLocationErr) }
+func (cfg Cfg) WarningLog() log.LogLocation { return log.LogLocation(cfg.LogLocationWarn) }
+func (cfg Cfg) InfoLog() log.LogLocation    { return log.LogLocation(cfg.LogLocationInfo) }
+func (cfg Cfg) DebugLog() log.LogLocation   { return log.LogLocation(cfg.LogLocationDebug) }
+func (cfg Cfg) EventLog() log.LogLocation   { return log.LogLocation(log.LogLocationNull) } // event logging not used.
+
+func GetCfg() (Cfg, error) {
+	var err error
+	logLocationDebugPtr := getopt.StringLong("log-location-debug", 'd', "", "Where to log debugs. May be a file path, stdout, stderr, or null, default ''")
+	logLocationErrorPtr := getopt.StringLong("log-location-error", 'e', "stderr", "Where to log errors. May be a file path, stdout, stderr, or null, default stderr")
+	logLocationInfoPtr := getopt.StringLong("log-location-info", 'i', "stderr", "Where to log info. May be a file path, stdout, stderr, or null, default stderr")
+	logLocationWarnPtr := getopt.StringLong("log-location-warning", 'w', "stderr", "Where to log warnings. May be a file path, stdout, stderr, or null, default stderr")
+	toInsecurePtr := getopt.BoolLong("traffic-ops-insecure", 'I', "[true | false] ignore certificate errors from Traffic Ops")
+	toUserPtr := getopt.StringLong("traffic-ops-user", 'u', "", "Traffic Ops username. Required.")
+	toPassPtr := getopt.StringLong("traffic-ops-passowrd", 'p', "", "Traffic Ops Password. Required")

Review comment:
       Typo, `traffic-ops-password`

##########
File path: traffic_ops/app/bin/checks/DnssecRefresh/ToDnssecRefresh.go
##########
@@ -0,0 +1,71 @@
+package main
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import (
+	"bytes"
+	"encoding/json"
+	"fmt"
+	"github.com/apache/trafficcontrol/lib/go-log"
+	"github.com/apache/trafficcontrol/traffic_ops/app/bin/checks/DnssecRefresh/config"
+	"io/ioutil"
+	"net/http"
+	"net/http/cookiejar"
+	"os"
+)
+
+func main() {
+	cfg, err := config.GetCfg()
+	config.ErrCheck(err)
+	log.Debugln("Including DEBUG messages in output. Config is:")
+	config.PrintConfig(cfg) // only if DEBUG logging is set.
+	body := &config.Creds{
+		User:     cfg.TOUser,
+		Password: cfg.TOPass,
+	}
+	loginUrl := fmt.Sprintf("%s%s", cfg.TOUrl, "/api/2.0/user/login")
+	buf := new(bytes.Buffer)
+	err = json.NewEncoder(buf).Encode(body)
+	config.ErrCheck(err)
+	req, _ := http.NewRequest("POST", loginUrl, buf)
+	jar, _ := cookiejar.New(nil)
+	client := &http.Client{Jar: jar, Transport: cfg.Transport}
+
+	log.Debugf("Posting to: %s", loginUrl)
+
+	res, err := client.Do(req)
+	config.ErrCheck(err)
+	defer config.Dclose(res.Body)
+	refreshUrl := fmt.Sprintf("%s%s", cfg.TOUrl, "/api/2.0/cdns/dnsseckeys/refresh")
+	resp, _ := http.NewRequest("GET", refreshUrl, buf)
+
+	log.Debugf("Get req to: %s", refreshUrl)
+
+	refresh, _ := client.Do(resp)
+	respData, _ := ioutil.ReadAll(refresh.Body)
+	defer config.Dclose(refresh.Body)
+	if refresh.StatusCode != 200 {
+		log.Debugln(string(respData))

Review comment:
       I think this should be a `log.Errorln`. This happened to me from a bad password, and I didn't have debug logging on, so I just got no output with an error code.

##########
File path: traffic_ops/app/bin/checks/DnssecRefresh/ToDnssecRefresh.go
##########
@@ -0,0 +1,71 @@
+package main
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import (
+	"bytes"
+	"encoding/json"
+	"fmt"
+	"github.com/apache/trafficcontrol/lib/go-log"
+	"github.com/apache/trafficcontrol/traffic_ops/app/bin/checks/DnssecRefresh/config"
+	"io/ioutil"
+	"net/http"
+	"net/http/cookiejar"
+	"os"
+)
+
+func main() {
+	cfg, err := config.GetCfg()
+	config.ErrCheck(err)
+	log.Debugln("Including DEBUG messages in output. Config is:")
+	config.PrintConfig(cfg) // only if DEBUG logging is set.
+	body := &config.Creds{
+		User:     cfg.TOUser,
+		Password: cfg.TOPass,
+	}
+	loginUrl := fmt.Sprintf("%s%s", cfg.TOUrl, "/api/2.0/user/login")
+	buf := new(bytes.Buffer)
+	err = json.NewEncoder(buf).Encode(body)
+	config.ErrCheck(err)
+	req, _ := http.NewRequest("POST", loginUrl, buf)

Review comment:
       Nitpick: `"POST"` -> `http.MethodPost`

##########
File path: traffic_ops/app/bin/checks/DnssecRefresh/ToDnssecRefresh.go
##########
@@ -0,0 +1,71 @@
+package main
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import (
+	"bytes"
+	"encoding/json"
+	"fmt"
+	"github.com/apache/trafficcontrol/lib/go-log"
+	"github.com/apache/trafficcontrol/traffic_ops/app/bin/checks/DnssecRefresh/config"
+	"io/ioutil"
+	"net/http"
+	"net/http/cookiejar"
+	"os"
+)
+
+func main() {
+	cfg, err := config.GetCfg()
+	config.ErrCheck(err)
+	log.Debugln("Including DEBUG messages in output. Config is:")
+	config.PrintConfig(cfg) // only if DEBUG logging is set.
+	body := &config.Creds{
+		User:     cfg.TOUser,
+		Password: cfg.TOPass,
+	}
+	loginUrl := fmt.Sprintf("%s%s", cfg.TOUrl, "/api/2.0/user/login")
+	buf := new(bytes.Buffer)
+	err = json.NewEncoder(buf).Encode(body)
+	config.ErrCheck(err)
+	req, _ := http.NewRequest("POST", loginUrl, buf)
+	jar, _ := cookiejar.New(nil)
+	client := &http.Client{Jar: jar, Transport: cfg.Transport}
+
+	log.Debugf("Posting to: %s", loginUrl)
+
+	res, err := client.Do(req)
+	config.ErrCheck(err)
+	defer config.Dclose(res.Body)
+	refreshUrl := fmt.Sprintf("%s%s", cfg.TOUrl, "/api/2.0/cdns/dnsseckeys/refresh")
+	resp, _ := http.NewRequest("GET", refreshUrl, buf)
+
+	log.Debugf("Get req to: %s", refreshUrl)
+
+	refresh, _ := client.Do(resp)
+	respData, _ := ioutil.ReadAll(refresh.Body)
+	defer config.Dclose(refresh.Body)

Review comment:
       Not sure what the purpose of `Dclose` is? This could just be `defer refresh.Body.Close()`

##########
File path: traffic_ops/app/bin/checks/DnssecRefresh/ToDnssecRefresh.go
##########
@@ -0,0 +1,71 @@
+package main
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import (
+	"bytes"
+	"encoding/json"
+	"fmt"
+	"github.com/apache/trafficcontrol/lib/go-log"
+	"github.com/apache/trafficcontrol/traffic_ops/app/bin/checks/DnssecRefresh/config"
+	"io/ioutil"
+	"net/http"
+	"net/http/cookiejar"
+	"os"
+)
+
+func main() {
+	cfg, err := config.GetCfg()
+	config.ErrCheck(err)
+	log.Debugln("Including DEBUG messages in output. Config is:")
+	config.PrintConfig(cfg) // only if DEBUG logging is set.
+	body := &config.Creds{
+		User:     cfg.TOUser,
+		Password: cfg.TOPass,
+	}
+	loginUrl := fmt.Sprintf("%s%s", cfg.TOUrl, "/api/2.0/user/login")
+	buf := new(bytes.Buffer)
+	err = json.NewEncoder(buf).Encode(body)
+	config.ErrCheck(err)
+	req, _ := http.NewRequest("POST", loginUrl, buf)
+	jar, _ := cookiejar.New(nil)
+	client := &http.Client{Jar: jar, Transport: cfg.Transport}
+
+	log.Debugf("Posting to: %s", loginUrl)
+
+	res, err := client.Do(req)
+	config.ErrCheck(err)
+	defer config.Dclose(res.Body)
+	refreshUrl := fmt.Sprintf("%s%s", cfg.TOUrl, "/api/2.0/cdns/dnsseckeys/refresh")
+	resp, _ := http.NewRequest("GET", refreshUrl, buf)
+
+	log.Debugf("Get req to: %s", refreshUrl)
+
+	refresh, _ := client.Do(resp)

Review comment:
       This needs to check and handle the error

##########
File path: traffic_ops/app/bin/checks/DnssecRefresh/ToDnssecRefresh.go
##########
@@ -0,0 +1,71 @@
+package main
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import (
+	"bytes"
+	"encoding/json"
+	"fmt"
+	"github.com/apache/trafficcontrol/lib/go-log"

Review comment:
       Nitpick: we usually like to separate standard library packages, internal ATC packages, and external packages by blank lines, just to make it easier to read

##########
File path: traffic_ops/app/bin/checks/DnssecRefresh/ToDnssecRefresh.go
##########
@@ -0,0 +1,71 @@
+package main
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import (
+	"bytes"
+	"encoding/json"
+	"fmt"
+	"github.com/apache/trafficcontrol/lib/go-log"
+	"github.com/apache/trafficcontrol/traffic_ops/app/bin/checks/DnssecRefresh/config"
+	"io/ioutil"
+	"net/http"
+	"net/http/cookiejar"
+	"os"
+)
+
+func main() {
+	cfg, err := config.GetCfg()
+	config.ErrCheck(err)
+	log.Debugln("Including DEBUG messages in output. Config is:")
+	config.PrintConfig(cfg) // only if DEBUG logging is set.
+	body := &config.Creds{
+		User:     cfg.TOUser,
+		Password: cfg.TOPass,
+	}
+	loginUrl := fmt.Sprintf("%s%s", cfg.TOUrl, "/api/2.0/user/login")
+	buf := new(bytes.Buffer)
+	err = json.NewEncoder(buf).Encode(body)
+	config.ErrCheck(err)
+	req, _ := http.NewRequest("POST", loginUrl, buf)
+	jar, _ := cookiejar.New(nil)
+	client := &http.Client{Jar: jar, Transport: cfg.Transport}
+
+	log.Debugf("Posting to: %s", loginUrl)
+
+	res, err := client.Do(req)
+	config.ErrCheck(err)
+	defer config.Dclose(res.Body)
+	refreshUrl := fmt.Sprintf("%s%s", cfg.TOUrl, "/api/2.0/cdns/dnsseckeys/refresh")
+	resp, _ := http.NewRequest("GET", refreshUrl, buf)
+
+	log.Debugf("Get req to: %s", refreshUrl)
+
+	refresh, _ := client.Do(resp)
+	respData, _ := ioutil.ReadAll(refresh.Body)

Review comment:
       Needs to check and handle the error

##########
File path: traffic_ops/app/bin/checks/DnssecRefresh/ToDnssecRefresh.go
##########
@@ -0,0 +1,71 @@
+package main
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import (
+	"bytes"
+	"encoding/json"
+	"fmt"
+	"github.com/apache/trafficcontrol/lib/go-log"
+	"github.com/apache/trafficcontrol/traffic_ops/app/bin/checks/DnssecRefresh/config"
+	"io/ioutil"
+	"net/http"
+	"net/http/cookiejar"
+	"os"
+)
+
+func main() {
+	cfg, err := config.GetCfg()
+	config.ErrCheck(err)
+	log.Debugln("Including DEBUG messages in output. Config is:")
+	config.PrintConfig(cfg) // only if DEBUG logging is set.
+	body := &config.Creds{
+		User:     cfg.TOUser,
+		Password: cfg.TOPass,
+	}
+	loginUrl := fmt.Sprintf("%s%s", cfg.TOUrl, "/api/2.0/user/login")
+	buf := new(bytes.Buffer)
+	err = json.NewEncoder(buf).Encode(body)
+	config.ErrCheck(err)
+	req, _ := http.NewRequest("POST", loginUrl, buf)
+	jar, _ := cookiejar.New(nil)

Review comment:
       Needs to check & handle the error

##########
File path: traffic_ops/app/bin/checks/DnssecRefresh/ToDnssecRefresh.go
##########
@@ -0,0 +1,71 @@
+package main
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import (
+	"bytes"
+	"encoding/json"
+	"fmt"
+	"github.com/apache/trafficcontrol/lib/go-log"
+	"github.com/apache/trafficcontrol/traffic_ops/app/bin/checks/DnssecRefresh/config"
+	"io/ioutil"
+	"net/http"
+	"net/http/cookiejar"
+	"os"
+)
+
+func main() {
+	cfg, err := config.GetCfg()
+	config.ErrCheck(err)
+	log.Debugln("Including DEBUG messages in output. Config is:")
+	config.PrintConfig(cfg) // only if DEBUG logging is set.
+	body := &config.Creds{
+		User:     cfg.TOUser,
+		Password: cfg.TOPass,
+	}
+	loginUrl := fmt.Sprintf("%s%s", cfg.TOUrl, "/api/2.0/user/login")
+	buf := new(bytes.Buffer)

Review comment:
       Nitpick: it's more idiomatic avoid `new` in Go unless there's no other way. 
   This can do the same thing with `buf := &bytes.Buffer{}`

##########
File path: traffic_ops/app/bin/checks/DnssecRefresh/ToDnssecRefresh.go
##########
@@ -0,0 +1,71 @@
+package main
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import (
+	"bytes"
+	"encoding/json"
+	"fmt"
+	"github.com/apache/trafficcontrol/lib/go-log"
+	"github.com/apache/trafficcontrol/traffic_ops/app/bin/checks/DnssecRefresh/config"
+	"io/ioutil"
+	"net/http"
+	"net/http/cookiejar"
+	"os"
+)
+
+func main() {
+	cfg, err := config.GetCfg()
+	config.ErrCheck(err)
+	log.Debugln("Including DEBUG messages in output. Config is:")
+	config.PrintConfig(cfg) // only if DEBUG logging is set.
+	body := &config.Creds{
+		User:     cfg.TOUser,
+		Password: cfg.TOPass,
+	}
+	loginUrl := fmt.Sprintf("%s%s", cfg.TOUrl, "/api/2.0/user/login")
+	buf := new(bytes.Buffer)
+	err = json.NewEncoder(buf).Encode(body)
+	config.ErrCheck(err)
+	req, _ := http.NewRequest("POST", loginUrl, buf)

Review comment:
       Needs to check & handle the error

##########
File path: traffic_ops/app/bin/checks/DnssecRefresh/ToDnssecRefresh.go
##########
@@ -0,0 +1,71 @@
+package main
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import (
+	"bytes"
+	"encoding/json"
+	"fmt"
+	"github.com/apache/trafficcontrol/lib/go-log"
+	"github.com/apache/trafficcontrol/traffic_ops/app/bin/checks/DnssecRefresh/config"
+	"io/ioutil"
+	"net/http"
+	"net/http/cookiejar"
+	"os"
+)
+
+func main() {
+	cfg, err := config.GetCfg()
+	config.ErrCheck(err)
+	log.Debugln("Including DEBUG messages in output. Config is:")
+	config.PrintConfig(cfg) // only if DEBUG logging is set.
+	body := &config.Creds{
+		User:     cfg.TOUser,
+		Password: cfg.TOPass,
+	}
+	loginUrl := fmt.Sprintf("%s%s", cfg.TOUrl, "/api/2.0/user/login")

Review comment:
       Nitpick: might be easier to read as string concatenation, 
   ```
   loginUrl := cfg.TOUrl + `/api/2.0/user/login`
   ```

##########
File path: traffic_ops/app/bin/checks/DnssecRefresh/config/config.go
##########
@@ -0,0 +1,153 @@
+package config
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import (
+	"crypto/tls"
+	"errors"
+	"fmt"
+	"github.com/apache/trafficcontrol/lib/go-log"
+	"github.com/pborman/getopt/v2"
+	"io"
+	"net/http"
+	"os"
+	"strings"
+)
+
+type Creds struct {
+	User     string `json:"u"`
+	Password string `json:"p"`
+}
+
+type Cfg struct {
+	LogLocationErr   string
+	LogLocationInfo  string
+	LogLocationWarn  string
+	LogLocationDebug string
+	TOInsecure       bool
+	TOUser           string
+	TOPass           string
+	TOUrl            string
+	Transport        *http.Transport
+}
+
+type ToResponse struct {
+	Response string `json:"response"`
+}
+
+func Dclose(c io.Closer) {
+	if err := c.Close(); err != nil {
+	}
+}
+
+func ErrCheck(err error) {
+	if err != nil {
+		log.Errorln(err)
+		os.Exit(1)
+	}
+}
+
+func (cfg Cfg) ErrorLog() log.LogLocation   { return log.LogLocation(cfg.LogLocationErr) }
+func (cfg Cfg) WarningLog() log.LogLocation { return log.LogLocation(cfg.LogLocationWarn) }
+func (cfg Cfg) InfoLog() log.LogLocation    { return log.LogLocation(cfg.LogLocationInfo) }
+func (cfg Cfg) DebugLog() log.LogLocation   { return log.LogLocation(cfg.LogLocationDebug) }
+func (cfg Cfg) EventLog() log.LogLocation   { return log.LogLocation(log.LogLocationNull) } // event logging not used.
+
+func GetCfg() (Cfg, error) {
+	var err error
+	logLocationDebugPtr := getopt.StringLong("log-location-debug", 'd', "", "Where to log debugs. May be a file path, stdout, stderr, or null, default ''")
+	logLocationErrorPtr := getopt.StringLong("log-location-error", 'e', "stderr", "Where to log errors. May be a file path, stdout, stderr, or null, default stderr")
+	logLocationInfoPtr := getopt.StringLong("log-location-info", 'i', "stderr", "Where to log info. May be a file path, stdout, stderr, or null, default stderr")
+	logLocationWarnPtr := getopt.StringLong("log-location-warning", 'w', "stderr", "Where to log warnings. May be a file path, stdout, stderr, or null, default stderr")
+	toInsecurePtr := getopt.BoolLong("traffic-ops-insecure", 'I', "[true | false] ignore certificate errors from Traffic Ops")
+	toUserPtr := getopt.StringLong("traffic-ops-user", 'u', "", "Traffic Ops username. Required.")
+	toPassPtr := getopt.StringLong("traffic-ops-passowrd", 'p', "", "Traffic Ops Password. Required")
+	toUrlPtr := getopt.StringLong("traffic-ops-url", 'U', "", "Traffic ops base URL. Required.")
+	helpPtr := getopt.BoolLong("help", 'h', "Print usage information and exit")
+	getopt.ParseV2()
+
+	logLocationDebug := *logLocationDebugPtr
+	logLocationError := *logLocationErrorPtr
+	logLocationInfo := *logLocationInfoPtr
+	logLocationWarn := *logLocationWarnPtr
+	toInsecure := *toInsecurePtr
+	toURL := *toUrlPtr
+	toUser := *toUserPtr
+	toPass := *toPassPtr
+	transport := &http.Transport{TLSClientConfig: &tls.Config{InsecureSkipVerify: toInsecure}}
+	help := *helpPtr
+
+	if help {
+		Usage()
+		return Cfg{}, nil
+	}
+
+	missingArgStr := "Missing required argument"
+	usageStr := "\nBasic usage: ToDnssecRefresh --traffic-ops-url=myurl --traffic-ops-user=myuser --traffic-ops-password=mypass"
+	if strings.TrimSpace(toURL) == "" {
+		return Cfg{}, errors.New(missingArgStr + " --traffic-ops-url" + usageStr)
+	}
+	if strings.TrimSpace(toUser) == "" {
+		return Cfg{}, errors.New(missingArgStr + " --traffic-ops-user" + usageStr)
+	}
+	if strings.TrimSpace(toPass) == "" {
+		return Cfg{}, errors.New(missingArgStr + " --traffic-ops-password" + usageStr)
+	}
+
+	cfg := Cfg{
+		LogLocationDebug: logLocationDebug,
+		LogLocationErr:   logLocationError,
+		LogLocationInfo:  logLocationInfo,
+		LogLocationWarn:  logLocationWarn,
+		TOInsecure:       toInsecure,
+		Transport:        transport,
+		TOUrl:            toURL,
+		TOUser:           toUser,
+		TOPass:           toPass,
+	}
+
+	if err = log.InitCfg(cfg); err != nil {
+		return Cfg{}, errors.New("Initializing loggers: " + err.Error() + "\n")
+	}
+
+	return cfg, nil
+}
+
+func PrintConfig(cfg Cfg) {
+	log.Debugf("TOUrl: %s\n", cfg.TOUrl)
+	log.Debugf("TOUser: %s\n", cfg.TOUser)
+	log.Debugf("TOPass: Pass len: %d\n", len(cfg.TOPass))
+	log.Debugf("TOInsecure: %t\n", cfg.TOInsecure)
+	log.Debugf("LogLocationDebug: %s\n", cfg.LogLocationDebug)
+	log.Debugf("LogLocationErr: %s\n", cfg.LogLocationErr)
+	log.Debugf("LogLocationInfo: %s\n", cfg.LogLocationInfo)
+	log.Debugf("LogLocationWarn: %s\n", cfg.LogLocationWarn)
+}
+
+func Usage() {
+	fmt.Println("\t  --log-location-debug=[value] | -d [value], Where to log debugs. May be a file path, stdout, stderr, or null, default stderr")

Review comment:
       Nitpick: this might be easier to read as a raw string literal:
   ```go
   usageStr := `	--log-location-debug=[value] | -d [value], Where to log debugs. May be a file path, stdout, stderr, or null, default stderr
   	--log-location-error=[value] | -e [value], Where to log errors. May be a file path, stdout, stderr, or null, default stderr
   	--log-location-info=[value] | -i [value], Where to log info. May be a file path, stdout, stderr, or null, default stderr
   	--log-location-warning=[value] | -w [value], Where to log warnings. May be a file path, stdout, stderr, or null, default stderr
   	--traffic-ops-url=[url] | -u [url], Traffic Ops URL. Must be the full URL, including the scheme. Required."
   	--traffic-ops-user=[username] | -U [username], Traffic Ops username. Required."
   	--traffic-ops-password=[password] | -P [password], Traffic Ops password. Required.
   	--help | -h, Print usage information and exit`
   	fmt.Println(usageStr)
   ```

##########
File path: traffic_ops/app/bin/checks/DnssecRefresh/ToDnssecRefresh.go
##########
@@ -0,0 +1,71 @@
+package main
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import (
+	"bytes"
+	"encoding/json"
+	"fmt"
+	"github.com/apache/trafficcontrol/lib/go-log"
+	"github.com/apache/trafficcontrol/traffic_ops/app/bin/checks/DnssecRefresh/config"
+	"io/ioutil"
+	"net/http"
+	"net/http/cookiejar"
+	"os"
+)
+
+func main() {
+	cfg, err := config.GetCfg()
+	config.ErrCheck(err)
+	log.Debugln("Including DEBUG messages in output. Config is:")
+	config.PrintConfig(cfg) // only if DEBUG logging is set.
+	body := &config.Creds{
+		User:     cfg.TOUser,
+		Password: cfg.TOPass,
+	}
+	loginUrl := fmt.Sprintf("%s%s", cfg.TOUrl, "/api/2.0/user/login")
+	buf := new(bytes.Buffer)
+	err = json.NewEncoder(buf).Encode(body)
+	config.ErrCheck(err)
+	req, _ := http.NewRequest("POST", loginUrl, buf)
+	jar, _ := cookiejar.New(nil)
+	client := &http.Client{Jar: jar, Transport: cfg.Transport}
+
+	log.Debugf("Posting to: %s", loginUrl)
+
+	res, err := client.Do(req)
+	config.ErrCheck(err)
+	defer config.Dclose(res.Body)
+	refreshUrl := fmt.Sprintf("%s%s", cfg.TOUrl, "/api/2.0/cdns/dnsseckeys/refresh")
+	resp, _ := http.NewRequest("GET", refreshUrl, buf)

Review comment:
       Needs to check & handle the error

##########
File path: traffic_ops/app/bin/checks/DnssecRefresh/ToDnssecRefresh.go
##########
@@ -0,0 +1,71 @@
+package main
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import (
+	"bytes"
+	"encoding/json"
+	"fmt"
+	"github.com/apache/trafficcontrol/lib/go-log"
+	"github.com/apache/trafficcontrol/traffic_ops/app/bin/checks/DnssecRefresh/config"
+	"io/ioutil"
+	"net/http"
+	"net/http/cookiejar"
+	"os"
+)
+
+func main() {
+	cfg, err := config.GetCfg()
+	config.ErrCheck(err)
+	log.Debugln("Including DEBUG messages in output. Config is:")
+	config.PrintConfig(cfg) // only if DEBUG logging is set.
+	body := &config.Creds{
+		User:     cfg.TOUser,
+		Password: cfg.TOPass,
+	}
+	loginUrl := fmt.Sprintf("%s%s", cfg.TOUrl, "/api/2.0/user/login")
+	buf := new(bytes.Buffer)
+	err = json.NewEncoder(buf).Encode(body)
+	config.ErrCheck(err)
+	req, _ := http.NewRequest("POST", loginUrl, buf)
+	jar, _ := cookiejar.New(nil)
+	client := &http.Client{Jar: jar, Transport: cfg.Transport}
+
+	log.Debugf("Posting to: %s", loginUrl)
+
+	res, err := client.Do(req)
+	config.ErrCheck(err)
+	defer config.Dclose(res.Body)
+	refreshUrl := fmt.Sprintf("%s%s", cfg.TOUrl, "/api/2.0/cdns/dnsseckeys/refresh")
+	resp, _ := http.NewRequest("GET", refreshUrl, buf)
+
+	log.Debugf("Get req to: %s", refreshUrl)
+
+	refresh, _ := client.Do(resp)
+	respData, _ := ioutil.ReadAll(refresh.Body)
+	defer config.Dclose(refresh.Body)
+	if refresh.StatusCode != 200 {
+		log.Debugln(string(respData))
+		os.Exit(1)
+	}
+	var response config.ToResponse

Review comment:
       Nitpick: Personally, I prefer to always use `:=` to declare variables, just so all variables have the same syntax, and also so it's obvious what the value is, `response := config.ToResponse{}`.
   But that's not a universal idiom, so feel free to ignore if you don't agree.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [trafficcontrol] jpappa200 commented on a change in pull request #5122: Dnssec refresh

Posted by GitBox <gi...@apache.org>.
jpappa200 commented on a change in pull request #5122:
URL: https://github.com/apache/trafficcontrol/pull/5122#discussion_r513011613



##########
File path: traffic_ops/app/bin/checks/DnssecRefresh/ToDnssecRefresh.go
##########
@@ -0,0 +1,71 @@
+package main
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import (
+	"bytes"
+	"encoding/json"
+	"fmt"
+	"github.com/apache/trafficcontrol/lib/go-log"
+	"github.com/apache/trafficcontrol/traffic_ops/app/bin/checks/DnssecRefresh/config"
+	"io/ioutil"
+	"net/http"
+	"net/http/cookiejar"
+	"os"
+)
+
+func main() {
+	cfg, err := config.GetCfg()
+	config.ErrCheck(err)
+	log.Debugln("Including DEBUG messages in output. Config is:")
+	config.PrintConfig(cfg) // only if DEBUG logging is set.
+	body := &config.Creds{
+		User:     cfg.TOUser,
+		Password: cfg.TOPass,
+	}
+	loginUrl := fmt.Sprintf("%s%s", cfg.TOUrl, "/api/2.0/user/login")

Review comment:
       changed to string concatenation. 




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org