ocket8888 commented on a change in pull request #4379: Rewrite isos to Golang
URL: https://github.com/apache/trafficcontrol/pull/4379#discussion_r382761910
 
 

 ##########
 File path: traffic_ops/traffic_ops_golang/iso/iso.go
 ##########
 @@ -0,0 +1,368 @@
+// Package iso provides support for generating ISO images.
+package iso
+
+/*
+ * 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 (
+       "encoding/json"
+       "errors"
+       "fmt"
+       "net"
+       "net/http"
+       "os/exec"
+       "path/filepath"
+       "strings"
+
+       "github.com/apache/trafficcontrol/lib/go-log"
+       "github.com/apache/trafficcontrol/lib/go-rfc"
+       "github.com/apache/trafficcontrol/lib/go-tc"
+       "github.com/apache/trafficcontrol/lib/go-util"
+       "github.com/apache/trafficcontrol/traffic_ops/traffic_ops_golang/api"
+       "github.com/apache/trafficcontrol/traffic_ops/traffic_ops_golang/auth"
+       "github.com/jmoiron/sqlx"
+)
+
+// Various directories and filenames related to ISO generation.
+const (
+       cfgDefaultDir   = "/var/www/files"  // Default directory containing 
config file
+       cfgFilename     = "osversions.json" // The JSON config file containing 
mapping of OS names to directories
+       cfgFilenamePerl = "osversions.cfg"  // Config file name in the Perl 
version
+
+       // This is the directory name inside each OS directory where
+       // configuration files for kickstart scripts are placed.
+       ksCfgDir = "ks_scripts"
+
+       // Configuration files that are generated inside the ks_scripts 
directory.
+       ksCfgNetwork     = "network.cfg"
+       ksCfgMgmtNetwork = "mgmt_network.cfg"
+       ksCfgPassword    = "password.cfg"
+       ksCfgDisk        = "disk.cfg"
+       ksStateOut       = "state.out"
+
+       ksAltCommand = "generate" // Optional executable that is invoked 
instead of mkisofs
+)
+
+// Various database columns and values.
+const (
+       ksFilesParamName       = "kickstart.files.location"
+       ksFilesParamConfigFile = "mkisofs"
+)
+
+// Various HTTP-related values.
+const (
+       httpHeaderContentDisposition = "Content-Disposition"
+       httpHeaderContentType        = "Content-Type"
+       httpHeaderContentDownload    = "application/download"
 
 Review comment:
   The "Content-Type" header is already a defined constant at 
`github.com/apache/trafficcontrol/lib/go-rfc.ContentType` - I'd suggest that 
"Content-Disposition" be similarly defined.
   
   Also, "application/download" isn't a MIME-Type recognized by [IANA's MIME 
registry](https://www.iana.org/assignments/media-types/media-types.xhtml). This 
is just binary data, so probably "application/octet-stream" is appropriate. 
Which I'd suggest be defined alongside 
`github.com/apache/trafficcontrol/lib/go-rfc.ApplicationJSON` (and/or 
`github.com/apache/trafficcontrol/lib/go-rfc.MIME_JSON`).

----------------------------------------------------------------
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:
[email protected]


With regards,
Apache Git Services

Reply via email to