Skip to content

Commit

Permalink
Build annotations (#60)
Browse files Browse the repository at this point in the history
  • Loading branch information
Oleg Sucharevich authored Oct 2, 2019
1 parent 0e52769 commit 034e4e3
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 6 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "venona",
"version": "0.27.1",
"version": "0.28.0",
"description": "Codefresh agent to run on Codefresh's runtime environment and execute pipeline",
"main": "index.js",
"scripts": {
Expand Down
13 changes: 13 additions & 0 deletions venonactl/cmd/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ var installCmdOptions struct {
runtimeEnvironmentName string
kubernetesRunnerType bool
buildNodeSelector string
buildAnnotations []string
}

// installCmd represents the install command
Expand Down Expand Up @@ -145,6 +146,17 @@ var installCmd = &cobra.Command{
builderInstallOpt.KubeBuilder = getKubeClientBuilder(builderInstallOpt.ClusterName, s.KubernetesAPI.Namespace, s.KubernetesAPI.ConfigPath, s.KubernetesAPI.InCluster)
builderInstallOpt.ClusterNamespace = s.KubernetesAPI.Namespace

annotations := make(map[string]string)
for _, annotation := range installCmdOptions.buildAnnotations {
v := strings.Split(annotation, "=")
if len(v) != 2 {
dieOnError(errors.New("annotations must be in form \"key=value\""))
}
annotations[v[0]] = v[1]
}

builderInstallOpt.Annotations = annotations

bns, err := parseNodeSelector(installCmdOptions.buildNodeSelector)
if err != nil {
dieOnError(err)
Expand Down Expand Up @@ -177,6 +189,7 @@ func init() {
installCmd.Flags().StringVar(&installCmdOptions.storageClass, "storage-class", "", "Set a name of your custom storage class, note: this will not install volume provisioning components")
installCmd.Flags().StringVar(&installCmdOptions.kube.nodeSelector, "kube-node-selector", "", "The kubernetes node selector \"key=value\" to be used by venona resources (default is no node selector)")
installCmd.Flags().StringVar(&installCmdOptions.buildNodeSelector, "build-node-selector", "", "The kubernetes node selector \"key=value\" to be used by venona build resources (default is no node selector)")
installCmd.Flags().StringArrayVar(&installCmdOptions.buildAnnotations, "build-annotations", []string{}, "The kubernetes metadata.annotations as \"key=value\" to be used by venona build resources (default is no node selector)")

installCmd.Flags().BoolVar(&installCmdOptions.skipRuntimeInstallation, "skip-runtime-installation", false, "Set flag if you already have a configured runtime-environment, add --runtime-environment flag with name")
installCmd.Flags().BoolVar(&installCmdOptions.kube.inCluster, "in-cluster", false, "Set flag if venona is been installed from inside a cluster")
Expand Down
10 changes: 7 additions & 3 deletions venonactl/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module github.com/codefresh-io/venona/venonactl
require (
contrib.go.opencensus.io/exporter/ocagent v0.4.3 // indirect
github.com/Azure/go-autorest v11.4.0+incompatible // indirect
github.com/codefresh-io/go-sdk v0.16.0
github.com/codefresh-io/go-sdk v0.17.0
github.com/dustin/go-humanize v1.0.0
github.com/google/go-github/v21 v21.0.0
github.com/google/gofuzz v0.0.0-20161122191042-44d81051d367 // indirect
Expand All @@ -25,17 +25,21 @@ require (
github.com/spf13/afero v1.2.2 // indirect
github.com/spf13/cobra v0.0.5
github.com/spf13/jwalterweatherman v1.1.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/spf13/viper v1.4.0
go.opencensus.io v0.19.0 // indirect
golang.org/x/sys v0.0.0-20190912141932-bc967efca4b8 // indirect
golang.org/x/sys v0.0.0-20191002091554-b397fe3ad8ed // indirect
golang.org/x/text v0.3.2 // indirect
google.golang.org/appengine v1.4.0 // indirect
gopkg.in/inf.v0 v0.9.0 // indirect
gopkg.in/yaml.v2 v2.2.3 // indirect
k8s.io/api v0.0.0-20181221193117-173ce66c1e39
k8s.io/apimachinery v0.0.0-20181127025237-2b1284ed4c93
k8s.io/client-go v10.0.0+incompatible
k8s.io/klog v0.0.0-20181108234604-8139d8cb77af // indirect
sigs.k8s.io/yaml v1.1.0 // indirect
)

replace git.apache.org/thrift.git => github.com/apache/thrift v0.0.0-20181218151757-9b75e4fe745a
replace git.apache.org/thrift.git => github.com/apache/thrift v0.0.0-20181218151757-9b75e4fe745a

go 1.13
11 changes: 9 additions & 2 deletions venonactl/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ github.com/census-instrumentation/opencensus-proto v0.1.0-0.20181214143942-ba49f
github.com/census-instrumentation/opencensus-proto v0.1.0-0.20181214143942-ba49f56771b8/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc=
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
github.com/codefresh-io/go-sdk v0.16.0 h1:vj59hlmxTW8JIk/UOTvIgEsfa+xoHF8ck19H7WTZxac=
github.com/codefresh-io/go-sdk v0.16.0/go.mod h1:U8c2f9/Vb2SXFbeKHSzofUOp3N78pDC3YdshFsUfdgc=
github.com/codefresh-io/go-sdk v0.17.0 h1:0fwE4K0QeqM2VfyjiALzkH2se4HbLh9BiQCuzQnJH/U=
github.com/codefresh-io/go-sdk v0.17.0/go.mod h1:b6hK9euSW+MDXUDHU1+YgP8vzcij749I31ZIZSXed+I=
github.com/coreos/bbolt v1.3.2/go.mod h1:iRUV2dpdMOn7Bo10OQBFzIJO9kkE559Wcmn+qkEiiKk=
github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE=
github.com/coreos/go-etcd v2.0.0+incompatible/go.mod h1:Jez6KQU2B/sWsbdaef3ED8NzMklzPG4d5KIOhIy30Tk=
Expand Down Expand Up @@ -113,6 +113,7 @@ github.com/mattn/go-runewidth v0.0.4 h1:2BvfKmzob6Bmd4YsL0zygOqfdFnK7GR4QL06Do4/
github.com/mattn/go-runewidth v0.0.4/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU=
github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
github.com/mitchellh/go-homedir v1.0.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y=
github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
github.com/mitchellh/mapstructure v1.1.2 h1:fmNYVwqnSfB9mZU6OS2O6GsXM+wcskZDuKQzvN1EDeE=
github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y=
Expand Down Expand Up @@ -169,6 +170,8 @@ github.com/spf13/jwalterweatherman v1.1.0 h1:ue6voC5bR5F8YxI5S67j9i582FU4Qvo2bmq
github.com/spf13/jwalterweatherman v1.1.0/go.mod h1:aNWZUN0dPAAO/Ljvb5BEdw96iTZ0EXowPYD95IqWIGo=
github.com/spf13/pflag v1.0.3 h1:zPAT6CGy6wXeQ7NtTnaTerfKOsV6V6F8agHXFiazDkg=
github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4=
github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
github.com/spf13/viper v1.3.1/go.mod h1:ZiWeW+zYFKm7srdB9IoDzzZXaJaI5eL9QjNiN/DMA2s=
github.com/spf13/viper v1.3.2/go.mod h1:ZiWeW+zYFKm7srdB9IoDzzZXaJaI5eL9QjNiN/DMA2s=
github.com/spf13/viper v1.4.0 h1:yXHLWeravcrgGyFSyCgdYpXQ9dR9c/WED3pg1RhxqEU=
Expand Down Expand Up @@ -227,6 +230,8 @@ golang.org/x/sys v0.0.0-20181228144115-9a3f9b0469bb/go.mod h1:STP8DvDyc/dI5b8T5h
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190912141932-bc967efca4b8 h1:41hwlulw1prEMBxLQSlMSux1zxJf07B3WPsdjJlKZxE=
golang.org/x/sys v0.0.0-20190912141932-bc967efca4b8/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20191002091554-b397fe3ad8ed h1:5TJcLJn2a55mJjzYk0yOoqN8X1OdvBDUnaZaKKyQtkY=
golang.org/x/sys v0.0.0-20191002091554-b397fe3ad8ed/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.2 h1:tW2bmiBqwgJj/UpqtC8EpXEZVYOwU0yG4iWbprSVAcs=
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
Expand Down Expand Up @@ -267,6 +272,8 @@ gopkg.in/yaml.v2 v2.0.0-20170812160011-eb3733d160e7/go.mod h1:JAlM8MvJe8wmxCU4Bl
gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.3 h1:fvjTMHxHEw/mxHbtzPi3JCcKXQRAnQTBRo6YCJSVHKI=
gopkg.in/yaml.v2 v2.2.3/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
honnef.co/go/tools v0.0.0-20180728063816-88497007e858/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
honnef.co/go/tools v0.0.0-20180920025451-e3ad64cb4ed3/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
Expand Down
7 changes: 7 additions & 0 deletions venonactl/pkg/codefresh/cfapi.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ type (
IsDefaultStorageClass bool
KubernetesRunnerType bool
BuildNodeSelector map[string]string
Annootaions map[string]string
}

RuntimeEnvironmentRegistrator interface {
Expand All @@ -62,6 +63,7 @@ type (
isDefaultStorageClass bool
kubernetesRunnerType bool
buildNodeSelector map[string]string
annotations map[string]string
}

logger interface {
Expand All @@ -86,6 +88,7 @@ func NewCodefreshAPI(opt *APIOptions) API {
isDefaultStorageClass: opt.IsDefaultStorageClass,
kubernetesRunnerType: opt.KubernetesRunnerType,
buildNodeSelector: opt.BuildNodeSelector,
annotations: opt.Annootaions,
}
}

Expand Down Expand Up @@ -180,6 +183,10 @@ func (a *api) Register() (*codefresh.RuntimeEnvironment, error) {
options.StorageClass = a.storageClass
}

if len(a.annotations) != 0 {
options.Annotations = a.annotations
}

re, err := a.codefresh.RuntimeEnvironments().Create(options)
if err != nil {
return nil, err
Expand Down
1 change: 1 addition & 0 deletions venonactl/pkg/plugins/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ type (
DryRun bool
KubernetesRunnerType bool
BuildNodeSelector map[string]string
Annotations map[string]string
}

DeleteOptions struct {
Expand Down
1 change: 1 addition & 0 deletions venonactl/pkg/plugins/runtime-environment.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ func (u *runtimeEnvironmentPlugin) Install(opt *InstallOptions, v Values) (Value
IsDefaultStorageClass: opt.IsDefaultStorageClass,
KubernetesRunnerType: opt.KubernetesRunnerType,
BuildNodeSelector: opt.BuildNodeSelector,
Annootaions: opt.Annotations,
}

cf := codefresh.NewCodefreshAPI(cfOpt)
Expand Down

0 comments on commit 034e4e3

Please sign in to comment.