Skip to content

Commit

Permalink
Move versions and license to separate files
Browse files Browse the repository at this point in the history
  • Loading branch information
heyealex committed Nov 4, 2021
1 parent 0221335 commit 90d232a
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 35 deletions.
19 changes: 19 additions & 0 deletions pkg/reswriter/license.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package reswriter

const license string = `/**
* Copyright 2021 Google LLC
*
* Licensed 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.
*/
`
17 changes: 0 additions & 17 deletions pkg/reswriter/reswriter.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,23 +31,6 @@ import (
const (
beginPassthroughExp string = `^\(\(.*$`
fullPassthroughExp string = `^\(\((.*)\)\)$`
license string = `/**
* Copyright 2021 Google LLC
*
* Licensed 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.
*/
`
)

// ResWriter interface for writing resources to a blueprint
Expand Down
18 changes: 18 additions & 0 deletions pkg/reswriter/tfversions.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package reswriter

const tfversions string = `
terraform {
required_version = ">= 0.13"
required_providers {
google = {
source = "hashicorp/google"
version = "~> 3.0"
}
google-beta = {
source = "hashicorp/google-beta"
version = "~> 3.0"
}
}
}
`
19 changes: 1 addition & 18 deletions pkg/reswriter/tfwriter.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,23 +32,6 @@ import (
"hpc-toolkit/pkg/config"
)

const versionBytes string = `
terraform {
required_version = ">= 0.13"
required_providers {
google = {
source = "hashicorp/google"
version = "~> 3.0"
}
google-beta = {
source = "hashicorp/google-beta"
version = "~> 3.0"
}
}
}
`

// TFWriter writes terraform to the blueprint folder
type TFWriter struct {
numResources int
Expand Down Expand Up @@ -300,7 +283,7 @@ func writeVersions(dst string) error {
return fmt.Errorf("error creating versions.tf file: %v", err)
}
// Write hard-coded version information
if err := appendHCLToFile(versionsPath, []byte(versionBytes)); err != nil {
if err := appendHCLToFile(versionsPath, []byte(tfversions)); err != nil {
return fmt.Errorf("error writing HCL to versions.tf file: %v", err)
}
return nil
Expand Down

0 comments on commit 90d232a

Please sign in to comment.