Skip to content
This repository has been archived by the owner on Sep 22, 2020. It is now read-only.

Allow users to provide a Registry URL for storing images #24

Merged
merged 79 commits into from
Mar 3, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
79 commits
Select commit Hold shift + click to select a range
38e8e84
Initial commit - basic infrastructure.
bigkevmcd Feb 6, 2020
18e303a
Update to reflect the new location of kubectl/util/templates.
bigkevmcd Feb 7, 2020
5ca148a
Start of generating Secrets.
bigkevmcd Feb 7, 2020
d04e35c
Include basic driver script.
bigkevmcd Feb 7, 2020
94eae5a
Rename the functions to make them package private.
bigkevmcd Feb 11, 2020
6c7e99f
implement tekton checks Co-authorized-by Ishita Sequelira <isequeir@…
wtam2018 Feb 12, 2020
d2ffb95
incoporate reiview feedbacks
wtam2018 Feb 12, 2020
bba092e
pass array of crd name strings
wtam2018 Feb 12, 2020
7b4eb93
Restructure code and add unit test
wtam2018 Feb 14, 2020
25ef5a8
Kill commented import
wtam2018 Feb 14, 2020
6a49fa6
Add eventlistener and route
chetan-rns Feb 14, 2020
ffb44ea
Import dependency for pipeline v1alpha1
chetan-rns Feb 14, 2020
50d99b8
Replace github repo name in filter string
chetan-rns Feb 14, 2020
5a0e262
Rename baseRepo param to githubRepo param
chetan-rns Feb 14, 2020
346dab9
fix typos, rename interface, use t.Efrror in table test
wtam2018 Feb 14, 2020
eec136a
add error wrapping to errors returned by apis
wtam2018 Feb 14, 2020
9351c47
Delete pipelines
bigkevmcd Feb 17, 2020
0f963cb
Add functions to generate Tekton task objects
chetan-rns Feb 17, 2020
4c5b9ab
initial commit for Gagan
wtam2018 Feb 17, 2020
86ee9a3
initial sumibt oc_adm.go, clean up service bindings.go
wtam2018 Feb 18, 2020
f956540
rename format parameter name to avoid name collision
wtam2018 Feb 18, 2020
16f0548
polish up oc_adm.go and add unit test
wtam2018 Feb 18, 2020
cf66a2a
Add cluster role "edit" creation
wtam2018 Feb 18, 2020
869633d
Replace objects in task_tests with suitable assertive functions
chetan-rns Feb 18, 2020
3f91238
create functions and get rid of the block comments
wtam2018 Feb 18, 2020
a09bb42
incorporate review feedbacks
wtam2018 Feb 18, 2020
e45a313
rename formal arguments from xxxName to name
wtam2018 Feb 18, 2020
1e40c29
Add secret name as parameter to Generate function
chetan-rns Feb 19, 2020
ed0b881
Merge pull request #5 from chetan-rns/bootstrap
wtam2018 Feb 19, 2020
d750ac9
Merge remote-tracking branch 'origin/bootstrap' into gitops-issue-36
wtam2018 Feb 19, 2020
5c5888b
pass ServiceAccount as object to createRoleBinding
wtam2018 Feb 19, 2020
cb6cbe6
pass ServiceAccount as object to createRoleBinding
wtam2018 Feb 19, 2020
7a264a0
Merge pull request #7 from rhd-gitops-example/gitops-issue-36
wtam2018 Feb 19, 2020
84163e7
Drive generation of the YAML for setting up the cluster (#11)
wtam2018 Feb 22, 2020
33b184a
add image-repo flag to pipeline bootstrap
wtam2018 Feb 23, 2020
f4d3ded
pass slice of key/value pairs instead of strings (#13)
wtam2018 Feb 24, 2020
a92de5b
minor flag rename, update description (#12)
wtam2018 Feb 24, 2020
febecc3
resolved merge conflicts
wtam2018 Feb 24, 2020
58f0d3c
improve tests
wtam2018 Feb 24, 2020
62b80f5
Add initial namespace creation logic. (#8)
bigkevmcd Feb 24, 2020
e250774
Merge branch 'bootstrap' of https://github.com/rhd-gitops-example/odo…
wtam2018 Feb 24, 2020
611d56c
Add Buildah to the list of existing tasks (#14)
chetan-rns Feb 24, 2020
5ccc7bb
Gitops issue 39 (#16)
DhanashriPalodkar Feb 25, 2020
fd4dd8b
Merge branch 'bootstrap' of https://github.com/rhd-gitops-example/odo…
wtam2018 Feb 25, 2020
2e439d6
Add function to validate image registry URL
chetan-rns Feb 25, 2020
71d5e6a
Issue 40: Add functions to generate trigger templates and bindings (#15)
chetan-rns Feb 25, 2020
bf5ae9f
Fix dockerconfigjson secret namespace and name swap issue. Move sourc…
wtam2018 Feb 25, 2020
ab6f3f3
Merge branch 'bootstrap' of https://github.com/rhd-gitops-example/odo…
wtam2018 Feb 25, 2020
31fea10
Merge branch 'gitops-issue-47' of https://github.com/rhd-gitops-examp…
wtam2018 Feb 25, 2020
90a5e6a
Issue 53: Add flag to bypass Tekton installation checks. (#19)
chetan-rns Feb 26, 2020
e550443
Changed the service account name from demo-sa to pipeline to run tas…
gaganhegde Feb 26, 2020
6865b76
Merge branch 'bootstrap' of https://github.com/rhd-gitops-example/odo…
wtam2018 Feb 26, 2020
c0be8af
unpack slice before appending to outputs slice, fix ns/name ordering…
wtam2018 Feb 27, 2020
202a9dd
Add params to dev CI pipelinerun (#21)
wtam2018 Feb 27, 2020
6a62a75
add image-repo flag to pipeline bootstrap
wtam2018 Feb 23, 2020
f9aa014
improve tests
wtam2018 Feb 24, 2020
9c5fd06
Add function to validate image registry URL
chetan-rns Feb 25, 2020
71ee764
Pass image repo name as parameter to trigger templates
chetan-rns Feb 27, 2020
a78afac
Gitops issue 44 (#22)
gaganhegde Feb 28, 2020
2e35d13
Merge branch 'bootstrap' of https://github.com/rhd-gitops-example/odo…
wtam2018 Feb 28, 2020
093c596
Merge branch 'gitops-issue-47' of https://github.com/rhd-gitops-examp…
wtam2018 Feb 28, 2020
a60a459
This seems to be lost with merges
wtam2018 Feb 28, 2020
ae2b207
Call t.Run() so that it prints out the test description when they fai…
wtam2018 Feb 28, 2020
b5fe8e6
Make dockerconfigson options as it is not required if internal regist…
wtam2018 Feb 28, 2020
1ca15fe
Issue 46: Add role bindings with edit access (#23)
chetan-rns Feb 28, 2020
2698578
Merge branch 'bootstrap' of https://github.com/rhd-gitops-example/odo…
wtam2018 Feb 28, 2020
80e0dfd
Updated quay-username flag as optional
chetan-rns Feb 28, 2020
282e3ce
Update bootstrap command to support internal registry
chetan-rns Feb 28, 2020
a9fb679
Some cleanup
wtam2018 Feb 29, 2020
1680d16
* Add optional flag to provide internal regiistry hostname with defau…
wtam2018 Mar 2, 2020
83abbcf
Check for namespace existence in internal registry URL
chetan-rns Mar 2, 2020
bb62076
Gitops issue 48 (#25)
gaganhegde Mar 2, 2020
cae3ed0
* Fixed typos
wtam2018 Mar 2, 2020
e876876
Merge branch 'bootstrap' of https://github.com/rhd-gitops-example/odo…
wtam2018 Mar 2, 2020
a50e07f
Issue 46: Add role bindings with edit access (#23)
chetan-rns Feb 28, 2020
55b63b3
* Renamed BootstrapOptions to BootstrapParameters which could contain…
wtam2018 Mar 3, 2020
2c34951
Merge branch 'bootstrap' of https://github.com/rhd-gitops-example/odo…
wtam2018 Mar 3, 2020
b9035f1
fix typos and comments
wtam2018 Mar 3, 2020
dac0d7f
Merge branch 'bootstrap' of https://github.com/rhd-gitops-example/odo…
wtam2018 Mar 3, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion glide.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

64 changes: 34 additions & 30 deletions pkg/odo/cli/pipelines/bootstrap.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,38 +25,39 @@ var (
bootstrapShortDesc = `Bootstrap pipelines`
)

// BootstrapOptions encapsulates the options for the odo pipelines bootstrap
// BootstrapParameters encapsulates the paratmeters for the odo pipelines bootstrap
// command.
type BootstrapOptions struct {
deploymentPath string
quayUsername string
gitRepo string // e.g. tekton/triggers
prefix string // used to generate the environments in a shared cluster
githubToken string
quayIOAuthFilename string
skipChecks bool
type BootstrapParameters struct {
deploymentPath string
githubToken string
gitRepo string // e.g. tekton/triggers
imageRepo string
internalRegistryHostname string
prefix string // used to generate the environments in a shared cluster
dockerConfigJSONFileName string
skipChecks bool
// generic context options common to all commands
*genericclioptions.Context
}

// NewBootstrapOptions bootstraps a BootstrapOptions instance.
func NewBootstrapOptions() *BootstrapOptions {
return &BootstrapOptions{}
// NewBootstrapParameters bootstraps a BootstrapParameters instance.
func NewBootstrapParameters() *BootstrapParameters {
return &BootstrapParameters{}
}

// Complete completes BootstrapOptions after they've been created.
// Complete completes BootstrapParameters after they've been created.
//
// If the prefix provided doesn't have a "-" then one is added, this makes the
// generated environment names nicer to read.
func (bo *BootstrapOptions) Complete(name string, cmd *cobra.Command, args []string) error {
func (bo *BootstrapParameters) Complete(name string, cmd *cobra.Command, args []string) error {
if bo.prefix != "" && !strings.HasSuffix(bo.prefix, "-") {
bo.prefix = bo.prefix + "-"
}
return nil
}

// Validate validates the parameters of the BootstrapOptions.
func (bo *BootstrapOptions) Validate() error {
// Validate validates the parameters of the BootstrapParameters.
func (bo *BootstrapParameters) Validate() error {
// TODO: this won't work with GitLab as the repo can have more path elements.
if len(strings.Split(bo.gitRepo, "/")) != 2 {
return fmt.Errorf("repo must be org/repo: %s", bo.gitRepo)
Expand All @@ -65,22 +66,24 @@ func (bo *BootstrapOptions) Validate() error {
}

// Run runs the project bootstrap command.
func (bo *BootstrapOptions) Run() error {
options := pipelines.BootstrapOptions{
DeploymentPath: bo.deploymentPath,
GithubToken: bo.githubToken,
GitRepo: bo.gitRepo,
Prefix: bo.prefix,
QuayAuthFileName: bo.quayIOAuthFilename,
QuayUserName: bo.quayUsername,
SkipChecks: bo.skipChecks,
func (bo *BootstrapParameters) Run() error {
options := pipelines.BootstrapParameters{
DeploymentPath: bo.deploymentPath,
GithubToken: bo.githubToken,
GitRepo: bo.gitRepo,
ImageRepo: bo.imageRepo,
InternalRegistryHostname: bo.internalRegistryHostname,
Prefix: bo.prefix,
DockerConfigJSONFileName: bo.dockerConfigJSONFileName,
SkipChecks: bo.skipChecks,
}

return pipelines.Bootstrap(&options)
}

// NewCmdBootstrap creates the project bootstrap command.
func NewCmdBootstrap(name, fullName string) *cobra.Command {
o := NewBootstrapOptions()
o := NewBootstrapParameters()

bootstrapCmd := &cobra.Command{
Use: name,
Expand All @@ -93,16 +96,17 @@ func NewCmdBootstrap(name, fullName string) *cobra.Command {
}

bootstrapCmd.Flags().StringVarP(&o.prefix, "prefix", "p", "", "add a prefix to the environment names")
bootstrapCmd.Flags().StringVar(&o.quayUsername, "quay-username", "", "image registry username")
bootstrapCmd.MarkFlagRequired("quay-username")
bootstrapCmd.Flags().StringVar(&o.githubToken, "github-token", "", "provide the Github token")
bootstrapCmd.MarkFlagRequired("github-token")
bootstrapCmd.Flags().StringVar(&o.quayIOAuthFilename, "dockerconfigjson", "", "Docker configuration json filename")
bootstrapCmd.MarkFlagRequired("dockerconfigjson")
bootstrapCmd.Flags().StringVar(&o.dockerConfigJSONFileName, "dockerconfigjson", "", "Docker configuration json filename")
bootstrapCmd.Flags().StringVar(&o.gitRepo, "git-repo", "", "git repository in this form <username>/<repository>")
bootstrapCmd.MarkFlagRequired("git-repo")
bootstrapCmd.Flags().StringVar(&o.imageRepo, "image-repo", "", "image repository in this form <registry>/<username>/<repository> or <project>/<app> for internal registry")
bootstrapCmd.MarkFlagRequired("image-repo")
bootstrapCmd.Flags().StringVar(&o.deploymentPath, "deployment-path", "", "deployment folder path name")
bootstrapCmd.MarkFlagRequired("deployment-path")
bootstrapCmd.Flags().BoolVarP(&o.skipChecks, "skip-checks", "b", false, "skip Tekton installation checks")
bootstrapCmd.Flags().StringVar(&o.internalRegistryHostname, "internal-registry-hostname", "image-registry.openshift-image-registry.svc:5000", "internal image registry hostname")

return bootstrapCmd
}
58 changes: 34 additions & 24 deletions pkg/odo/cli/pipelines/bootstrap_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ type keyValuePair struct {
value string
}

func TestCompleteBootstrapOptions(t *testing.T) {
func TestCompleteBootstrapParameters(t *testing.T) {
completeTests := []struct {
name string
prefix string
Expand All @@ -25,7 +25,7 @@ func TestCompleteBootstrapOptions(t *testing.T) {
}

for _, tt := range completeTests {
o := BootstrapOptions{prefix: tt.prefix}
o := BootstrapParameters{prefix: tt.prefix}

err := o.Complete("test", &cobra.Command{}, []string{"test", "test/repo"})

Expand All @@ -39,7 +39,7 @@ func TestCompleteBootstrapOptions(t *testing.T) {
}
}

func TestValidateBootstrapOptions(t *testing.T) {
func TestValidateBootstrapParameters(t *testing.T) {
optionTests := []struct {
name string
gitRepo string
Expand All @@ -50,7 +50,7 @@ func TestValidateBootstrapOptions(t *testing.T) {
}

for _, tt := range optionTests {
o := BootstrapOptions{quayUsername: "testing", gitRepo: tt.gitRepo, prefix: "test"}
o := BootstrapParameters{gitRepo: tt.gitRepo, prefix: "test"}

err := o.Validate()

Expand All @@ -64,25 +64,33 @@ func TestValidateBootstrapOptions(t *testing.T) {
}
}
}

func TestBootstrapCommandWithMissingParams(t *testing.T) {
cmdTests := []struct {
desc string
flags []keyValuePair
wantErr string
}{
{[]keyValuePair{flag("quay-username", "example"), flag("github-token", "abc123"), flag("dockerconfigjson", "~/"),
flag("deployment-path", "foo")}, `Required flag(s) "git-repo" have/has not been set`},
{[]keyValuePair{flag("quay-username", "example"), flag("github-token", "abc123"), flag("git-repo", "example/repo"),
flag("deployment-path", "foo")}, `Required flag(s) "dockerconfigjson" have/has not been set`},
{[]keyValuePair{flag("quay-username", "example"), flag("dockerconfigjson", "~/"), flag("git-repo", "example/repo"),
flag("deployment-path", "foo")}, `Required flag(s) "github-token" have/has not been set`},
{[]keyValuePair{flag("github-token", "abc123"), flag("dockerconfigjson", "~/"), flag("git-repo", "example/repo"),
flag("deployment-path", "foo")}, `Required flag(s) "quay-username" have/has not been set`},
{"Missing git-repo flag",
[]keyValuePair{flag("github-token", "abc123"),
flag("dockerconfigjson", "~/"), flag("image-repo", "foo/bar/bar"), flag("deployment-path", "foo")},
`Required flag(s) "git-repo" have/has not been set`},
{"Missing github-token flag",
[]keyValuePair{flag("dockerconfigjson", "~/"),
flag("git-repo", "example/repo"), flag("image-repo", "foo/bar/bar"), flag("deployment-path", "foo")},
`Required flag(s) "github-token" have/has not been set`},
{"Missing image-repo",
[]keyValuePair{flag("github-token", "abc123"),
flag("dockerconfigjson", "~/"), flag("git-repo", "example/repo"), flag("deployment-path", "foo")},
`Required flag(s) "image-repo" have/has not been set`},
}
for _, tt := range cmdTests {
_, _, err := executeCommand(NewCmdBootstrap("bootstrap", "odo pipelines bootstrap"), tt.flags...)
if err.Error() != tt.wantErr {
t.Errorf("got %s, want %s", err, tt.wantErr)
}
t.Run(tt.desc, func(t *testing.T) {
_, _, err := executeCommand(NewCmdBootstrap("bootstrap", "odo pipelines bootstrap"), tt.flags...)
if err.Error() != tt.wantErr {
t.Errorf("got %s, want %s", err, tt.wantErr)
}
})
}
}

Expand All @@ -97,17 +105,19 @@ func TestBypassChecks(t *testing.T) {
}

for _, test := range tests {
o := BootstrapOptions{skipChecks: test.skipChecks}
t.Run(test.description, func(t *testing.T) {
o := BootstrapParameters{skipChecks: test.skipChecks}

err := o.Complete("test", &cobra.Command{}, []string{"test", "test/repo"})
err := o.Complete("test", &cobra.Command{}, []string{"test", "test/repo"})

if err != nil {
t.Errorf("Complete() %#v failed: ", err)
}
if err != nil {
t.Errorf("Complete() %#v failed: ", err)
}

if o.skipChecks != test.wantedBypassChecks {
t.Errorf("Complete() %#v bypassChecks flag: got %v, want %v", test.description, o.skipChecks, test.wantedBypassChecks)
}
if o.skipChecks != test.wantedBypassChecks {
t.Errorf("Complete() %#v bypassChecks flag: got %v, want %v", test.description, o.skipChecks, test.wantedBypassChecks)
}
})
}

}
Expand Down
Loading