Skip to content

Commit 22d749d

Browse files
committed
Changed the mg dev build and mg dev up flow. mg dev build now creates
and updates buildconfig's and imagestreams. mg dev up creates or updates deployment and configuration related manifests.
1 parent 72a86a7 commit 22d749d

File tree

5 files changed

+23
-8
lines changed

5 files changed

+23
-8
lines changed

go.mod

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ require (
99
github.com/coreos/prometheus-operator v0.41.1
1010
github.com/crossplane/crossplane-runtime v0.9.0 // indirect
1111
github.com/crossplane/oam-kubernetes-runtime v0.0.9
12+
github.com/ghodss/yaml v1.0.0
1213
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b
1314
github.com/google/go-containerregistry v0.4.0
1415
github.com/google/gofuzz v1.2.0 // indirect

mg/cmd/config.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Copyright 2019 The metaGraf Authors
2+
Copyright 2019-2021 The metaGraf Authors
33
44
Licensed under the Apache License, Version 2.0 (the "License");
55
you may not use this file except in compliance with the License.

mg/cmd/dev.go

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ func init() {
3939

4040
devCmd.AddCommand(devCmdUp)
4141
devCmdUp.Flags().StringVarP(&params.NameSpace, "namespace", "n", "", "namespace to work on, if not supplied it will use current active namespace.")
42-
devCmdUp.Flags().StringVar(&params.SourceRef, "ref", "", "use for overriding source ref or branch ref in buildconfig.")
4342
devCmdUp.Flags().StringSliceVar(&CVars, "cvars", []string{}, "Slice of key=value pairs, seperated by ,")
4443
devCmdUp.Flags().StringVar(&params.PropertiesFile, "cvfile", "", "Property file with component configuration values. Can be generated with \"mg generate properties\" command.)")
4544
devCmdUp.Flags().StringVar(&OName, "name", "", "Overrides name of application.")
@@ -59,6 +58,7 @@ func init() {
5958
devCmdDown.Flags().StringVar(&OName, "name", "", "Overrides name of application.")
6059

6160
devCmd.AddCommand(devCmdBuild)
61+
devCmdBuild.Flags().StringVar(&params.SourceRef, "ref", "master", "Specify the git ref or branch ref to build.")
6262
devCmdBuild.Flags().StringVarP(&params.NameSpace, "namespace", "n", "", "namespace to work on, if not supplied it will use current active namespace.")
6363
devCmdBuild.Flags().BoolVar(&params.LocalBuild, "local", false, "Builds application from src in current (.) direcotry.")
6464
}
@@ -110,6 +110,17 @@ var devCmdBuild = &cobra.Command{
110110
mg := metagraf.Parse(args[0])
111111
bc := mg.Name(OName, Version)
112112

113+
FlagPassingHack()
114+
modules.NameSpace = params.NameSpace
115+
116+
// Remove RepSecRef from generated BuildConfig if --local argument is provided.
117+
if params.LocalBuild && len(mg.Spec.RepSecRef) > 0 {
118+
mg.Spec.RepSecRef = ""
119+
}
120+
121+
modules.GenImageStream(&mg, params.NameSpace)
122+
modules.GenBuildConfig(&mg)
123+
113124
path, err := exec.LookPath("oc")
114125
if err != nil {
115126
log.Fatal(err)
@@ -143,8 +154,6 @@ func devUp(mgf string) {
143154
modules.PullPolicy = corev1.PullAlways
144155
modules.GenSecrets(&mg)
145156
modules.GenConfigMaps(&mg)
146-
modules.GenImageStream(&mg, params.NameSpace)
147-
modules.GenBuildConfig(&mg)
148157
modules.GenDeploymentConfig(&mg)
149158
modules.GenService(&mg)
150159
modules.GenRoute(&mg)

mg/cmd/kaniko.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ var kanikoCreateRegistryCredentialsCmd = &cobra.Command{
177177
if err != nil {
178178
log.Fatal(err)
179179
}
180-
fmt.Println("created secret: %v", res.Name)
180+
fmt.Printf("created secret: %v", res.Name)
181181
}
182182

183183
if Output {

pkg/modules/buildconfig.go

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -185,16 +185,21 @@ func genGitBuildSource(mg *metagraf.MetaGraf) buildv1.BuildSource {
185185
branch = mg.Spec.Branch
186186
}
187187

188-
return buildv1.BuildSource{
188+
bs := buildv1.BuildSource{
189189
Type: "Git",
190190
Git: &buildv1.GitBuildSource{
191191
URI: mg.Spec.Repository,
192192
Ref: branch,
193193
},
194-
SourceSecret: &corev1.LocalObjectReference{
194+
}
195+
196+
if len(mg.Spec.RepSecRef) > 0 {
197+
bs.SourceSecret = &corev1.LocalObjectReference{
195198
Name: mg.Spec.RepSecRef,
196-
},
199+
}
197200
}
201+
202+
return bs
198203
}
199204

200205
func StoreBuildConfig(obj buildv1.BuildConfig) {

0 commit comments

Comments
 (0)