-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Triggers change when that component changed - Delays action execution until after input component has completed
- Loading branch information
1 parent
f0e46c7
commit 7f66bce
Showing
20 changed files
with
388 additions
and
89 deletions.
There are no files selected for viewing
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
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,8 @@ | ||
name: "base-image" | ||
|
||
actions: | ||
build: | ||
commands: | ||
- $ROOT/scripts/build.sh | ||
- docker tag localhost:5000/$COMPONENT_NAME:$INPUTS_HASH localhost:5000/$COMPONENT_NAME:0.1.0 | ||
- docker push localhost:5000/$COMPONENT_NAME:0.1.0 |
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 @@ | ||
FROM alpine |
11 changes: 11 additions & 0 deletions
11
examples/components/with-dependency-on-example-1/.component.yml
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,11 @@ | ||
name: "with-dependency-on-example-1" | ||
|
||
inputs: | ||
- type: "Files" | ||
paths: ["$ROOT/.knega.root.yml"] | ||
- type: "GitFiles" | ||
paths: ["*"] | ||
- type: "Component" | ||
name: "example-1" | ||
- type: "Component" | ||
name: "base-image" |
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 @@ | ||
FROM localhost:5000/base-image:0.1.0 |
11 changes: 11 additions & 0 deletions
11
examples/components/with-nested-dependency-1/.component.yml
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,11 @@ | ||
name: "with-nested-dependency-1" | ||
|
||
inputs: | ||
- type: "Files" | ||
paths: ["$ROOT/.knega.root.yml"] | ||
- type: "GitFiles" | ||
paths: ["*"] | ||
- type: "Component" | ||
name: "with-dependency-on-example-1" | ||
- type: "Component" | ||
name: "base-image" |
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 @@ | ||
FROM localhost:5000/base-image:0.1.0 |
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,28 @@ | ||
package configuration | ||
|
||
import "log" | ||
|
||
type componentInput struct { | ||
name string | ||
} | ||
|
||
func (input componentInput) Hash() []byte { | ||
repository := GetRepository() | ||
var component Component | ||
found := false | ||
for _, repoComponent := range repository.components { | ||
if repoComponent.Name == input.name { | ||
component = repoComponent | ||
found = true | ||
} | ||
} | ||
|
||
if !found { | ||
log.Fatalf("Input component with name %s could not be found", input.name) | ||
} | ||
|
||
// just returning inputshash of that component should be enough if resolved in correct order | ||
// return []byte(component.InputsHash) | ||
// for now we'll need to rerun the calculation | ||
return []byte(calculateHash(component.Inputs)) | ||
} |
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,76 @@ | ||
package configuration | ||
|
||
import ( | ||
"crypto/sha512" | ||
"io" | ||
"log" | ||
"os" | ||
"path/filepath" | ||
"strings" | ||
) | ||
|
||
type fileInput struct { | ||
path string | ||
} | ||
|
||
func fileInputPatternsToPaths(patterns []string, rootPath string) []string { | ||
var results []string | ||
|
||
for _, pattern := range patterns { | ||
pattern = strings.ReplaceAll(pattern, "$ROOT", rootPath) | ||
matches, err := filepath.Glob(pattern) | ||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
results = append(results, matches...) | ||
} | ||
return results | ||
} | ||
|
||
func gitFileInputPatternsToPaths(patterns []string, applicationPath string) []string { | ||
var results []string | ||
|
||
for _, pattern := range patterns { | ||
matches := gitLsFiles(applicationPath, pattern) | ||
for _, relativePath := range matches { | ||
path := filepath.Join(applicationPath, relativePath) | ||
if isFile(path) { | ||
results = append(results, path) | ||
} | ||
} | ||
} | ||
|
||
return results | ||
} | ||
|
||
func deDuplicateStringSlice(paths []string) []string { | ||
pathMap := make(map[string]string) | ||
var results []string | ||
for _, path := range paths { | ||
exists := pathMap[path] | ||
if exists == "" { | ||
pathMap[path] = path | ||
results = append(results, path) | ||
} | ||
} | ||
|
||
return results | ||
} | ||
|
||
func (input fileInput) Hash() []byte { | ||
file, err := os.Open(input.path) | ||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
|
||
defer file.Close() | ||
|
||
hash := sha512.New384() | ||
|
||
_, copyErr := io.Copy(hash, file) | ||
if copyErr != nil { | ||
log.Fatal(copyErr) | ||
} | ||
|
||
return hash.Sum(nil) | ||
} |
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
Oops, something went wrong.