-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
112 changed files
with
19,031 additions
and
1 deletion.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# Gopkg.toml example | ||
# | ||
# Refer to https://golang.github.io/dep/docs/Gopkg.toml.html | ||
# for detailed Gopkg.toml documentation. | ||
# | ||
# required = ["github.com/user/thing/cmd/thing"] | ||
# ignored = ["github.com/user/project/pkgX", "bitbucket.org/user/project/pkgA/pkgY"] | ||
# | ||
# [[constraint]] | ||
# name = "github.com/user/project" | ||
# version = "1.0.0" | ||
# | ||
# [[constraint]] | ||
# name = "github.com/user/project2" | ||
# branch = "dev" | ||
# source = "github.com/myfork/project2" | ||
# | ||
# [[override]] | ||
# name = "github.com/x/y" | ||
# version = "2.4.0" | ||
# | ||
# [prune] | ||
# non-go = false | ||
# go-tests = true | ||
# unused-packages = true | ||
|
||
|
||
[[constraint]] | ||
name = "github.com/Masterminds/sprig" | ||
version = "2.19.0" | ||
|
||
[[constraint]] | ||
name = "gopkg.in/yaml.v2" | ||
version = "2.2.2" | ||
|
||
[prune] | ||
go-tests = true | ||
unused-packages = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
BINARIES = scribe | ||
GOBIN=$(or ${GOPATH},~/go)/bin | ||
CMD_PACKAGE_PATH = $(PWD)/cmd | ||
|
||
all: $(BINARIES) | ||
|
||
$(BINARIES): setup | ||
@mkdir -p bin | ||
go build -o bin/$@ $(CMD_PACKAGE_PATH)/$@ | ||
cp bin/$@ $(GOBIN)/$@ | ||
|
||
setup: | ||
if [ ! -d $(GOBIN) ] ; then mkdir $(GOBIN); fi | ||
|
||
clean: | ||
rm -rf bin/ |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
/* | ||
Copyright © 2019 IBM | ||
Copyright © 2019 Brian Richardson <brianthemathguy@gmail.com> | ||
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. | ||
*/ | ||
|
||
package main | ||
|
||
import ( | ||
"flag" | ||
"fmt" | ||
"os" | ||
|
||
"github.com/bdrich/scribe/pkg/fileSystem" | ||
"github.com/bdrich/scribe/pkg/templates" | ||
) | ||
|
||
func main() { | ||
|
||
pwd, _ := os.Getwd() | ||
const usage = "USAGE:\tscribe \n\t\t-in <input_path>\n\t\t-out <output_path>\n\t\t-templates <dir_path>\n" | ||
|
||
// flags | ||
inputFileName := flag.String("in", "", "Input Values File -- input file which populates templates") | ||
outputPathName := flag.String("out", "", "Output Path -- path with populated templates") | ||
templatesPath := flag.String("templates", "", "Template File(s) -- path to recursively populate") | ||
flag.Parse() | ||
|
||
if *outputPathName == "" || *inputFileName == "" || *templatesPath == "" { | ||
fmt.Println("Error: Input Values File, Output, Templates paths cannot be empty.") | ||
fmt.Printf("----------------------------------------\n%s\n", usage) | ||
os.Exit(1) | ||
} | ||
|
||
outputPath := pwd + "/" + *outputPathName | ||
inputPath := pwd + "/" + *inputFileName | ||
fmt.Printf("Input Values File: %s\n", inputPath) | ||
|
||
// Ensure input file exists | ||
if !fileSystem.PathExists(inputPath) { | ||
fmt.Printf("Error: Input Values File '%s' does not exist.\n", inputPath) | ||
return | ||
} | ||
|
||
// If env directory doesn't exist, create it | ||
if !fileSystem.PathExists(outputPath) { | ||
fileSystem.CreateDir(outputPath) | ||
} | ||
|
||
templates.WalkExecuteTemplates(*templatesPath, inputPath, outputPath) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/* | ||
Copyright © 2019 IBM | ||
Copyright © 2019 Brian Richardson <brianthemathguy@gmail.com> | ||
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. | ||
*/ | ||
|
||
package fileSystem | ||
|
||
import ( | ||
"os" | ||
) | ||
|
||
// PathExists returns true if given path exists, false otherwise | ||
func PathExists(path string) bool { | ||
if _, err := os.Stat(path); err != nil { | ||
if os.IsNotExist(err) { | ||
return false | ||
} | ||
} | ||
return true | ||
} | ||
|
||
// CreateDir creates a directory at given path, permission mode option | ||
func CreateDir(path string, _mode ...int) error { | ||
var mode = 0777 | ||
if len(_mode) > 0 { | ||
mode = _mode[0] | ||
} | ||
fileMode := os.FileMode(uint32(mode)) | ||
err := os.MkdirAll(path, fileMode) | ||
return err | ||
} | ||
|
||
// CreateFile creates a file at given path | ||
func CreateFile(path string) (*os.File, error) { | ||
file, err := os.Create(path) | ||
return file, err | ||
} | ||
|
||
// DeleteFile deletes a file at given path | ||
func DeleteFile(path string) error { | ||
err := os.Remove(path) | ||
return err | ||
} |
Oops, something went wrong.