Skip to content
This repository has been archived by the owner on Apr 30, 2021. It is now read-only.

Commit

Permalink
Merge pull request #1200 from alphagov/update-conc-op-6-6
Browse files Browse the repository at this point in the history
concourse-operator: updates for concourse v6.6.0
  • Loading branch information
Chris Farmiloe authored Oct 14, 2020
2 parents a5c36f6 + 9a00e98 commit 83219bb
Show file tree
Hide file tree
Showing 8 changed files with 113 additions and 23 deletions.
2 changes: 1 addition & 1 deletion components/concourse-operator/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.11 as builder
FROM golang:1.13 as builder

# install dep (required when not vendored)
RUN wget https://github.com/golang/dep/releases/download/v0.5.3/dep-linux-amd64 \
Expand Down
106 changes: 99 additions & 7 deletions components/concourse-operator/Gopkg.lock

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

3 changes: 2 additions & 1 deletion components/concourse-operator/Gopkg.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ ignored = [

[[constraint]]
name="github.com/concourse/concourse"
version="v6.4.0"
version="v6.6.0"

# STANZAS BELOW ARE GENERATED AND MAY BE WRITTEN - DO NOT MODIFY BELOW THIS LINE.

Expand All @@ -44,3 +44,4 @@ ignored = [
name = "gopkg.in/fsnotify.v1"
source = "https://github.com/fsnotify/fsnotify.git"
version="v1.4.7"

7 changes: 2 additions & 5 deletions components/concourse-operator/pkg/controller/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ func NewClientFromEnv(team string) (concourse.Client, error) {
Password: os.Getenv("CONCOURSE_PASSWORD"),
TeamName: team,
InsecureSkipVerify: os.Getenv("CONCOURSE_INSECURE_SKIP_VERIFY") == "true",
EnableTracing: os.Getenv("CONCOURSE_ENABLE_TRACING") == "true",
}
return newClient(cfg)
}
Expand All @@ -49,14 +50,10 @@ func newClient(cfg ConcourseClientConfig) (concourse.Client, error) {
if err != nil {
return nil, fmt.Errorf("resource: couldn't obtain auth token: %s", err)
}
idToken, ok := token.Extra("id_token").(string)
if !ok {
return nil, fmt.Errorf("failed to find id_token extra in oauth2 token")
}
// create a concourse client
client := concourse.NewClient(cfg.ATCAddr, &http.Client{
Transport: ConcourseAuthTransport{
AccessToken: idToken,
AccessToken: token.AccessToken,
TokenType: token.TokenType,
TLSClientConfig: &tls.Config{InsecureSkipVerify: cfg.InsecureSkipVerify},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ func TestReconcile(t *testing.T) {
pipelineString := `---
jobs:
- name: say-hello
task:
plan:
- task:
config:
platform: linux
image_resource:
Expand All @@ -64,7 +65,7 @@ jobs:
path: echo
args: [hello world]
`
err := yaml.Unmarshal([]byte(pipelineString), &config)
err := atc.UnmarshalConfig([]byte(pipelineString), &config)
g.Expect(err).NotTo(gomega.HaveOccurred())

pipelineResourceWithConfig := &concoursev1beta1.Pipeline{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ func (r *ReconcileTeam) update(instance *concoursev1beta1.Team) error {
if err != nil {
return err
}
_, _, _, err = concourseClient.Team(team.Name).CreateOrUpdate(team)
_, _, _, _, err = concourseClient.Team(team.Name).CreateOrUpdate(team)
if err != nil {
return err
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import (

concoursev1beta1 "github.com/alphagov/gsp/components/concourse-operator/pkg/apis/concourse/v1beta1"
"github.com/concourse/concourse/atc"
"gopkg.in/yaml.v2"
"github.com/concourse/concourse/atc/configvalidate"
"sigs.k8s.io/controller-runtime/pkg/runtime/inject"
"sigs.k8s.io/controller-runtime/pkg/webhook/admission"
"sigs.k8s.io/controller-runtime/pkg/webhook/admission/types"
Expand Down Expand Up @@ -65,7 +65,7 @@ func (h *PipelineCreateUpdateHandler) Validate(config *atc.Config) (bool, string
func (h *PipelineCreateUpdateHandler) validationWarnings(config *atc.Config) ([]string, error) {
warnings := []string{}

warningMessages, errorMessages := config.Validate()
warningMessages, errorMessages := configvalidate.Validate(*config)

if len(warningMessages) > 0 {
for _, warning := range warningMessages {
Expand Down Expand Up @@ -98,7 +98,7 @@ func (h *PipelineCreateUpdateHandler) Handle(ctx context.Context, req types.Requ
if len(obj.Spec.Config.Jobs) > 0 {
config = obj.Spec.Config
} else if obj.Spec.PipelineString != "" {
err := yaml.Unmarshal([]byte(obj.Spec.PipelineString), &config)
err := atc.UnmarshalConfig([]byte(obj.Spec.PipelineString), &config)
if err != nil {
return admission.ErrorResponse(http.StatusInternalServerError, err)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"testing"

"github.com/concourse/concourse/atc"
"gopkg.in/yaml.v2"
)

type ValidationTestCase struct {
Expand Down Expand Up @@ -61,7 +60,7 @@ jobs:
{
Name: "non-existant-resource",
Valid: false,
ValidationMessageContains: "non-existant-resource refers to a resource that does not exist",
ValidationMessageContains: "jobs.bad-job.plan.do[0].get(non-existant-resource): unknown resource",
Pipeline: `
jobs:
- name: bad-job
Expand Down Expand Up @@ -92,7 +91,7 @@ func TestPipelineValidation(t *testing.T) {
func testPipelineValidation(tc ValidationTestCase) error {
h := &PipelineCreateUpdateHandler{}
var config atc.Config
unmarshalError := yaml.Unmarshal([]byte(tc.Pipeline), &config)
unmarshalError := atc.UnmarshalConfig([]byte(tc.Pipeline), &config)
if unmarshalError != nil {
return fmt.Errorf("did not expect unmarshalError but got: %v", unmarshalError)
}
Expand Down

0 comments on commit 83219bb

Please sign in to comment.