-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove runtime dependency on Build controller #326
Merged
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
493145c
Create and watch Pods directly
imjasonh e3a52f2
Vendor build cmds, update deps, fix controller/main.go
imjasonh 0064f0e
Build and use base image for creds-init and git-init
imjasonh 1d34458
Use knative/build:build-base for now
imjasonh 87de70e
fix merge bugs
imjasonh b2008ab
update-codegen
imjasonh cb06bfe
Correctly create Pod, and track correct ref
imjasonh 8108ebb
Move sidecar containers into build-pipeline repo; kodata symlinks did…
imjasonh cb2b2ac
Fork pod.go, don't vendor it
imjasonh 3283cb8
Fix e2e test
imjasonh 4dca80e
Remove build client from tests and reconciler
imjasonh dc3bb13
Address review comments; fork images/ from build
imjasonh f2e7a2e
Fix e2e YAML tests
imjasonh e86be5f
Update taskrun_types_test.go
imjasonh File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
baseImageOverrides: | ||
# TODO(jasonhall): Use build-base in the build-pipeline path, when it's build/released. | ||
github.com/knative/build-pipeline/cmd/creds-init: gcr.io/knative-nightly/github.com/knative/build/build-base:latest | ||
github.com/knative/build-pipeline/cmd/git-init: gcr.io/knative-nightly/github.com/knative/build/build-base:latest |
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,4 @@ | ||
baseImageOverrides: | ||
# TODO(jasonhall): Use build-base in the build-pipeline path, when it's build/released. | ||
github.com/knative/build-pipeline/cmd/creds-init: gcr.io/knative-release/github.com/knative/build/build-base:latest | ||
github.com/knative/build-pipeline/cmd/git-init: gcr.io/knative-release/github.com/knative/build/build-base:latest |
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
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 @@ | ||
../../../.git/HEAD |
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 @@ | ||
../../../LICENSE |
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 @@ | ||
../../../third_party/VENDOR-LICENSE |
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,41 @@ | ||
/* | ||
Copyright 2018 The Knative Authors | ||
|
||
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" | ||
|
||
"github.com/knative/build-pipeline/pkg/credentials" | ||
"github.com/knative/build-pipeline/pkg/credentials/dockercreds" | ||
"github.com/knative/build-pipeline/pkg/credentials/gitcreds" | ||
"github.com/knative/pkg/logging" | ||
) | ||
|
||
func main() { | ||
flag.Parse() | ||
|
||
// ignore atomic level because we are not watching this config for any updates | ||
logger, _ := logging.NewLogger("", "creds-init") | ||
defer logger.Sync() | ||
|
||
builders := []credentials.Builder{dockercreds.NewBuilder(), gitcreds.NewBuilder()} | ||
for _, c := range builders { | ||
if err := c.Write(); err != nil { | ||
logger.Fatalf("Error initializing credentials: %v", err) | ||
} | ||
} | ||
logger.Infof("Credentials initialized.") | ||
} |
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 @@ | ||
../../../.git/HEAD |
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 @@ | ||
../../../LICENSE |
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 @@ | ||
../../../third_party/VENDOR-LICENSE |
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,93 @@ | ||
/* | ||
Copyright 2018 The Knative Authors | ||
|
||
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 ( | ||
"bytes" | ||
"flag" | ||
"os" | ||
"os/exec" | ||
"path/filepath" | ||
|
||
"github.com/knative/pkg/logging" | ||
"go.uber.org/zap" | ||
) | ||
|
||
var ( | ||
url = flag.String("url", "", "The url of the Git repository to initialize.") | ||
revision = flag.String("revision", "", "The Git revision to make the repository HEAD") | ||
path = flag.String("path", "", "Path of directory under which git repository will be copied") | ||
) | ||
|
||
func run(logger *zap.SugaredLogger, cmd string, args ...string) { | ||
c := exec.Command(cmd, args...) | ||
var output bytes.Buffer | ||
c.Stderr = &output | ||
c.Stdout = &output | ||
if err := c.Run(); err != nil { | ||
logger.Errorf("Error running %v %v: %v\n%v", cmd, args, err, output.String()) | ||
} | ||
} | ||
|
||
func runOrFail(logger *zap.SugaredLogger, cmd string, args ...string) { | ||
c := exec.Command(cmd, args...) | ||
var output bytes.Buffer | ||
c.Stderr = &output | ||
c.Stdout = &output | ||
|
||
if err := c.Run(); err != nil { | ||
logger.Fatalf("Unexpected error running %v %v: %v\n%v", cmd, args, err, output.String()) | ||
} | ||
} | ||
|
||
func main() { | ||
flag.Parse() | ||
logger, _ := logging.NewLogger("", "git-init") | ||
defer logger.Sync() | ||
|
||
// HACK HACK HACK | ||
// Git seems to ignore $HOME/.ssh and look in /root/.ssh for unknown reasons. | ||
// As a workaround, symlink /root/.ssh to where we expect the $HOME to land. | ||
// This means SSH auth only works for our built-in git support, and not | ||
// custom steps. | ||
err := os.Symlink("/builder/home/.ssh", "/root/.ssh") | ||
if err != nil { | ||
logger.Fatalf("Unexpected error creating symlink: %v", err) | ||
} | ||
|
||
dir, err := os.Getwd() | ||
if err != nil { | ||
logger.Errorf("Failed to get current dir", err) | ||
} | ||
|
||
if *path != "" { | ||
runOrFail(logger, "git", "init", *path) | ||
path := filepath.Join(dir, *path) | ||
if err := os.Chdir(path); err != nil { | ||
logger.Fatalf("Failed to change directory with path %s; err %v", path, err) | ||
} | ||
// update dir variable with new path | ||
dir = path | ||
} else { | ||
run(logger, "git", "init") | ||
} | ||
|
||
run(logger, "git", "remote", "add", "origin", *url) | ||
runOrFail(logger, "git", "fetch", "--depth=1", "--recurse-submodules=yes", "origin", *revision) | ||
runOrFail(logger, "git", "reset", "--hard", "FETCH_HEAD") | ||
|
||
logger.Infof("Successfully cloned %q @ %q in path %q", *url, *revision, dir) | ||
} |
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 @@ | ||
../../../.git/HEAD |
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 @@ | ||
../../../LICENSE |
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 @@ | ||
../../../third_party/VENDOR-LICENSE |
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
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,4 @@ | ||
FROM alpine:latest | ||
|
||
RUN apk add --update git openssh-client | ||
|
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 |
---|---|---|
|
@@ -174,11 +174,11 @@ type TaskRunList struct { | |
Items []TaskRun `json:"items"` | ||
} | ||
|
||
// GetBuildRef for task | ||
func (tr *TaskRun) GetBuildRef() corev1.ObjectReference { | ||
// GetBuildPodRef for task | ||
func (tr *TaskRun) GetBuildPodRef() corev1.ObjectReference { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: comment for the function is referring to old function name |
||
return corev1.ObjectReference{ | ||
APIVersion: "build.knative.dev/v1alpha1", | ||
Kind: "Build", | ||
APIVersion: "v1", | ||
Kind: "Pod", | ||
Namespace: tr.Namespace, | ||
Name: tr.Name, | ||
} | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggestion:
In output PR, I am introducing shell based image. We could consider using that image and pass arguments
echo Build Successful
instead of maintaining nop imageThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe. Having this image based on distroless/base means that the image doesn't have a shell at all, which reduces its size and attack surface. I'm not opposed if this becomes difficult to maintain for some reason, but we should bias toward minimal images where possible.