├── .gitignore ├── NOTICE ├── vendor ├── github.com │ ├── coreos │ │ ├── go-systemd │ │ │ ├── NOTICE │ │ │ ├── dbus │ │ │ │ ├── set.go │ │ │ │ └── subscription_set.go │ │ │ └── unit │ │ │ │ ├── option.go │ │ │ │ └── serialize.go │ │ ├── ignition │ │ │ ├── NOTICE │ │ │ └── config │ │ │ │ ├── v1 │ │ │ │ ├── types │ │ │ │ │ ├── systemd.go │ │ │ │ │ ├── networkd.go │ │ │ │ │ ├── passwd.go │ │ │ │ │ ├── storage.go │ │ │ │ │ ├── group.go │ │ │ │ │ ├── config.go │ │ │ │ │ ├── path.go │ │ │ │ │ ├── file.go │ │ │ │ │ ├── raid.go │ │ │ │ │ ├── user.go │ │ │ │ │ ├── filesystem.go │ │ │ │ │ ├── partition.go │ │ │ │ │ └── unit.go │ │ │ │ ├── cloudinit.go │ │ │ │ └── config.go │ │ │ │ ├── v2_0 │ │ │ │ ├── types │ │ │ │ │ ├── systemd.go │ │ │ │ │ ├── verification.go │ │ │ │ │ ├── networkd.go │ │ │ │ │ ├── passwd.go │ │ │ │ │ ├── group.go │ │ │ │ │ ├── storage.go │ │ │ │ │ ├── compression.go │ │ │ │ │ ├── path.go │ │ │ │ │ ├── raid.go │ │ │ │ │ ├── user.go │ │ │ │ │ ├── url.go │ │ │ │ │ ├── hash.go │ │ │ │ │ ├── file.go │ │ │ │ │ ├── filesystem.go │ │ │ │ │ ├── ignition.go │ │ │ │ │ ├── partition.go │ │ │ │ │ └── config.go │ │ │ │ ├── cloudinit.go │ │ │ │ ├── config.go │ │ │ │ └── append.go │ │ │ │ ├── v2_1 │ │ │ │ ├── types │ │ │ │ │ ├── mode.go │ │ │ │ │ ├── path.go │ │ │ │ │ ├── directory.go │ │ │ │ │ ├── link.go │ │ │ │ │ ├── url.go │ │ │ │ │ ├── file.go │ │ │ │ │ ├── ignition.go │ │ │ │ │ ├── raid.go │ │ │ │ │ ├── passwd.go │ │ │ │ │ ├── node.go │ │ │ │ │ ├── verification.go │ │ │ │ │ ├── partition.go │ │ │ │ │ ├── config.go │ │ │ │ │ └── unit.go │ │ │ │ ├── cloudinit.go │ │ │ │ ├── config.go │ │ │ │ └── append.go │ │ │ │ ├── util │ │ │ │ ├── helpers.go │ │ │ │ └── parsingErrors.go │ │ │ │ ├── v2_2 │ │ │ │ ├── types │ │ │ │ │ ├── path.go │ │ │ │ │ ├── mode.go │ │ │ │ │ ├── ca.go │ │ │ │ │ ├── link.go │ │ │ │ │ ├── directory.go │ │ │ │ │ ├── url.go │ │ │ │ │ ├── ignition.go │ │ │ │ │ ├── raid.go │ │ │ │ │ ├── file.go │ │ │ │ │ ├── passwd.go │ │ │ │ │ ├── node.go │ │ │ │ │ ├── verification.go │ │ │ │ │ ├── partition.go │ │ │ │ │ └── config.go │ │ │ │ ├── cloudinit.go │ │ │ │ ├── config.go │ │ │ │ └── append.go │ │ │ │ ├── v2_3_experimental │ │ │ │ └── types │ │ │ │ │ ├── mode.go │ │ │ │ │ ├── path.go │ │ │ │ │ ├── ca.go │ │ │ │ │ ├── link.go │ │ │ │ │ ├── directory.go │ │ │ │ │ ├── url.go │ │ │ │ │ ├── ignition.go │ │ │ │ │ ├── raid.go │ │ │ │ │ ├── passwd.go │ │ │ │ │ ├── node.go │ │ │ │ │ ├── file.go │ │ │ │ │ ├── verification.go │ │ │ │ │ ├── partition.go │ │ │ │ │ └── config.go │ │ │ │ ├── validate │ │ │ │ ├── astnode │ │ │ │ │ └── astnode.go │ │ │ │ └── astjson │ │ │ │ │ └── node.go │ │ │ │ └── shared │ │ │ │ └── validations │ │ │ │ └── unit.go │ │ ├── coreos-cloudinit │ │ │ ├── NOTICE │ │ │ └── config │ │ │ │ ├── etc_hosts.go │ │ │ │ ├── oem.go │ │ │ │ ├── update.go │ │ │ │ ├── script.go │ │ │ │ ├── file.go │ │ │ │ ├── ignition.go │ │ │ │ ├── unit.go │ │ │ │ ├── decode.go │ │ │ │ ├── flannel.go │ │ │ │ ├── locksmith.go │ │ │ │ ├── validate │ │ │ │ ├── context.go │ │ │ │ └── report.go │ │ │ │ ├── user.go │ │ │ │ └── fleet.go │ │ ├── go-semver │ │ │ ├── example.go │ │ │ └── semver │ │ │ │ └── sort.go │ │ └── yaml │ │ │ ├── LICENSE.libyaml │ │ │ ├── writerc.go │ │ │ └── sorter.go │ ├── gorilla │ │ ├── mux │ │ │ ├── context_native.go │ │ │ ├── context_gorilla.go │ │ │ ├── test_helpers.go │ │ │ ├── middleware.go │ │ │ └── LICENSE │ │ └── context │ │ │ ├── LICENSE │ │ │ └── doc.go │ ├── crawford │ │ └── nap │ │ │ ├── LICENSE │ │ │ ├── status.go │ │ │ └── nap.go │ ├── vincent-petithory │ │ └── dataurl │ │ │ ├── LICENSE │ │ │ └── doc.go │ └── ajeddeloh │ │ └── go-json │ │ └── tags.go └── go4.org │ └── errorutil │ └── highlight.go ├── Dockerfile ├── glide.yaml ├── README.md ├── DCO ├── glide.lock └── code-of-conduct.md /.gitignore: -------------------------------------------------------------------------------- 1 | bin/ 2 | gopath/ 3 | *.swp 4 | -------------------------------------------------------------------------------- /NOTICE: -------------------------------------------------------------------------------- 1 | CoreOS Project 2 | Copyright 2018 CoreOS, Inc 3 | 4 | This product includes software developed at CoreOS, Inc. 5 | (http://www.coreos.com/). 6 | -------------------------------------------------------------------------------- /vendor/github.com/coreos/go-systemd/NOTICE: -------------------------------------------------------------------------------- 1 | CoreOS Project 2 | Copyright 2018 CoreOS, Inc 3 | 4 | This product includes software developed at CoreOS, Inc. 5 | (http://www.coreos.com/). 6 | -------------------------------------------------------------------------------- /vendor/github.com/coreos/ignition/NOTICE: -------------------------------------------------------------------------------- 1 | CoreOS Project 2 | Copyright 2015 CoreOS, Inc 3 | 4 | This product includes software developed at CoreOS, Inc. 5 | (http://www.coreos.com/). 6 | -------------------------------------------------------------------------------- /vendor/github.com/coreos/coreos-cloudinit/NOTICE: -------------------------------------------------------------------------------- 1 | CoreOS Project 2 | Copyright 2014 CoreOS, Inc 3 | 4 | This product includes software developed at CoreOS, Inc. 5 | (http://www.coreos.com/). 6 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM golang as build 2 | WORKDIR /go/src/github.com/coreos/container-linux-userdata-validator/ 3 | COPY . . 4 | RUN CGO_ENABLED=0 go build -o validate ./... 5 | 6 | 7 | FROM scratch 8 | WORKDIR /opt/validate/bin 9 | EXPOSE 80 10 | CMD ["./validate"] 11 | COPY --from=build /go/src/github.com/coreos/container-linux-userdata-validator/validate . 12 | -------------------------------------------------------------------------------- /glide.yaml: -------------------------------------------------------------------------------- 1 | package: github.com/coreos/container-linux-userdata-validator 2 | import: 3 | - package: github.com/coreos/coreos-cloudinit 4 | version: 1.14.0 5 | subpackages: 6 | - config/validate 7 | - package: github.com/coreos/ignition 8 | version: 0.24.0 9 | subpackages: 10 | - config 11 | - package: github.com/crawford/nap 12 | version: 0.1.0 13 | - package: github.com/gorilla/mux 14 | version: 1.6.1 15 | -------------------------------------------------------------------------------- /vendor/github.com/coreos/go-semver/example.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "github.com/coreos/go-semver/semver" 6 | "os" 7 | ) 8 | 9 | func main() { 10 | vA, err := semver.NewVersion(os.Args[1]) 11 | if err != nil { 12 | fmt.Println(err.Error()) 13 | } 14 | vB, err := semver.NewVersion(os.Args[2]) 15 | if err != nil { 16 | fmt.Println(err.Error()) 17 | } 18 | 19 | fmt.Printf("%s < %s == %t\n", vA, vB, vA.LessThan(*vB)) 20 | } 21 | -------------------------------------------------------------------------------- /vendor/github.com/gorilla/mux/context_native.go: -------------------------------------------------------------------------------- 1 | // +build go1.7 2 | 3 | package mux 4 | 5 | import ( 6 | "context" 7 | "net/http" 8 | ) 9 | 10 | func contextGet(r *http.Request, key interface{}) interface{} { 11 | return r.Context().Value(key) 12 | } 13 | 14 | func contextSet(r *http.Request, key, val interface{}) *http.Request { 15 | if val == nil { 16 | return r 17 | } 18 | 19 | return r.WithContext(context.WithValue(r.Context(), key, val)) 20 | } 21 | 22 | func contextClear(r *http.Request) { 23 | return 24 | } 25 | -------------------------------------------------------------------------------- /vendor/github.com/gorilla/mux/context_gorilla.go: -------------------------------------------------------------------------------- 1 | // +build !go1.7 2 | 3 | package mux 4 | 5 | import ( 6 | "net/http" 7 | 8 | "github.com/gorilla/context" 9 | ) 10 | 11 | func contextGet(r *http.Request, key interface{}) interface{} { 12 | return context.Get(r, key) 13 | } 14 | 15 | func contextSet(r *http.Request, key, val interface{}) *http.Request { 16 | if val == nil { 17 | return r 18 | } 19 | 20 | context.Set(r, key, val) 21 | return r 22 | } 23 | 24 | func contextClear(r *http.Request) { 25 | context.Clear(r) 26 | } 27 | -------------------------------------------------------------------------------- /vendor/github.com/crawford/nap/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2014 Alex Crawford 2 | 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this project except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | 9 | http://www.apache.org/licenses/LICENSE-2.0 10 | 11 | 12 | Unless required by applicable law or agreed to in writing, software 13 | distributed under the License is distributed on an "AS IS" BASIS, 14 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | See the License for the specific language governing permissions and 16 | limitations under the License. 17 | -------------------------------------------------------------------------------- /vendor/github.com/coreos/coreos-cloudinit/config/etc_hosts.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 CoreOS, Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package config 16 | 17 | type EtcHosts string 18 | -------------------------------------------------------------------------------- /vendor/github.com/coreos/ignition/config/v1/types/systemd.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 CoreOS, Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package types 16 | 17 | type Systemd struct { 18 | Units []SystemdUnit `json:"units,omitempty"` 19 | } 20 | -------------------------------------------------------------------------------- /vendor/github.com/coreos/ignition/config/v2_0/types/systemd.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 CoreOS, Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package types 16 | 17 | type Systemd struct { 18 | Units []SystemdUnit `json:"units,omitempty"` 19 | } 20 | -------------------------------------------------------------------------------- /vendor/github.com/coreos/ignition/config/v2_0/types/verification.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 CoreOS, Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package types 16 | 17 | type Verification struct { 18 | Hash *Hash `json:"hash,omitempty"` 19 | } 20 | -------------------------------------------------------------------------------- /vendor/github.com/coreos/ignition/config/v1/types/networkd.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 CoreOS, Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package types 16 | 17 | type Networkd struct { 18 | Units []NetworkdUnit `json:"units,omitempty"` 19 | } 20 | -------------------------------------------------------------------------------- /vendor/github.com/coreos/ignition/config/v2_0/types/networkd.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 CoreOS, Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package types 16 | 17 | type Networkd struct { 18 | Units []NetworkdUnit `json:"units,omitempty"` 19 | } 20 | -------------------------------------------------------------------------------- /vendor/github.com/gorilla/mux/test_helpers.go: -------------------------------------------------------------------------------- 1 | // Copyright 2012 The Gorilla Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package mux 6 | 7 | import "net/http" 8 | 9 | // SetURLVars sets the URL variables for the given request, to be accessed via 10 | // mux.Vars for testing route behaviour. 11 | // 12 | // This API should only be used for testing purposes; it provides a way to 13 | // inject variables into the request context. Alternatively, URL variables 14 | // can be set by making a route that captures the required variables, 15 | // starting a server and sending the request to that server. 16 | func SetURLVars(r *http.Request, val map[string]string) *http.Request { 17 | return setVars(r, val) 18 | } 19 | -------------------------------------------------------------------------------- /vendor/github.com/coreos/ignition/config/v1/types/passwd.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 CoreOS, Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package types 16 | 17 | type Passwd struct { 18 | Users []User `json:"users,omitempty"` 19 | Groups []Group `json:"groups,omitempty"` 20 | } 21 | -------------------------------------------------------------------------------- /vendor/github.com/coreos/ignition/config/v2_0/types/passwd.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 CoreOS, Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package types 16 | 17 | type Passwd struct { 18 | Users []User `json:"users,omitempty"` 19 | Groups []Group `json:"groups,omitempty"` 20 | } 21 | -------------------------------------------------------------------------------- /vendor/github.com/coreos/ignition/config/v1/types/storage.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 CoreOS, Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package types 16 | 17 | type Storage struct { 18 | Disks []Disk `json:"disks,omitempty"` 19 | Arrays []Raid `json:"raid,omitempty"` 20 | Filesystems []Filesystem `json:"filesystems,omitempty"` 21 | } 22 | -------------------------------------------------------------------------------- /vendor/github.com/coreos/ignition/config/v2_1/types/mode.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 CoreOS, Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package types 16 | 17 | import ( 18 | "github.com/coreos/ignition/config/shared/errors" 19 | ) 20 | 21 | func validateMode(m int) error { 22 | if m < 0 || m > 07777 { 23 | return errors.ErrFileIllegalMode 24 | } 25 | return nil 26 | } 27 | -------------------------------------------------------------------------------- /vendor/github.com/coreos/ignition/config/util/helpers.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 CoreOS, Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package util 16 | 17 | func IntToPtr(x int) *int { 18 | return &x 19 | } 20 | 21 | func StrToPtr(s string) *string { 22 | if s == "" { 23 | return nil 24 | } 25 | return &s 26 | } 27 | 28 | func BoolToPtr(b bool) *bool { 29 | return &b 30 | } 31 | -------------------------------------------------------------------------------- /vendor/github.com/coreos/ignition/config/v2_1/types/path.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 CoreOS, Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package types 16 | 17 | import ( 18 | "path" 19 | 20 | "github.com/coreos/ignition/config/shared/errors" 21 | ) 22 | 23 | func validatePath(p string) error { 24 | if !path.IsAbs(p) { 25 | return errors.ErrPathRelative 26 | } 27 | return nil 28 | } 29 | -------------------------------------------------------------------------------- /vendor/github.com/coreos/ignition/config/v2_2/types/path.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 CoreOS, Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package types 16 | 17 | import ( 18 | "path" 19 | 20 | "github.com/coreos/ignition/config/shared/errors" 21 | ) 22 | 23 | func validatePath(p string) error { 24 | if !path.IsAbs(p) { 25 | return errors.ErrPathRelative 26 | } 27 | return nil 28 | } 29 | -------------------------------------------------------------------------------- /vendor/github.com/coreos/ignition/config/v1/types/group.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 CoreOS, Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package types 16 | 17 | type Group struct { 18 | Name string `json:"name,omitempty"` 19 | Gid *uint `json:"gid,omitempty"` 20 | PasswordHash string `json:"passwordHash,omitempty"` 21 | System bool `json:"system,omitempty"` 22 | } 23 | -------------------------------------------------------------------------------- /vendor/github.com/coreos/ignition/config/v2_0/types/group.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 CoreOS, Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package types 16 | 17 | type Group struct { 18 | Name string `json:"name,omitempty"` 19 | Gid *uint `json:"gid,omitempty"` 20 | PasswordHash string `json:"passwordHash,omitempty"` 21 | System bool `json:"system,omitempty"` 22 | } 23 | -------------------------------------------------------------------------------- /vendor/github.com/coreos/ignition/config/v2_2/types/mode.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 CoreOS, Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package types 16 | 17 | import ( 18 | "github.com/coreos/ignition/config/shared/errors" 19 | ) 20 | 21 | func validateMode(m *int) error { 22 | if m != nil && (*m < 0 || *m > 07777) { 23 | return errors.ErrFileIllegalMode 24 | } 25 | return nil 26 | } 27 | -------------------------------------------------------------------------------- /vendor/github.com/coreos/coreos-cloudinit/config/oem.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 CoreOS, Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package config 16 | 17 | type OEM struct { 18 | ID string `yaml:"id"` 19 | Name string `yaml:"name"` 20 | VersionID string `yaml:"version_id"` 21 | HomeURL string `yaml:"home_url"` 22 | BugReportURL string `yaml:"bug_report_url"` 23 | } 24 | -------------------------------------------------------------------------------- /vendor/github.com/coreos/ignition/config/v2_3_experimental/types/mode.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 CoreOS, Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package types 16 | 17 | import ( 18 | "github.com/coreos/ignition/config/shared/errors" 19 | ) 20 | 21 | func validateMode(m *int) error { 22 | if m != nil && (*m < 0 || *m > 07777) { 23 | return errors.ErrFileIllegalMode 24 | } 25 | return nil 26 | } 27 | -------------------------------------------------------------------------------- /vendor/github.com/coreos/ignition/config/v2_3_experimental/types/path.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 CoreOS, Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package types 16 | 17 | import ( 18 | "path" 19 | 20 | "github.com/coreos/ignition/config/shared/errors" 21 | ) 22 | 23 | func validatePath(p string) error { 24 | if !path.IsAbs(p) { 25 | return errors.ErrPathRelative 26 | } 27 | return nil 28 | } 29 | -------------------------------------------------------------------------------- /vendor/github.com/coreos/ignition/config/v2_0/types/storage.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 CoreOS, Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package types 16 | 17 | type Storage struct { 18 | Disks []Disk `json:"disks,omitempty"` 19 | Arrays []Raid `json:"raid,omitempty"` 20 | Filesystems []Filesystem `json:"filesystems,omitempty"` 21 | Files []File `json:"files,omitempty"` 22 | } 23 | -------------------------------------------------------------------------------- /vendor/github.com/coreos/coreos-cloudinit/config/update.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 CoreOS, Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package config 16 | 17 | type Update struct { 18 | RebootStrategy string `yaml:"reboot_strategy" env:"REBOOT_STRATEGY" valid:"^(etcd-lock|reboot|off)$"` 19 | Group string `yaml:"group" env:"GROUP"` 20 | Server string `yaml:"server" env:"SERVER"` 21 | } 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # CoreOS Userdata Validator 2 | 3 | This code powers the public service at https://coreos.com/validate/. 4 | 5 | ## Building 6 | 7 | The included multi-stage Dockerfile can be used to build working images. Just run the following: 8 | 9 | docker build . 10 | 11 | ## Updating dependencies 12 | 13 | The following glide commands can be used to update the dependencies of this project: 14 | 15 | glide update --strip-vendor 16 | glide-vc --use-lock-file --no-tests --only-code 17 | 18 | ## Deployment 19 | 20 | This repository is configured for autobuilding on Quay, so that new git 21 | tags are automatically available as container images. 22 | Autobuilt images are pushed to `quay.io/coreosinc/coreos-userdata-validator`, 23 | which is not available for pulling by the general audience. 24 | 25 | Deployable tags are pushed to git in the format `yyyymmdd-rev`. 26 | The corresponding image needs to be manually bumped in the relevant 27 | Helm chart for the CoreOS kubernetes cluster. 28 | -------------------------------------------------------------------------------- /vendor/github.com/coreos/ignition/config/v2_2/types/ca.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 CoreOS, Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package types 16 | 17 | import ( 18 | "github.com/coreos/ignition/config/validate/report" 19 | ) 20 | 21 | func (c CaReference) ValidateSource() report.Report { 22 | err := validateURL(c.Source) 23 | if err != nil { 24 | return report.ReportFromError(err, report.EntryError) 25 | } 26 | return report.Report{} 27 | } 28 | -------------------------------------------------------------------------------- /vendor/github.com/coreos/ignition/config/v2_3_experimental/types/ca.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 CoreOS, Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package types 16 | 17 | import ( 18 | "github.com/coreos/ignition/config/validate/report" 19 | ) 20 | 21 | func (c CaReference) ValidateSource() report.Report { 22 | err := validateURL(c.Source) 23 | if err != nil { 24 | return report.ReportFromError(err, report.EntryError) 25 | } 26 | return report.Report{} 27 | } 28 | -------------------------------------------------------------------------------- /vendor/github.com/coreos/ignition/config/v1/types/config.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 CoreOS, Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package types 16 | 17 | const ( 18 | Version = 1 19 | ) 20 | 21 | type Config struct { 22 | Version int `json:"ignitionVersion"` 23 | Storage Storage `json:"storage,omitempty"` 24 | Systemd Systemd `json:"systemd,omitempty"` 25 | Networkd Networkd `json:"networkd,omitempty"` 26 | Passwd Passwd `json:"passwd,omitempty"` 27 | } 28 | -------------------------------------------------------------------------------- /vendor/github.com/coreos/coreos-cloudinit/config/script.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 CoreOS, Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package config 16 | 17 | import ( 18 | "strings" 19 | ) 20 | 21 | type Script []byte 22 | 23 | func IsScript(userdata string) bool { 24 | header := strings.SplitN(userdata, "\n", 2)[0] 25 | return strings.HasPrefix(header, "#!") 26 | } 27 | 28 | func NewScript(userdata string) (*Script, error) { 29 | s := Script(userdata) 30 | return &s, nil 31 | } 32 | -------------------------------------------------------------------------------- /vendor/github.com/coreos/ignition/config/v2_1/types/directory.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 CoreOS, Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package types 16 | 17 | import ( 18 | "github.com/coreos/ignition/config/validate/report" 19 | ) 20 | 21 | func (d Directory) ValidateMode() report.Report { 22 | r := report.Report{} 23 | if err := validateMode(d.Mode); err != nil { 24 | r.Add(report.Entry{ 25 | Message: err.Error(), 26 | Kind: report.EntryError, 27 | }) 28 | } 29 | return r 30 | } 31 | -------------------------------------------------------------------------------- /vendor/github.com/coreos/coreos-cloudinit/config/file.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 CoreOS, Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package config 16 | 17 | type File struct { 18 | Encoding string `yaml:"encoding" valid:"^(base64|b64|gz|gzip|gz\\+base64|gzip\\+base64|gz\\+b64|gzip\\+b64)$"` 19 | Content string `yaml:"content"` 20 | Owner string `yaml:"owner"` 21 | Path string `yaml:"path"` 22 | RawFilePermissions string `yaml:"permissions" valid:"^0?[0-7]{3,4}$"` 23 | } 24 | -------------------------------------------------------------------------------- /vendor/github.com/coreos/ignition/config/v1/types/path.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 CoreOS, Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package types 16 | 17 | import ( 18 | "path" 19 | 20 | "github.com/coreos/ignition/config/shared/errors" 21 | "github.com/coreos/ignition/config/validate/report" 22 | ) 23 | 24 | type Path string 25 | 26 | func (d Path) Validate() report.Report { 27 | if !path.IsAbs(string(d)) { 28 | return report.ReportFromError(errors.ErrPathRelative, report.EntryError) 29 | } 30 | return report.Report{} 31 | } 32 | -------------------------------------------------------------------------------- /vendor/github.com/coreos/coreos-cloudinit/config/ignition.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 CoreOS, Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package config 16 | 17 | import ( 18 | "encoding/json" 19 | ) 20 | 21 | func IsIgnitionConfig(userdata string) bool { 22 | var cfg struct { 23 | Version *int `json:"ignitionVersion"` 24 | Ignition struct { 25 | Version *string `json:"version"` 26 | } `json:"ignition"` 27 | } 28 | return (json.Unmarshal([]byte(userdata), &cfg) == nil && (cfg.Version != nil || cfg.Ignition.Version != nil)) 29 | } 30 | -------------------------------------------------------------------------------- /vendor/github.com/coreos/ignition/config/v2_1/types/link.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 CoreOS, Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package types 16 | 17 | import ( 18 | "github.com/coreos/ignition/config/validate/report" 19 | ) 20 | 21 | func (s LinkEmbedded1) ValidateTarget() report.Report { 22 | r := report.Report{} 23 | if !s.Hard { 24 | err := validatePath(s.Target) 25 | if err != nil { 26 | r.Add(report.Entry{ 27 | Message: err.Error(), 28 | Kind: report.EntryError, 29 | }) 30 | } 31 | } 32 | return r 33 | } 34 | -------------------------------------------------------------------------------- /vendor/github.com/coreos/ignition/config/v2_2/types/link.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 CoreOS, Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package types 16 | 17 | import ( 18 | "github.com/coreos/ignition/config/validate/report" 19 | ) 20 | 21 | func (s LinkEmbedded1) ValidateTarget() report.Report { 22 | r := report.Report{} 23 | if !s.Hard { 24 | err := validatePath(s.Target) 25 | if err != nil { 26 | r.Add(report.Entry{ 27 | Message: err.Error(), 28 | Kind: report.EntryError, 29 | }) 30 | } 31 | } 32 | return r 33 | } 34 | -------------------------------------------------------------------------------- /vendor/github.com/coreos/ignition/config/v2_3_experimental/types/link.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 CoreOS, Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package types 16 | 17 | import ( 18 | "github.com/coreos/ignition/config/validate/report" 19 | ) 20 | 21 | func (s LinkEmbedded1) ValidateTarget() report.Report { 22 | r := report.Report{} 23 | if !s.Hard { 24 | err := validatePath(s.Target) 25 | if err != nil { 26 | r.Add(report.Entry{ 27 | Message: err.Error(), 28 | Kind: report.EntryError, 29 | }) 30 | } 31 | } 32 | return r 33 | } 34 | -------------------------------------------------------------------------------- /vendor/github.com/coreos/ignition/config/v2_0/types/compression.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 CoreOS, Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package types 16 | 17 | import ( 18 | "github.com/coreos/ignition/config/shared/errors" 19 | "github.com/coreos/ignition/config/validate/report" 20 | ) 21 | 22 | type Compression string 23 | 24 | func (c Compression) Validate() report.Report { 25 | switch c { 26 | case "", "gzip": 27 | default: 28 | return report.ReportFromError(errors.ErrCompressionInvalid, report.EntryError) 29 | } 30 | return report.Report{} 31 | } 32 | -------------------------------------------------------------------------------- /vendor/github.com/coreos/go-semver/semver/sort.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013-2015 CoreOS, Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package semver 16 | 17 | import ( 18 | "sort" 19 | ) 20 | 21 | type Versions []*Version 22 | 23 | func (s Versions) Len() int { 24 | return len(s) 25 | } 26 | 27 | func (s Versions) Swap(i, j int) { 28 | s[i], s[j] = s[j], s[i] 29 | } 30 | 31 | func (s Versions) Less(i, j int) bool { 32 | return s[i].LessThan(*s[j]) 33 | } 34 | 35 | // Sort sorts the given slice of Version 36 | func Sort(versions []*Version) { 37 | sort.Sort(Versions(versions)) 38 | } 39 | -------------------------------------------------------------------------------- /vendor/github.com/vincent-petithory/dataurl/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 Vincent Petithory 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | this software and associated documentation files (the "Software"), to deal in 7 | the Software without restriction, including without limitation the rights to 8 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 9 | the Software, and to permit persons to whom the Software is furnished to do so, 10 | subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 19 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 20 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /vendor/github.com/coreos/ignition/config/v2_0/types/path.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 CoreOS, Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package types 16 | 17 | import ( 18 | "path" 19 | 20 | "github.com/coreos/ignition/config/shared/errors" 21 | "github.com/coreos/ignition/config/validate/report" 22 | ) 23 | 24 | type Path string 25 | 26 | func (p Path) MarshalJSON() ([]byte, error) { 27 | return []byte(`"` + string(p) + `"`), nil 28 | } 29 | 30 | func (p Path) Validate() report.Report { 31 | if !path.IsAbs(string(p)) { 32 | return report.ReportFromError(errors.ErrPathRelative, report.EntryError) 33 | } 34 | return report.Report{} 35 | } 36 | -------------------------------------------------------------------------------- /vendor/github.com/vincent-petithory/dataurl/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | Package dataurl parses Data URL Schemes 3 | according to RFC 2397 4 | (http://tools.ietf.org/html/rfc2397). 5 | 6 | Data URLs are small chunks of data commonly used in browsers to display inline data, 7 | typically like small images, or when you use the FileReader API of the browser. 8 | 9 | A dataurl looks like: 10 | 11 | data:text/plain;charset=utf-8,A%20brief%20note 12 | 13 | Or, with base64 encoding: 14 | 15 | data:image/vnd.microsoft.icon;name=golang%20favicon;base64,AAABAAEAEBAAAAEAIABoBAAAFgAAACgAAAAQAAAAIAAAAAEAIAAAAAAAAAAAAAAAAAAAAAAAAAAA 16 | AAAAAAD///8AVE44//7hdv/+4Xb//uF2//7hdv/+4Xb//uF2//7hdv/+4Xb//uF2//7hdv/+4Xb/ 17 | /uF2/1ROOP////8A////AFROOP/+4Xb//uF2//7hdv/+4Xb//uF2//7hdv/+4Xb//uF2//7hdv/+ 18 | ... 19 | /6CcjP97c07/e3NO/1dOMf9BOiX/TkUn/2VXLf97c07/e3NO/6CcjP/h4uX/////AP///wD///8A 20 | ////AP///wD///8A////AP///wDq6/H/3N/j/9fZ3f/q6/H/////AP///wD///8A////AP///wD/ 21 | //8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA 22 | AAAAAAAAAAAAAA== 23 | 24 | Common functions are Decode and DecodeString to obtain a DataURL, 25 | and DataURL.String() and DataURL.WriteTo to generate a Data URL string. 26 | 27 | */ 28 | package dataurl 29 | -------------------------------------------------------------------------------- /vendor/github.com/coreos/coreos-cloudinit/config/unit.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 CoreOS, Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package config 16 | 17 | type Unit struct { 18 | Name string `yaml:"name"` 19 | Mask bool `yaml:"mask"` 20 | Enable bool `yaml:"enable"` 21 | Runtime bool `yaml:"runtime"` 22 | Content string `yaml:"content"` 23 | Command string `yaml:"command" valid:"^(start|stop|restart|reload|try-restart|reload-or-restart|reload-or-try-restart)$"` 24 | DropIns []UnitDropIn `yaml:"drop_ins"` 25 | } 26 | 27 | type UnitDropIn struct { 28 | Name string `yaml:"name"` 29 | Content string `yaml:"content"` 30 | } 31 | -------------------------------------------------------------------------------- /vendor/github.com/coreos/ignition/config/v2_2/types/directory.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 CoreOS, Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package types 16 | 17 | import ( 18 | "github.com/coreos/ignition/config/shared/errors" 19 | "github.com/coreos/ignition/config/validate/report" 20 | ) 21 | 22 | func (d Directory) ValidateMode() report.Report { 23 | r := report.Report{} 24 | if err := validateMode(d.Mode); err != nil { 25 | r.Add(report.Entry{ 26 | Message: err.Error(), 27 | Kind: report.EntryError, 28 | }) 29 | } 30 | if d.Mode == nil { 31 | r.Add(report.Entry{ 32 | Message: errors.ErrPermissionsUnset.Error(), 33 | Kind: report.EntryWarning, 34 | }) 35 | } 36 | return r 37 | } 38 | -------------------------------------------------------------------------------- /vendor/github.com/coreos/ignition/config/v2_3_experimental/types/directory.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 CoreOS, Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package types 16 | 17 | import ( 18 | "github.com/coreos/ignition/config/shared/errors" 19 | "github.com/coreos/ignition/config/validate/report" 20 | ) 21 | 22 | func (d Directory) ValidateMode() report.Report { 23 | r := report.Report{} 24 | if err := validateMode(d.Mode); err != nil { 25 | r.Add(report.Entry{ 26 | Message: err.Error(), 27 | Kind: report.EntryError, 28 | }) 29 | } 30 | if d.Mode == nil { 31 | r.Add(report.Entry{ 32 | Message: errors.ErrPermissionsUnset.Error(), 33 | Kind: report.EntryWarning, 34 | }) 35 | } 36 | return r 37 | } 38 | -------------------------------------------------------------------------------- /vendor/github.com/ajeddeloh/go-json/tags.go: -------------------------------------------------------------------------------- 1 | // Copyright 2011 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package json 6 | 7 | import ( 8 | "strings" 9 | ) 10 | 11 | // tagOptions is the string following a comma in a struct field's "json" 12 | // tag, or the empty string. It does not include the leading comma. 13 | type tagOptions string 14 | 15 | // parseTag splits a struct field's json tag into its name and 16 | // comma-separated options. 17 | func parseTag(tag string) (string, tagOptions) { 18 | if idx := strings.Index(tag, ","); idx != -1 { 19 | return tag[:idx], tagOptions(tag[idx+1:]) 20 | } 21 | return tag, tagOptions("") 22 | } 23 | 24 | // Contains reports whether a comma-separated list of options 25 | // contains a particular substr flag. substr must be surrounded by a 26 | // string boundary or commas. 27 | func (o tagOptions) Contains(optionName string) bool { 28 | if len(o) == 0 { 29 | return false 30 | } 31 | s := string(o) 32 | for s != "" { 33 | var next string 34 | i := strings.Index(s, ",") 35 | if i >= 0 { 36 | s, next = s[:i], s[i+1:] 37 | } 38 | if s == optionName { 39 | return true 40 | } 41 | s = next 42 | } 43 | return false 44 | } 45 | -------------------------------------------------------------------------------- /vendor/github.com/coreos/go-systemd/dbus/set.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 CoreOS, Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package dbus 16 | 17 | type set struct { 18 | data map[string]bool 19 | } 20 | 21 | func (s *set) Add(value string) { 22 | s.data[value] = true 23 | } 24 | 25 | func (s *set) Remove(value string) { 26 | delete(s.data, value) 27 | } 28 | 29 | func (s *set) Contains(value string) (exists bool) { 30 | _, exists = s.data[value] 31 | return 32 | } 33 | 34 | func (s *set) Length() int { 35 | return len(s.data) 36 | } 37 | 38 | func (s *set) Values() (values []string) { 39 | for val, _ := range s.data { 40 | values = append(values, val) 41 | } 42 | return 43 | } 44 | 45 | func newSet() *set { 46 | return &set{make(map[string]bool)} 47 | } 48 | -------------------------------------------------------------------------------- /vendor/github.com/coreos/ignition/config/v2_1/types/url.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 CoreOS, Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package types 16 | 17 | import ( 18 | "net/url" 19 | 20 | "github.com/coreos/ignition/config/shared/errors" 21 | "github.com/vincent-petithory/dataurl" 22 | ) 23 | 24 | func validateURL(s string) error { 25 | // Empty url is valid, indicates an empty file 26 | if s == "" { 27 | return nil 28 | } 29 | u, err := url.Parse(s) 30 | if err != nil { 31 | return errors.ErrInvalidUrl 32 | } 33 | 34 | switch u.Scheme { 35 | case "http", "https", "oem", "tftp", "s3": 36 | return nil 37 | case "data": 38 | if _, err := dataurl.DecodeString(s); err != nil { 39 | return err 40 | } 41 | return nil 42 | default: 43 | return errors.ErrInvalidScheme 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /vendor/github.com/coreos/ignition/config/v1/types/file.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 CoreOS, Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package types 16 | 17 | import ( 18 | "os" 19 | 20 | "github.com/coreos/ignition/config/shared/errors" 21 | "github.com/coreos/ignition/config/validate/report" 22 | ) 23 | 24 | type FileMode os.FileMode 25 | 26 | type File struct { 27 | Path Path `json:"path,omitempty"` 28 | Contents string `json:"contents,omitempty"` 29 | Mode FileMode `json:"mode,omitempty"` 30 | Uid int `json:"uid,omitempty"` 31 | Gid int `json:"gid,omitempty"` 32 | } 33 | 34 | func (m FileMode) Validate() report.Report { 35 | if (m &^ 07777) != 0 { 36 | return report.ReportFromError(errors.ErrFileIllegalMode, report.EntryError) 37 | } 38 | return report.Report{} 39 | } 40 | -------------------------------------------------------------------------------- /vendor/github.com/coreos/ignition/config/v2_2/types/url.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 CoreOS, Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package types 16 | 17 | import ( 18 | "net/url" 19 | 20 | "github.com/vincent-petithory/dataurl" 21 | 22 | "github.com/coreos/ignition/config/shared/errors" 23 | ) 24 | 25 | func validateURL(s string) error { 26 | // Empty url is valid, indicates an empty file 27 | if s == "" { 28 | return nil 29 | } 30 | u, err := url.Parse(s) 31 | if err != nil { 32 | return errors.ErrInvalidUrl 33 | } 34 | 35 | switch u.Scheme { 36 | case "http", "https", "oem", "tftp", "s3": 37 | return nil 38 | case "data": 39 | if _, err := dataurl.DecodeString(s); err != nil { 40 | return err 41 | } 42 | return nil 43 | default: 44 | return errors.ErrInvalidScheme 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /vendor/github.com/coreos/coreos-cloudinit/config/decode.go: -------------------------------------------------------------------------------- 1 | package config 2 | 3 | import ( 4 | "bytes" 5 | "compress/gzip" 6 | "encoding/base64" 7 | "fmt" 8 | ) 9 | 10 | func DecodeBase64Content(content string) ([]byte, error) { 11 | output, err := base64.StdEncoding.DecodeString(content) 12 | 13 | if err != nil { 14 | return nil, fmt.Errorf("Unable to decode base64: %q", err) 15 | } 16 | 17 | return output, nil 18 | } 19 | 20 | func DecodeGzipContent(content string) ([]byte, error) { 21 | gzr, err := gzip.NewReader(bytes.NewReader([]byte(content))) 22 | 23 | if err != nil { 24 | return nil, fmt.Errorf("Unable to decode gzip: %q", err) 25 | } 26 | defer gzr.Close() 27 | 28 | buf := new(bytes.Buffer) 29 | buf.ReadFrom(gzr) 30 | 31 | return buf.Bytes(), nil 32 | } 33 | 34 | func DecodeContent(content string, encoding string) ([]byte, error) { 35 | switch encoding { 36 | case "": 37 | return []byte(content), nil 38 | 39 | case "b64", "base64": 40 | return DecodeBase64Content(content) 41 | 42 | case "gz", "gzip": 43 | return DecodeGzipContent(content) 44 | 45 | case "gz+base64", "gzip+base64", "gz+b64", "gzip+b64": 46 | gz, err := DecodeBase64Content(content) 47 | 48 | if err != nil { 49 | return nil, err 50 | } 51 | 52 | return DecodeGzipContent(string(gz)) 53 | } 54 | 55 | return nil, fmt.Errorf("Unsupported encoding %q", encoding) 56 | } 57 | -------------------------------------------------------------------------------- /vendor/github.com/coreos/ignition/config/v2_3_experimental/types/url.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 CoreOS, Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package types 16 | 17 | import ( 18 | "net/url" 19 | 20 | "github.com/vincent-petithory/dataurl" 21 | 22 | "github.com/coreos/ignition/config/shared/errors" 23 | ) 24 | 25 | func validateURL(s string) error { 26 | // Empty url is valid, indicates an empty file 27 | if s == "" { 28 | return nil 29 | } 30 | u, err := url.Parse(s) 31 | if err != nil { 32 | return errors.ErrInvalidUrl 33 | } 34 | 35 | switch u.Scheme { 36 | case "http", "https", "oem", "tftp", "s3": 37 | return nil 38 | case "data": 39 | if _, err := dataurl.DecodeString(s); err != nil { 40 | return err 41 | } 42 | return nil 43 | default: 44 | return errors.ErrInvalidScheme 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /vendor/github.com/crawford/nap/status.go: -------------------------------------------------------------------------------- 1 | package nap 2 | 3 | import ( 4 | "net/http" 5 | ) 6 | 7 | type Status interface { 8 | Code() int 9 | Message() string 10 | } 11 | 12 | type OK struct { 13 | Msg string 14 | } 15 | 16 | func (s OK) Code() int { 17 | return http.StatusOK 18 | } 19 | func (s OK) Message() string { 20 | return s.Msg 21 | } 22 | 23 | type Created struct { 24 | Msg string 25 | } 26 | 27 | func (s Created) Code() int { 28 | return http.StatusCreated 29 | } 30 | func (s Created) Message() string { 31 | return s.Msg 32 | } 33 | 34 | type NotFound struct { 35 | Msg string 36 | } 37 | 38 | func (s NotFound) Code() int { 39 | return http.StatusNotFound 40 | } 41 | func (s NotFound) Message() string { 42 | return s.Msg 43 | } 44 | 45 | type BadRequest struct { 46 | Msg string 47 | } 48 | 49 | func (s BadRequest) Code() int { 50 | return http.StatusBadRequest 51 | } 52 | func (s BadRequest) Message() string { 53 | return s.Msg 54 | } 55 | 56 | type MethodNotAllowed struct { 57 | Msg string 58 | } 59 | 60 | func (s MethodNotAllowed) Code() int { 61 | return http.StatusMethodNotAllowed 62 | } 63 | func (s MethodNotAllowed) Message() string { 64 | return s.Msg 65 | } 66 | 67 | type InternalError struct { 68 | Msg string 69 | } 70 | 71 | func (s InternalError) Code() int { 72 | return http.StatusInternalServerError 73 | } 74 | func (s InternalError) Message() string { 75 | return s.Msg 76 | } 77 | -------------------------------------------------------------------------------- /vendor/github.com/gorilla/mux/middleware.go: -------------------------------------------------------------------------------- 1 | package mux 2 | 3 | import "net/http" 4 | 5 | // MiddlewareFunc is a function which receives an http.Handler and returns another http.Handler. 6 | // Typically, the returned handler is a closure which does something with the http.ResponseWriter and http.Request passed 7 | // to it, and then calls the handler passed as parameter to the MiddlewareFunc. 8 | type MiddlewareFunc func(http.Handler) http.Handler 9 | 10 | // middleware interface is anything which implements a MiddlewareFunc named Middleware. 11 | type middleware interface { 12 | Middleware(handler http.Handler) http.Handler 13 | } 14 | 15 | // MiddlewareFunc also implements the middleware interface. 16 | func (mw MiddlewareFunc) Middleware(handler http.Handler) http.Handler { 17 | return mw(handler) 18 | } 19 | 20 | // Use appends a MiddlewareFunc to the chain. Middleware can be used to intercept or otherwise modify requests and/or responses, and are executed in the order that they are applied to the Router. 21 | func (r *Router) Use(mwf MiddlewareFunc) { 22 | r.middlewares = append(r.middlewares, mwf) 23 | } 24 | 25 | // useInterface appends a middleware to the chain. Middleware can be used to intercept or otherwise modify requests and/or responses, and are executed in the order that they are applied to the Router. 26 | func (r *Router) useInterface(mw middleware) { 27 | r.middlewares = append(r.middlewares, mw) 28 | } 29 | -------------------------------------------------------------------------------- /vendor/github.com/coreos/yaml/LICENSE.libyaml: -------------------------------------------------------------------------------- 1 | The following files were ported to Go from C files of libyaml, and thus 2 | are still covered by their original copyright and license: 3 | 4 | apic.go 5 | emitterc.go 6 | parserc.go 7 | readerc.go 8 | scannerc.go 9 | writerc.go 10 | yamlh.go 11 | yamlprivateh.go 12 | 13 | Copyright (c) 2006 Kirill Simonov 14 | 15 | Permission is hereby granted, free of charge, to any person obtaining a copy of 16 | this software and associated documentation files (the "Software"), to deal in 17 | the Software without restriction, including without limitation the rights to 18 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 19 | of the Software, and to permit persons to whom the Software is furnished to do 20 | so, subject to the following conditions: 21 | 22 | The above copyright notice and this permission notice shall be included in all 23 | copies or substantial portions of the Software. 24 | 25 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 26 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 27 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 28 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 29 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 30 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 31 | SOFTWARE. 32 | -------------------------------------------------------------------------------- /DCO: -------------------------------------------------------------------------------- 1 | Developer Certificate of Origin 2 | Version 1.1 3 | 4 | Copyright (C) 2004, 2006 The Linux Foundation and its contributors. 5 | 660 York Street, Suite 102, 6 | San Francisco, CA 94110 USA 7 | 8 | Everyone is permitted to copy and distribute verbatim copies of this 9 | license document, but changing it is not allowed. 10 | 11 | 12 | Developer's Certificate of Origin 1.1 13 | 14 | By making a contribution to this project, I certify that: 15 | 16 | (a) The contribution was created in whole or in part by me and I 17 | have the right to submit it under the open source license 18 | indicated in the file; or 19 | 20 | (b) The contribution is based upon previous work that, to the best 21 | of my knowledge, is covered under an appropriate open source 22 | license and I have the right under that license to submit that 23 | work with modifications, whether created in whole or in part 24 | by me, under the same open source license (unless I am 25 | permitted to submit under a different license), as indicated 26 | in the file; or 27 | 28 | (c) The contribution was provided directly to me by some other 29 | person who certified (a), (b) or (c) and I have not modified 30 | it. 31 | 32 | (d) I understand and agree that this project and the contribution 33 | are public and that a record of the contribution (including all 34 | personal information I submit with it, including my sign-off) is 35 | maintained indefinitely and may be redistributed consistent with 36 | this project or the open source license(s) involved. 37 | -------------------------------------------------------------------------------- /vendor/github.com/coreos/ignition/config/v1/types/raid.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 CoreOS, Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package types 16 | 17 | import ( 18 | "github.com/coreos/ignition/config/shared/errors" 19 | "github.com/coreos/ignition/config/validate/report" 20 | ) 21 | 22 | type Raid struct { 23 | Name string `json:"name"` 24 | Level string `json:"level"` 25 | Devices []Path `json:"devices,omitempty"` 26 | Spares int `json:"spares,omitempty"` 27 | } 28 | 29 | func (n Raid) Validate() report.Report { 30 | switch n.Level { 31 | case "linear", "raid0", "0", "stripe": 32 | if n.Spares != 0 { 33 | return report.ReportFromError(errors.ErrSparesUnsupportedForLevel, report.EntryError) 34 | } 35 | case "raid1", "1", "mirror": 36 | case "raid4", "4": 37 | case "raid5", "5": 38 | case "raid6", "6": 39 | case "raid10", "10": 40 | default: 41 | return report.ReportFromError(errors.ErrUnrecognizedRaidLevel, report.EntryError) 42 | } 43 | return report.Report{} 44 | } 45 | -------------------------------------------------------------------------------- /vendor/github.com/coreos/ignition/config/v2_0/types/raid.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 CoreOS, Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package types 16 | 17 | import ( 18 | "github.com/coreos/ignition/config/shared/errors" 19 | "github.com/coreos/ignition/config/validate/report" 20 | ) 21 | 22 | type Raid struct { 23 | Name string `json:"name"` 24 | Level string `json:"level"` 25 | Devices []Path `json:"devices,omitempty"` 26 | Spares int `json:"spares,omitempty"` 27 | } 28 | 29 | func (n Raid) Validate() report.Report { 30 | switch n.Level { 31 | case "linear", "raid0", "0", "stripe": 32 | if n.Spares != 0 { 33 | return report.ReportFromError(errors.ErrSparesUnsupportedForLevel, report.EntryError) 34 | } 35 | case "raid1", "1", "mirror": 36 | case "raid4", "4": 37 | case "raid5", "5": 38 | case "raid6", "6": 39 | case "raid10", "10": 40 | default: 41 | return report.ReportFromError(errors.ErrUnrecognizedRaidLevel, report.EntryError) 42 | } 43 | return report.Report{} 44 | } 45 | -------------------------------------------------------------------------------- /vendor/github.com/coreos/coreos-cloudinit/config/flannel.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 CoreOS, Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package config 16 | 17 | type Flannel struct { 18 | EtcdEndpoints string `yaml:"etcd_endpoints" env:"FLANNELD_ETCD_ENDPOINTS"` 19 | EtcdCAFile string `yaml:"etcd_cafile" env:"FLANNELD_ETCD_CAFILE"` 20 | EtcdCertFile string `yaml:"etcd_certfile" env:"FLANNELD_ETCD_CERTFILE"` 21 | EtcdKeyFile string `yaml:"etcd_keyfile" env:"FLANNELD_ETCD_KEYFILE"` 22 | EtcdPrefix string `yaml:"etcd_prefix" env:"FLANNELD_ETCD_PREFIX"` 23 | EtcdUsername string `yaml:"etcd_username" env:"FLANNELD_ETCD_USERNAME"` 24 | EtcdPassword string `yaml:"etcd_password" env:"FLANNELD_ETCD_PASSWORD"` 25 | IPMasq string `yaml:"ip_masq" env:"FLANNELD_IP_MASQ"` 26 | SubnetFile string `yaml:"subnet_file" env:"FLANNELD_SUBNET_FILE"` 27 | Iface string `yaml:"interface" env:"FLANNELD_IFACE"` 28 | PublicIP string `yaml:"public_ip" env:"FLANNELD_PUBLIC_IP"` 29 | } 30 | -------------------------------------------------------------------------------- /vendor/github.com/coreos/ignition/config/v1/types/user.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 CoreOS, Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package types 16 | 17 | type User struct { 18 | Name string `json:"name,omitempty"` 19 | PasswordHash string `json:"passwordHash,omitempty"` 20 | SSHAuthorizedKeys []string `json:"sshAuthorizedKeys,omitempty"` 21 | Create *UserCreate `json:"create,omitempty"` 22 | } 23 | 24 | type UserCreate struct { 25 | Uid *uint `json:"uid,omitempty"` 26 | GECOS string `json:"gecos,omitempty"` 27 | Homedir string `json:"homeDir,omitempty"` 28 | NoCreateHome bool `json:"noCreateHome,omitempty"` 29 | PrimaryGroup string `json:"primaryGroup,omitempty"` 30 | Groups []string `json:"groups,omitempty"` 31 | NoUserGroup bool `json:"noUserGroup,omitempty"` 32 | System bool `json:"system,omitempty"` 33 | NoLogInit bool `json:"noLogInit,omitempty"` 34 | Shell string `json:"shell,omitempty"` 35 | } 36 | -------------------------------------------------------------------------------- /vendor/github.com/coreos/ignition/config/v2_0/types/user.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 CoreOS, Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package types 16 | 17 | type User struct { 18 | Name string `json:"name,omitempty"` 19 | PasswordHash string `json:"passwordHash,omitempty"` 20 | SSHAuthorizedKeys []string `json:"sshAuthorizedKeys,omitempty"` 21 | Create *UserCreate `json:"create,omitempty"` 22 | } 23 | 24 | type UserCreate struct { 25 | Uid *uint `json:"uid,omitempty"` 26 | GECOS string `json:"gecos,omitempty"` 27 | Homedir string `json:"homeDir,omitempty"` 28 | NoCreateHome bool `json:"noCreateHome,omitempty"` 29 | PrimaryGroup string `json:"primaryGroup,omitempty"` 30 | Groups []string `json:"groups,omitempty"` 31 | NoUserGroup bool `json:"noUserGroup,omitempty"` 32 | System bool `json:"system,omitempty"` 33 | NoLogInit bool `json:"noLogInit,omitempty"` 34 | Shell string `json:"shell,omitempty"` 35 | } 36 | -------------------------------------------------------------------------------- /vendor/github.com/coreos/go-systemd/unit/option.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 CoreOS, Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package unit 16 | 17 | import ( 18 | "fmt" 19 | ) 20 | 21 | type UnitOption struct { 22 | Section string 23 | Name string 24 | Value string 25 | } 26 | 27 | func NewUnitOption(section, name, value string) *UnitOption { 28 | return &UnitOption{Section: section, Name: name, Value: value} 29 | } 30 | 31 | func (uo *UnitOption) String() string { 32 | return fmt.Sprintf("{Section: %q, Name: %q, Value: %q}", uo.Section, uo.Name, uo.Value) 33 | } 34 | 35 | func (uo *UnitOption) Match(other *UnitOption) bool { 36 | return uo.Section == other.Section && 37 | uo.Name == other.Name && 38 | uo.Value == other.Value 39 | } 40 | 41 | func AllMatch(u1 []*UnitOption, u2 []*UnitOption) bool { 42 | length := len(u1) 43 | if length != len(u2) { 44 | return false 45 | } 46 | 47 | for i := 0; i < length; i++ { 48 | if !u1[i].Match(u2[i]) { 49 | return false 50 | } 51 | } 52 | 53 | return true 54 | } 55 | -------------------------------------------------------------------------------- /vendor/github.com/coreos/ignition/config/v1/types/filesystem.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 CoreOS, Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package types 16 | 17 | import ( 18 | "github.com/coreos/ignition/config/shared/errors" 19 | "github.com/coreos/ignition/config/validate/report" 20 | ) 21 | 22 | type Filesystem struct { 23 | Device Path `json:"device,omitempty"` 24 | Format FilesystemFormat `json:"format,omitempty"` 25 | Create *FilesystemCreate `json:"create,omitempty"` 26 | Files []File `json:"files,omitempty"` 27 | } 28 | 29 | type FilesystemCreate struct { 30 | Force bool `json:"force,omitempty"` 31 | Options MkfsOptions `json:"options,omitempty"` 32 | } 33 | 34 | type FilesystemFormat string 35 | 36 | func (f FilesystemFormat) Validate() report.Report { 37 | switch f { 38 | case "ext4", "btrfs", "xfs": 39 | return report.Report{} 40 | default: 41 | return report.ReportFromError(errors.ErrFilesystemInvalidFormat, report.EntryError) 42 | } 43 | } 44 | 45 | type MkfsOptions []string 46 | -------------------------------------------------------------------------------- /vendor/github.com/gorilla/context/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2012 Rodrigo Moraes. All rights reserved. 2 | 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions are 5 | met: 6 | 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above 10 | copyright notice, this list of conditions and the following disclaimer 11 | in the documentation and/or other materials provided with the 12 | distribution. 13 | * Neither the name of Google Inc. nor the names of its 14 | contributors may be used to endorse or promote products derived from 15 | this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | -------------------------------------------------------------------------------- /vendor/github.com/gorilla/mux/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2012 Rodrigo Moraes. All rights reserved. 2 | 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions are 5 | met: 6 | 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above 10 | copyright notice, this list of conditions and the following disclaimer 11 | in the documentation and/or other materials provided with the 12 | distribution. 13 | * Neither the name of Google Inc. nor the names of its 14 | contributors may be used to endorse or promote products derived from 15 | this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | -------------------------------------------------------------------------------- /vendor/github.com/coreos/coreos-cloudinit/config/locksmith.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 CoreOS, Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package config 16 | 17 | type Locksmith struct { 18 | Endpoint string `yaml:"endpoint" env:"LOCKSMITHD_ENDPOINT"` 19 | EtcdCAFile string `yaml:"etcd_cafile" env:"LOCKSMITHD_ETCD_CAFILE"` 20 | EtcdCertFile string `yaml:"etcd_certfile" env:"LOCKSMITHD_ETCD_CERTFILE"` 21 | EtcdKeyFile string `yaml:"etcd_keyfile" env:"LOCKSMITHD_ETCD_KEYFILE"` 22 | EtcdUsername string `yaml:"etcd_username" env:"LOCKSMITHD_ETCD_USERNAME"` 23 | EtcdPassword string `yaml:"etcd_password" env:"LOCKSMITHD_ETCD_PASSWORD"` 24 | Group string `yaml:"group" env:"LOCKSMITHD_GROUP"` 25 | RebootWindowStart string `yaml:"window_start" env:"REBOOT_WINDOW_START" valid:"^((?i:sun|mon|tue|wed|thu|fri|sat|sun) )?0*([0-9]|1[0-9]|2[0-3]):0*([0-9]|[1-5][0-9])$"` 26 | RebootWindowLength string `yaml:"window_length" env:"REBOOT_WINDOW_LENGTH" valid:"^[-+]?([0-9]*(\\.[0-9]*)?[a-z]+)+$"` 27 | } 28 | -------------------------------------------------------------------------------- /vendor/github.com/coreos/ignition/config/v2_1/types/file.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 CoreOS, Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package types 16 | 17 | import ( 18 | "github.com/coreos/ignition/config/shared/errors" 19 | "github.com/coreos/ignition/config/validate/report" 20 | ) 21 | 22 | func (f File) ValidateMode() report.Report { 23 | r := report.Report{} 24 | if err := validateMode(f.Mode); err != nil { 25 | r.Add(report.Entry{ 26 | Message: err.Error(), 27 | Kind: report.EntryError, 28 | }) 29 | } 30 | return r 31 | } 32 | 33 | func (fc FileContents) ValidateCompression() report.Report { 34 | r := report.Report{} 35 | switch fc.Compression { 36 | case "", "gzip": 37 | default: 38 | r.Add(report.Entry{ 39 | Message: errors.ErrCompressionInvalid.Error(), 40 | Kind: report.EntryError, 41 | }) 42 | } 43 | return r 44 | } 45 | 46 | func (fc FileContents) ValidateSource() report.Report { 47 | r := report.Report{} 48 | err := validateURL(fc.Source) 49 | if err != nil { 50 | r.Add(report.Entry{ 51 | Message: err.Error(), 52 | Kind: report.EntryError, 53 | }) 54 | } 55 | return r 56 | } 57 | -------------------------------------------------------------------------------- /vendor/github.com/coreos/ignition/config/v1/cloudinit.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 CoreOS, Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | // These functions are copied from github.com/coreos/coreos-cloudinit/config. 16 | 17 | package v1 18 | 19 | import ( 20 | "bytes" 21 | "compress/gzip" 22 | "io/ioutil" 23 | "strings" 24 | "unicode" 25 | ) 26 | 27 | func isCloudConfig(userdata []byte) bool { 28 | header := strings.SplitN(string(decompressIfGzipped(userdata)), "\n", 2)[0] 29 | 30 | // Trim trailing whitespaces 31 | header = strings.TrimRightFunc(header, unicode.IsSpace) 32 | 33 | return (header == "#cloud-config") 34 | } 35 | 36 | func isScript(userdata []byte) bool { 37 | header := strings.SplitN(string(decompressIfGzipped(userdata)), "\n", 2)[0] 38 | return strings.HasPrefix(header, "#!") 39 | } 40 | 41 | func decompressIfGzipped(data []byte) []byte { 42 | if reader, err := gzip.NewReader(bytes.NewReader(data)); err == nil { 43 | uncompressedData, err := ioutil.ReadAll(reader) 44 | reader.Close() 45 | if err == nil { 46 | return uncompressedData 47 | } else { 48 | return data 49 | } 50 | } else { 51 | return data 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /vendor/github.com/coreos/ignition/config/v2_0/cloudinit.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 CoreOS, Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | // These functions are copied from github.com/coreos/coreos-cloudinit/config. 16 | 17 | package v2_0 18 | 19 | import ( 20 | "bytes" 21 | "compress/gzip" 22 | "io/ioutil" 23 | "strings" 24 | "unicode" 25 | ) 26 | 27 | func isCloudConfig(userdata []byte) bool { 28 | header := strings.SplitN(string(decompressIfGzipped(userdata)), "\n", 2)[0] 29 | 30 | // Trim trailing whitespaces 31 | header = strings.TrimRightFunc(header, unicode.IsSpace) 32 | 33 | return (header == "#cloud-config") 34 | } 35 | 36 | func isScript(userdata []byte) bool { 37 | header := strings.SplitN(string(decompressIfGzipped(userdata)), "\n", 2)[0] 38 | return strings.HasPrefix(header, "#!") 39 | } 40 | 41 | func decompressIfGzipped(data []byte) []byte { 42 | if reader, err := gzip.NewReader(bytes.NewReader(data)); err == nil { 43 | uncompressedData, err := ioutil.ReadAll(reader) 44 | reader.Close() 45 | if err == nil { 46 | return uncompressedData 47 | } else { 48 | return data 49 | } 50 | } else { 51 | return data 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /vendor/github.com/coreos/ignition/config/v2_1/cloudinit.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 CoreOS, Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | // These functions are copied from github.com/coreos/coreos-cloudinit/config. 16 | 17 | package v2_1 18 | 19 | import ( 20 | "bytes" 21 | "compress/gzip" 22 | "io/ioutil" 23 | "strings" 24 | "unicode" 25 | ) 26 | 27 | func isCloudConfig(userdata []byte) bool { 28 | header := strings.SplitN(string(decompressIfGzipped(userdata)), "\n", 2)[0] 29 | 30 | // Trim trailing whitespaces 31 | header = strings.TrimRightFunc(header, unicode.IsSpace) 32 | 33 | return (header == "#cloud-config") 34 | } 35 | 36 | func isScript(userdata []byte) bool { 37 | header := strings.SplitN(string(decompressIfGzipped(userdata)), "\n", 2)[0] 38 | return strings.HasPrefix(header, "#!") 39 | } 40 | 41 | func decompressIfGzipped(data []byte) []byte { 42 | if reader, err := gzip.NewReader(bytes.NewReader(data)); err == nil { 43 | uncompressedData, err := ioutil.ReadAll(reader) 44 | reader.Close() 45 | if err == nil { 46 | return uncompressedData 47 | } else { 48 | return data 49 | } 50 | } else { 51 | return data 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /vendor/github.com/coreos/ignition/config/v2_2/cloudinit.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 CoreOS, Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | // These functions are copied from github.com/coreos/coreos-cloudinit/config. 16 | 17 | package v2_2 18 | 19 | import ( 20 | "bytes" 21 | "compress/gzip" 22 | "io/ioutil" 23 | "strings" 24 | "unicode" 25 | ) 26 | 27 | func isCloudConfig(userdata []byte) bool { 28 | header := strings.SplitN(string(decompressIfGzipped(userdata)), "\n", 2)[0] 29 | 30 | // Trim trailing whitespaces 31 | header = strings.TrimRightFunc(header, unicode.IsSpace) 32 | 33 | return (header == "#cloud-config") 34 | } 35 | 36 | func isScript(userdata []byte) bool { 37 | header := strings.SplitN(string(decompressIfGzipped(userdata)), "\n", 2)[0] 38 | return strings.HasPrefix(header, "#!") 39 | } 40 | 41 | func decompressIfGzipped(data []byte) []byte { 42 | if reader, err := gzip.NewReader(bytes.NewReader(data)); err == nil { 43 | uncompressedData, err := ioutil.ReadAll(reader) 44 | reader.Close() 45 | if err == nil { 46 | return uncompressedData 47 | } else { 48 | return data 49 | } 50 | } else { 51 | return data 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /vendor/github.com/coreos/ignition/config/v2_1/types/ignition.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 CoreOS, Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package types 16 | 17 | import ( 18 | "github.com/coreos/go-semver/semver" 19 | 20 | "github.com/coreos/ignition/config/shared/errors" 21 | "github.com/coreos/ignition/config/validate/report" 22 | ) 23 | 24 | func (c ConfigReference) ValidateSource() report.Report { 25 | r := report.Report{} 26 | err := validateURL(c.Source) 27 | if err != nil { 28 | r.Add(report.Entry{ 29 | Message: err.Error(), 30 | Kind: report.EntryError, 31 | }) 32 | } 33 | return r 34 | } 35 | 36 | func (v Ignition) Semver() (*semver.Version, error) { 37 | return semver.NewVersion(v.Version) 38 | } 39 | 40 | func (v Ignition) Validate() report.Report { 41 | tv, err := v.Semver() 42 | if err != nil { 43 | return report.ReportFromError(errors.ErrInvalidVersion, report.EntryError) 44 | } 45 | if MaxVersion.Major > tv.Major { 46 | return report.ReportFromError(errors.ErrOldVersion, report.EntryError) 47 | } 48 | if MaxVersion.LessThan(*tv) { 49 | return report.ReportFromError(errors.ErrNewVersion, report.EntryError) 50 | } 51 | return report.Report{} 52 | } 53 | -------------------------------------------------------------------------------- /vendor/github.com/coreos/ignition/config/v2_2/types/ignition.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 CoreOS, Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package types 16 | 17 | import ( 18 | "github.com/coreos/go-semver/semver" 19 | 20 | "github.com/coreos/ignition/config/shared/errors" 21 | "github.com/coreos/ignition/config/validate/report" 22 | ) 23 | 24 | func (c ConfigReference) ValidateSource() report.Report { 25 | r := report.Report{} 26 | err := validateURL(c.Source) 27 | if err != nil { 28 | r.Add(report.Entry{ 29 | Message: err.Error(), 30 | Kind: report.EntryError, 31 | }) 32 | } 33 | return r 34 | } 35 | 36 | func (v Ignition) Semver() (*semver.Version, error) { 37 | return semver.NewVersion(v.Version) 38 | } 39 | 40 | func (v Ignition) Validate() report.Report { 41 | tv, err := v.Semver() 42 | if err != nil { 43 | return report.ReportFromError(errors.ErrInvalidVersion, report.EntryError) 44 | } 45 | if MaxVersion.Major > tv.Major { 46 | return report.ReportFromError(errors.ErrOldVersion, report.EntryError) 47 | } 48 | if MaxVersion.LessThan(*tv) { 49 | return report.ReportFromError(errors.ErrNewVersion, report.EntryError) 50 | } 51 | return report.Report{} 52 | } 53 | -------------------------------------------------------------------------------- /vendor/github.com/coreos/ignition/config/v2_3_experimental/types/ignition.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 CoreOS, Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package types 16 | 17 | import ( 18 | "github.com/coreos/go-semver/semver" 19 | 20 | "github.com/coreos/ignition/config/shared/errors" 21 | "github.com/coreos/ignition/config/validate/report" 22 | ) 23 | 24 | func (c ConfigReference) ValidateSource() report.Report { 25 | r := report.Report{} 26 | err := validateURL(c.Source) 27 | if err != nil { 28 | r.Add(report.Entry{ 29 | Message: err.Error(), 30 | Kind: report.EntryError, 31 | }) 32 | } 33 | return r 34 | } 35 | 36 | func (v Ignition) Semver() (*semver.Version, error) { 37 | return semver.NewVersion(v.Version) 38 | } 39 | 40 | func (v Ignition) Validate() report.Report { 41 | tv, err := v.Semver() 42 | if err != nil { 43 | return report.ReportFromError(errors.ErrInvalidVersion, report.EntryError) 44 | } 45 | if MaxVersion.Major > tv.Major { 46 | return report.ReportFromError(errors.ErrOldVersion, report.EntryError) 47 | } 48 | if MaxVersion.LessThan(*tv) { 49 | return report.ReportFromError(errors.ErrNewVersion, report.EntryError) 50 | } 51 | return report.Report{} 52 | } 53 | -------------------------------------------------------------------------------- /vendor/github.com/coreos/ignition/config/v2_1/types/raid.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 CoreOS, Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package types 16 | 17 | import ( 18 | "github.com/coreos/ignition/config/shared/errors" 19 | "github.com/coreos/ignition/config/validate/report" 20 | ) 21 | 22 | func (n Raid) ValidateLevel() report.Report { 23 | r := report.Report{} 24 | switch n.Level { 25 | case "linear", "raid0", "0", "stripe": 26 | if n.Spares != 0 { 27 | r.Add(report.Entry{ 28 | Message: errors.ErrSparesUnsupportedForLevel.Error(), 29 | Kind: report.EntryError, 30 | }) 31 | } 32 | case "raid1", "1", "mirror": 33 | case "raid4", "4": 34 | case "raid5", "5": 35 | case "raid6", "6": 36 | case "raid10", "10": 37 | default: 38 | r.Add(report.Entry{ 39 | Message: errors.ErrUnrecognizedRaidLevel.Error(), 40 | Kind: report.EntryError, 41 | }) 42 | } 43 | return r 44 | } 45 | 46 | func (n Raid) ValidateDevices() report.Report { 47 | r := report.Report{} 48 | for _, d := range n.Devices { 49 | if err := validatePath(string(d)); err != nil { 50 | r.Add(report.Entry{ 51 | Message: errors.ErrPathRelative.Error(), 52 | Kind: report.EntryError, 53 | }) 54 | } 55 | } 56 | return r 57 | } 58 | -------------------------------------------------------------------------------- /vendor/github.com/coreos/ignition/config/v2_2/types/raid.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 CoreOS, Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package types 16 | 17 | import ( 18 | "github.com/coreos/ignition/config/shared/errors" 19 | "github.com/coreos/ignition/config/validate/report" 20 | ) 21 | 22 | func (n Raid) ValidateLevel() report.Report { 23 | r := report.Report{} 24 | switch n.Level { 25 | case "linear", "raid0", "0", "stripe": 26 | if n.Spares != 0 { 27 | r.Add(report.Entry{ 28 | Message: errors.ErrSparesUnsupportedForLevel.Error(), 29 | Kind: report.EntryError, 30 | }) 31 | } 32 | case "raid1", "1", "mirror": 33 | case "raid4", "4": 34 | case "raid5", "5": 35 | case "raid6", "6": 36 | case "raid10", "10": 37 | default: 38 | r.Add(report.Entry{ 39 | Message: errors.ErrUnrecognizedRaidLevel.Error(), 40 | Kind: report.EntryError, 41 | }) 42 | } 43 | return r 44 | } 45 | 46 | func (n Raid) ValidateDevices() report.Report { 47 | r := report.Report{} 48 | for _, d := range n.Devices { 49 | if err := validatePath(string(d)); err != nil { 50 | r.Add(report.Entry{ 51 | Message: errors.ErrPathRelative.Error(), 52 | Kind: report.EntryError, 53 | }) 54 | } 55 | } 56 | return r 57 | } 58 | -------------------------------------------------------------------------------- /vendor/github.com/coreos/ignition/config/v2_3_experimental/types/raid.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 CoreOS, Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package types 16 | 17 | import ( 18 | "github.com/coreos/ignition/config/shared/errors" 19 | "github.com/coreos/ignition/config/validate/report" 20 | ) 21 | 22 | func (n Raid) ValidateLevel() report.Report { 23 | r := report.Report{} 24 | switch n.Level { 25 | case "linear", "raid0", "0", "stripe": 26 | if n.Spares != 0 { 27 | r.Add(report.Entry{ 28 | Message: errors.ErrSparesUnsupportedForLevel.Error(), 29 | Kind: report.EntryError, 30 | }) 31 | } 32 | case "raid1", "1", "mirror": 33 | case "raid4", "4": 34 | case "raid5", "5": 35 | case "raid6", "6": 36 | case "raid10", "10": 37 | default: 38 | r.Add(report.Entry{ 39 | Message: errors.ErrUnrecognizedRaidLevel.Error(), 40 | Kind: report.EntryError, 41 | }) 42 | } 43 | return r 44 | } 45 | 46 | func (n Raid) ValidateDevices() report.Report { 47 | r := report.Report{} 48 | for _, d := range n.Devices { 49 | if err := validatePath(string(d)); err != nil { 50 | r.Add(report.Entry{ 51 | Message: errors.ErrPathRelative.Error(), 52 | Kind: report.EntryError, 53 | }) 54 | } 55 | } 56 | return r 57 | } 58 | -------------------------------------------------------------------------------- /glide.lock: -------------------------------------------------------------------------------- 1 | hash: 361698403c3a67ca32aabb1ce778355419ad0c27cc0203078b4a4c6de99da88a 2 | updated: 2018-04-30T16:06:07.780123753-07:00 3 | imports: 4 | - name: github.com/ajeddeloh/go-json 5 | version: 73d058cf8437a1989030afe571eeab9f90eebbbd 6 | - name: github.com/coreos/coreos-cloudinit 7 | version: f1f0405491dfd073bbf074f7e374c9ef85600691 8 | subpackages: 9 | - config 10 | - config/validate 11 | - name: github.com/coreos/go-semver 12 | version: 294930c1e79c64e7dbe360054274fdad492c8cf5 13 | subpackages: 14 | - semver 15 | - name: github.com/coreos/go-systemd 16 | version: 40e2722dffead74698ca12a750f64ef313ddce05 17 | subpackages: 18 | - dbus 19 | - unit 20 | - name: github.com/coreos/ignition 21 | version: 8bc8a13ee812ce0755be0245808c3044a7ef0add 22 | subpackages: 23 | - config 24 | - config/shared/errors 25 | - config/shared/validations 26 | - config/util 27 | - config/v1 28 | - config/v1/types 29 | - config/v2_0 30 | - config/v2_0/types 31 | - config/v2_1 32 | - config/v2_1/types 33 | - config/v2_2 34 | - config/v2_2/types 35 | - config/v2_3_experimental/types 36 | - config/validate 37 | - config/validate/astjson 38 | - config/validate/astnode 39 | - config/validate/report 40 | - name: github.com/coreos/yaml 41 | version: 6b16a5714269b2f70720a45406b1babd947a17ef 42 | - name: github.com/crawford/nap 43 | version: b8a59dd5865651e5006eed1d919ecc3c87d22b08 44 | - name: github.com/gorilla/context 45 | version: 08b5f424b9271eedf6f9f0ce86cb9396ed337a42 46 | - name: github.com/gorilla/mux 47 | version: 53c1911da2b537f792e7cafcb446b05ffe33b996 48 | - name: github.com/vincent-petithory/dataurl 49 | version: 9a301d65acbb728fcc3ace14f45f511a4cfeea9c 50 | - name: go4.org 51 | version: 03efcb870d84809319ea509714dd6d19a1498483 52 | subpackages: 53 | - errorutil 54 | testImports: [] 55 | -------------------------------------------------------------------------------- /vendor/github.com/coreos/ignition/config/validate/astnode/astnode.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 CoreOS, Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package astnode 16 | 17 | import ( 18 | "io" 19 | ) 20 | 21 | // AstNode abstracts the differences between yaml and json nodes, providing a 22 | // common interface 23 | type AstNode interface { 24 | // ValueLineCol returns the line, column, and highlight string of the value of 25 | // this node in the source. 26 | ValueLineCol(source io.ReadSeeker) (int, int, string) 27 | 28 | // KeyLineCol returns the line, column, and highlight string of the key for the 29 | // value of this node in the source. 30 | KeyLineCol(source io.ReadSeeker) (int, int, string) 31 | 32 | // LiteralValue returns the value of this node. 33 | LiteralValue() interface{} 34 | 35 | // SliceChild returns the child node at the index specified. If this node is not 36 | // a slice node, an empty AstNode and false is returned. 37 | SliceChild(index int) (AstNode, bool) 38 | 39 | // KeyValueMap returns a map of keys and values. If this node is not a mapping 40 | // node, nil and false are returned. 41 | KeyValueMap() (map[string]AstNode, bool) 42 | 43 | // Tag returns the struct tag used in the config structure used to unmarshal. 44 | Tag() string 45 | } 46 | -------------------------------------------------------------------------------- /vendor/github.com/coreos/coreos-cloudinit/config/validate/context.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 CoreOS, Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package validate 16 | 17 | import ( 18 | "strings" 19 | ) 20 | 21 | // context represents the current position within a newline-delimited string. 22 | // Each line is loaded, one by one, into currentLine (newline omitted) and 23 | // lineNumber keeps track of its position within the original string. 24 | type context struct { 25 | currentLine string 26 | remainingLines string 27 | lineNumber int 28 | } 29 | 30 | // Increment moves the context to the next line (if available). 31 | func (c *context) Increment() { 32 | if c.currentLine == "" && c.remainingLines == "" { 33 | return 34 | } 35 | 36 | lines := strings.SplitN(c.remainingLines, "\n", 2) 37 | c.currentLine = lines[0] 38 | if len(lines) == 2 { 39 | c.remainingLines = lines[1] 40 | } else { 41 | c.remainingLines = "" 42 | } 43 | c.lineNumber++ 44 | } 45 | 46 | // NewContext creates a context from the provided data. It strips out all 47 | // carriage returns and moves to the first line (if available). 48 | func NewContext(content []byte) context { 49 | c := context{remainingLines: strings.Replace(string(content), "\r", "", -1)} 50 | c.Increment() 51 | return c 52 | } 53 | -------------------------------------------------------------------------------- /vendor/github.com/coreos/coreos-cloudinit/config/user.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 CoreOS, Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package config 16 | 17 | type User struct { 18 | Name string `yaml:"name"` 19 | PasswordHash string `yaml:"passwd"` 20 | SSHAuthorizedKeys []string `yaml:"ssh_authorized_keys"` 21 | SSHImportGithubUser string `yaml:"coreos_ssh_import_github" deprecated:"trying to fetch from a remote endpoint introduces too many intermittent errors"` 22 | SSHImportGithubUsers []string `yaml:"coreos_ssh_import_github_users" deprecated:"trying to fetch from a remote endpoint introduces too many intermittent errors"` 23 | SSHImportURL string `yaml:"coreos_ssh_import_url" deprecated:"trying to fetch from a remote endpoint introduces too many intermittent errors"` 24 | GECOS string `yaml:"gecos"` 25 | Homedir string `yaml:"homedir"` 26 | NoCreateHome bool `yaml:"no_create_home"` 27 | PrimaryGroup string `yaml:"primary_group"` 28 | Groups []string `yaml:"groups"` 29 | NoUserGroup bool `yaml:"no_user_group"` 30 | System bool `yaml:"system"` 31 | NoLogInit bool `yaml:"no_log_init"` 32 | Shell string `yaml:"shell"` 33 | } 34 | -------------------------------------------------------------------------------- /vendor/go4.org/errorutil/highlight.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2011 Google Inc. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Package errorutil helps make better error messages. 18 | package errorutil // import "go4.org/errorutil" 19 | 20 | import ( 21 | "bufio" 22 | "bytes" 23 | "fmt" 24 | "io" 25 | "strings" 26 | ) 27 | 28 | // HighlightBytePosition takes a reader and the location in bytes of a parse 29 | // error (for instance, from json.SyntaxError.Offset) and returns the line, column, 30 | // and pretty-printed context around the error with an arrow indicating the exact 31 | // position of the syntax error. 32 | func HighlightBytePosition(f io.Reader, pos int64) (line, col int, highlight string) { 33 | line = 1 34 | br := bufio.NewReader(f) 35 | lastLine := "" 36 | thisLine := new(bytes.Buffer) 37 | for n := int64(0); n < pos; n++ { 38 | b, err := br.ReadByte() 39 | if err != nil { 40 | break 41 | } 42 | if b == '\n' { 43 | lastLine = thisLine.String() 44 | thisLine.Reset() 45 | line++ 46 | col = 1 47 | } else { 48 | col++ 49 | thisLine.WriteByte(b) 50 | } 51 | } 52 | if line > 1 { 53 | highlight += fmt.Sprintf("%5d: %s\n", line-1, lastLine) 54 | } 55 | highlight += fmt.Sprintf("%5d: %s\n", line, thisLine.String()) 56 | highlight += fmt.Sprintf("%s^\n", strings.Repeat(" ", col+5)) 57 | return 58 | } 59 | -------------------------------------------------------------------------------- /vendor/github.com/coreos/ignition/config/v2_0/types/url.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 CoreOS, Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package types 16 | 17 | import ( 18 | "encoding/json" 19 | "net/url" 20 | 21 | "github.com/vincent-petithory/dataurl" 22 | 23 | "github.com/coreos/ignition/config/shared/errors" 24 | "github.com/coreos/ignition/config/validate/report" 25 | ) 26 | 27 | type Url url.URL 28 | 29 | func (u *Url) UnmarshalJSON(data []byte) error { 30 | var tu string 31 | if err := json.Unmarshal(data, &tu); err != nil { 32 | return err 33 | } 34 | 35 | pu, err := url.Parse(tu) 36 | if err != nil { 37 | return errors.ErrInvalidUrl 38 | } 39 | 40 | *u = Url(*pu) 41 | return nil 42 | } 43 | 44 | func (u Url) MarshalJSON() ([]byte, error) { 45 | return []byte(`"` + u.String() + `"`), nil 46 | } 47 | 48 | func (u Url) String() string { 49 | tu := url.URL(u) 50 | return (&tu).String() 51 | } 52 | 53 | func (u Url) Validate() report.Report { 54 | // Empty url is valid, indicates an empty file 55 | if u.String() == "" { 56 | return report.Report{} 57 | } 58 | switch url.URL(u).Scheme { 59 | case "http", "https", "oem": 60 | return report.Report{} 61 | case "data": 62 | if _, err := dataurl.DecodeString(u.String()); err != nil { 63 | return report.ReportFromError(err, report.EntryError) 64 | } 65 | return report.Report{} 66 | default: 67 | return report.ReportFromError(errors.ErrInvalidScheme, report.EntryError) 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /vendor/github.com/coreos/ignition/config/v2_0/types/hash.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 CoreOS, Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package types 16 | 17 | import ( 18 | "crypto" 19 | "encoding/hex" 20 | "encoding/json" 21 | "strings" 22 | 23 | "github.com/coreos/ignition/config/shared/errors" 24 | "github.com/coreos/ignition/config/validate/report" 25 | ) 26 | 27 | type Hash struct { 28 | Function string 29 | Sum string 30 | } 31 | 32 | func (h *Hash) UnmarshalJSON(data []byte) error { 33 | var th string 34 | if err := json.Unmarshal(data, &th); err != nil { 35 | return err 36 | } 37 | 38 | parts := strings.SplitN(th, "-", 2) 39 | if len(parts) != 2 { 40 | return errors.ErrHashMalformed 41 | } 42 | 43 | h.Function = parts[0] 44 | h.Sum = parts[1] 45 | 46 | return nil 47 | } 48 | 49 | func (h Hash) MarshalJSON() ([]byte, error) { 50 | return []byte(`"` + h.Function + "-" + h.Sum + `"`), nil 51 | } 52 | 53 | func (h Hash) String() string { 54 | bytes, _ := h.MarshalJSON() 55 | return string(bytes) 56 | } 57 | 58 | func (h Hash) Validate() report.Report { 59 | var hash crypto.Hash 60 | switch h.Function { 61 | case "sha512": 62 | hash = crypto.SHA512 63 | default: 64 | return report.ReportFromError(errors.ErrHashUnrecognized, report.EntryError) 65 | } 66 | 67 | if len(h.Sum) != hex.EncodedLen(hash.Size()) { 68 | return report.ReportFromError(errors.ErrHashWrongSize, report.EntryError) 69 | } 70 | 71 | return report.Report{} 72 | } 73 | -------------------------------------------------------------------------------- /vendor/github.com/coreos/ignition/config/v2_0/types/file.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 CoreOS, Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package types 16 | 17 | import ( 18 | "os" 19 | 20 | "github.com/coreos/ignition/config/shared/errors" 21 | "github.com/coreos/ignition/config/validate/report" 22 | ) 23 | 24 | type File struct { 25 | Filesystem string `json:"filesystem,omitempty"` 26 | Path Path `json:"path,omitempty"` 27 | Contents FileContents `json:"contents,omitempty"` 28 | Mode FileMode `json:"mode,omitempty"` 29 | User FileUser `json:"user,omitempty"` 30 | Group FileGroup `json:"group,omitempty"` 31 | } 32 | 33 | func (f File) Validate() report.Report { 34 | if f.Filesystem == "" { 35 | return report.ReportFromError(errors.ErrNoFilesystem, report.EntryError) 36 | } 37 | return report.Report{} 38 | } 39 | 40 | type FileUser struct { 41 | Id int `json:"id,omitempty"` 42 | } 43 | 44 | type FileGroup struct { 45 | Id int `json:"id,omitempty"` 46 | } 47 | 48 | type FileContents struct { 49 | Compression Compression `json:"compression,omitempty"` 50 | Source Url `json:"source,omitempty"` 51 | Verification Verification `json:"verification,omitempty"` 52 | } 53 | 54 | type FileMode os.FileMode 55 | 56 | func (m FileMode) Validate() report.Report { 57 | if (m &^ 07777) != 0 { 58 | return report.ReportFromError(errors.ErrFileIllegalMode, report.EntryError) 59 | } 60 | return report.Report{} 61 | } 62 | -------------------------------------------------------------------------------- /vendor/github.com/coreos/ignition/config/shared/validations/unit.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 CoreOS, Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | // Package validations contains validations shared between multiple config 16 | // versions. 17 | package validations 18 | 19 | import ( 20 | "github.com/coreos/go-systemd/unit" 21 | "github.com/coreos/ignition/config/shared/errors" 22 | "github.com/coreos/ignition/config/validate/report" 23 | ) 24 | 25 | // ValidateInstallSection is a helper to validate a given unit 26 | func ValidateInstallSection(name string, enabled bool, contentsEmpty bool, contentSections []*unit.UnitOption) report.Report { 27 | if !enabled { 28 | // install sections don't matter for not-enabled units 29 | return report.Report{} 30 | } 31 | if contentsEmpty { 32 | // install sections don't matter if it has no contents, e.g. it's being masked or just has dropins or such 33 | return report.Report{} 34 | } 35 | if contentSections == nil { 36 | // Should only happen if the unit could not be parsed, at which point an 37 | // error is probably already in the report so we don't need to double-up on 38 | // errors + warnings. 39 | return report.Report{} 40 | } 41 | 42 | for _, section := range contentSections { 43 | if section.Section == "Install" { 44 | return report.Report{} 45 | } 46 | } 47 | 48 | return report.Report{ 49 | Entries: []report.Entry{{ 50 | Message: errors.NewNoInstallSectionError(name).Error(), 51 | Kind: report.EntryWarning, 52 | }}, 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /vendor/github.com/coreos/ignition/config/v1/config.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 CoreOS, Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package v1 16 | 17 | import ( 18 | "github.com/coreos/ignition/config/shared/errors" 19 | "github.com/coreos/ignition/config/util" 20 | "github.com/coreos/ignition/config/v1/types" 21 | "github.com/coreos/ignition/config/validate" 22 | "github.com/coreos/ignition/config/validate/report" 23 | 24 | json "github.com/ajeddeloh/go-json" 25 | ) 26 | 27 | func Parse(rawConfig []byte) (types.Config, report.Report, error) { 28 | if isEmpty(rawConfig) { 29 | return types.Config{}, report.Report{}, errors.ErrEmpty 30 | } else if isCloudConfig(rawConfig) { 31 | return types.Config{}, report.Report{}, errors.ErrCloudConfig 32 | } else if isScript(rawConfig) { 33 | return types.Config{}, report.Report{}, errors.ErrScript 34 | } 35 | 36 | var err error 37 | var config types.Config 38 | 39 | err = json.Unmarshal(rawConfig, &config) 40 | if err != nil { 41 | rpt, err := util.HandleParseErrors(rawConfig) 42 | // HandleParseErrors always returns an error 43 | return types.Config{}, rpt, err 44 | } 45 | 46 | if config.Version != types.Version { 47 | return types.Config{}, report.Report{}, errors.ErrInvalid 48 | } 49 | 50 | rpt := validate.ValidateConfig(rawConfig, config) 51 | if rpt.IsFatal() { 52 | return types.Config{}, rpt, errors.ErrInvalid 53 | } 54 | return config, rpt, nil 55 | } 56 | 57 | func isEmpty(userdata []byte) bool { 58 | return len(userdata) == 0 59 | } 60 | -------------------------------------------------------------------------------- /vendor/github.com/coreos/ignition/config/v2_2/types/file.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 CoreOS, Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package types 16 | 17 | import ( 18 | "github.com/coreos/ignition/config/shared/errors" 19 | "github.com/coreos/ignition/config/validate/report" 20 | ) 21 | 22 | func (f File) Validate() report.Report { 23 | if f.Overwrite != nil && *f.Overwrite && f.Append { 24 | return report.ReportFromError(errors.ErrAppendAndOverwrite, report.EntryError) 25 | } 26 | return report.Report{} 27 | } 28 | 29 | func (f File) ValidateMode() report.Report { 30 | r := report.Report{} 31 | if err := validateMode(f.Mode); err != nil { 32 | r.Add(report.Entry{ 33 | Message: err.Error(), 34 | Kind: report.EntryError, 35 | }) 36 | } 37 | if f.Mode == nil { 38 | r.Add(report.Entry{ 39 | Message: errors.ErrPermissionsUnset.Error(), 40 | Kind: report.EntryWarning, 41 | }) 42 | } 43 | return r 44 | } 45 | 46 | func (fc FileContents) ValidateCompression() report.Report { 47 | r := report.Report{} 48 | switch fc.Compression { 49 | case "", "gzip": 50 | default: 51 | r.Add(report.Entry{ 52 | Message: errors.ErrCompressionInvalid.Error(), 53 | Kind: report.EntryError, 54 | }) 55 | } 56 | return r 57 | } 58 | 59 | func (fc FileContents) ValidateSource() report.Report { 60 | r := report.Report{} 61 | err := validateURL(fc.Source) 62 | if err != nil { 63 | r.Add(report.Entry{ 64 | Message: err.Error(), 65 | Kind: report.EntryError, 66 | }) 67 | } 68 | return r 69 | } 70 | -------------------------------------------------------------------------------- /vendor/github.com/coreos/ignition/config/v2_1/types/passwd.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 CoreOS, Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package types 16 | 17 | import ( 18 | "github.com/coreos/ignition/config/shared/errors" 19 | "github.com/coreos/ignition/config/validate/report" 20 | ) 21 | 22 | func (p PasswdUser) Validate() report.Report { 23 | r := report.Report{} 24 | if p.Create != nil { 25 | r.Add(report.Entry{ 26 | Message: errors.ErrPasswdCreateDeprecated.Error(), 27 | Kind: report.EntryWarning, 28 | }) 29 | addErr := func(err error) { 30 | r.Add(report.Entry{ 31 | Message: err.Error(), 32 | Kind: report.EntryError, 33 | }) 34 | } 35 | if p.Gecos != "" { 36 | addErr(errors.ErrPasswdCreateAndGecos) 37 | } 38 | if len(p.Groups) > 0 { 39 | addErr(errors.ErrPasswdCreateAndGroups) 40 | } 41 | if p.HomeDir != "" { 42 | addErr(errors.ErrPasswdCreateAndHomeDir) 43 | } 44 | if p.NoCreateHome { 45 | addErr(errors.ErrPasswdCreateAndNoCreateHome) 46 | } 47 | if p.NoLogInit { 48 | addErr(errors.ErrPasswdCreateAndNoLogInit) 49 | } 50 | if p.NoUserGroup { 51 | addErr(errors.ErrPasswdCreateAndNoUserGroup) 52 | } 53 | if p.PrimaryGroup != "" { 54 | addErr(errors.ErrPasswdCreateAndPrimaryGroup) 55 | } 56 | if p.Shell != "" { 57 | addErr(errors.ErrPasswdCreateAndShell) 58 | } 59 | if p.System { 60 | addErr(errors.ErrPasswdCreateAndSystem) 61 | } 62 | if p.UID != nil { 63 | addErr(errors.ErrPasswdCreateAndUID) 64 | } 65 | } 66 | return r 67 | } 68 | -------------------------------------------------------------------------------- /vendor/github.com/coreos/ignition/config/v2_2/types/passwd.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 CoreOS, Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package types 16 | 17 | import ( 18 | "github.com/coreos/ignition/config/shared/errors" 19 | "github.com/coreos/ignition/config/validate/report" 20 | ) 21 | 22 | func (p PasswdUser) Validate() report.Report { 23 | r := report.Report{} 24 | if p.Create != nil { 25 | r.Add(report.Entry{ 26 | Message: errors.ErrPasswdCreateDeprecated.Error(), 27 | Kind: report.EntryWarning, 28 | }) 29 | addErr := func(err error) { 30 | r.Add(report.Entry{ 31 | Message: err.Error(), 32 | Kind: report.EntryError, 33 | }) 34 | } 35 | if p.Gecos != "" { 36 | addErr(errors.ErrPasswdCreateAndGecos) 37 | } 38 | if len(p.Groups) > 0 { 39 | addErr(errors.ErrPasswdCreateAndGroups) 40 | } 41 | if p.HomeDir != "" { 42 | addErr(errors.ErrPasswdCreateAndHomeDir) 43 | } 44 | if p.NoCreateHome { 45 | addErr(errors.ErrPasswdCreateAndNoCreateHome) 46 | } 47 | if p.NoLogInit { 48 | addErr(errors.ErrPasswdCreateAndNoLogInit) 49 | } 50 | if p.NoUserGroup { 51 | addErr(errors.ErrPasswdCreateAndNoUserGroup) 52 | } 53 | if p.PrimaryGroup != "" { 54 | addErr(errors.ErrPasswdCreateAndPrimaryGroup) 55 | } 56 | if p.Shell != "" { 57 | addErr(errors.ErrPasswdCreateAndShell) 58 | } 59 | if p.System { 60 | addErr(errors.ErrPasswdCreateAndSystem) 61 | } 62 | if p.UID != nil { 63 | addErr(errors.ErrPasswdCreateAndUID) 64 | } 65 | } 66 | return r 67 | } 68 | -------------------------------------------------------------------------------- /vendor/github.com/coreos/ignition/config/v2_3_experimental/types/passwd.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 CoreOS, Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package types 16 | 17 | import ( 18 | "github.com/coreos/ignition/config/shared/errors" 19 | "github.com/coreos/ignition/config/validate/report" 20 | ) 21 | 22 | func (p PasswdUser) Validate() report.Report { 23 | r := report.Report{} 24 | if p.Create != nil { 25 | r.Add(report.Entry{ 26 | Message: errors.ErrPasswdCreateDeprecated.Error(), 27 | Kind: report.EntryWarning, 28 | }) 29 | addErr := func(err error) { 30 | r.Add(report.Entry{ 31 | Message: err.Error(), 32 | Kind: report.EntryError, 33 | }) 34 | } 35 | if p.Gecos != "" { 36 | addErr(errors.ErrPasswdCreateAndGecos) 37 | } 38 | if len(p.Groups) > 0 { 39 | addErr(errors.ErrPasswdCreateAndGroups) 40 | } 41 | if p.HomeDir != "" { 42 | addErr(errors.ErrPasswdCreateAndHomeDir) 43 | } 44 | if p.NoCreateHome { 45 | addErr(errors.ErrPasswdCreateAndNoCreateHome) 46 | } 47 | if p.NoLogInit { 48 | addErr(errors.ErrPasswdCreateAndNoLogInit) 49 | } 50 | if p.NoUserGroup { 51 | addErr(errors.ErrPasswdCreateAndNoUserGroup) 52 | } 53 | if p.PrimaryGroup != "" { 54 | addErr(errors.ErrPasswdCreateAndPrimaryGroup) 55 | } 56 | if p.Shell != "" { 57 | addErr(errors.ErrPasswdCreateAndShell) 58 | } 59 | if p.System { 60 | addErr(errors.ErrPasswdCreateAndSystem) 61 | } 62 | if p.UID != nil { 63 | addErr(errors.ErrPasswdCreateAndUID) 64 | } 65 | } 66 | return r 67 | } 68 | -------------------------------------------------------------------------------- /vendor/github.com/coreos/ignition/config/v2_0/types/filesystem.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 CoreOS, Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package types 16 | 17 | import ( 18 | "github.com/coreos/ignition/config/shared/errors" 19 | "github.com/coreos/ignition/config/validate/report" 20 | ) 21 | 22 | type Filesystem struct { 23 | Name string `json:"name,omitempty"` 24 | Mount *FilesystemMount `json:"mount,omitempty"` 25 | Path *Path `json:"path,omitempty"` 26 | } 27 | 28 | type FilesystemMount struct { 29 | Device Path `json:"device,omitempty"` 30 | Format FilesystemFormat `json:"format,omitempty"` 31 | Create *FilesystemCreate `json:"create,omitempty"` 32 | } 33 | 34 | type FilesystemCreate struct { 35 | Force bool `json:"force,omitempty"` 36 | Options MkfsOptions `json:"options,omitempty"` 37 | } 38 | 39 | func (f Filesystem) Validate() report.Report { 40 | if f.Mount == nil && f.Path == nil { 41 | return report.ReportFromError(errors.ErrFilesystemNoMountPath, report.EntryError) 42 | } 43 | if f.Mount != nil && f.Path != nil { 44 | return report.ReportFromError(errors.ErrFilesystemMountAndPath, report.EntryError) 45 | } 46 | return report.Report{} 47 | } 48 | 49 | type FilesystemFormat string 50 | 51 | func (f FilesystemFormat) Validate() report.Report { 52 | switch f { 53 | case "ext4", "btrfs", "xfs": 54 | return report.Report{} 55 | default: 56 | return report.ReportFromError(errors.ErrFilesystemInvalidFormat, report.EntryError) 57 | } 58 | } 59 | 60 | type MkfsOptions []string 61 | -------------------------------------------------------------------------------- /vendor/github.com/coreos/ignition/config/v2_1/types/node.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 CoreOS, Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package types 16 | 17 | import ( 18 | "path/filepath" 19 | 20 | "github.com/coreos/ignition/config/shared/errors" 21 | "github.com/coreos/ignition/config/validate/report" 22 | ) 23 | 24 | func (n Node) ValidateFilesystem() report.Report { 25 | r := report.Report{} 26 | if n.Filesystem == "" { 27 | r.Add(report.Entry{ 28 | Message: errors.ErrNoFilesystem.Error(), 29 | Kind: report.EntryError, 30 | }) 31 | } 32 | return r 33 | } 34 | 35 | func (n Node) ValidatePath() report.Report { 36 | r := report.Report{} 37 | if err := validatePath(n.Path); err != nil { 38 | r.Add(report.Entry{ 39 | Message: err.Error(), 40 | Kind: report.EntryError, 41 | }) 42 | } 43 | return r 44 | } 45 | 46 | func (n Node) Depth() int { 47 | count := 0 48 | for p := filepath.Clean(string(n.Path)); p != "/"; count++ { 49 | p = filepath.Dir(p) 50 | } 51 | return count 52 | } 53 | 54 | func (nu NodeUser) Validate() report.Report { 55 | r := report.Report{} 56 | if nu.ID != nil && nu.Name != "" { 57 | r.Add(report.Entry{ 58 | Message: errors.ErrBothIDAndNameSet.Error(), 59 | Kind: report.EntryError, 60 | }) 61 | } 62 | return r 63 | } 64 | func (ng NodeGroup) Validate() report.Report { 65 | r := report.Report{} 66 | if ng.ID != nil && ng.Name != "" { 67 | r.Add(report.Entry{ 68 | Message: errors.ErrBothIDAndNameSet.Error(), 69 | Kind: report.EntryError, 70 | }) 71 | } 72 | return r 73 | } 74 | -------------------------------------------------------------------------------- /vendor/github.com/coreos/ignition/config/v2_2/types/node.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 CoreOS, Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package types 16 | 17 | import ( 18 | "path/filepath" 19 | 20 | "github.com/coreos/ignition/config/shared/errors" 21 | "github.com/coreos/ignition/config/validate/report" 22 | ) 23 | 24 | func (n Node) ValidateFilesystem() report.Report { 25 | r := report.Report{} 26 | if n.Filesystem == "" { 27 | r.Add(report.Entry{ 28 | Message: errors.ErrNoFilesystem.Error(), 29 | Kind: report.EntryError, 30 | }) 31 | } 32 | return r 33 | } 34 | 35 | func (n Node) ValidatePath() report.Report { 36 | r := report.Report{} 37 | if err := validatePath(n.Path); err != nil { 38 | r.Add(report.Entry{ 39 | Message: err.Error(), 40 | Kind: report.EntryError, 41 | }) 42 | } 43 | return r 44 | } 45 | 46 | func (n Node) Depth() int { 47 | count := 0 48 | for p := filepath.Clean(string(n.Path)); p != "/"; count++ { 49 | p = filepath.Dir(p) 50 | } 51 | return count 52 | } 53 | 54 | func (nu NodeUser) Validate() report.Report { 55 | r := report.Report{} 56 | if nu.ID != nil && nu.Name != "" { 57 | r.Add(report.Entry{ 58 | Message: errors.ErrBothIDAndNameSet.Error(), 59 | Kind: report.EntryError, 60 | }) 61 | } 62 | return r 63 | } 64 | func (ng NodeGroup) Validate() report.Report { 65 | r := report.Report{} 66 | if ng.ID != nil && ng.Name != "" { 67 | r.Add(report.Entry{ 68 | Message: errors.ErrBothIDAndNameSet.Error(), 69 | Kind: report.EntryError, 70 | }) 71 | } 72 | return r 73 | } 74 | -------------------------------------------------------------------------------- /vendor/github.com/coreos/ignition/config/v2_3_experimental/types/node.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 CoreOS, Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package types 16 | 17 | import ( 18 | "path/filepath" 19 | 20 | "github.com/coreos/ignition/config/shared/errors" 21 | "github.com/coreos/ignition/config/validate/report" 22 | ) 23 | 24 | func (n Node) ValidateFilesystem() report.Report { 25 | r := report.Report{} 26 | if n.Filesystem == "" { 27 | r.Add(report.Entry{ 28 | Message: errors.ErrNoFilesystem.Error(), 29 | Kind: report.EntryError, 30 | }) 31 | } 32 | return r 33 | } 34 | 35 | func (n Node) ValidatePath() report.Report { 36 | r := report.Report{} 37 | if err := validatePath(n.Path); err != nil { 38 | r.Add(report.Entry{ 39 | Message: err.Error(), 40 | Kind: report.EntryError, 41 | }) 42 | } 43 | return r 44 | } 45 | 46 | func (n Node) Depth() int { 47 | count := 0 48 | for p := filepath.Clean(string(n.Path)); p != "/"; count++ { 49 | p = filepath.Dir(p) 50 | } 51 | return count 52 | } 53 | 54 | func (nu NodeUser) Validate() report.Report { 55 | r := report.Report{} 56 | if nu.ID != nil && nu.Name != "" { 57 | r.Add(report.Entry{ 58 | Message: errors.ErrBothIDAndNameSet.Error(), 59 | Kind: report.EntryError, 60 | }) 61 | } 62 | return r 63 | } 64 | func (ng NodeGroup) Validate() report.Report { 65 | r := report.Report{} 66 | if ng.ID != nil && ng.Name != "" { 67 | r.Add(report.Entry{ 68 | Message: errors.ErrBothIDAndNameSet.Error(), 69 | Kind: report.EntryError, 70 | }) 71 | } 72 | return r 73 | } 74 | -------------------------------------------------------------------------------- /vendor/github.com/coreos/ignition/config/v2_3_experimental/types/file.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 CoreOS, Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package types 16 | 17 | import ( 18 | "fmt" 19 | 20 | "github.com/coreos/ignition/config/shared/errors" 21 | "github.com/coreos/ignition/config/validate/report" 22 | ) 23 | 24 | func (f File) Validate() report.Report { 25 | if f.Overwrite != nil && *f.Overwrite && f.Append { 26 | return report.ReportFromError(errors.ErrAppendAndOverwrite, report.EntryError) 27 | } 28 | return report.Report{} 29 | } 30 | 31 | func (f File) ValidateMode() report.Report { 32 | r := report.Report{} 33 | if err := validateMode(f.Mode); err != nil { 34 | r.Add(report.Entry{ 35 | Message: err.Error(), 36 | Kind: report.EntryError, 37 | }) 38 | } 39 | if f.Mode == nil { 40 | r.Add(report.Entry{ 41 | Message: errors.ErrPermissionsUnset.Error(), 42 | Kind: report.EntryWarning, 43 | }) 44 | } 45 | return r 46 | } 47 | 48 | func (fc FileContents) ValidateCompression() report.Report { 49 | r := report.Report{} 50 | switch fc.Compression { 51 | case "", "gzip": 52 | default: 53 | r.Add(report.Entry{ 54 | Message: errors.ErrCompressionInvalid.Error(), 55 | Kind: report.EntryError, 56 | }) 57 | } 58 | return r 59 | } 60 | 61 | func (fc FileContents) ValidateSource() report.Report { 62 | r := report.Report{} 63 | err := validateURL(fc.Source) 64 | if err != nil { 65 | r.Add(report.Entry{ 66 | Message: fmt.Sprintf("invalid url %q: %v", fc.Source, err), 67 | Kind: report.EntryError, 68 | }) 69 | } 70 | return r 71 | } 72 | -------------------------------------------------------------------------------- /vendor/github.com/coreos/go-systemd/unit/serialize.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 CoreOS, Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package unit 16 | 17 | import ( 18 | "bytes" 19 | "io" 20 | ) 21 | 22 | // Serialize encodes all of the given UnitOption objects into a 23 | // unit file. When serialized the options are sorted in their 24 | // supplied order but grouped by section. 25 | func Serialize(opts []*UnitOption) io.Reader { 26 | var buf bytes.Buffer 27 | 28 | if len(opts) == 0 { 29 | return &buf 30 | } 31 | 32 | // Index of sections -> ordered options 33 | idx := map[string][]*UnitOption{} 34 | // Separately preserve order in which sections were seen 35 | sections := []string{} 36 | for _, opt := range opts { 37 | sec := opt.Section 38 | if _, ok := idx[sec]; !ok { 39 | sections = append(sections, sec) 40 | } 41 | idx[sec] = append(idx[sec], opt) 42 | } 43 | 44 | for i, sect := range sections { 45 | writeSectionHeader(&buf, sect) 46 | writeNewline(&buf) 47 | 48 | opts := idx[sect] 49 | for _, opt := range opts { 50 | writeOption(&buf, opt) 51 | writeNewline(&buf) 52 | } 53 | if i < len(sections)-1 { 54 | writeNewline(&buf) 55 | } 56 | } 57 | 58 | return &buf 59 | } 60 | 61 | func writeNewline(buf *bytes.Buffer) { 62 | buf.WriteRune('\n') 63 | } 64 | 65 | func writeSectionHeader(buf *bytes.Buffer, section string) { 66 | buf.WriteRune('[') 67 | buf.WriteString(section) 68 | buf.WriteRune(']') 69 | } 70 | 71 | func writeOption(buf *bytes.Buffer, opt *UnitOption) { 72 | buf.WriteString(opt.Name) 73 | buf.WriteRune('=') 74 | buf.WriteString(opt.Value) 75 | } 76 | -------------------------------------------------------------------------------- /vendor/github.com/coreos/ignition/config/v2_0/types/ignition.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 CoreOS, Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package types 16 | 17 | import ( 18 | "encoding/json" 19 | 20 | "github.com/coreos/go-semver/semver" 21 | 22 | "github.com/coreos/ignition/config/shared/errors" 23 | "github.com/coreos/ignition/config/validate/report" 24 | ) 25 | 26 | type Ignition struct { 27 | Version IgnitionVersion `json:"version,omitempty" merge:"old"` 28 | Config IgnitionConfig `json:"config,omitempty" merge:"new"` 29 | } 30 | 31 | type IgnitionConfig struct { 32 | Append []ConfigReference `json:"append,omitempty"` 33 | Replace *ConfigReference `json:"replace,omitempty"` 34 | } 35 | 36 | type ConfigReference struct { 37 | Source Url `json:"source,omitempty"` 38 | Verification Verification `json:"verification,omitempty"` 39 | } 40 | 41 | type IgnitionVersion semver.Version 42 | 43 | func (v *IgnitionVersion) UnmarshalJSON(data []byte) error { 44 | tv := semver.Version(*v) 45 | if err := json.Unmarshal(data, &tv); err != nil { 46 | return err 47 | } 48 | *v = IgnitionVersion(tv) 49 | return nil 50 | } 51 | 52 | func (v IgnitionVersion) MarshalJSON() ([]byte, error) { 53 | return semver.Version(v).MarshalJSON() 54 | } 55 | 56 | func (v IgnitionVersion) Validate() report.Report { 57 | if MaxVersion.Major > v.Major { 58 | return report.ReportFromError(errors.ErrOldVersion, report.EntryError) 59 | } 60 | if MaxVersion.LessThan(semver.Version(v)) { 61 | return report.ReportFromError(errors.ErrNewVersion, report.EntryError) 62 | } 63 | return report.Report{} 64 | } 65 | -------------------------------------------------------------------------------- /vendor/github.com/coreos/go-systemd/dbus/subscription_set.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 CoreOS, Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package dbus 16 | 17 | import ( 18 | "time" 19 | ) 20 | 21 | // SubscriptionSet returns a subscription set which is like conn.Subscribe but 22 | // can filter to only return events for a set of units. 23 | type SubscriptionSet struct { 24 | *set 25 | conn *Conn 26 | } 27 | 28 | func (s *SubscriptionSet) filter(unit string) bool { 29 | return !s.Contains(unit) 30 | } 31 | 32 | // Subscribe starts listening for dbus events for all of the units in the set. 33 | // Returns channels identical to conn.SubscribeUnits. 34 | func (s *SubscriptionSet) Subscribe() (<-chan map[string]*UnitStatus, <-chan error) { 35 | // TODO: Make fully evented by using systemd 209 with properties changed values 36 | return s.conn.SubscribeUnitsCustom(time.Second, 0, 37 | mismatchUnitStatus, 38 | func(unit string) bool { return s.filter(unit) }, 39 | ) 40 | } 41 | 42 | // NewSubscriptionSet returns a new subscription set. 43 | func (conn *Conn) NewSubscriptionSet() *SubscriptionSet { 44 | return &SubscriptionSet{newSet(), conn} 45 | } 46 | 47 | // mismatchUnitStatus returns true if the provided UnitStatus objects 48 | // are not equivalent. false is returned if the objects are equivalent. 49 | // Only the Name, Description and state-related fields are used in 50 | // the comparison. 51 | func mismatchUnitStatus(u1, u2 *UnitStatus) bool { 52 | return u1.Name != u2.Name || 53 | u1.Description != u2.Description || 54 | u1.LoadState != u2.LoadState || 55 | u1.ActiveState != u2.ActiveState || 56 | u1.SubState != u2.SubState 57 | } 58 | -------------------------------------------------------------------------------- /vendor/github.com/coreos/ignition/config/v2_1/types/verification.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 CoreOS, Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package types 16 | 17 | import ( 18 | "crypto" 19 | "encoding/hex" 20 | "strings" 21 | 22 | "github.com/coreos/ignition/config/shared/errors" 23 | "github.com/coreos/ignition/config/validate/report" 24 | ) 25 | 26 | // HashParts will return the sum and function (in that order) of the hash stored 27 | // in this Verification, or an error if there is an issue during parsing. 28 | func (v Verification) HashParts() (string, string, error) { 29 | if v.Hash == nil { 30 | // The hash can be nil 31 | return "", "", nil 32 | } 33 | parts := strings.SplitN(*v.Hash, "-", 2) 34 | if len(parts) != 2 { 35 | return "", "", errors.ErrHashMalformed 36 | } 37 | 38 | return parts[0], parts[1], nil 39 | } 40 | 41 | func (v Verification) Validate() report.Report { 42 | r := report.Report{} 43 | 44 | if v.Hash == nil { 45 | // The hash can be nil 46 | return r 47 | } 48 | 49 | function, sum, err := v.HashParts() 50 | if err != nil { 51 | r.Add(report.Entry{ 52 | Message: err.Error(), 53 | Kind: report.EntryError, 54 | }) 55 | return r 56 | } 57 | var hash crypto.Hash 58 | switch function { 59 | case "sha512": 60 | hash = crypto.SHA512 61 | default: 62 | r.Add(report.Entry{ 63 | Message: errors.ErrHashUnrecognized.Error(), 64 | Kind: report.EntryError, 65 | }) 66 | return r 67 | } 68 | 69 | if len(sum) != hex.EncodedLen(hash.Size()) { 70 | r.Add(report.Entry{ 71 | Message: errors.ErrHashWrongSize.Error(), 72 | Kind: report.EntryError, 73 | }) 74 | } 75 | 76 | return r 77 | } 78 | -------------------------------------------------------------------------------- /vendor/github.com/coreos/ignition/config/v2_2/types/verification.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 CoreOS, Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package types 16 | 17 | import ( 18 | "crypto" 19 | "encoding/hex" 20 | "strings" 21 | 22 | "github.com/coreos/ignition/config/shared/errors" 23 | "github.com/coreos/ignition/config/validate/report" 24 | ) 25 | 26 | // HashParts will return the sum and function (in that order) of the hash stored 27 | // in this Verification, or an error if there is an issue during parsing. 28 | func (v Verification) HashParts() (string, string, error) { 29 | if v.Hash == nil { 30 | // The hash can be nil 31 | return "", "", nil 32 | } 33 | parts := strings.SplitN(*v.Hash, "-", 2) 34 | if len(parts) != 2 { 35 | return "", "", errors.ErrHashMalformed 36 | } 37 | 38 | return parts[0], parts[1], nil 39 | } 40 | 41 | func (v Verification) Validate() report.Report { 42 | r := report.Report{} 43 | 44 | if v.Hash == nil { 45 | // The hash can be nil 46 | return r 47 | } 48 | 49 | function, sum, err := v.HashParts() 50 | if err != nil { 51 | r.Add(report.Entry{ 52 | Message: err.Error(), 53 | Kind: report.EntryError, 54 | }) 55 | return r 56 | } 57 | var hash crypto.Hash 58 | switch function { 59 | case "sha512": 60 | hash = crypto.SHA512 61 | default: 62 | r.Add(report.Entry{ 63 | Message: errors.ErrHashUnrecognized.Error(), 64 | Kind: report.EntryError, 65 | }) 66 | return r 67 | } 68 | 69 | if len(sum) != hex.EncodedLen(hash.Size()) { 70 | r.Add(report.Entry{ 71 | Message: errors.ErrHashWrongSize.Error(), 72 | Kind: report.EntryError, 73 | }) 74 | } 75 | 76 | return r 77 | } 78 | -------------------------------------------------------------------------------- /vendor/github.com/coreos/ignition/config/v2_3_experimental/types/verification.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 CoreOS, Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package types 16 | 17 | import ( 18 | "crypto" 19 | "encoding/hex" 20 | "strings" 21 | 22 | "github.com/coreos/ignition/config/shared/errors" 23 | "github.com/coreos/ignition/config/validate/report" 24 | ) 25 | 26 | // HashParts will return the sum and function (in that order) of the hash stored 27 | // in this Verification, or an error if there is an issue during parsing. 28 | func (v Verification) HashParts() (string, string, error) { 29 | if v.Hash == nil { 30 | // The hash can be nil 31 | return "", "", nil 32 | } 33 | parts := strings.SplitN(*v.Hash, "-", 2) 34 | if len(parts) != 2 { 35 | return "", "", errors.ErrHashMalformed 36 | } 37 | 38 | return parts[0], parts[1], nil 39 | } 40 | 41 | func (v Verification) Validate() report.Report { 42 | r := report.Report{} 43 | 44 | if v.Hash == nil { 45 | // The hash can be nil 46 | return r 47 | } 48 | 49 | function, sum, err := v.HashParts() 50 | if err != nil { 51 | r.Add(report.Entry{ 52 | Message: err.Error(), 53 | Kind: report.EntryError, 54 | }) 55 | return r 56 | } 57 | var hash crypto.Hash 58 | switch function { 59 | case "sha512": 60 | hash = crypto.SHA512 61 | default: 62 | r.Add(report.Entry{ 63 | Message: errors.ErrHashUnrecognized.Error(), 64 | Kind: report.EntryError, 65 | }) 66 | return r 67 | } 68 | 69 | if len(sum) != hex.EncodedLen(hash.Size()) { 70 | r.Add(report.Entry{ 71 | Message: errors.ErrHashWrongSize.Error(), 72 | Kind: report.EntryError, 73 | }) 74 | } 75 | 76 | return r 77 | } 78 | -------------------------------------------------------------------------------- /vendor/github.com/coreos/ignition/config/v1/types/partition.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 CoreOS, Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package types 16 | 17 | import ( 18 | "fmt" 19 | "regexp" 20 | 21 | "github.com/coreos/ignition/config/shared/errors" 22 | "github.com/coreos/ignition/config/validate/report" 23 | ) 24 | 25 | type Partition struct { 26 | Label PartitionLabel `json:"label,omitempty"` 27 | Number int `json:"number"` 28 | Size PartitionDimension `json:"size"` 29 | Start PartitionDimension `json:"start"` 30 | TypeGUID PartitionTypeGUID `json:"typeGuid,omitempty"` 31 | } 32 | 33 | type PartitionLabel string 34 | 35 | func (n PartitionLabel) Validate() report.Report { 36 | // http://en.wikipedia.org/wiki/GUID_Partition_Table#Partition_entries: 37 | // 56 (0x38) 72 bytes Partition name (36 UTF-16LE code units) 38 | 39 | // XXX(vc): note GPT calls it a name, we're using label for consistency 40 | // with udev naming /dev/disk/by-partlabel/*. 41 | if len(string(n)) > 36 { 42 | return report.ReportFromError(errors.ErrLabelTooLong, report.EntryError) 43 | } 44 | return report.Report{} 45 | } 46 | 47 | type PartitionDimension uint64 48 | 49 | type PartitionTypeGUID string 50 | 51 | func (d PartitionTypeGUID) Validate() report.Report { 52 | ok, err := regexp.MatchString("^(|[[:xdigit:]]{8}-[[:xdigit:]]{4}-[[:xdigit:]]{4}-[[:xdigit:]]{4}-[[:xdigit:]]{12})$", string(d)) 53 | if err != nil { 54 | return report.ReportFromError(fmt.Errorf("error matching type-guid regexp: %v", err), report.EntryError) 55 | } 56 | if !ok { 57 | return report.ReportFromError(fmt.Errorf(`partition type-guid must have the form "01234567-89AB-CDEF-EDCB-A98765432101", got: %q`, string(d)), report.EntryError) 58 | } 59 | return report.Report{} 60 | } 61 | -------------------------------------------------------------------------------- /vendor/github.com/coreos/coreos-cloudinit/config/fleet.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 CoreOS, Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package config 16 | 17 | type Fleet struct { 18 | AgentTTL string `yaml:"agent_ttl" env:"FLEET_AGENT_TTL"` 19 | AuthorizedKeysFile string `yaml:"authorized_keys_file" env:"FLEET_AUTHORIZED_KEYS_FILE"` 20 | DisableEngine bool `yaml:"disable_engine" env:"FLEET_DISABLE_ENGINE"` 21 | EngineReconcileInterval float64 `yaml:"engine_reconcile_interval" env:"FLEET_ENGINE_RECONCILE_INTERVAL"` 22 | EtcdCAFile string `yaml:"etcd_cafile" env:"FLEET_ETCD_CAFILE"` 23 | EtcdCertFile string `yaml:"etcd_certfile" env:"FLEET_ETCD_CERTFILE"` 24 | EtcdKeyFile string `yaml:"etcd_keyfile" env:"FLEET_ETCD_KEYFILE"` 25 | EtcdKeyPrefix string `yaml:"etcd_key_prefix" env:"FLEET_ETCD_KEY_PREFIX"` 26 | EtcdRequestTimeout float64 `yaml:"etcd_request_timeout" env:"FLEET_ETCD_REQUEST_TIMEOUT"` 27 | EtcdServers string `yaml:"etcd_servers" env:"FLEET_ETCD_SERVERS"` 28 | EtcdUsername string `yaml:"etcd_username" env:"FLEET_ETCD_USERNAME"` 29 | EtcdPassword string `yaml:"etcd_password" env:"FLEET_ETCD_PASSWORD"` 30 | Metadata string `yaml:"metadata" env:"FLEET_METADATA"` 31 | PublicIP string `yaml:"public_ip" env:"FLEET_PUBLIC_IP"` 32 | TokenLimit int `yaml:"token_limit" env:"FLEET_TOKEN_LIMIT"` 33 | Verbosity int `yaml:"verbosity" env:"FLEET_VERBOSITY"` 34 | VerifyUnits bool `yaml:"verify_units" env:"FLEET_VERIFY_UNITS"` 35 | } 36 | -------------------------------------------------------------------------------- /vendor/github.com/coreos/ignition/config/v2_1/config.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 CoreOS, Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package v2_1 16 | 17 | import ( 18 | "github.com/coreos/go-semver/semver" 19 | "github.com/coreos/ignition/config/shared/errors" 20 | "github.com/coreos/ignition/config/v2_0" 21 | "github.com/coreos/ignition/config/v2_1/types" 22 | "github.com/coreos/ignition/config/validate" 23 | "github.com/coreos/ignition/config/validate/report" 24 | 25 | json "github.com/ajeddeloh/go-json" 26 | ) 27 | 28 | func Parse(rawConfig []byte) (types.Config, report.Report, error) { 29 | if isEmpty(rawConfig) { 30 | return types.Config{}, report.Report{}, errors.ErrEmpty 31 | } else if isCloudConfig(rawConfig) { 32 | return types.Config{}, report.Report{}, errors.ErrCloudConfig 33 | } else if isScript(rawConfig) { 34 | return types.Config{}, report.Report{}, errors.ErrScript 35 | } 36 | 37 | var err error 38 | var config types.Config 39 | 40 | err = json.Unmarshal(rawConfig, &config) 41 | 42 | version, semverErr := semver.NewVersion(config.Ignition.Version) 43 | 44 | if err != nil || semverErr != nil || version.LessThan(types.MaxVersion) { 45 | // We can fail unmarshaling if it's an older config. Attempt to parse 46 | // it as such. 47 | config, rpt, err := v2_0.Parse(rawConfig) 48 | if err != nil { 49 | return types.Config{}, rpt, err 50 | } 51 | return TranslateFromV2_0(config), rpt, err 52 | } 53 | 54 | if *version != types.MaxVersion { 55 | return types.Config{}, report.Report{}, errors.ErrUnknownVersion 56 | } 57 | 58 | rpt := validate.ValidateConfig(rawConfig, config) 59 | if rpt.IsFatal() { 60 | return types.Config{}, rpt, errors.ErrInvalid 61 | } 62 | 63 | return config, rpt, nil 64 | } 65 | 66 | func isEmpty(userdata []byte) bool { 67 | return len(userdata) == 0 68 | } 69 | -------------------------------------------------------------------------------- /vendor/github.com/coreos/ignition/config/validate/astjson/node.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 CoreOS, Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package astjson 16 | 17 | import ( 18 | "io" 19 | 20 | json "github.com/ajeddeloh/go-json" 21 | "github.com/coreos/ignition/config/validate/astnode" 22 | "go4.org/errorutil" 23 | ) 24 | 25 | type JsonNode json.Node 26 | 27 | func FromJsonRoot(n json.Node) JsonNode { 28 | return JsonNode(n) 29 | } 30 | 31 | func (n JsonNode) ValueLineCol(source io.ReadSeeker) (int, int, string) { 32 | return posFromOffset(n.End, source) 33 | } 34 | 35 | func (n JsonNode) KeyLineCol(source io.ReadSeeker) (int, int, string) { 36 | return posFromOffset(n.KeyEnd, source) 37 | } 38 | 39 | func (n JsonNode) LiteralValue() interface{} { 40 | return n.Value 41 | } 42 | 43 | func (n JsonNode) SliceChild(index int) (astnode.AstNode, bool) { 44 | if slice, ok := n.Value.([]json.Node); ok { 45 | return JsonNode(slice[index]), true 46 | } 47 | return JsonNode{}, false 48 | } 49 | 50 | func (n JsonNode) KeyValueMap() (map[string]astnode.AstNode, bool) { 51 | if kvmap, ok := n.Value.(map[string]json.Node); ok { 52 | newKvmap := map[string]astnode.AstNode{} 53 | for k, v := range kvmap { 54 | newKvmap[k] = JsonNode(v) 55 | } 56 | return newKvmap, true 57 | } 58 | return nil, false 59 | } 60 | 61 | func (n JsonNode) Tag() string { 62 | return "json" 63 | } 64 | 65 | // wrapper for errorutil that handles missing sources sanely and resets the reader afterwards 66 | func posFromOffset(offset int, source io.ReadSeeker) (int, int, string) { 67 | if source == nil { 68 | return 0, 0, "" 69 | } 70 | line, col, highlight := errorutil.HighlightBytePosition(source, int64(offset)) 71 | source.Seek(0, 0) // Reset the reader to the start so the next call isn't relative to this position 72 | return line, col, highlight 73 | } 74 | -------------------------------------------------------------------------------- /vendor/github.com/coreos/ignition/config/v2_0/types/partition.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 CoreOS, Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package types 16 | 17 | import ( 18 | "fmt" 19 | "regexp" 20 | "strings" 21 | 22 | "github.com/coreos/ignition/config/shared/errors" 23 | "github.com/coreos/ignition/config/validate/report" 24 | ) 25 | 26 | type Partition struct { 27 | Label PartitionLabel `json:"label,omitempty"` 28 | Number int `json:"number"` 29 | Size PartitionDimension `json:"size"` 30 | Start PartitionDimension `json:"start"` 31 | TypeGUID PartitionTypeGUID `json:"typeGuid,omitempty"` 32 | } 33 | 34 | type PartitionLabel string 35 | 36 | func (n PartitionLabel) Validate() report.Report { 37 | // http://en.wikipedia.org/wiki/GUID_Partition_Table#Partition_entries: 38 | // 56 (0x38) 72 bytes Partition name (36 UTF-16LE code units) 39 | 40 | // XXX(vc): note GPT calls it a name, we're using label for consistency 41 | // with udev naming /dev/disk/by-partlabel/*. 42 | if len(string(n)) > 36 { 43 | return report.ReportFromError(errors.ErrLabelTooLong, report.EntryError) 44 | } 45 | if strings.Contains(string(n), ":") { 46 | return report.ReportFromError(errors.ErrLabelContainsColon, report.EntryWarning) 47 | } 48 | return report.Report{} 49 | } 50 | 51 | type PartitionDimension uint64 52 | 53 | type PartitionTypeGUID string 54 | 55 | func (d PartitionTypeGUID) Validate() report.Report { 56 | ok, err := regexp.MatchString("^(|[[:xdigit:]]{8}-[[:xdigit:]]{4}-[[:xdigit:]]{4}-[[:xdigit:]]{4}-[[:xdigit:]]{12})$", string(d)) 57 | if err != nil { 58 | return report.ReportFromError(fmt.Errorf("error matching type-guid regexp: %v", err), report.EntryError) 59 | } 60 | if !ok { 61 | return report.ReportFromError(errors.ErrDoesntMatchGUIDRegex, report.EntryError) 62 | } 63 | return report.Report{} 64 | } 65 | -------------------------------------------------------------------------------- /vendor/github.com/crawford/nap/nap.go: -------------------------------------------------------------------------------- 1 | package nap 2 | 3 | import ( 4 | "encoding/json" 5 | "net/http" 6 | ) 7 | 8 | var ( 9 | MethodNotAllowedHandler HandlerFunc = HandlerFunc(defaultMethodNotAllowed) 10 | NotFoundHandler HandlerFunc = HandlerFunc(defaultNotFound) 11 | PayloadWrapper Wrapper = DefaultWrapper{} 12 | PanicHandler ErrorHandler = nil 13 | ResponseHeaders []Header = defaultHeaders 14 | ) 15 | 16 | type Wrapper interface { 17 | Wrap(payload interface{}, status Status) (interface{}, int) 18 | } 19 | 20 | type ErrorHandler interface { 21 | Handle(e interface{}) 22 | } 23 | 24 | type DefaultWrapper struct{} 25 | 26 | func (w DefaultWrapper) Wrap(payload interface{}, status Status) (interface{}, int) { 27 | if status == nil { 28 | status = OK{} 29 | } 30 | return payload, status.Code() 31 | } 32 | 33 | type Header struct { 34 | Name string 35 | Value []string 36 | } 37 | 38 | type HandlerFunc func(req *http.Request) (interface{}, Status) 39 | 40 | func (f HandlerFunc) ServeHTTP(writer http.ResponseWriter, request *http.Request) { 41 | var payload interface{} 42 | var status Status 43 | defer func() { 44 | var result interface{} 45 | var code int 46 | defer func() { 47 | for _, header := range ResponseHeaders { 48 | writer.Header()[header.Name] = header.Value 49 | } 50 | 51 | if r := recover(); r != nil { 52 | handlePanic(r) 53 | } else { 54 | if res, err := json.Marshal(result); err == nil { 55 | writer.WriteHeader(code) 56 | writer.Write(res) 57 | return 58 | } 59 | } 60 | writer.WriteHeader(http.StatusInternalServerError) 61 | }() 62 | if r := recover(); r != nil { 63 | handlePanic(r) 64 | status = InternalError{} 65 | } 66 | result, code = PayloadWrapper.Wrap(payload, status) 67 | }() 68 | payload, status = f(request) 69 | } 70 | 71 | func handlePanic(r interface{}) { 72 | if PanicHandler != nil { 73 | func() { 74 | defer func() { 75 | recover() 76 | }() 77 | PanicHandler.Handle(r) 78 | }() 79 | } 80 | } 81 | 82 | var ( 83 | defaultHeaders = []Header{ 84 | {"Content-Type", []string{"application/json"}}, 85 | {"Cache-Control", []string{"no-cache,must-revalidate"}}, 86 | } 87 | ) 88 | 89 | func defaultMethodNotAllowed(req *http.Request) (interface{}, Status) { 90 | return nil, MethodNotAllowed{"method not allowed on resource"} 91 | } 92 | 93 | func defaultNotFound(req *http.Request) (interface{}, Status) { 94 | return nil, NotFound{"resource not found"} 95 | } 96 | -------------------------------------------------------------------------------- /vendor/github.com/coreos/ignition/config/v2_1/types/partition.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 CoreOS, Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package types 16 | 17 | import ( 18 | "fmt" 19 | "regexp" 20 | "strings" 21 | 22 | "github.com/coreos/ignition/config/shared/errors" 23 | "github.com/coreos/ignition/config/validate/report" 24 | ) 25 | 26 | const ( 27 | guidRegexStr = "^(|[[:xdigit:]]{8}-[[:xdigit:]]{4}-[[:xdigit:]]{4}-[[:xdigit:]]{4}-[[:xdigit:]]{12})$" 28 | ) 29 | 30 | func (p Partition) ValidateLabel() report.Report { 31 | r := report.Report{} 32 | // http://en.wikipedia.org/wiki/GUID_Partition_Table#Partition_entries: 33 | // 56 (0x38) 72 bytes Partition name (36 UTF-16LE code units) 34 | 35 | // XXX(vc): note GPT calls it a name, we're using label for consistency 36 | // with udev naming /dev/disk/by-partlabel/*. 37 | if len(p.Label) > 36 { 38 | r.Add(report.Entry{ 39 | Message: errors.ErrLabelTooLong.Error(), 40 | Kind: report.EntryError, 41 | }) 42 | } 43 | 44 | // sgdisk uses colons for delimitting compound arguments and does not allow escaping them. 45 | if strings.Contains(p.Label, ":") { 46 | r.Add(report.Entry{ 47 | Message: errors.ErrLabelContainsColon.Error(), 48 | Kind: report.EntryWarning, 49 | }) 50 | } 51 | return r 52 | } 53 | 54 | func (p Partition) ValidateTypeGUID() report.Report { 55 | return validateGUID(p.TypeGUID) 56 | } 57 | 58 | func (p Partition) ValidateGUID() report.Report { 59 | return validateGUID(p.GUID) 60 | } 61 | 62 | func validateGUID(guid string) report.Report { 63 | r := report.Report{} 64 | ok, err := regexp.MatchString(guidRegexStr, guid) 65 | if err != nil { 66 | r.Add(report.Entry{ 67 | Message: fmt.Sprintf("error matching guid regexp: %v", err), 68 | Kind: report.EntryError, 69 | }) 70 | } else if !ok { 71 | r.Add(report.Entry{ 72 | Message: errors.ErrDoesntMatchGUIDRegex.Error(), 73 | Kind: report.EntryError, 74 | }) 75 | } 76 | return r 77 | } 78 | -------------------------------------------------------------------------------- /vendor/github.com/coreos/ignition/config/v2_2/types/partition.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 CoreOS, Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package types 16 | 17 | import ( 18 | "fmt" 19 | "regexp" 20 | "strings" 21 | 22 | "github.com/coreos/ignition/config/shared/errors" 23 | "github.com/coreos/ignition/config/validate/report" 24 | ) 25 | 26 | const ( 27 | guidRegexStr = "^(|[[:xdigit:]]{8}-[[:xdigit:]]{4}-[[:xdigit:]]{4}-[[:xdigit:]]{4}-[[:xdigit:]]{12})$" 28 | ) 29 | 30 | func (p Partition) ValidateLabel() report.Report { 31 | r := report.Report{} 32 | // http://en.wikipedia.org/wiki/GUID_Partition_Table#Partition_entries: 33 | // 56 (0x38) 72 bytes Partition name (36 UTF-16LE code units) 34 | 35 | // XXX(vc): note GPT calls it a name, we're using label for consistency 36 | // with udev naming /dev/disk/by-partlabel/*. 37 | if len(p.Label) > 36 { 38 | r.Add(report.Entry{ 39 | Message: errors.ErrLabelTooLong.Error(), 40 | Kind: report.EntryError, 41 | }) 42 | } 43 | 44 | // sgdisk uses colons for delimitting compound arguments and does not allow escaping them. 45 | if strings.Contains(p.Label, ":") { 46 | r.Add(report.Entry{ 47 | Message: errors.ErrLabelContainsColon.Error(), 48 | Kind: report.EntryWarning, 49 | }) 50 | } 51 | return r 52 | } 53 | 54 | func (p Partition) ValidateTypeGUID() report.Report { 55 | return validateGUID(p.TypeGUID) 56 | } 57 | 58 | func (p Partition) ValidateGUID() report.Report { 59 | return validateGUID(p.GUID) 60 | } 61 | 62 | func validateGUID(guid string) report.Report { 63 | r := report.Report{} 64 | ok, err := regexp.MatchString(guidRegexStr, guid) 65 | if err != nil { 66 | r.Add(report.Entry{ 67 | Message: fmt.Sprintf("error matching guid regexp: %v", err), 68 | Kind: report.EntryError, 69 | }) 70 | } else if !ok { 71 | r.Add(report.Entry{ 72 | Message: errors.ErrDoesntMatchGUIDRegex.Error(), 73 | Kind: report.EntryError, 74 | }) 75 | } 76 | return r 77 | } 78 | -------------------------------------------------------------------------------- /vendor/github.com/coreos/ignition/config/v2_3_experimental/types/partition.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 CoreOS, Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package types 16 | 17 | import ( 18 | "fmt" 19 | "regexp" 20 | "strings" 21 | 22 | "github.com/coreos/ignition/config/shared/errors" 23 | "github.com/coreos/ignition/config/validate/report" 24 | ) 25 | 26 | const ( 27 | guidRegexStr = "^(|[[:xdigit:]]{8}-[[:xdigit:]]{4}-[[:xdigit:]]{4}-[[:xdigit:]]{4}-[[:xdigit:]]{12})$" 28 | ) 29 | 30 | func (p Partition) ValidateLabel() report.Report { 31 | r := report.Report{} 32 | // http://en.wikipedia.org/wiki/GUID_Partition_Table#Partition_entries: 33 | // 56 (0x38) 72 bytes Partition name (36 UTF-16LE code units) 34 | 35 | // XXX(vc): note GPT calls it a name, we're using label for consistency 36 | // with udev naming /dev/disk/by-partlabel/*. 37 | if len(p.Label) > 36 { 38 | r.Add(report.Entry{ 39 | Message: errors.ErrLabelTooLong.Error(), 40 | Kind: report.EntryError, 41 | }) 42 | } 43 | 44 | // sgdisk uses colons for delimitting compound arguments and does not allow escaping them. 45 | if strings.Contains(p.Label, ":") { 46 | r.Add(report.Entry{ 47 | Message: errors.ErrLabelContainsColon.Error(), 48 | Kind: report.EntryWarning, 49 | }) 50 | } 51 | return r 52 | } 53 | 54 | func (p Partition) ValidateTypeGUID() report.Report { 55 | return validateGUID(p.TypeGUID) 56 | } 57 | 58 | func (p Partition) ValidateGUID() report.Report { 59 | return validateGUID(p.GUID) 60 | } 61 | 62 | func validateGUID(guid string) report.Report { 63 | r := report.Report{} 64 | ok, err := regexp.MatchString(guidRegexStr, guid) 65 | if err != nil { 66 | r.Add(report.Entry{ 67 | Message: fmt.Sprintf("error matching guid regexp: %v", err), 68 | Kind: report.EntryError, 69 | }) 70 | } else if !ok { 71 | r.Add(report.Entry{ 72 | Message: errors.ErrDoesntMatchGUIDRegex.Error(), 73 | Kind: report.EntryError, 74 | }) 75 | } 76 | return r 77 | } 78 | -------------------------------------------------------------------------------- /vendor/github.com/coreos/ignition/config/v1/types/unit.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 CoreOS, Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package types 16 | 17 | import ( 18 | "path" 19 | 20 | "github.com/coreos/ignition/config/shared/errors" 21 | "github.com/coreos/ignition/config/validate/report" 22 | ) 23 | 24 | type SystemdUnit struct { 25 | Name SystemdUnitName `json:"name,omitempty"` 26 | Enable bool `json:"enable,omitempty"` 27 | Mask bool `json:"mask,omitempty"` 28 | Contents string `json:"contents,omitempty"` 29 | DropIns []SystemdUnitDropIn `json:"dropins,omitempty"` 30 | } 31 | 32 | type SystemdUnitDropIn struct { 33 | Name SystemdUnitDropInName `json:"name,omitempty"` 34 | Contents string `json:"contents,omitempty"` 35 | } 36 | 37 | type SystemdUnitName string 38 | 39 | func (n SystemdUnitName) Validate() report.Report { 40 | switch path.Ext(string(n)) { 41 | case ".service", ".socket", ".device", ".mount", ".automount", ".swap", ".target", ".path", ".timer", ".snapshot", ".slice", ".scope": 42 | return report.Report{} 43 | default: 44 | return report.ReportFromError(errors.ErrInvalidSystemdExt, report.EntryError) 45 | } 46 | } 47 | 48 | type SystemdUnitDropInName string 49 | 50 | func (n SystemdUnitDropInName) Validate() report.Report { 51 | switch path.Ext(string(n)) { 52 | case ".conf": 53 | return report.Report{} 54 | default: 55 | return report.ReportFromError(errors.ErrInvalidSystemdDropinExt, report.EntryError) 56 | } 57 | } 58 | 59 | type NetworkdUnit struct { 60 | Name NetworkdUnitName `json:"name,omitempty"` 61 | Contents string `json:"contents,omitempty"` 62 | } 63 | 64 | type NetworkdUnitName string 65 | 66 | func (n NetworkdUnitName) Validate() report.Report { 67 | switch path.Ext(string(n)) { 68 | case ".link", ".netdev", ".network": 69 | return report.Report{} 70 | default: 71 | return report.ReportFromError(errors.ErrInvalidNetworkdExt, report.EntryError) 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /vendor/github.com/coreos/ignition/config/v2_0/config.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 CoreOS, Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package v2_0 16 | 17 | import ( 18 | "github.com/coreos/ignition/config/shared/errors" 19 | "github.com/coreos/ignition/config/v1" 20 | "github.com/coreos/ignition/config/v2_0/types" 21 | "github.com/coreos/ignition/config/validate" 22 | "github.com/coreos/ignition/config/validate/report" 23 | 24 | json "github.com/ajeddeloh/go-json" 25 | "github.com/coreos/go-semver/semver" 26 | ) 27 | 28 | // Parse parses the raw config into a types.Config struct and generates a report of any 29 | // errors, warnings, info, and deprecations it encountered 30 | func Parse(rawConfig []byte) (types.Config, report.Report, error) { 31 | if isEmpty(rawConfig) { 32 | return types.Config{}, report.Report{}, errors.ErrEmpty 33 | } else if isCloudConfig(rawConfig) { 34 | return types.Config{}, report.Report{}, errors.ErrCloudConfig 35 | } else if isScript(rawConfig) { 36 | return types.Config{}, report.Report{}, errors.ErrScript 37 | } 38 | 39 | var err error 40 | var config types.Config 41 | 42 | err = json.Unmarshal(rawConfig, &config) 43 | 44 | if err != nil || semver.Version(config.Ignition.Version).LessThan(types.MaxVersion) { 45 | // We can fail unmarshaling if it's an older config. Attempt to parse 46 | // it as such. 47 | config, rpt, err := v1.Parse(rawConfig) 48 | if err != nil { 49 | return types.Config{}, rpt, err 50 | } 51 | 52 | rpt.Merge(report.ReportFromError(errors.ErrDeprecated, report.EntryDeprecated)) 53 | return TranslateFromV1(config), rpt, err 54 | } 55 | 56 | if semver.Version(config.Ignition.Version) != types.MaxVersion { 57 | return types.Config{}, report.Report{}, errors.ErrUnknownVersion 58 | } 59 | 60 | rpt := validate.ValidateConfig(rawConfig, config) 61 | if rpt.IsFatal() { 62 | return types.Config{}, rpt, errors.ErrInvalid 63 | } 64 | 65 | return config, rpt, nil 66 | } 67 | 68 | func isEmpty(userdata []byte) bool { 69 | return len(userdata) == 0 70 | } 71 | -------------------------------------------------------------------------------- /vendor/github.com/coreos/ignition/config/v2_2/config.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 CoreOS, Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package v2_2 16 | 17 | import ( 18 | "github.com/coreos/ignition/config/shared/errors" 19 | "github.com/coreos/ignition/config/v2_1" 20 | "github.com/coreos/ignition/config/v2_2/types" 21 | "github.com/coreos/ignition/config/validate" 22 | "github.com/coreos/ignition/config/validate/report" 23 | 24 | json "github.com/ajeddeloh/go-json" 25 | "github.com/coreos/go-semver/semver" 26 | ) 27 | 28 | // Parse parses the raw config into a types.Config struct and generates a report of any 29 | // errors, warnings, info, and deprecations it encountered. Unlike config.Parse, 30 | // it does not attempt to translate the config. 31 | func Parse(rawConfig []byte) (types.Config, report.Report, error) { 32 | if isEmpty(rawConfig) { 33 | return types.Config{}, report.Report{}, errors.ErrEmpty 34 | } else if isCloudConfig(rawConfig) { 35 | return types.Config{}, report.Report{}, errors.ErrCloudConfig 36 | } else if isScript(rawConfig) { 37 | return types.Config{}, report.Report{}, errors.ErrScript 38 | } 39 | 40 | var err error 41 | var config types.Config 42 | 43 | err = json.Unmarshal(rawConfig, &config) 44 | 45 | version, semverErr := semver.NewVersion(config.Ignition.Version) 46 | 47 | if err != nil || semverErr != nil || version.LessThan(types.MaxVersion) { 48 | // We can fail unmarshaling if it's an older config. Attempt to parse 49 | // it as such. 50 | config, rpt, err := v2_1.Parse(rawConfig) 51 | if err != nil { 52 | return types.Config{}, rpt, err 53 | } 54 | return TranslateFromV2_1(config), rpt, err 55 | } 56 | 57 | if *version != types.MaxVersion { 58 | return types.Config{}, report.Report{}, errors.ErrUnknownVersion 59 | } 60 | 61 | rpt := validate.ValidateConfig(rawConfig, config) 62 | if rpt.IsFatal() { 63 | return types.Config{}, rpt, errors.ErrInvalid 64 | } 65 | 66 | return config, rpt, nil 67 | } 68 | 69 | func isEmpty(userdata []byte) bool { 70 | return len(userdata) == 0 71 | } 72 | -------------------------------------------------------------------------------- /vendor/github.com/coreos/ignition/config/v2_1/append.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 CoreOS, Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package v2_1 16 | 17 | import ( 18 | "reflect" 19 | 20 | "github.com/coreos/ignition/config/v2_1/types" 21 | ) 22 | 23 | // Append appends newConfig to oldConfig and returns the result. Appending one 24 | // config to another is accomplished by iterating over every field in the 25 | // config structure, appending slices, recursively appending structs, and 26 | // overwriting old values with new values for all other types. 27 | func Append(oldConfig, newConfig types.Config) types.Config { 28 | vOld := reflect.ValueOf(oldConfig) 29 | vNew := reflect.ValueOf(newConfig) 30 | 31 | vResult := appendStruct(vOld, vNew) 32 | 33 | return vResult.Interface().(types.Config) 34 | } 35 | 36 | // appendStruct is an internal helper function to AppendConfig. Given two values 37 | // of structures (assumed to be the same type), recursively iterate over every 38 | // field in the struct, appending slices, recursively appending structs, and 39 | // overwriting old values with the new for all other types. Some individual 40 | // struct fields have alternate merge strategies, determined by the field name. 41 | // Currently these fields are "ignition.version", which uses the old value, and 42 | // "ignition.config" which uses the new value. 43 | func appendStruct(vOld, vNew reflect.Value) reflect.Value { 44 | tOld := vOld.Type() 45 | vRes := reflect.New(tOld) 46 | 47 | for i := 0; i < tOld.NumField(); i++ { 48 | vfOld := vOld.Field(i) 49 | vfNew := vNew.Field(i) 50 | vfRes := vRes.Elem().Field(i) 51 | 52 | switch tOld.Field(i).Name { 53 | case "Version": 54 | vfRes.Set(vfOld) 55 | continue 56 | case "Config": 57 | vfRes.Set(vfNew) 58 | continue 59 | } 60 | 61 | switch vfOld.Type().Kind() { 62 | case reflect.Struct: 63 | vfRes.Set(appendStruct(vfOld, vfNew)) 64 | case reflect.Slice: 65 | vfRes.Set(reflect.AppendSlice(vfOld, vfNew)) 66 | default: 67 | vfRes.Set(vfNew) 68 | } 69 | } 70 | 71 | return vRes.Elem() 72 | } 73 | -------------------------------------------------------------------------------- /vendor/github.com/coreos/coreos-cloudinit/config/validate/report.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 CoreOS, Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package validate 16 | 17 | import ( 18 | "encoding/json" 19 | "fmt" 20 | ) 21 | 22 | // Report represents the list of entries resulting from validation. 23 | type Report struct { 24 | entries []Entry 25 | } 26 | 27 | // Error adds an error entry to the report. 28 | func (r *Report) Error(line int, message string) { 29 | r.entries = append(r.entries, Entry{entryError, message, line}) 30 | } 31 | 32 | // Warning adds a warning entry to the report. 33 | func (r *Report) Warning(line int, message string) { 34 | r.entries = append(r.entries, Entry{entryWarning, message, line}) 35 | } 36 | 37 | // Info adds an info entry to the report. 38 | func (r *Report) Info(line int, message string) { 39 | r.entries = append(r.entries, Entry{entryInfo, message, line}) 40 | } 41 | 42 | // Entries returns the list of entries in the report. 43 | func (r *Report) Entries() []Entry { 44 | return r.entries 45 | } 46 | 47 | // Entry represents a single generic item in the report. 48 | type Entry struct { 49 | kind entryKind 50 | message string 51 | line int 52 | } 53 | 54 | // String returns a human-readable representation of the entry. 55 | func (e Entry) String() string { 56 | return fmt.Sprintf("line %d: %s: %s", e.line, e.kind, e.message) 57 | } 58 | 59 | // MarshalJSON satisfies the json.Marshaler interface, returning the entry 60 | // encoded as a JSON object. 61 | func (e Entry) MarshalJSON() ([]byte, error) { 62 | return json.Marshal(map[string]interface{}{ 63 | "kind": e.kind.String(), 64 | "message": e.message, 65 | "line": e.line, 66 | }) 67 | } 68 | 69 | type entryKind int 70 | 71 | const ( 72 | entryError entryKind = iota 73 | entryWarning 74 | entryInfo 75 | ) 76 | 77 | func (k entryKind) String() string { 78 | switch k { 79 | case entryError: 80 | return "error" 81 | case entryWarning: 82 | return "warning" 83 | case entryInfo: 84 | return "info" 85 | default: 86 | panic(fmt.Sprintf("invalid kind %d", k)) 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /vendor/github.com/coreos/ignition/config/v2_0/append.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 CoreOS, Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package v2_0 16 | 17 | import ( 18 | "reflect" 19 | 20 | "github.com/coreos/ignition/config/v2_0/types" 21 | ) 22 | 23 | // Append appends newConfig to oldConfig and returns the result. Appending one 24 | // config to another is accomplished by iterating over every field in the 25 | // config structure, appending slices, recursively appending structs, and 26 | // overwriting old values with new values for all other types. 27 | func Append(oldConfig, newConfig types.Config) types.Config { 28 | vOld := reflect.ValueOf(oldConfig) 29 | vNew := reflect.ValueOf(newConfig) 30 | 31 | vResult := appendStruct(vOld, vNew) 32 | 33 | return vResult.Interface().(types.Config) 34 | } 35 | 36 | // appendStruct is an internal helper function to AppendConfig. Given two values 37 | // of structures (assumed to be the same type), recursively iterate over every 38 | // field in the struct, appending slices, recursively appending structs, and 39 | // overwriting old values with the new for all other types. Individual fields 40 | // are able to override their merge strategy using the "merge" tag. Accepted 41 | // values are "new" or "old": "new" uses the new value, "old" uses the old 42 | // value. These are currently only used for "ignition.config" and 43 | // "ignition.version". 44 | func appendStruct(vOld, vNew reflect.Value) reflect.Value { 45 | tOld := vOld.Type() 46 | vRes := reflect.New(tOld) 47 | 48 | for i := 0; i < tOld.NumField(); i++ { 49 | vfOld := vOld.Field(i) 50 | vfNew := vNew.Field(i) 51 | vfRes := vRes.Elem().Field(i) 52 | 53 | switch tOld.Field(i).Tag.Get("merge") { 54 | case "old": 55 | vfRes.Set(vfOld) 56 | continue 57 | case "new": 58 | vfRes.Set(vfNew) 59 | continue 60 | } 61 | 62 | switch vfOld.Type().Kind() { 63 | case reflect.Struct: 64 | vfRes.Set(appendStruct(vfOld, vfNew)) 65 | case reflect.Slice: 66 | vfRes.Set(reflect.AppendSlice(vfOld, vfNew)) 67 | default: 68 | vfRes.Set(vfNew) 69 | } 70 | } 71 | 72 | return vRes.Elem() 73 | } 74 | -------------------------------------------------------------------------------- /vendor/github.com/coreos/ignition/config/util/parsingErrors.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 CoreOS, Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package util 16 | 17 | import ( 18 | "bytes" 19 | "errors" 20 | 21 | configErrors "github.com/coreos/ignition/config/shared/errors" 22 | "github.com/coreos/ignition/config/v2_3_experimental/types" 23 | "github.com/coreos/ignition/config/validate/report" 24 | 25 | json "github.com/ajeddeloh/go-json" 26 | "go4.org/errorutil" 27 | ) 28 | 29 | var ( 30 | ErrValidConfig = errors.New("HandleParseErrors called with a valid config") 31 | ) 32 | 33 | // HandleParseErrors will attempt to unmarshal an invalid rawConfig into the 34 | // latest config struct, so as to generate a report.Report from the errors. It 35 | // will always return an error. This is called after config/v* parse functions 36 | // chain has failed to parse a config. 37 | func HandleParseErrors(rawConfig []byte) (report.Report, error) { 38 | config := types.Config{} 39 | err := json.Unmarshal(rawConfig, &config) 40 | if err == nil { 41 | return report.Report{}, ErrValidConfig 42 | } 43 | 44 | // Handle json syntax and type errors first, since they are fatal but have offset info 45 | if serr, ok := err.(*json.SyntaxError); ok { 46 | line, col, highlight := errorutil.HighlightBytePosition(bytes.NewReader(rawConfig), serr.Offset) 47 | return report.Report{ 48 | Entries: []report.Entry{{ 49 | Kind: report.EntryError, 50 | Message: serr.Error(), 51 | Line: line, 52 | Column: col, 53 | Highlight: highlight, 54 | }}, 55 | }, 56 | configErrors.ErrInvalid 57 | } 58 | 59 | if terr, ok := err.(*json.UnmarshalTypeError); ok { 60 | line, col, highlight := errorutil.HighlightBytePosition(bytes.NewReader(rawConfig), terr.Offset) 61 | return report.Report{ 62 | Entries: []report.Entry{{ 63 | Kind: report.EntryError, 64 | Message: terr.Error(), 65 | Line: line, 66 | Column: col, 67 | Highlight: highlight, 68 | }}, 69 | }, 70 | configErrors.ErrInvalid 71 | } 72 | 73 | return report.ReportFromError(err, report.EntryError), err 74 | } 75 | -------------------------------------------------------------------------------- /vendor/github.com/coreos/ignition/config/v2_2/append.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 CoreOS, Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package v2_2 16 | 17 | import ( 18 | "reflect" 19 | 20 | "github.com/coreos/ignition/config/v2_2/types" 21 | ) 22 | 23 | // Append appends newConfig to oldConfig and returns the result. Appending one 24 | // config to another is accomplished by iterating over every field in the 25 | // config structure, appending slices, recursively appending structs, and 26 | // overwriting old values with new values for all other types. 27 | func Append(oldConfig, newConfig types.Config) types.Config { 28 | vOld := reflect.ValueOf(oldConfig) 29 | vNew := reflect.ValueOf(newConfig) 30 | 31 | vResult := appendStruct(vOld, vNew) 32 | 33 | return vResult.Interface().(types.Config) 34 | } 35 | 36 | // appendStruct is an internal helper function to AppendConfig. Given two values 37 | // of structures (assumed to be the same type), recursively iterate over every 38 | // field in the struct, appending slices, recursively appending structs, and 39 | // overwriting old values with the new for all other types. Some individual 40 | // struct fields have alternate merge strategies, determined by the field name. 41 | // Currently these fields are "ignition.version", which uses the old value, and 42 | // "ignition.config" which uses the new value. 43 | func appendStruct(vOld, vNew reflect.Value) reflect.Value { 44 | tOld := vOld.Type() 45 | vRes := reflect.New(tOld) 46 | 47 | for i := 0; i < tOld.NumField(); i++ { 48 | vfOld := vOld.Field(i) 49 | vfNew := vNew.Field(i) 50 | vfRes := vRes.Elem().Field(i) 51 | 52 | switch tOld.Field(i).Name { 53 | case "Version": 54 | vfRes.Set(vfOld) 55 | continue 56 | case "Config": 57 | vfRes.Set(vfNew) 58 | continue 59 | } 60 | 61 | switch vfOld.Type().Kind() { 62 | case reflect.Struct: 63 | vfRes.Set(appendStruct(vfOld, vfNew)) 64 | case reflect.Slice: 65 | vfRes.Set(reflect.AppendSlice(vfOld, vfNew)) 66 | default: 67 | if vfNew.Kind() == reflect.Ptr && vfNew.IsNil() { 68 | vfRes.Set(vfOld) 69 | } else { 70 | vfRes.Set(vfNew) 71 | } 72 | } 73 | } 74 | 75 | return vRes.Elem() 76 | } 77 | -------------------------------------------------------------------------------- /vendor/github.com/coreos/ignition/config/v2_0/types/config.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 CoreOS, Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package types 16 | 17 | import ( 18 | "fmt" 19 | 20 | "github.com/coreos/go-semver/semver" 21 | 22 | "github.com/coreos/ignition/config/validate/report" 23 | ) 24 | 25 | var ( 26 | MaxVersion = semver.Version{ 27 | Major: 2, 28 | Minor: 0, 29 | } 30 | ) 31 | 32 | type Config struct { 33 | Ignition Ignition `json:"ignition"` 34 | Storage Storage `json:"storage,omitempty"` 35 | Systemd Systemd `json:"systemd,omitempty"` 36 | Networkd Networkd `json:"networkd,omitempty"` 37 | Passwd Passwd `json:"passwd,omitempty"` 38 | } 39 | 40 | func (c Config) Validate() report.Report { 41 | r := report.Report{} 42 | rules := []rule{ 43 | checkFilesFilesystems, 44 | checkDuplicateFilesystems, 45 | } 46 | 47 | for _, rule := range rules { 48 | rule(c, &r) 49 | } 50 | return r 51 | } 52 | 53 | type rule func(cfg Config, report *report.Report) 54 | 55 | func checkFilesFilesystems(cfg Config, r *report.Report) { 56 | filesystems := map[string]struct{}{"root": {}} 57 | for _, filesystem := range cfg.Storage.Filesystems { 58 | filesystems[filesystem.Name] = struct{}{} 59 | } 60 | for _, file := range cfg.Storage.Files { 61 | if file.Filesystem == "" { 62 | // Filesystem was not specified. This is an error, but its handled in types.File's Validate, not here 63 | continue 64 | } 65 | _, ok := filesystems[file.Filesystem] 66 | if !ok { 67 | r.Add(report.Entry{ 68 | Kind: report.EntryWarning, 69 | Message: fmt.Sprintf("File %q references nonexistent filesystem %q. (This is ok if it is defined in a referenced config)", 70 | file.Path, file.Filesystem), 71 | }) 72 | } 73 | } 74 | } 75 | 76 | func checkDuplicateFilesystems(cfg Config, r *report.Report) { 77 | filesystems := map[string]struct{}{"root": {}} 78 | for _, filesystem := range cfg.Storage.Filesystems { 79 | if _, ok := filesystems[filesystem.Name]; ok { 80 | r.Add(report.Entry{ 81 | Kind: report.EntryWarning, 82 | Message: fmt.Sprintf("Filesystem %q shadows exising filesystem definition", filesystem.Name), 83 | }) 84 | } 85 | filesystems[filesystem.Name] = struct{}{} 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /vendor/github.com/coreos/yaml/writerc.go: -------------------------------------------------------------------------------- 1 | package yaml 2 | 3 | // Set the writer error and return false. 4 | func yaml_emitter_set_writer_error(emitter *yaml_emitter_t, problem string) bool { 5 | emitter.error = yaml_WRITER_ERROR 6 | emitter.problem = problem 7 | return false 8 | } 9 | 10 | // Flush the output buffer. 11 | func yaml_emitter_flush(emitter *yaml_emitter_t) bool { 12 | if emitter.write_handler == nil { 13 | panic("write handler not set") 14 | } 15 | 16 | // Check if the buffer is empty. 17 | if emitter.buffer_pos == 0 { 18 | return true 19 | } 20 | 21 | // If the output encoding is UTF-8, we don't need to recode the buffer. 22 | if emitter.encoding == yaml_UTF8_ENCODING { 23 | if err := emitter.write_handler(emitter, emitter.buffer[:emitter.buffer_pos]); err != nil { 24 | return yaml_emitter_set_writer_error(emitter, "write error: "+err.Error()) 25 | } 26 | emitter.buffer_pos = 0 27 | return true 28 | } 29 | 30 | // Recode the buffer into the raw buffer. 31 | var low, high int 32 | if emitter.encoding == yaml_UTF16LE_ENCODING { 33 | low, high = 0, 1 34 | } else { 35 | high, low = 1, 0 36 | } 37 | 38 | pos := 0 39 | for pos < emitter.buffer_pos { 40 | // See the "reader.c" code for more details on UTF-8 encoding. Note 41 | // that we assume that the buffer contains a valid UTF-8 sequence. 42 | 43 | // Read the next UTF-8 character. 44 | octet := emitter.buffer[pos] 45 | 46 | var w int 47 | var value rune 48 | switch { 49 | case octet&0x80 == 0x00: 50 | w, value = 1, rune(octet&0x7F) 51 | case octet&0xE0 == 0xC0: 52 | w, value = 2, rune(octet&0x1F) 53 | case octet&0xF0 == 0xE0: 54 | w, value = 3, rune(octet&0x0F) 55 | case octet&0xF8 == 0xF0: 56 | w, value = 4, rune(octet&0x07) 57 | } 58 | for k := 1; k < w; k++ { 59 | octet = emitter.buffer[pos+k] 60 | value = (value << 6) + (rune(octet) & 0x3F) 61 | } 62 | pos += w 63 | 64 | // Write the character. 65 | if value < 0x10000 { 66 | var b [2]byte 67 | b[high] = byte(value >> 8) 68 | b[low] = byte(value & 0xFF) 69 | emitter.raw_buffer = append(emitter.raw_buffer, b[0], b[1]) 70 | } else { 71 | // Write the character using a surrogate pair (check "reader.c"). 72 | var b [4]byte 73 | value -= 0x10000 74 | b[high] = byte(0xD8 + (value >> 18)) 75 | b[low] = byte((value >> 10) & 0xFF) 76 | b[high+2] = byte(0xDC + ((value >> 8) & 0xFF)) 77 | b[low+2] = byte(value & 0xFF) 78 | emitter.raw_buffer = append(emitter.raw_buffer, b[0], b[1], b[2], b[3]) 79 | } 80 | } 81 | 82 | // Write the raw buffer. 83 | if err := emitter.write_handler(emitter, emitter.raw_buffer); err != nil { 84 | return yaml_emitter_set_writer_error(emitter, "write error: "+err.Error()) 85 | } 86 | emitter.buffer_pos = 0 87 | emitter.raw_buffer = emitter.raw_buffer[:0] 88 | return true 89 | } 90 | -------------------------------------------------------------------------------- /vendor/github.com/coreos/ignition/config/v2_1/types/config.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 CoreOS, Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package types 16 | 17 | import ( 18 | "fmt" 19 | 20 | "github.com/coreos/go-semver/semver" 21 | 22 | "github.com/coreos/ignition/config/validate/report" 23 | ) 24 | 25 | var ( 26 | MaxVersion = semver.Version{ 27 | Major: 2, 28 | Minor: 1, 29 | } 30 | ) 31 | 32 | func (c Config) Validate() report.Report { 33 | r := report.Report{} 34 | rules := []rule{ 35 | checkFilesFilesystems, 36 | checkDuplicateFilesystems, 37 | } 38 | 39 | for _, rule := range rules { 40 | rule(c, &r) 41 | } 42 | return r 43 | } 44 | 45 | type rule func(cfg Config, report *report.Report) 46 | 47 | func checkNodeFilesystems(node Node, filesystems map[string]struct{}, nodeType string) report.Report { 48 | r := report.Report{} 49 | if node.Filesystem == "" { 50 | // Filesystem was not specified. This is an error, but its handled in types.File's Validate, not here 51 | return r 52 | } 53 | _, ok := filesystems[node.Filesystem] 54 | if !ok { 55 | r.Add(report.Entry{ 56 | Kind: report.EntryWarning, 57 | Message: fmt.Sprintf("%v %q references nonexistent filesystem %q. (This is ok if it is defined in a referenced config)", 58 | nodeType, node.Path, node.Filesystem), 59 | }) 60 | } 61 | return r 62 | } 63 | 64 | func checkFilesFilesystems(cfg Config, r *report.Report) { 65 | filesystems := map[string]struct{}{"root": {}} 66 | for _, filesystem := range cfg.Storage.Filesystems { 67 | filesystems[filesystem.Name] = struct{}{} 68 | } 69 | for _, file := range cfg.Storage.Files { 70 | r.Merge(checkNodeFilesystems(file.Node, filesystems, "File")) 71 | } 72 | for _, link := range cfg.Storage.Links { 73 | r.Merge(checkNodeFilesystems(link.Node, filesystems, "Link")) 74 | } 75 | for _, dir := range cfg.Storage.Directories { 76 | r.Merge(checkNodeFilesystems(dir.Node, filesystems, "Directory")) 77 | } 78 | } 79 | 80 | func checkDuplicateFilesystems(cfg Config, r *report.Report) { 81 | filesystems := map[string]struct{}{"root": {}} 82 | for _, filesystem := range cfg.Storage.Filesystems { 83 | if _, ok := filesystems[filesystem.Name]; ok { 84 | r.Add(report.Entry{ 85 | Kind: report.EntryWarning, 86 | Message: fmt.Sprintf("Filesystem %q shadows exising filesystem definition", filesystem.Name), 87 | }) 88 | } 89 | filesystems[filesystem.Name] = struct{}{} 90 | } 91 | } 92 | -------------------------------------------------------------------------------- /vendor/github.com/coreos/ignition/config/v2_2/types/config.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 CoreOS, Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package types 16 | 17 | import ( 18 | "fmt" 19 | 20 | "github.com/coreos/go-semver/semver" 21 | 22 | "github.com/coreos/ignition/config/validate/report" 23 | ) 24 | 25 | var ( 26 | MaxVersion = semver.Version{ 27 | Major: 2, 28 | Minor: 2, 29 | } 30 | ) 31 | 32 | func (c Config) Validate() report.Report { 33 | r := report.Report{} 34 | rules := []rule{ 35 | checkFilesFilesystems, 36 | checkDuplicateFilesystems, 37 | } 38 | 39 | for _, rule := range rules { 40 | rule(c, &r) 41 | } 42 | return r 43 | } 44 | 45 | type rule func(cfg Config, report *report.Report) 46 | 47 | func checkNodeFilesystems(node Node, filesystems map[string]struct{}, nodeType string) report.Report { 48 | r := report.Report{} 49 | if node.Filesystem == "" { 50 | // Filesystem was not specified. This is an error, but its handled in types.File's Validate, not here 51 | return r 52 | } 53 | _, ok := filesystems[node.Filesystem] 54 | if !ok { 55 | r.Add(report.Entry{ 56 | Kind: report.EntryWarning, 57 | Message: fmt.Sprintf("%v %q references nonexistent filesystem %q. (This is ok if it is defined in a referenced config)", 58 | nodeType, node.Path, node.Filesystem), 59 | }) 60 | } 61 | return r 62 | } 63 | 64 | func checkFilesFilesystems(cfg Config, r *report.Report) { 65 | filesystems := map[string]struct{}{"root": {}} 66 | for _, filesystem := range cfg.Storage.Filesystems { 67 | filesystems[filesystem.Name] = struct{}{} 68 | } 69 | for _, file := range cfg.Storage.Files { 70 | r.Merge(checkNodeFilesystems(file.Node, filesystems, "File")) 71 | } 72 | for _, link := range cfg.Storage.Links { 73 | r.Merge(checkNodeFilesystems(link.Node, filesystems, "Link")) 74 | } 75 | for _, dir := range cfg.Storage.Directories { 76 | r.Merge(checkNodeFilesystems(dir.Node, filesystems, "Directory")) 77 | } 78 | } 79 | 80 | func checkDuplicateFilesystems(cfg Config, r *report.Report) { 81 | filesystems := map[string]struct{}{"root": {}} 82 | for _, filesystem := range cfg.Storage.Filesystems { 83 | if _, ok := filesystems[filesystem.Name]; ok { 84 | r.Add(report.Entry{ 85 | Kind: report.EntryWarning, 86 | Message: fmt.Sprintf("Filesystem %q shadows exising filesystem definition", filesystem.Name), 87 | }) 88 | } 89 | filesystems[filesystem.Name] = struct{}{} 90 | } 91 | } 92 | -------------------------------------------------------------------------------- /vendor/github.com/coreos/yaml/sorter.go: -------------------------------------------------------------------------------- 1 | package yaml 2 | 3 | import ( 4 | "reflect" 5 | "unicode" 6 | ) 7 | 8 | type keyList []reflect.Value 9 | 10 | func (l keyList) Len() int { return len(l) } 11 | func (l keyList) Swap(i, j int) { l[i], l[j] = l[j], l[i] } 12 | func (l keyList) Less(i, j int) bool { 13 | a := l[i] 14 | b := l[j] 15 | ak := a.Kind() 16 | bk := b.Kind() 17 | for (ak == reflect.Interface || ak == reflect.Ptr) && !a.IsNil() { 18 | a = a.Elem() 19 | ak = a.Kind() 20 | } 21 | for (bk == reflect.Interface || bk == reflect.Ptr) && !b.IsNil() { 22 | b = b.Elem() 23 | bk = b.Kind() 24 | } 25 | af, aok := keyFloat(a) 26 | bf, bok := keyFloat(b) 27 | if aok && bok { 28 | if af != bf { 29 | return af < bf 30 | } 31 | if ak != bk { 32 | return ak < bk 33 | } 34 | return numLess(a, b) 35 | } 36 | if ak != reflect.String || bk != reflect.String { 37 | return ak < bk 38 | } 39 | ar, br := []rune(a.String()), []rune(b.String()) 40 | for i := 0; i < len(ar) && i < len(br); i++ { 41 | if ar[i] == br[i] { 42 | continue 43 | } 44 | al := unicode.IsLetter(ar[i]) 45 | bl := unicode.IsLetter(br[i]) 46 | if al && bl { 47 | return ar[i] < br[i] 48 | } 49 | if al || bl { 50 | return bl 51 | } 52 | var ai, bi int 53 | var an, bn int64 54 | for ai = i; ai < len(ar) && unicode.IsDigit(ar[ai]); ai++ { 55 | an = an*10 + int64(ar[ai]-'0') 56 | } 57 | for bi = i; bi < len(br) && unicode.IsDigit(br[bi]); bi++ { 58 | bn = bn*10 + int64(br[bi]-'0') 59 | } 60 | if an != bn { 61 | return an < bn 62 | } 63 | if ai != bi { 64 | return ai < bi 65 | } 66 | return ar[i] < br[i] 67 | } 68 | return len(ar) < len(br) 69 | } 70 | 71 | // keyFloat returns a float value for v if it is a number/bool 72 | // and whether it is a number/bool or not. 73 | func keyFloat(v reflect.Value) (f float64, ok bool) { 74 | switch v.Kind() { 75 | case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: 76 | return float64(v.Int()), true 77 | case reflect.Float32, reflect.Float64: 78 | return v.Float(), true 79 | case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr: 80 | return float64(v.Uint()), true 81 | case reflect.Bool: 82 | if v.Bool() { 83 | return 1, true 84 | } 85 | return 0, true 86 | } 87 | return 0, false 88 | } 89 | 90 | // numLess returns whether a < b. 91 | // a and b must necessarily have the same kind. 92 | func numLess(a, b reflect.Value) bool { 93 | switch a.Kind() { 94 | case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: 95 | return a.Int() < b.Int() 96 | case reflect.Float32, reflect.Float64: 97 | return a.Float() < b.Float() 98 | case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr: 99 | return a.Uint() < b.Uint() 100 | case reflect.Bool: 101 | return !a.Bool() && b.Bool() 102 | } 103 | panic("not a number") 104 | } 105 | -------------------------------------------------------------------------------- /vendor/github.com/coreos/ignition/config/v2_3_experimental/types/config.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 CoreOS, Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package types 16 | 17 | import ( 18 | "fmt" 19 | 20 | "github.com/coreos/go-semver/semver" 21 | 22 | "github.com/coreos/ignition/config/validate/report" 23 | ) 24 | 25 | var ( 26 | MaxVersion = semver.Version{ 27 | Major: 2, 28 | Minor: 3, 29 | PreRelease: "experimental", 30 | } 31 | ) 32 | 33 | func (c Config) Validate() report.Report { 34 | r := report.Report{} 35 | rules := []rule{ 36 | checkFilesFilesystems, 37 | checkDuplicateFilesystems, 38 | } 39 | 40 | for _, rule := range rules { 41 | rule(c, &r) 42 | } 43 | return r 44 | } 45 | 46 | type rule func(cfg Config, report *report.Report) 47 | 48 | func checkNodeFilesystems(node Node, filesystems map[string]struct{}, nodeType string) report.Report { 49 | r := report.Report{} 50 | if node.Filesystem == "" { 51 | // Filesystem was not specified. This is an error, but its handled in types.File's Validate, not here 52 | return r 53 | } 54 | _, ok := filesystems[node.Filesystem] 55 | if !ok { 56 | r.Add(report.Entry{ 57 | Kind: report.EntryWarning, 58 | Message: fmt.Sprintf("%v %q references nonexistent filesystem %q. (This is ok if it is defined in a referenced config)", 59 | nodeType, node.Path, node.Filesystem), 60 | }) 61 | } 62 | return r 63 | } 64 | 65 | func checkFilesFilesystems(cfg Config, r *report.Report) { 66 | filesystems := map[string]struct{}{"root": {}} 67 | for _, filesystem := range cfg.Storage.Filesystems { 68 | filesystems[filesystem.Name] = struct{}{} 69 | } 70 | for _, file := range cfg.Storage.Files { 71 | r.Merge(checkNodeFilesystems(file.Node, filesystems, "File")) 72 | } 73 | for _, link := range cfg.Storage.Links { 74 | r.Merge(checkNodeFilesystems(link.Node, filesystems, "Link")) 75 | } 76 | for _, dir := range cfg.Storage.Directories { 77 | r.Merge(checkNodeFilesystems(dir.Node, filesystems, "Directory")) 78 | } 79 | } 80 | 81 | func checkDuplicateFilesystems(cfg Config, r *report.Report) { 82 | filesystems := map[string]struct{}{"root": {}} 83 | for _, filesystem := range cfg.Storage.Filesystems { 84 | if _, ok := filesystems[filesystem.Name]; ok { 85 | r.Add(report.Entry{ 86 | Kind: report.EntryWarning, 87 | Message: fmt.Sprintf("Filesystem %q shadows exising filesystem definition", filesystem.Name), 88 | }) 89 | } 90 | filesystems[filesystem.Name] = struct{}{} 91 | } 92 | } 93 | -------------------------------------------------------------------------------- /vendor/github.com/gorilla/context/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2012 The Gorilla Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | /* 6 | Package context stores values shared during a request lifetime. 7 | 8 | Note: gorilla/context, having been born well before `context.Context` existed, 9 | does not play well > with the shallow copying of the request that 10 | [`http.Request.WithContext`](https://golang.org/pkg/net/http/#Request.WithContext) 11 | (added to net/http Go 1.7 onwards) performs. You should either use *just* 12 | gorilla/context, or moving forward, the new `http.Request.Context()`. 13 | 14 | For example, a router can set variables extracted from the URL and later 15 | application handlers can access those values, or it can be used to store 16 | sessions values to be saved at the end of a request. There are several 17 | others common uses. 18 | 19 | The idea was posted by Brad Fitzpatrick to the go-nuts mailing list: 20 | 21 | http://groups.google.com/group/golang-nuts/msg/e2d679d303aa5d53 22 | 23 | Here's the basic usage: first define the keys that you will need. The key 24 | type is interface{} so a key can be of any type that supports equality. 25 | Here we define a key using a custom int type to avoid name collisions: 26 | 27 | package foo 28 | 29 | import ( 30 | "github.com/gorilla/context" 31 | ) 32 | 33 | type key int 34 | 35 | const MyKey key = 0 36 | 37 | Then set a variable. Variables are bound to an http.Request object, so you 38 | need a request instance to set a value: 39 | 40 | context.Set(r, MyKey, "bar") 41 | 42 | The application can later access the variable using the same key you provided: 43 | 44 | func MyHandler(w http.ResponseWriter, r *http.Request) { 45 | // val is "bar". 46 | val := context.Get(r, foo.MyKey) 47 | 48 | // returns ("bar", true) 49 | val, ok := context.GetOk(r, foo.MyKey) 50 | // ... 51 | } 52 | 53 | And that's all about the basic usage. We discuss some other ideas below. 54 | 55 | Any type can be stored in the context. To enforce a given type, make the key 56 | private and wrap Get() and Set() to accept and return values of a specific 57 | type: 58 | 59 | type key int 60 | 61 | const mykey key = 0 62 | 63 | // GetMyKey returns a value for this package from the request values. 64 | func GetMyKey(r *http.Request) SomeType { 65 | if rv := context.Get(r, mykey); rv != nil { 66 | return rv.(SomeType) 67 | } 68 | return nil 69 | } 70 | 71 | // SetMyKey sets a value for this package in the request values. 72 | func SetMyKey(r *http.Request, val SomeType) { 73 | context.Set(r, mykey, val) 74 | } 75 | 76 | Variables must be cleared at the end of a request, to remove all values 77 | that were stored. This can be done in an http.Handler, after a request was 78 | served. Just call Clear() passing the request: 79 | 80 | context.Clear(r) 81 | 82 | ...or use ClearHandler(), which conveniently wraps an http.Handler to clear 83 | variables at the end of a request lifetime. 84 | 85 | The Routers from the packages gorilla/mux and gorilla/pat call Clear() 86 | so if you are using either of them you don't need to clear the context manually. 87 | */ 88 | package context 89 | -------------------------------------------------------------------------------- /vendor/github.com/coreos/ignition/config/v2_1/types/unit.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 CoreOS, Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package types 16 | 17 | import ( 18 | "fmt" 19 | "path" 20 | "strings" 21 | 22 | "github.com/coreos/go-systemd/unit" 23 | 24 | "github.com/coreos/ignition/config/shared/errors" 25 | "github.com/coreos/ignition/config/shared/validations" 26 | "github.com/coreos/ignition/config/validate/report" 27 | ) 28 | 29 | func (u Unit) ValidateContents() report.Report { 30 | r := report.Report{} 31 | opts, err := validateUnitContent(u.Contents) 32 | if err != nil { 33 | r.Add(report.Entry{ 34 | Message: err.Error(), 35 | Kind: report.EntryError, 36 | }) 37 | } 38 | 39 | isEnabled := u.Enable || (u.Enabled != nil && *u.Enabled) 40 | r.Merge(validations.ValidateInstallSection(u.Name, isEnabled, u.Contents == "", opts)) 41 | 42 | return r 43 | } 44 | 45 | func (u Unit) ValidateName() report.Report { 46 | r := report.Report{} 47 | switch path.Ext(u.Name) { 48 | case ".service", ".socket", ".device", ".mount", ".automount", ".swap", ".target", ".path", ".timer", ".snapshot", ".slice", ".scope": 49 | default: 50 | r.Add(report.Entry{ 51 | Message: errors.ErrInvalidSystemdExt.Error(), 52 | Kind: report.EntryError, 53 | }) 54 | } 55 | return r 56 | } 57 | 58 | func (d Dropin) Validate() report.Report { 59 | r := report.Report{} 60 | 61 | if _, err := validateUnitContent(d.Contents); err != nil { 62 | r.Add(report.Entry{ 63 | Message: err.Error(), 64 | Kind: report.EntryError, 65 | }) 66 | } 67 | 68 | switch path.Ext(d.Name) { 69 | case ".conf": 70 | default: 71 | r.Add(report.Entry{ 72 | Message: errors.ErrInvalidSystemdDropinExt.Error(), 73 | Kind: report.EntryError, 74 | }) 75 | } 76 | 77 | return r 78 | } 79 | 80 | func (u Networkdunit) Validate() report.Report { 81 | r := report.Report{} 82 | 83 | if _, err := validateUnitContent(u.Contents); err != nil { 84 | r.Add(report.Entry{ 85 | Message: err.Error(), 86 | Kind: report.EntryError, 87 | }) 88 | } 89 | 90 | switch path.Ext(u.Name) { 91 | case ".link", ".netdev", ".network": 92 | default: 93 | r.Add(report.Entry{ 94 | Message: errors.ErrInvalidNetworkdExt.Error(), 95 | Kind: report.EntryError, 96 | }) 97 | } 98 | 99 | return r 100 | } 101 | 102 | func validateUnitContent(content string) ([]*unit.UnitOption, error) { 103 | c := strings.NewReader(content) 104 | opts, err := unit.Deserialize(c) 105 | if err != nil { 106 | return nil, fmt.Errorf("invalid unit content: %s", err) 107 | } 108 | return opts, nil 109 | } 110 | -------------------------------------------------------------------------------- /code-of-conduct.md: -------------------------------------------------------------------------------- 1 | ## CoreOS Community Code of Conduct 2 | 3 | ### Contributor Code of Conduct 4 | 5 | As contributors and maintainers of this project, and in the interest of 6 | fostering an open and welcoming community, we pledge to respect all people who 7 | contribute through reporting issues, posting feature requests, updating 8 | documentation, submitting pull requests or patches, and other activities. 9 | 10 | We are committed to making participation in this project a harassment-free 11 | experience for everyone, regardless of level of experience, gender, gender 12 | identity and expression, sexual orientation, disability, personal appearance, 13 | body size, race, ethnicity, age, religion, or nationality. 14 | 15 | Examples of unacceptable behavior by participants include: 16 | 17 | * The use of sexualized language or imagery 18 | * Personal attacks 19 | * Trolling or insulting/derogatory comments 20 | * Public or private harassment 21 | * Publishing others' private information, such as physical or electronic addresses, without explicit permission 22 | * Other unethical or unprofessional conduct. 23 | 24 | Project maintainers have the right and responsibility to remove, edit, or 25 | reject comments, commits, code, wiki edits, issues, and other contributions 26 | that are not aligned to this Code of Conduct. By adopting this Code of Conduct, 27 | project maintainers commit themselves to fairly and consistently applying these 28 | principles to every aspect of managing this project. Project maintainers who do 29 | not follow or enforce the Code of Conduct may be permanently removed from the 30 | project team. 31 | 32 | This code of conduct applies both within project spaces and in public spaces 33 | when an individual is representing the project or its community. 34 | 35 | Instances of abusive, harassing, or otherwise unacceptable behavior may be 36 | reported by contacting a project maintainer, Brandon Philips 37 | , and/or Rithu John . 38 | 39 | This Code of Conduct is adapted from the Contributor Covenant 40 | (http://contributor-covenant.org), version 1.2.0, available at 41 | http://contributor-covenant.org/version/1/2/0/ 42 | 43 | ### CoreOS Events Code of Conduct 44 | 45 | CoreOS events are working conferences intended for professional networking and 46 | collaboration in the CoreOS community. Attendees are expected to behave 47 | according to professional standards and in accordance with their employer’s 48 | policies on appropriate workplace behavior. 49 | 50 | While at CoreOS events or related social networking opportunities, attendees 51 | should not engage in discriminatory or offensive speech or actions including 52 | but not limited to gender, sexuality, race, age, disability, or religion. 53 | Speakers should be especially aware of these concerns. 54 | 55 | CoreOS does not condone any statements by speakers contrary to these standards. 56 | CoreOS reserves the right to deny entrance and/or eject from an event (without 57 | refund) any individual found to be engaging in discriminatory or offensive 58 | speech or actions. 59 | 60 | Please bring any concerns to the immediate attention of designated on-site 61 | staff, Brandon Philips , and/or Rithu John . 62 | --------------------------------------------------------------------------------