Merge pull request #22382 from hashicorp/appilon/delete-files

[CLEANUP] Prune internal usage of config package (with 1 exception)
This commit is contained in:
appilon 2019-08-08 13:01:00 -04:00 committed by GitHub
commit d3dc1263bf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
156 changed files with 213 additions and 4654 deletions

View File

@ -293,8 +293,13 @@ func validateFn(c *terraform.ResourceConfig) (ws []string, es []error) {
// Validate service level configs
services, ok := c.Get("service")
if ok {
for _, svc := range services.([]interface{}) {
service := svc.(map[string]interface{})
for i, svc := range services.([]interface{}) {
service, ok := svc.(map[string]interface{})
if !ok {
es = append(es, fmt.Errorf("service %d: must be a block", i))
continue
}
strategy, ok := service["strategy"].(string)
if ok && !updateStrategies[strategy] {
es = append(es, errors.New(strategy+" is not a valid update strategy."))

View File

@ -1,114 +0,0 @@
package module
import (
"io"
"os"
"path/filepath"
"strings"
)
// copyDir copies the src directory contents into dst. Both directories
// should already exist.
func copyDir(dst, src string) error {
src, err := filepath.EvalSymlinks(src)
if err != nil {
return err
}
walkFn := func(path string, info os.FileInfo, err error) error {
if err != nil {
return err
}
if path == src {
return nil
}
if strings.HasPrefix(filepath.Base(path), ".") {
// Skip any dot files
if info.IsDir() {
return filepath.SkipDir
} else {
return nil
}
}
// The "path" has the src prefixed to it. We need to join our
// destination with the path without the src on it.
dstPath := filepath.Join(dst, path[len(src):])
// we don't want to try and copy the same file over itself.
if eq, err := sameFile(path, dstPath); eq {
return nil
} else if err != nil {
return err
}
// If we have a directory, make that subdirectory, then continue
// the walk.
if info.IsDir() {
if path == filepath.Join(src, dst) {
// dst is in src; don't walk it.
return nil
}
if err := os.MkdirAll(dstPath, 0755); err != nil {
return err
}
return nil
}
// If we have a file, copy the contents.
srcF, err := os.Open(path)
if err != nil {
return err
}
defer srcF.Close()
dstF, err := os.Create(dstPath)
if err != nil {
return err
}
defer dstF.Close()
if _, err := io.Copy(dstF, srcF); err != nil {
return err
}
// Chmod it
return os.Chmod(dstPath, info.Mode())
}
return filepath.Walk(src, walkFn)
}
// sameFile tried to determine if to paths are the same file.
// If the paths don't match, we lookup the inode on supported systems.
func sameFile(a, b string) (bool, error) {
if a == b {
return true, nil
}
aIno, err := inode(a)
if err != nil {
if os.IsNotExist(err) {
return false, nil
}
return false, err
}
bIno, err := inode(b)
if err != nil {
if os.IsNotExist(err) {
return false, nil
}
return false, err
}
if aIno > 0 && aIno == bIno {
return true, nil
}
return false, nil
}

View File

@ -1,112 +0,0 @@
package module
import (
"fmt"
"testing"
"github.com/hashicorp/terraform/registry/regsrc"
)
func TestParseRegistrySource(t *testing.T) {
for _, tc := range []struct {
source string
host string
id string
err bool
notRegistry bool
}{
{ // simple source id
source: "namespace/id/provider",
id: "namespace/id/provider",
},
{ // source with hostname
source: "registry.com/namespace/id/provider",
host: "registry.com",
id: "namespace/id/provider",
},
{ // source with hostname and port
source: "registry.com:4443/namespace/id/provider",
host: "registry.com:4443",
id: "namespace/id/provider",
},
{ // too many parts
source: "registry.com/namespace/id/provider/extra",
err: true,
},
{ // local path
source: "./local/file/path",
notRegistry: true,
},
{ // local path with hostname
source: "./registry.com/namespace/id/provider",
notRegistry: true,
},
{ // full URL
source: "https://example.com/foo/bar/baz",
notRegistry: true,
},
{ // punycode host not allowed in source
source: "xn--80akhbyknj4f.com/namespace/id/provider",
err: true,
},
{ // simple source id with subdir
source: "namespace/id/provider//subdir",
id: "namespace/id/provider",
},
{ // source with hostname and subdir
source: "registry.com/namespace/id/provider//subdir",
host: "registry.com",
id: "namespace/id/provider",
},
{ // source with hostname
source: "registry.com/namespace/id/provider",
host: "registry.com",
id: "namespace/id/provider",
},
{ // we special case github
source: "github.com/namespace/id/provider",
notRegistry: true,
},
{ // we special case github ssh
source: "git@github.com:namespace/id/provider",
notRegistry: true,
},
{ // we special case bitbucket
source: "bitbucket.org/namespace/id/provider",
notRegistry: true,
},
} {
t.Run(tc.source, func(t *testing.T) {
mod, err := regsrc.ParseModuleSource(tc.source)
if tc.notRegistry {
if err != regsrc.ErrInvalidModuleSource {
t.Fatalf("%q should not be a registry source, got err %v", tc.source, err)
}
return
}
if tc.err {
if err == nil {
t.Fatal("expected error")
}
return
}
if err != nil {
t.Fatal(err)
}
id := fmt.Sprintf("%s/%s/%s", mod.RawNamespace, mod.RawName, mod.RawProvider)
if tc.host != "" {
if mod.RawHost.Normalized() != tc.host {
t.Fatalf("expected host %q, got %q", tc.host, mod.RawHost)
}
}
if tc.id != id {
t.Fatalf("expected id %q, got %q", tc.id, id)
}
})
}
}

View File

@ -1,57 +0,0 @@
package module
import (
"io/ioutil"
"os"
"path/filepath"
"github.com/hashicorp/go-getter"
)
// GetMode is an enum that describes how modules are loaded.
//
// GetModeLoad says that modules will not be downloaded or updated, they will
// only be loaded from the storage.
//
// GetModeGet says that modules can be initially downloaded if they don't
// exist, but otherwise to just load from the current version in storage.
//
// GetModeUpdate says that modules should be checked for updates and
// downloaded prior to loading. If there are no updates, we load the version
// from disk, otherwise we download first and then load.
type GetMode byte
const (
GetModeNone GetMode = iota
GetModeGet
GetModeUpdate
)
// GetCopy is the same as Get except that it downloads a copy of the
// module represented by source.
//
// This copy will omit and dot-prefixed files (such as .git/, .hg/) and
// can't be updated on its own.
func GetCopy(dst, src string) error {
// Create the temporary directory to do the real Get to
tmpDir, err := ioutil.TempDir("", "tf")
if err != nil {
return err
}
defer os.RemoveAll(tmpDir)
tmpDir = filepath.Join(tmpDir, "module")
// Get to that temporary dir
if err := getter.Get(tmpDir, src); err != nil {
return err
}
// Make sure the destination exists
if err := os.MkdirAll(dst, 0755); err != nil {
return err
}
// Copy to the final location
return copyDir(dst, tmpDir)
}

View File

@ -1,21 +0,0 @@
// +build linux darwin openbsd netbsd solaris dragonfly
package module
import (
"fmt"
"os"
"syscall"
)
// lookup the inode of a file on posix systems
func inode(path string) (uint64, error) {
stat, err := os.Stat(path)
if err != nil {
return 0, err
}
if st, ok := stat.Sys().(*syscall.Stat_t); ok {
return st.Ino, nil
}
return 0, fmt.Errorf("could not determine file inode")
}

View File

@ -1,21 +0,0 @@
// +build freebsd
package module
import (
"fmt"
"os"
"syscall"
)
// lookup the inode of a file on posix systems
func inode(path string) (uint64, error) {
stat, err := os.Stat(path)
if err != nil {
return 0, err
}
if st, ok := stat.Sys().(*syscall.Stat_t); ok {
return uint64(st.Ino), nil
}
return 0, fmt.Errorf("could not determine file inode")
}

View File

@ -1,8 +0,0 @@
// +build windows
package module
// no syscall.Stat_t on windows, return 0 for inodes
func inode(path string) (uint64, error) {
return 0, nil
}

View File

@ -1,9 +0,0 @@
package module
// Module represents the metadata for a single module.
type Module struct {
Name string
Source string
Version string
Providers map[string]string
}

View File

@ -1,48 +0,0 @@
package module
import (
"io/ioutil"
"log"
"os"
"path/filepath"
"testing"
"github.com/hashicorp/terraform/config"
"github.com/hashicorp/terraform/svchost/disco"
)
func init() {
if os.Getenv("TF_LOG") == "" {
log.SetOutput(ioutil.Discard)
}
}
const fixtureDir = "./testdata"
func tempDir(t *testing.T) string {
t.Helper()
dir, err := ioutil.TempDir("", "tf")
if err != nil {
t.Fatalf("err: %s", err)
}
if err := os.RemoveAll(dir); err != nil {
t.Fatalf("err: %s", err)
}
return dir
}
func testConfig(t *testing.T, n string) *config.Config {
t.Helper()
c, err := config.LoadDir(filepath.Join(fixtureDir, n))
if err != nil {
t.Fatalf("err: %s", err)
}
return c
}
func testStorage(t *testing.T, d *disco.Disco) *Storage {
t.Helper()
return NewStorage(tempDir(t), d)
}

View File

@ -1,346 +0,0 @@
package module
import (
"encoding/json"
"fmt"
"io/ioutil"
"log"
"os"
"path/filepath"
getter "github.com/hashicorp/go-getter"
"github.com/hashicorp/terraform/registry"
"github.com/hashicorp/terraform/registry/regsrc"
"github.com/hashicorp/terraform/svchost/disco"
"github.com/mitchellh/cli"
)
const manifestName = "modules.json"
// moduleManifest is the serialization structure used to record the stored
// module's metadata.
type moduleManifest struct {
Modules []moduleRecord
}
// moduleRecords represents the stored module's metadata.
// This is compared for equality using '==', so all fields needs to remain
// comparable.
type moduleRecord struct {
// Source is the module source string from the config, minus any
// subdirectory.
Source string
// Key is the locally unique identifier for this module.
Key string
// Version is the exact version string for the stored module.
Version string
// Dir is the directory name returned by the FileStorage. This is what
// allows us to correlate a particular module version with the location on
// disk.
Dir string
// Root is the root directory containing the module. If the module is
// unpacked from an archive, and not located in the root directory, this is
// used to direct the loader to the correct subdirectory. This is
// independent from any subdirectory in the original source string, which
// may traverse further into the module tree.
Root string
// url is the location of the module source
url string
// Registry is true if this module is sourced from a registry
registry bool
}
// Storage implements methods to manage the storage of modules.
// This is used by Tree.Load to query registries, authenticate requests, and
// store modules locally.
type Storage struct {
// StorageDir is the full path to the directory where all modules will be
// stored.
StorageDir string
// Ui is an optional cli.Ui for user output
Ui cli.Ui
// Mode is the GetMode that will be used for various operations.
Mode GetMode
registry *registry.Client
}
// NewStorage returns a new initialized Storage object.
func NewStorage(dir string, services *disco.Disco) *Storage {
regClient := registry.NewClient(services, nil)
return &Storage{
StorageDir: dir,
registry: regClient,
}
}
// loadManifest returns the moduleManifest file from the parent directory.
func (s Storage) loadManifest() (moduleManifest, error) {
manifest := moduleManifest{}
manifestPath := filepath.Join(s.StorageDir, manifestName)
data, err := ioutil.ReadFile(manifestPath)
if err != nil && !os.IsNotExist(err) {
return manifest, err
}
if len(data) == 0 {
return manifest, nil
}
if err := json.Unmarshal(data, &manifest); err != nil {
return manifest, err
}
return manifest, nil
}
// Store the location of the module, along with the version used and the module
// root directory. The storage method loads the entire file and rewrites it
// each time. This is only done a few times during init, so efficiency is
// not a concern.
func (s Storage) recordModule(rec moduleRecord) error {
manifest, err := s.loadManifest()
if err != nil {
// if there was a problem with the file, we will attempt to write a new
// one. Any non-data related error should surface there.
log.Printf("[WARN] error reading module manifest: %s", err)
}
// do nothing if we already have the exact module
for i, stored := range manifest.Modules {
if rec == stored {
return nil
}
// they are not equal, but if the storage path is the same we need to
// remove this rec to be replaced.
if rec.Dir == stored.Dir {
manifest.Modules[i] = manifest.Modules[len(manifest.Modules)-1]
manifest.Modules = manifest.Modules[:len(manifest.Modules)-1]
break
}
}
manifest.Modules = append(manifest.Modules, rec)
js, err := json.Marshal(manifest)
if err != nil {
panic(err)
}
manifestPath := filepath.Join(s.StorageDir, manifestName)
return ioutil.WriteFile(manifestPath, js, 0644)
}
// load the manifest from dir, and return all module versions matching the
// provided source. Records with no version info will be skipped, as they need
// to be uniquely identified by other means.
func (s Storage) moduleVersions(source string) ([]moduleRecord, error) {
manifest, err := s.loadManifest()
if err != nil {
return manifest.Modules, err
}
var matching []moduleRecord
for _, m := range manifest.Modules {
if m.Source == source && m.Version != "" {
log.Printf("[DEBUG] found local version %q for module %s", m.Version, m.Source)
matching = append(matching, m)
}
}
return matching, nil
}
func (s Storage) moduleDir(key string) (string, error) {
manifest, err := s.loadManifest()
if err != nil {
return "", err
}
for _, m := range manifest.Modules {
if m.Key == key {
return m.Dir, nil
}
}
return "", nil
}
// return only the root directory of the module stored in dir.
func (s Storage) getModuleRoot(dir string) (string, error) {
manifest, err := s.loadManifest()
if err != nil {
return "", err
}
for _, mod := range manifest.Modules {
if mod.Dir == dir {
return mod.Root, nil
}
}
return "", nil
}
// record only the Root directory for the module stored at dir.
func (s Storage) recordModuleRoot(dir, root string) error {
rec := moduleRecord{
Dir: dir,
Root: root,
}
return s.recordModule(rec)
}
func (s Storage) output(msg string) {
if s.Ui == nil || s.Mode == GetModeNone {
return
}
s.Ui.Output(msg)
}
func (s Storage) getStorage(key string, src string) (string, bool, error) {
storage := &getter.FolderStorage{
StorageDir: s.StorageDir,
}
log.Printf("[DEBUG] fetching module from %s", src)
// Get the module with the level specified if we were told to.
if s.Mode > GetModeNone {
log.Printf("[DEBUG] fetching %q with key %q", src, key)
if err := storage.Get(key, src, s.Mode == GetModeUpdate); err != nil {
return "", false, err
}
}
// Get the directory where the module is.
dir, found, err := storage.Dir(key)
log.Printf("[DEBUG] found %q in %q: %t", src, dir, found)
return dir, found, err
}
// find a stored module that's not from a registry
func (s Storage) findModule(key string) (string, error) {
if s.Mode == GetModeUpdate {
return "", nil
}
return s.moduleDir(key)
}
// GetModule fetches a module source into the specified directory. This is used
// as a convenience function by the CLI to initialize a configuration.
func (s Storage) GetModule(dst, src string) error {
// reset this in case the caller was going to re-use it
mode := s.Mode
s.Mode = GetModeUpdate
defer func() {
s.Mode = mode
}()
rec, err := s.findRegistryModule(src, anyVersion)
if err != nil {
return err
}
pwd, err := os.Getwd()
if err != nil {
return err
}
source := rec.url
if source == "" {
source, err = getter.Detect(src, pwd, getter.Detectors)
if err != nil {
return fmt.Errorf("module %s: %s", src, err)
}
}
if source == "" {
return fmt.Errorf("module %q not found", src)
}
return GetCopy(dst, source)
}
// find a registry module
func (s Storage) findRegistryModule(mSource, constraint string) (moduleRecord, error) {
rec := moduleRecord{
Source: mSource,
}
// detect if we have a registry source
mod, err := regsrc.ParseModuleSource(mSource)
switch err {
case nil:
//ok
case regsrc.ErrInvalidModuleSource:
return rec, nil
default:
return rec, err
}
rec.registry = true
log.Printf("[TRACE] %q is a registry module", mod.Display())
versions, err := s.moduleVersions(mod.String())
if err != nil {
log.Printf("[ERROR] error looking up versions for %q: %s", mod.Display(), err)
return rec, err
}
match, err := newestRecord(versions, constraint)
if err != nil {
log.Printf("[INFO] no matching version for %q<%s>, %s", mod.Display(), constraint, err)
}
log.Printf("[DEBUG] matched %q version %s for %s", mod, match.Version, constraint)
rec.Dir = match.Dir
rec.Version = match.Version
found := rec.Dir != ""
// we need to lookup available versions
// Only on Get if it's not found, on unconditionally on Update
if (s.Mode == GetModeGet && !found) || (s.Mode == GetModeUpdate) {
resp, err := s.registry.ModuleVersions(mod)
if err != nil {
return rec, err
}
if len(resp.Modules) == 0 {
return rec, fmt.Errorf("module %q not found in registry", mod.Display())
}
match, err := newestVersion(resp.Modules[0].Versions, constraint)
if err != nil {
return rec, err
}
if match == nil {
return rec, fmt.Errorf("no versions for %q found matching %q", mod.Display(), constraint)
}
rec.Version = match.Version
rec.url, err = s.registry.ModuleLocation(mod, rec.Version)
if err != nil {
return rec, err
}
// we've already validated this by now
host, _ := mod.SvcHost()
s.output(fmt.Sprintf(" Found version %s of %s on %s", rec.Version, mod.Module(), host.ForDisplay()))
}
return rec, nil
}

View File

@ -1,189 +0,0 @@
package module
import (
"io/ioutil"
"net/url"
"os"
"path/filepath"
"strings"
"testing"
"github.com/hashicorp/terraform/registry/regsrc"
"github.com/hashicorp/terraform/registry/test"
)
func TestGetModule(t *testing.T) {
server := test.Registry()
defer server.Close()
disco := test.Disco(server)
td, err := ioutil.TempDir("", "tf")
if err != nil {
t.Fatal(err)
}
defer os.RemoveAll(td)
storage := NewStorage(td, disco)
// this module exists in a test fixture, and is known by the test.Registry
// relative to our cwd.
err = storage.GetModule(filepath.Join(td, "foo"), "registry/local/sub")
if err != nil {
t.Fatal(err)
}
// list everything to make sure nothing else got unpacked in here
ls, err := ioutil.ReadDir(td)
if err != nil {
t.Fatal(err)
}
var names []string
for _, info := range ls {
names = append(names, info.Name())
}
if !(len(names) == 1 && names[0] == "foo") {
t.Fatalf("expected only directory 'foo', found entries %q", names)
}
_, err = os.Stat(filepath.Join(td, "foo", "main.tf"))
if err != nil {
t.Fatal(err)
}
}
// GitHub archives always contain the module source in a single subdirectory,
// so the registry will return a path with with a `//*` suffix. We need to make
// sure this doesn't intefere with our internal handling of `//` subdir.
func TestRegistryGitHubArchive(t *testing.T) {
server := test.Registry()
defer server.Close()
disco := test.Disco(server)
storage := testStorage(t, disco)
tree := NewTree("", testConfig(t, "registry-tar-subdir"))
storage.Mode = GetModeGet
if err := tree.Load(storage); err != nil {
t.Fatalf("err: %s", err)
}
if !tree.Loaded() {
t.Fatal("should be loaded")
}
storage.Mode = GetModeNone
if err := tree.Load(storage); err != nil {
t.Fatalf("err: %s", err)
}
// stop the registry server, and make sure that we don't need to call out again
server.Close()
tree = NewTree("", testConfig(t, "registry-tar-subdir"))
storage.Mode = GetModeGet
if err := tree.Load(storage); err != nil {
t.Fatalf("err: %s", err)
}
if !tree.Loaded() {
t.Fatal("should be loaded")
}
actual := strings.TrimSpace(tree.String())
expected := strings.TrimSpace(treeLoadSubdirStr)
if actual != expected {
t.Fatalf("got: \n\n%s\nexpected: \n\n%s", actual, expected)
}
}
// Test that the //subdir notation can be used with registry modules
func TestRegisryModuleSubdir(t *testing.T) {
server := test.Registry()
defer server.Close()
disco := test.Disco(server)
storage := testStorage(t, disco)
tree := NewTree("", testConfig(t, "registry-subdir"))
storage.Mode = GetModeGet
if err := tree.Load(storage); err != nil {
t.Fatalf("err: %s", err)
}
if !tree.Loaded() {
t.Fatal("should be loaded")
}
storage.Mode = GetModeNone
if err := tree.Load(storage); err != nil {
t.Fatalf("err: %s", err)
}
actual := strings.TrimSpace(tree.String())
expected := strings.TrimSpace(treeLoadRegistrySubdirStr)
if actual != expected {
t.Fatalf("got: \n\n%s\nexpected: \n\n%s", actual, expected)
}
}
func TestAccRegistryDiscover(t *testing.T) {
if os.Getenv("TF_ACC") == "" {
t.Skip("skipping ACC test")
}
// simply check that we get a valid github URL for this from the registry
module, err := regsrc.ParseModuleSource("hashicorp/consul/aws")
if err != nil {
t.Fatal(err)
}
s := NewStorage("/tmp", nil)
loc, err := s.registry.ModuleLocation(module, "")
if err != nil {
t.Fatal(err)
}
u, err := url.Parse(loc)
if err != nil {
t.Fatal(err)
}
if !strings.HasSuffix(u.Host, "github.com") {
t.Fatalf("expected host 'github.com', got: %q", u.Host)
}
if !strings.Contains(u.String(), "consul") {
t.Fatalf("url doesn't contain 'consul': %s", u.String())
}
}
func TestAccRegistryLoad(t *testing.T) {
if os.Getenv("TF_ACC") == "" {
t.Skip("skipping ACC test")
}
storage := testStorage(t, nil)
tree := NewTree("", testConfig(t, "registry-load"))
storage.Mode = GetModeGet
if err := tree.Load(storage); err != nil {
t.Fatalf("err: %s", err)
}
if !tree.Loaded() {
t.Fatal("should be loaded")
}
storage.Mode = GetModeNone
if err := tree.Load(storage); err != nil {
t.Fatalf("err: %s", err)
}
// TODO expand this further by fetching some metadata from the registry
actual := strings.TrimSpace(tree.String())
if !strings.Contains(actual, "(path: vault)") {
t.Fatal("missing vault module, got:\n", actual)
}
}

View File

@ -1 +0,0 @@
# Hi

View File

@ -1,5 +0,0 @@
# Hello
module "foo" {
source = "./foo"
}

View File

@ -1,7 +0,0 @@
add subdir
# Please enter the commit message for your changes. Lines starting
# with '#' will be ignored, and an empty message aborts the commit.
# On branch master
# Changes to be committed:
# new file: subdir/sub.tf
#

View File

@ -1 +0,0 @@
ref: refs/heads/master

View File

@ -1,7 +0,0 @@
[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
ignorecase = true
precomposeunicode = true

View File

@ -1 +0,0 @@
Unnamed repository; edit this file 'description' to name the repository.

View File

@ -1,15 +0,0 @@
#!/bin/sh
#
# An example hook script to check the commit log message taken by
# applypatch from an e-mail message.
#
# The hook should exit with non-zero status after issuing an
# appropriate message if it wants to stop the commit. The hook is
# allowed to edit the commit message file.
#
# To enable this hook, rename this file to "applypatch-msg".
. git-sh-setup
test -x "$GIT_DIR/hooks/commit-msg" &&
exec "$GIT_DIR/hooks/commit-msg" ${1+"$@"}
:

View File

@ -1,24 +0,0 @@
#!/bin/sh
#
# An example hook script to check the commit log message.
# Called by "git commit" with one argument, the name of the file
# that has the commit message. The hook should exit with non-zero
# status after issuing an appropriate message if it wants to stop the
# commit. The hook is allowed to edit the commit message file.
#
# To enable this hook, rename this file to "commit-msg".
# Uncomment the below to add a Signed-off-by line to the message.
# Doing this in a hook is a bad idea in general, but the prepare-commit-msg
# hook is more suited to it.
#
# SOB=$(git var GIT_AUTHOR_IDENT | sed -n 's/^\(.*>\).*$/Signed-off-by: \1/p')
# grep -qs "^$SOB" "$1" || echo "$SOB" >> "$1"
# This example catches duplicate Signed-off-by lines.
test "" = "$(grep '^Signed-off-by: ' "$1" |
sort | uniq -c | sed -e '/^[ ]*1[ ]/d')" || {
echo >&2 Duplicate Signed-off-by lines.
exit 1
}

View File

@ -1,8 +0,0 @@
#!/bin/sh
#
# An example hook script to prepare a packed repository for use over
# dumb transports.
#
# To enable this hook, rename this file to "post-update".
exec git update-server-info

View File

@ -1,14 +0,0 @@
#!/bin/sh
#
# An example hook script to verify what is about to be committed
# by applypatch from an e-mail message.
#
# The hook should exit with non-zero status after issuing an
# appropriate message if it wants to stop the commit.
#
# To enable this hook, rename this file to "pre-applypatch".
. git-sh-setup
test -x "$GIT_DIR/hooks/pre-commit" &&
exec "$GIT_DIR/hooks/pre-commit" ${1+"$@"}
:

View File

@ -1,49 +0,0 @@
#!/bin/sh
#
# An example hook script to verify what is about to be committed.
# Called by "git commit" with no arguments. The hook should
# exit with non-zero status after issuing an appropriate message if
# it wants to stop the commit.
#
# To enable this hook, rename this file to "pre-commit".
if git rev-parse --verify HEAD >/dev/null 2>&1
then
against=HEAD
else
# Initial commit: diff against an empty tree object
against=4b825dc642cb6eb9a060e54bf8d69288fbee4904
fi
# If you want to allow non-ASCII filenames set this variable to true.
allownonascii=$(git config --bool hooks.allownonascii)
# Redirect output to stderr.
exec 1>&2
# Cross platform projects tend to avoid non-ASCII filenames; prevent
# them from being added to the repository. We exploit the fact that the
# printable range starts at the space character and ends with tilde.
if [ "$allownonascii" != "true" ] &&
# Note that the use of brackets around a tr range is ok here, (it's
# even required, for portability to Solaris 10's /usr/bin/tr), since
# the square bracket bytes happen to fall in the designated range.
test $(git diff --cached --name-only --diff-filter=A -z $against |
LC_ALL=C tr -d '[ -~]\0' | wc -c) != 0
then
cat <<\EOF
Error: Attempt to add a non-ASCII file name.
This can cause problems if you want to work with people on other platforms.
To be portable it is advisable to rename the file.
If you know what you are doing you can disable this check using:
git config hooks.allownonascii true
EOF
exit 1
fi
# If there are whitespace errors, print the offending file names and fail.
exec git diff-index --check --cached $against --

View File

@ -1,54 +0,0 @@
#!/bin/sh
# An example hook script to verify what is about to be pushed. Called by "git
# push" after it has checked the remote status, but before anything has been
# pushed. If this script exits with a non-zero status nothing will be pushed.
#
# This hook is called with the following parameters:
#
# $1 -- Name of the remote to which the push is being done
# $2 -- URL to which the push is being done
#
# If pushing without using a named remote those arguments will be equal.
#
# Information about the commits which are being pushed is supplied as lines to
# the standard input in the form:
#
# <local ref> <local sha1> <remote ref> <remote sha1>
#
# This sample shows how to prevent push of commits where the log message starts
# with "WIP" (work in progress).
remote="$1"
url="$2"
z40=0000000000000000000000000000000000000000
IFS=' '
while read local_ref local_sha remote_ref remote_sha
do
if [ "$local_sha" = $z40 ]
then
# Handle delete
:
else
if [ "$remote_sha" = $z40 ]
then
# New branch, examine all commits
range="$local_sha"
else
# Update to existing branch, examine new commits
range="$remote_sha..$local_sha"
fi
# Check for WIP commit
commit=`git rev-list -n 1 --grep '^WIP' "$range"`
if [ -n "$commit" ]
then
echo "Found WIP commit in $local_ref, not pushing"
exit 1
fi
fi
done
exit 0

View File

@ -1,169 +0,0 @@
#!/bin/sh
#
# Copyright (c) 2006, 2008 Junio C Hamano
#
# The "pre-rebase" hook is run just before "git rebase" starts doing
# its job, and can prevent the command from running by exiting with
# non-zero status.
#
# The hook is called with the following parameters:
#
# $1 -- the upstream the series was forked from.
# $2 -- the branch being rebased (or empty when rebasing the current branch).
#
# This sample shows how to prevent topic branches that are already
# merged to 'next' branch from getting rebased, because allowing it
# would result in rebasing already published history.
publish=next
basebranch="$1"
if test "$#" = 2
then
topic="refs/heads/$2"
else
topic=`git symbolic-ref HEAD` ||
exit 0 ;# we do not interrupt rebasing detached HEAD
fi
case "$topic" in
refs/heads/??/*)
;;
*)
exit 0 ;# we do not interrupt others.
;;
esac
# Now we are dealing with a topic branch being rebased
# on top of master. Is it OK to rebase it?
# Does the topic really exist?
git show-ref -q "$topic" || {
echo >&2 "No such branch $topic"
exit 1
}
# Is topic fully merged to master?
not_in_master=`git rev-list --pretty=oneline ^master "$topic"`
if test -z "$not_in_master"
then
echo >&2 "$topic is fully merged to master; better remove it."
exit 1 ;# we could allow it, but there is no point.
fi
# Is topic ever merged to next? If so you should not be rebasing it.
only_next_1=`git rev-list ^master "^$topic" ${publish} | sort`
only_next_2=`git rev-list ^master ${publish} | sort`
if test "$only_next_1" = "$only_next_2"
then
not_in_topic=`git rev-list "^$topic" master`
if test -z "$not_in_topic"
then
echo >&2 "$topic is already up-to-date with master"
exit 1 ;# we could allow it, but there is no point.
else
exit 0
fi
else
not_in_next=`git rev-list --pretty=oneline ^${publish} "$topic"`
/usr/bin/perl -e '
my $topic = $ARGV[0];
my $msg = "* $topic has commits already merged to public branch:\n";
my (%not_in_next) = map {
/^([0-9a-f]+) /;
($1 => 1);
} split(/\n/, $ARGV[1]);
for my $elem (map {
/^([0-9a-f]+) (.*)$/;
[$1 => $2];
} split(/\n/, $ARGV[2])) {
if (!exists $not_in_next{$elem->[0]}) {
if ($msg) {
print STDERR $msg;
undef $msg;
}
print STDERR " $elem->[1]\n";
}
}
' "$topic" "$not_in_next" "$not_in_master"
exit 1
fi
exit 0
################################################################
This sample hook safeguards topic branches that have been
published from being rewound.
The workflow assumed here is:
* Once a topic branch forks from "master", "master" is never
merged into it again (either directly or indirectly).
* Once a topic branch is fully cooked and merged into "master",
it is deleted. If you need to build on top of it to correct
earlier mistakes, a new topic branch is created by forking at
the tip of the "master". This is not strictly necessary, but
it makes it easier to keep your history simple.
* Whenever you need to test or publish your changes to topic
branches, merge them into "next" branch.
The script, being an example, hardcodes the publish branch name
to be "next", but it is trivial to make it configurable via
$GIT_DIR/config mechanism.
With this workflow, you would want to know:
(1) ... if a topic branch has ever been merged to "next". Young
topic branches can have stupid mistakes you would rather
clean up before publishing, and things that have not been
merged into other branches can be easily rebased without
affecting other people. But once it is published, you would
not want to rewind it.
(2) ... if a topic branch has been fully merged to "master".
Then you can delete it. More importantly, you should not
build on top of it -- other people may already want to
change things related to the topic as patches against your
"master", so if you need further changes, it is better to
fork the topic (perhaps with the same name) afresh from the
tip of "master".
Let's look at this example:
o---o---o---o---o---o---o---o---o---o "next"
/ / / /
/ a---a---b A / /
/ / / /
/ / c---c---c---c B /
/ / / \ /
/ / / b---b C \ /
/ / / / \ /
---o---o---o---o---o---o---o---o---o---o---o "master"
A, B and C are topic branches.
* A has one fix since it was merged up to "next".
* B has finished. It has been fully merged up to "master" and "next",
and is ready to be deleted.
* C has not merged to "next" at all.
We would want to allow C to be rebased, refuse A, and encourage
B to be deleted.
To compute (1):
git rev-list ^master ^topic next
git rev-list ^master next
if these match, topic has not merged in next at all.
To compute (2):
git rev-list master..topic
if this is empty, it is fully merged to "master".

View File

@ -1,36 +0,0 @@
#!/bin/sh
#
# An example hook script to prepare the commit log message.
# Called by "git commit" with the name of the file that has the
# commit message, followed by the description of the commit
# message's source. The hook's purpose is to edit the commit
# message file. If the hook fails with a non-zero status,
# the commit is aborted.
#
# To enable this hook, rename this file to "prepare-commit-msg".
# This hook includes three examples. The first comments out the
# "Conflicts:" part of a merge commit.
#
# The second includes the output of "git diff --name-status -r"
# into the message, just before the "git status" output. It is
# commented because it doesn't cope with --amend or with squashed
# commits.
#
# The third example adds a Signed-off-by line to the message, that can
# still be edited. This is rarely a good idea.
case "$2,$3" in
merge,)
/usr/bin/perl -i.bak -ne 's/^/# /, s/^# #/#/ if /^Conflicts/ .. /#/; print' "$1" ;;
# ,|template,)
# /usr/bin/perl -i.bak -pe '
# print "\n" . `git diff --cached --name-status -r`
# if /^#/ && $first++ == 0' "$1" ;;
*) ;;
esac
# SOB=$(git var GIT_AUTHOR_IDENT | sed -n 's/^\(.*>\).*$/Signed-off-by: \1/p')
# grep -qs "^$SOB" "$1" || echo "$SOB" >> "$1"

View File

@ -1,128 +0,0 @@
#!/bin/sh
#
# An example hook script to blocks unannotated tags from entering.
# Called by "git receive-pack" with arguments: refname sha1-old sha1-new
#
# To enable this hook, rename this file to "update".
#
# Config
# ------
# hooks.allowunannotated
# This boolean sets whether unannotated tags will be allowed into the
# repository. By default they won't be.
# hooks.allowdeletetag
# This boolean sets whether deleting tags will be allowed in the
# repository. By default they won't be.
# hooks.allowmodifytag
# This boolean sets whether a tag may be modified after creation. By default
# it won't be.
# hooks.allowdeletebranch
# This boolean sets whether deleting branches will be allowed in the
# repository. By default they won't be.
# hooks.denycreatebranch
# This boolean sets whether remotely creating branches will be denied
# in the repository. By default this is allowed.
#
# --- Command line
refname="$1"
oldrev="$2"
newrev="$3"
# --- Safety check
if [ -z "$GIT_DIR" ]; then
echo "Don't run this script from the command line." >&2
echo " (if you want, you could supply GIT_DIR then run" >&2
echo " $0 <ref> <oldrev> <newrev>)" >&2
exit 1
fi
if [ -z "$refname" -o -z "$oldrev" -o -z "$newrev" ]; then
echo "usage: $0 <ref> <oldrev> <newrev>" >&2
exit 1
fi
# --- Config
allowunannotated=$(git config --bool hooks.allowunannotated)
allowdeletebranch=$(git config --bool hooks.allowdeletebranch)
denycreatebranch=$(git config --bool hooks.denycreatebranch)
allowdeletetag=$(git config --bool hooks.allowdeletetag)
allowmodifytag=$(git config --bool hooks.allowmodifytag)
# check for no description
projectdesc=$(sed -e '1q' "$GIT_DIR/description")
case "$projectdesc" in
"Unnamed repository"* | "")
echo "*** Project description file hasn't been set" >&2
exit 1
;;
esac
# --- Check types
# if $newrev is 0000...0000, it's a commit to delete a ref.
zero="0000000000000000000000000000000000000000"
if [ "$newrev" = "$zero" ]; then
newrev_type=delete
else
newrev_type=$(git cat-file -t $newrev)
fi
case "$refname","$newrev_type" in
refs/tags/*,commit)
# un-annotated tag
short_refname=${refname##refs/tags/}
if [ "$allowunannotated" != "true" ]; then
echo "*** The un-annotated tag, $short_refname, is not allowed in this repository" >&2
echo "*** Use 'git tag [ -a | -s ]' for tags you want to propagate." >&2
exit 1
fi
;;
refs/tags/*,delete)
# delete tag
if [ "$allowdeletetag" != "true" ]; then
echo "*** Deleting a tag is not allowed in this repository" >&2
exit 1
fi
;;
refs/tags/*,tag)
# annotated tag
if [ "$allowmodifytag" != "true" ] && git rev-parse $refname > /dev/null 2>&1
then
echo "*** Tag '$refname' already exists." >&2
echo "*** Modifying a tag is not allowed in this repository." >&2
exit 1
fi
;;
refs/heads/*,commit)
# branch
if [ "$oldrev" = "$zero" -a "$denycreatebranch" = "true" ]; then
echo "*** Creating a branch is not allowed in this repository" >&2
exit 1
fi
;;
refs/heads/*,delete)
# delete branch
if [ "$allowdeletebranch" != "true" ]; then
echo "*** Deleting a branch is not allowed in this repository" >&2
exit 1
fi
;;
refs/remotes/*,commit)
# tracking branch
;;
refs/remotes/*,delete)
# delete tracking branch
if [ "$allowdeletebranch" != "true" ]; then
echo "*** Deleting a tracking branch is not allowed in this repository" >&2
exit 1
fi
;;
*)
# Anything else (is there anything else?)
echo "*** Update hook: unknown type of update to ref $refname of type $newrev_type" >&2
exit 1
;;
esac
# --- Finished
exit 0

Binary file not shown.

View File

@ -1,6 +0,0 @@
# git ls-files --others --exclude-from=.git/info/exclude
# Lines that start with '#' are comments.
# For a project mostly in C, the following would be a good set of
# exclude patterns (uncomment them if you want to use them):
# *.[oa]
# *~

View File

@ -1,7 +0,0 @@
0000000000000000000000000000000000000000 497bc37401eb3c9b11865b1768725b64066eccee Mitchell Hashimoto <mitchell.hashimoto@gmail.com> 1410850637 -0700 commit (initial): A commit
497bc37401eb3c9b11865b1768725b64066eccee 243f0fc5c4e586d1a3daa54c981b6f34e9ab1085 Mitchell Hashimoto <mitchell.hashimoto@gmail.com> 1410886526 -0700 commit: tag1
243f0fc5c4e586d1a3daa54c981b6f34e9ab1085 1f31e97f053caeb5d6b7bffa3faf82941c99efa2 Mitchell Hashimoto <mitchell.hashimoto@gmail.com> 1410886536 -0700 commit: remove tag1
1f31e97f053caeb5d6b7bffa3faf82941c99efa2 1f31e97f053caeb5d6b7bffa3faf82941c99efa2 Mitchell Hashimoto <mitchell.hashimoto@gmail.com> 1410886909 -0700 checkout: moving from master to test-branch
1f31e97f053caeb5d6b7bffa3faf82941c99efa2 7b7614f8759ac8b5e4b02be65ad8e2667be6dd87 Mitchell Hashimoto <mitchell.hashimoto@gmail.com> 1410886913 -0700 commit: Branch
7b7614f8759ac8b5e4b02be65ad8e2667be6dd87 1f31e97f053caeb5d6b7bffa3faf82941c99efa2 Mitchell Hashimoto <mitchell.hashimoto@gmail.com> 1410886916 -0700 checkout: moving from test-branch to master
1f31e97f053caeb5d6b7bffa3faf82941c99efa2 146492b04efe0aae2b8288c5c0aef6a951030fde Mitchell Hashimoto <mitchell.hashimoto@gmail.com> 1411767116 -0700 commit: add subdir

View File

@ -1,4 +0,0 @@
0000000000000000000000000000000000000000 497bc37401eb3c9b11865b1768725b64066eccee Mitchell Hashimoto <mitchell.hashimoto@gmail.com> 1410850637 -0700 commit (initial): A commit
497bc37401eb3c9b11865b1768725b64066eccee 243f0fc5c4e586d1a3daa54c981b6f34e9ab1085 Mitchell Hashimoto <mitchell.hashimoto@gmail.com> 1410886526 -0700 commit: tag1
243f0fc5c4e586d1a3daa54c981b6f34e9ab1085 1f31e97f053caeb5d6b7bffa3faf82941c99efa2 Mitchell Hashimoto <mitchell.hashimoto@gmail.com> 1410886536 -0700 commit: remove tag1
1f31e97f053caeb5d6b7bffa3faf82941c99efa2 146492b04efe0aae2b8288c5c0aef6a951030fde Mitchell Hashimoto <mitchell.hashimoto@gmail.com> 1411767116 -0700 commit: add subdir

View File

@ -1,2 +0,0 @@
0000000000000000000000000000000000000000 1f31e97f053caeb5d6b7bffa3faf82941c99efa2 Mitchell Hashimoto <mitchell.hashimoto@gmail.com> 1410886909 -0700 branch: Created from HEAD
1f31e97f053caeb5d6b7bffa3faf82941c99efa2 7b7614f8759ac8b5e4b02be65ad8e2667be6dd87 Mitchell Hashimoto <mitchell.hashimoto@gmail.com> 1410886913 -0700 commit: Branch

View File

@ -1,2 +0,0 @@
x­ÌM
1 @a×=E.à<>þMZÑ<>¦Æxâ Ü>x_ê­Uƒ´“-gˆ³³&—<>çx»G<C2BB> EBöyA >ÅÅÅ/)}ƒk•TòºÂ…Ÿ¥¶.ü´©üÚéѸ®SêíÚé<C39A>àl öHˆjÔqHþ ¦ÎðõÔ%øD‡

View File

@ -1,2 +0,0 @@
x­ÎK
Â0…aÇYE6`Iš7ˆˆ#'.â&¹×šFbÜ¿EpN?ø'µZ—Ág££#r-´•>…l&`²²&éQdŠÑ€ò.YØ:nƒKRƒ#aTŒ&Ûè"(òsÐ2…€3ƒ÷(­óû2RÁuå7x•¥¶Ñøi?ðµ©üìò¨°¬SjõÌ¥Â{¤âGá„`»îÅÀ¿Œ±k‡-öÛS„

View File

@ -1 +0,0 @@
146492b04efe0aae2b8288c5c0aef6a951030fde

View File

@ -1 +0,0 @@
7b7614f8759ac8b5e4b02be65ad8e2667be6dd87

View File

@ -1 +0,0 @@
243f0fc5c4e586d1a3daa54c981b6f34e9ab1085

View File

@ -1,5 +0,0 @@
# Hello
module "foo" {
source = "./foo"
}

Binary file not shown.

View File

@ -1 +0,0 @@
default

View File

@ -1,3 +0,0 @@
c65e998d747ffbb1fe3b1c067a50664bb3fb5da4 1
dcaed7754d58264cb9a5916215a5442377307bd1 o default
c65e998d747ffbb1fe3b1c067a50664bb3fb5da4 o test-branch

View File

@ -1,2 +0,0 @@
1 c65e998d747ffbb1fe3b1c067a50664bb3fb5da4

Binary file not shown.

View File

@ -1,2 +0,0 @@
Branch

View File

@ -1,4 +0,0 @@
dotencode
fncache
revlogv1
store

View File

@ -1,2 +0,0 @@
data/main.tf.i
data/main_branch.tf.i

View File

@ -1 +0,0 @@
1 dcaed7754d58264cb9a5916215a5442377307bd1

Binary file not shown.

View File

@ -1 +0,0 @@
1 dcaed7754d58264cb9a5916215a5442377307bd1

View File

@ -1 +0,0 @@
test-branch

View File

@ -1,2 +0,0 @@
1
commit

Binary file not shown.

View File

@ -1,5 +0,0 @@
# Hello
module "foo" {
source = "./foo"
}

View File

@ -1,3 +0,0 @@
module "b" {
source = "../c"
}

View File

@ -1 +0,0 @@
# Hello

View File

@ -1,3 +0,0 @@
module "a" {
source = "./a"
}

View File

@ -1,3 +0,0 @@
module "bar" {
source = "./baz"
}

View File

@ -1,3 +0,0 @@
module "foo" {
source = "./foo//sub"
}

Binary file not shown.

View File

@ -1,3 +0,0 @@
module "foo" {
source = "./foo.tgz//sub"
}

View File

@ -1 +0,0 @@
# Hello

View File

@ -1,5 +0,0 @@
# Hello
module "foo" {
source = "./foo"
}

View File

@ -1 +0,0 @@
resource "test_resource" "a-b" {}

View File

@ -1,3 +0,0 @@
module "b" {
source = "./b"
}

View File

@ -1 +0,0 @@
resource "test_resource" "c-b" {}

View File

@ -1,3 +0,0 @@
module "b" {
source = "./b"
}

View File

@ -1,3 +0,0 @@
module "a" {
source = "./a"
}

View File

@ -1,3 +0,0 @@
module "a" {
source = "./c"
}

View File

@ -1,2 +0,0 @@
# Hello

View File

@ -1,5 +0,0 @@
# Hello
module "bar" {
source = "./bar"
}

View File

@ -1,5 +0,0 @@
# Hello
module "foo" {
source = "./foo"
}

View File

@ -1 +0,0 @@
resource "test_instance" "a-c" {}

View File

@ -1,3 +0,0 @@
module "c" {
source = "./c"
}

View File

@ -1 +0,0 @@
resource "test_instance" "b-c" {}

View File

@ -1,3 +0,0 @@
module "c" {
source = "./c"
}

View File

@ -1,7 +0,0 @@
module "a" {
source = "./a"
}
module "b" {
source = "./b"
}

View File

@ -1,3 +0,0 @@
output "local" {
value = "test"
}

View File

@ -1,3 +0,0 @@
module "provider" {
source = "exists-in-registry/identifier/provider"
}

View File

@ -1,3 +0,0 @@
module "provider" {
source = "namespace/identifier/provider"
}

View File

@ -1,3 +0,0 @@
output "local" {
value = "test"
}

View File

@ -1,7 +0,0 @@
module "foo" {
source = "./foo"
}
module "foo" {
source = "./foo"
}

View File

@ -1,3 +0,0 @@
module "vault" {
source = "hashicorp/vault/aws"
}

Some files were not shown because too many files have changed in this diff Show More