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

pulls in DRONE_RUNNER_ANNOTATONS and puts it on the job spec #61

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
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
20 changes: 15 additions & 5 deletions engine/kube/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,14 @@ package kube
import (
"path"
"path/filepath"
"strings"
"strconv"
"strings"

"github.com/drone/drone-runtime/engine"
"github.com/drone/drone/cmd/drone-controller/config"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is a standalone package and should not link to the main Drone repository as a dependency.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was wondering about this. I couldn't find a better way to pull the config in without copy-pasting the config code.. :/

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you would typically pass these through the Engine Constructor from Drone https://github.com/drone/drone-runtime/blob/master/engine/kube/kube.go#L34

I recommend looking at how the controller passes the Node to the Engine, for example.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the tip. I will work on this tonight

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This, too has been removed in recent commits!

"github.com/sirupsen/logrus"

"k8s.io/api/core/v1"
v1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/resource"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/intstr"
Expand Down Expand Up @@ -236,6 +238,13 @@ func toResources(step *engine.Step) v1.ResourceRequirements {
// helper function returns a kubernetes pod for the
// given step and specification.
func toPod(spec *engine.Spec, step *engine.Step) *v1.Pod {
config, err := config.Environ()

if err != nil {
logrus.WithError(err).Fatalln("invalid configuration")
Copy link
Member

@bradrydzewski bradrydzewski Mar 28, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should return an error. Fatalln will kill the program.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This has been removed in refactoring to use step config!


}

var volumes []v1.Volume
volumes = append(volumes, toVolumes(spec, step)...)
volumes = append(volumes, toConfigVolumes(spec, step)...)
Expand All @@ -253,9 +262,10 @@ func toPod(spec *engine.Spec, step *engine.Step) *v1.Pod {

return &v1.Pod{
ObjectMeta: metav1.ObjectMeta{
Name: step.Metadata.UID,
Namespace: step.Metadata.Namespace,
Labels: step.Metadata.Labels,
Name: step.Metadata.UID,
Namespace: step.Metadata.Namespace,
Labels: step.Metadata.Labels,
Annotations: config.Runner.Annotations,
},
Spec: v1.PodSpec{
AutomountServiceAccountToken: boolptr(false),
Expand Down