Merge pull request #135 from navi-infra/INFRA-2175
INFRA-2175| Saqib | Fix lint errors
This commit is contained in:
7
main.go
7
main.go
@@ -67,7 +67,7 @@ func parseManifest(manifestPath string, tfActions *Actions) (*Manifest, error) {
|
||||
}
|
||||
|
||||
if manifest.ExtraResources.Workspace == "" {
|
||||
var workspace = ""
|
||||
var workspace string
|
||||
if manifest.Cluster != "" {
|
||||
workspace = manifest.Cluster
|
||||
log.Printf("Got workspace from manifest.cluster: %v", workspace)
|
||||
@@ -282,5 +282,8 @@ func main() {
|
||||
},
|
||||
}
|
||||
|
||||
app.Run(os.Args)
|
||||
err := app.Run(os.Args)
|
||||
if err != nil {
|
||||
log.Fatalf("\nErr: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,8 +26,6 @@ const documentDbTfPath = "document-db-tf"
|
||||
|
||||
var manifestFiles = [2]string{"sample_infra_manifest", "sample_infra_manifest_2"}
|
||||
|
||||
var testActions Actions
|
||||
|
||||
func textDiff(text1, text2 string) string {
|
||||
dmp := diffmatchpatch.New()
|
||||
diffs := dmp.DiffMain(text1, text2, false)
|
||||
@@ -72,7 +70,7 @@ func compareResourceWithOutput(resouceDir string, resource string, manifestFileN
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if bytes.Compare(expectedOutput, actualOutput) != 0 {
|
||||
if !bytes.Equal(expectedOutput, actualOutput) {
|
||||
return fmt.Errorf("Mismatch for %s, diff: %s\n", path, textDiff(string(actualOutput), string(expectedOutput)))
|
||||
}
|
||||
return nil
|
||||
@@ -103,7 +101,7 @@ func TestBinData_CompareWithTemplates(t *testing.T) {
|
||||
t.Error(err)
|
||||
}
|
||||
|
||||
if bytes.Compare(actualTemplate, binDataTemplate) != 0 {
|
||||
if !bytes.Equal(actualTemplate, binDataTemplate) {
|
||||
t.Errorf("Found outdated bindata for %s", path)
|
||||
}
|
||||
return nil
|
||||
|
||||
@@ -59,7 +59,11 @@ func provisionAllResource(manifest *Manifest) error {
|
||||
func checkResourceExists(resourceName string, manifest *Manifest) bool {
|
||||
var myMap map[string]interface{}
|
||||
data, _ := json.Marshal(manifest.ExtraResources)
|
||||
json.Unmarshal(data, &myMap)
|
||||
err := json.Unmarshal(data, &myMap)
|
||||
if err != nil {
|
||||
log.Fatalf("\nErr: %v", err)
|
||||
}
|
||||
|
||||
val, ok := myMap[resourceName]
|
||||
if ok && val != nil {
|
||||
return true
|
||||
|
||||
20
types.go
20
types.go
@@ -5,8 +5,8 @@ const DefaultInfraVertical = "lending"
|
||||
const DefaultOwner = "lending"
|
||||
|
||||
type Deployment struct {
|
||||
Namespace string `json:namespace`
|
||||
Cluster string `json:cluster`
|
||||
Namespace string `json:"namespace"`
|
||||
Cluster string `json:"cluster"`
|
||||
}
|
||||
|
||||
type Actions struct {
|
||||
@@ -31,11 +31,11 @@ type Manifest struct {
|
||||
}
|
||||
|
||||
type Metadata struct {
|
||||
Repo string `json:"repo, omitempty"`
|
||||
Language string `json:"language, omitempty"`
|
||||
DataSensitivity string `json:"dataSensitivity, omitempty"`
|
||||
LogCriticality string `json:"logCriticality, omitempty"`
|
||||
DisasterRecovery string `json:"disasterRecovery, omitempty"`
|
||||
Repo string `json:"repo,omitempty"`
|
||||
Language string `json:"language,omitempty"`
|
||||
DataSensitivity string `json:"dataSensitivity,omitempty"`
|
||||
LogCriticality string `json:"logCriticality,omitempty"`
|
||||
DisasterRecovery string `json:"disasterRecovery,omitempty"`
|
||||
}
|
||||
|
||||
type ExtraResources struct {
|
||||
@@ -276,9 +276,9 @@ type LifecycleRule struct {
|
||||
}
|
||||
|
||||
type CorsRule struct {
|
||||
AllowedHeaders []string `json:AllowedHeaders`
|
||||
AllowedMethods []string `json:AllowedMethods`
|
||||
AllowedOrigins []string `json:AllowedOrigins`
|
||||
AllowedHeaders []string `json:"AllowedHeaders"`
|
||||
AllowedMethods []string `json:"AllowedMethods"`
|
||||
AllowedOrigins []string `json:"AllowedOrigins"`
|
||||
}
|
||||
|
||||
type ReadReplica struct {
|
||||
|
||||
7
util.go
7
util.go
@@ -11,17 +11,18 @@ func createFile(dir, fileName string) (*os.File, error) {
|
||||
err := os.MkdirAll(dir, os.ModePerm)
|
||||
if err != nil {
|
||||
log.Fatalf("\nErr: %v", err)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
filePath := strings.Join([]string{dir, fileName}, "/")
|
||||
file, err := os.Create(filePath)
|
||||
if err != nil {
|
||||
log.Fatalf("\nErr: %v", err)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
os.Chmod(filePath, os.ModePerm)
|
||||
if err := os.Chmod(filePath, os.ModePerm); err != nil {
|
||||
log.Fatalf("\nErr: %v", err)
|
||||
}
|
||||
|
||||
return file, err
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user