diff --git a/Gopkg.lock b/Gopkg.lock index 0c8dbdd56e6..16a9a8f022d 100644 --- a/Gopkg.lock +++ b/Gopkg.lock @@ -106,29 +106,24 @@ version = "v18" [[projects]] - digest = "1:fb5b2aed0d774e210c1f2c0893e620cb3fa98957d3b925d0378f93b9613eb605" + branch = "master" + digest = "1:7cec07ad484a499c64047be4fe96b2a34c4f37c3370c7d81868c20533f417cbd" name = "github.com/coreos/ignition" packages = [ + "config/merge", "config/shared/errors", "config/shared/validations", "config/util", - "config/v1", - "config/v1/types", - "config/v2_0", - "config/v2_0/types", - "config/v2_1", - "config/v2_1/types", - "config/v2_2", - "config/v2_2/types", - "config/v2_3_experimental/types", + "config/v3_0", + "config/v3_0/types", "config/validate", "config/validate/astjson", "config/validate/astnode", "config/validate/report", + "config/validate/util", ] pruneopts = "NUT" - revision = "76107251acd117c6d3e5b4dae2b47f82f944984b" - version = "v0.26.0" + revision = "924e3fbee015ccd898b0c6ae8120a02cee982784" [[projects]] digest = "1:ffe9824d294da03b391f44e1ae8281281b4afc1bdaa9588c9097785e3af10cec" @@ -452,15 +447,15 @@ revision = "4b9f6ceb6598ebd4dd6c9385ef024abf7a18159b" [[projects]] - digest = "1:5bfff65eba275066cdf304a0faf91c7709e0f612ebb9760046adf6035d63ef5c" + branch = "ign-update" + digest = "1:905882ea18ab06dc7996630ac1feb9c7e7ab8694889291822ec1f97bf515203a" name = "github.com/openshift/machine-config-operator" packages = [ "pkg/apis", "pkg/apis/machineconfiguration.openshift.io/v1", ] pruneopts = "NUT" - revision = "7efcbbbcada2af39a505c7a0305c7b32acec0af3" - version = "v3.11.0" + revision = "d12b437e1310637c74d6321d4acfe69eca2a63e7" [[projects]] digest = "1:93b1d84c5fa6d1ea52f4114c37714cddd84d5b78f151b62bb101128dd51399bf" @@ -558,14 +553,6 @@ pruneopts = "NUT" revision = "9a301d65acbb728fcc3ace14f45f511a4cfeea9c" -[[projects]] - branch = "master" - digest = "1:91ed6116b126ec7fa7b9f9460356ee6b3005e5ed320b8e85510937f44d3d62d5" - name = "go4.org" - packages = ["errorutil"] - pruneopts = "NUT" - revision = "417644f6feb5ed3a356ca5d6d8e3a3fac7dfd33f" - [[projects]] branch = "master" digest = "1:bf004bff766c8754f1c9b1e0a1ac6f253cd8e98fac385a33a9e9bd70325b72a8" @@ -873,6 +860,14 @@ revision = "a5bc97fbc634d635061f3146511332c7e313a55a" version = "v0.1.0" +[[projects]] + digest = "1:3779973ba544114a6c2b9799b1b4997f5e6e34253537f39b5baeff46d6b0131b" + name = "k8s.io/kubelet" + packages = ["config/v1beta1"] + pruneopts = "NUT" + revision = "dbc73c1cf0484128518b1f3821cc2de24523de47" + version = "kubernetes-1.12.5" + [[projects]] digest = "1:ff54706d46de40c865b5fcfc4bde1087c02510cd12e0150de8e405ab427d9907" name = "k8s.io/utils" @@ -957,7 +952,7 @@ "github.com/aws/aws-sdk-go/service/s3", "github.com/aws/aws-sdk-go/service/s3/s3manager", "github.com/coreos/ignition/config/util", - "github.com/coreos/ignition/config/v2_2/types", + "github.com/coreos/ignition/config/v3_0/types", "github.com/ghodss/yaml", "github.com/golang/mock/gomock", "github.com/gophercloud/gophercloud/openstack/common/extensions", diff --git a/Gopkg.toml b/Gopkg.toml index 8ace70325fa..4c778bee9ec 100644 --- a/Gopkg.toml +++ b/Gopkg.toml @@ -18,7 +18,8 @@ ignored = [ [[constraint]] name = "github.com/coreos/ignition" - version = "0.26.0" + branch = "master" + #version = "0.26.0" [[constraint]] name = "github.com/libvirt/libvirt-go" diff --git a/pkg/asset/ignition/bootstrap/bootstrap.go b/pkg/asset/ignition/bootstrap/bootstrap.go index 5e8e2fcf3fe..8500c1c9d67 100644 --- a/pkg/asset/ignition/bootstrap/bootstrap.go +++ b/pkg/asset/ignition/bootstrap/bootstrap.go @@ -9,11 +9,13 @@ import ( "os" "path" "path/filepath" + "reflect" "strings" "text/template" "github.com/coreos/ignition/config/util" - igntypes "github.com/coreos/ignition/config/v2_2/types" + igntypes "github.com/coreos/ignition/config/v3_0/types" + "github.com/coreos/ignition/config/validate" "github.com/pkg/errors" "github.com/sirupsen/logrus" @@ -136,10 +138,25 @@ func (a *Bootstrap) Generate(dependencies asset.Parents) error { igntypes.PasswdUser{Name: "core", SSHAuthorizedKeys: []igntypes.SSHAuthorizedKey{igntypes.SSHAuthorizedKey(installConfig.Config.SSHKey)}}, ) + dup := make(map[string]bool) + for _, f := range a.Config.Storage.Files { + if dup[f.Path] { + fmt.Printf("dup %q\n", f.Path) + continue + } + dup[f.Path] = true + } + + rpt := validate.ValidateWithoutSource(reflect.ValueOf(a.Config)) + if rpt.IsFatal() { + return errors.Errorf("invalid Ignition config found: %v", rpt) + } + data, err := json.Marshal(a.Config) if err != nil { return errors.Wrap(err, "failed to Marshal Ignition config") } + fmt.Println(string(data)) a.File = &asset.File{ Filename: bootstrapIgnFilename, Data: data, @@ -237,9 +254,34 @@ func (a *Bootstrap) addStorageFiles(base string, uri string, templateData *boots } else { mode = 0600 } - ign := ignition.FileFromBytes(strings.TrimSuffix(base, ".template"), "root", mode, data) - ign.Append = appendToFile - a.Config.Storage.Files = append(a.Config.Storage.Files, ign) + var ign igntypes.File + if appendToFile { + var appended bool + for _, f := range a.Config.Storage.Files { + if f.Path == strings.TrimSuffix(base, ".template") { + ign = ignition.FileAppendFromBytes(strings.TrimSuffix(base, ".template"), "root", mode, data) + a.Config.Storage.Files = append(a.Config.Storage.Files, ign) + appended = true + break + } + } + if !appended { + ign = ignition.FileAppendFromBytes(strings.TrimSuffix(base, ".template"), "root", mode, data) + a.Config.Storage.Files = append(a.Config.Storage.Files, ign) + } + } else { + var found bool + for _, f := range a.Config.Storage.Files { + if f.Path == strings.TrimSuffix(base, ".template") { + found = true + break + } + } + if !found { + ign = ignition.FileFromBytes(strings.TrimSuffix(base, ".template"), "root", mode, data) + a.Config.Storage.Files = append(a.Config.Storage.Files, ign) + } + } return nil } @@ -290,7 +332,7 @@ func (a *Bootstrap) addSystemdUnits(uri string, templateData *bootstrapTemplateD return err } - dropins := []igntypes.SystemdDropin{} + dropins := []igntypes.Dropin{} for _, childInfo := range children { file, err := data.Assets.Open(path.Join(dir, childInfo.Name())) if err != nil { @@ -298,14 +340,15 @@ func (a *Bootstrap) addSystemdUnits(uri string, templateData *bootstrapTemplateD } defer file.Close() - childName, contents, err := readFile(childInfo.Name(), file, templateData) + childName, cbytes, err := readFile(childInfo.Name(), file, templateData) if err != nil { return err } - dropins = append(dropins, igntypes.SystemdDropin{ + contents := string(cbytes) + dropins = append(dropins, igntypes.Dropin{ Name: childName, - Contents: string(contents), + Contents: &contents, }) } @@ -319,14 +362,15 @@ func (a *Bootstrap) addSystemdUnits(uri string, templateData *bootstrapTemplateD } a.Config.Systemd.Units = append(a.Config.Systemd.Units, unit) } else { - name, contents, err := readFile(childInfo.Name(), file, templateData) + name, cbytes, err := readFile(childInfo.Name(), file, templateData) if err != nil { return err } + contents := string(cbytes) unit := igntypes.Unit{ Name: name, - Contents: string(contents), + Contents: &contents, } if _, ok := enabled[name]; ok { unit.Enabled = util.BoolToPtr(true) @@ -364,12 +408,21 @@ func readFile(name string, reader io.Reader, templateData interface{}) (finalNam func (a *Bootstrap) addParentFiles(dependencies asset.Parents) { // These files are all added with mode 0644, i.e. readable // by all processes on the system. + dup := make(map[string]bool) for _, asset := range []asset.WritableAsset{ &manifests.Manifests{}, &manifests.Openshift{}, &machines.Master{}, } { dependencies.Get(asset) + files := ignition.FilesFromAsset(rootDir, "root", 0644, asset) + for _, f := range files { + if dup[f.Path] { + fmt.Printf("dup %q \n", f.Path) + continue + } + dup[f.Path] = true + } a.Config.Storage.Files = append(a.Config.Storage.Files, ignition.FilesFromAsset(rootDir, "root", 0644, asset)...) } @@ -421,6 +474,14 @@ func (a *Bootstrap) addParentFiles(dependencies asset.Parents) { &tls.JournalCertKey{}, } { dependencies.Get(asset) + files := ignition.FilesFromAsset(rootDir, "root", 0600, asset) + for _, f := range files { + if dup[f.Path] { + fmt.Printf("dup %q \n", f.Path) + continue + } + dup[f.Path] = true + } a.Config.Storage.Files = append(a.Config.Storage.Files, ignition.FilesFromAsset(rootDir, "root", 0600, asset)...) } diff --git a/pkg/asset/ignition/machine/master.go b/pkg/asset/ignition/machine/master.go index 8ae8ae920f9..a6b04a4d975 100644 --- a/pkg/asset/ignition/machine/master.go +++ b/pkg/asset/ignition/machine/master.go @@ -4,7 +4,7 @@ import ( "encoding/json" "os" - igntypes "github.com/coreos/ignition/config/v2_2/types" + igntypes "github.com/coreos/ignition/config/v3_0/types" "github.com/pkg/errors" "github.com/openshift/installer/pkg/asset" diff --git a/pkg/asset/ignition/machine/node.go b/pkg/asset/ignition/machine/node.go index 62c5452fb0b..84908b7bb30 100644 --- a/pkg/asset/ignition/machine/node.go +++ b/pkg/asset/ignition/machine/node.go @@ -4,7 +4,7 @@ import ( "fmt" "net/url" - ignition "github.com/coreos/ignition/config/v2_2/types" + ignition "github.com/coreos/ignition/config/v3_0/types" "github.com/vincent-petithory/dataurl" "github.com/openshift/installer/pkg/types" @@ -13,18 +13,19 @@ import ( // pointerIgnitionConfig generates a config which references the remote config // served by the machine config server. func pointerIgnitionConfig(installConfig *types.InstallConfig, rootCA []byte, role string) *ignition.Config { + source := func() *url.URL { + return &url.URL{ + Scheme: "https", + Host: fmt.Sprintf("api.%s:22623", installConfig.ClusterDomain()), + Path: fmt.Sprintf("/config/%s", role), + } + }().String() return &ignition.Config{ Ignition: ignition.Ignition{ Version: ignition.MaxVersion.String(), Config: ignition.IgnitionConfig{ - Append: []ignition.ConfigReference{{ - Source: func() *url.URL { - return &url.URL{ - Scheme: "https", - Host: fmt.Sprintf("api.%s:22623", installConfig.ClusterDomain()), - Path: fmt.Sprintf("/config/%s", role), - } - }().String(), + Merge: []ignition.ConfigReference{{ + Source: &source, }}, }, Security: ignition.Security{ diff --git a/pkg/asset/ignition/machine/worker.go b/pkg/asset/ignition/machine/worker.go index 83944cc2a43..17dcda6a499 100644 --- a/pkg/asset/ignition/machine/worker.go +++ b/pkg/asset/ignition/machine/worker.go @@ -4,7 +4,7 @@ import ( "encoding/json" "os" - igntypes "github.com/coreos/ignition/config/v2_2/types" + igntypes "github.com/coreos/ignition/config/v3_0/types" "github.com/pkg/errors" "github.com/openshift/installer/pkg/asset" diff --git a/pkg/asset/ignition/node.go b/pkg/asset/ignition/node.go index ed3dd0843b5..2af613e380f 100644 --- a/pkg/asset/ignition/node.go +++ b/pkg/asset/ignition/node.go @@ -3,7 +3,7 @@ package ignition import ( "path/filepath" - ignition "github.com/coreos/ignition/config/v2_2/types" + ignition "github.com/coreos/ignition/config/v3_0/types" "github.com/vincent-petithory/dataurl" "github.com/openshift/installer/pkg/asset" @@ -13,8 +13,14 @@ import ( // asset. func FilesFromAsset(pathPrefix string, username string, mode int, asset asset.WritableAsset) []ignition.File { var files []ignition.File + dup := make(map[string]bool) for _, f := range asset.Files() { - files = append(files, FileFromBytes(filepath.Join(pathPrefix, f.Filename), username, mode, f.Data)) + path := filepath.Join(pathPrefix, f.Filename) + if dup[path] { + continue + } + files = append(files, FileFromBytes(path, username, mode, f.Data)) + dup[path] = true } return files } @@ -26,18 +32,43 @@ func FileFromString(path string, username string, mode int, contents string) ign // FileFromBytes creates an ignition-config file with the given contents. func FileFromBytes(path string, username string, mode int, contents []byte) ignition.File { + source := dataurl.EncodeBytes(contents) + overwrite := true return ignition.File{ Node: ignition.Node{ - Filesystem: "root", - Path: path, - User: &ignition.NodeUser{ - Name: username, + Path: path, + User: ignition.NodeUser{ + Name: &username, }, + Overwrite: &overwrite, }, FileEmbedded1: ignition.FileEmbedded1{ Mode: &mode, Contents: ignition.FileContents{ - Source: dataurl.EncodeBytes(contents), + Source: &source, + }, + }, + } +} + +// FileAppendFromBytes ... TODO(runcom) +func FileAppendFromBytes(path string, username string, mode int, contents []byte) ignition.File { + source := dataurl.EncodeBytes(contents) + overwrite := true + return ignition.File{ + Node: ignition.Node{ + Path: path, + User: ignition.NodeUser{ + Name: &username, + }, + Overwrite: &overwrite, + }, + FileEmbedded1: ignition.FileEmbedded1{ + Mode: &mode, + Append: []ignition.FileContents{ + { + Source: &source, + }, }, }, } diff --git a/pkg/asset/machines/machineconfig/authorizedkeys.go b/pkg/asset/machines/machineconfig/authorizedkeys.go index 973641839cb..e641144fe15 100644 --- a/pkg/asset/machines/machineconfig/authorizedkeys.go +++ b/pkg/asset/machines/machineconfig/authorizedkeys.go @@ -3,7 +3,7 @@ package machineconfig import ( "fmt" - ignv2_2types "github.com/coreos/ignition/config/v2_2/types" + ignition "github.com/coreos/ignition/config/v3_0/types" mcfgv1 "github.com/openshift/machine-config-operator/pkg/apis/machineconfiguration.openshift.io/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) @@ -22,13 +22,13 @@ func ForAuthorizedKeys(key string, role string) *mcfgv1.MachineConfig { }, }, Spec: mcfgv1.MachineConfigSpec{ - Config: ignv2_2types.Config{ - Ignition: ignv2_2types.Ignition{ - Version: ignv2_2types.MaxVersion.String(), + Config: ignition.Config{ + Ignition: ignition.Ignition{ + Version: ignition.MaxVersion.String(), }, - Passwd: ignv2_2types.Passwd{ - Users: []ignv2_2types.PasswdUser{{ - Name: "core", SSHAuthorizedKeys: []ignv2_2types.SSHAuthorizedKey{ignv2_2types.SSHAuthorizedKey(key)}, + Passwd: ignition.Passwd{ + Users: []ignition.PasswdUser{{ + Name: "core", SSHAuthorizedKeys: []ignition.SSHAuthorizedKey{ignition.SSHAuthorizedKey(key)}, }}, }, }, diff --git a/pkg/asset/machines/master_test.go b/pkg/asset/machines/master_test.go index 99232f98fb2..ddb0e3a0db6 100644 --- a/pkg/asset/machines/master_test.go +++ b/pkg/asset/machines/master_test.go @@ -38,12 +38,13 @@ metadata: spec: config: ignition: - config: {} + config: + replace: + source: null + verification: {} security: tls: {} timeouts: {} - version: 2.2.0 - networkd: {} passwd: users: - name: core diff --git a/pkg/asset/tls/aggregator.go b/pkg/asset/tls/aggregator.go index 036c96a9b5d..9ec6432da46 100644 --- a/pkg/asset/tls/aggregator.go +++ b/pkg/asset/tls/aggregator.go @@ -161,7 +161,7 @@ func (a *AggregatorClientCertKey) Generate(dependencies asset.Parents) error { Validity: ValidityOneDay, } - return a.SignedCertKey.Generate(cfg, ca, "apiserver-proxy", DoNotAppendParent) + return a.SignedCertKey.Generate(cfg, ca, "aggregator-client", DoNotAppendParent) } // Name returns the human-friendly name of the asset. diff --git a/vendor/github.com/coreos/ignition/config/merge/merge.go b/vendor/github.com/coreos/ignition/config/merge/merge.go new file mode 100644 index 00000000000..10748ac403f --- /dev/null +++ b/vendor/github.com/coreos/ignition/config/merge/merge.go @@ -0,0 +1,224 @@ +// Copyright 2016 CoreOS, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package merge + +import ( + "reflect" + + "github.com/coreos/ignition/config/util" +) + +// Rules of Config Merging: +// 1) Parent and child configs must be the same version/type +// 2) Only valid configs can be merged +// 3) It is possible to merge two valid configs and get an invalid config +// 3) For structs: +// a) Members that are structs get merged recursively (i.e. ignition.storage) +// b) Members that are primitives get replaced by the child's member (e.g. ignition.storage.files[i].path) +// c) Members that are pointers only get replaced by the child's value if the child's value is non-nil (e.g. ignition.config.replace.source) +// d) List merging of a list with IgnoreDuplicates: append the lists (e.g. ignition.storage.files[i].append) +// e) List merging of a list not merged with other lists: merge any entries with the same Key() and append the others (e.g. ignition.storage.filesystems by path) +// f) List merging of a list merged with other lists: (e.g. ignition.storage.{files,links,directories} by path) +// - merge entries with the same Key() that are in the same list +// - remove entries from the parent with the same Key() that are not in the same list +// - append entries that are unique to the child + +// appendToSlice is a helper that appends to a slice without returning a new one. +// panics if len >= cap +func appendToSlice(s, v reflect.Value) { + s.SetLen(s.Len() + 1) + s.Index(s.Len() - 1).Set(v) +} + +type handleKey struct { + handle string + key string +} + +// structInfo holds information about a struct being processed and has helper methods for querying that +// information in a way that is more clear what the intent is. +type structInfo struct { + // set of field names to not do duplicate merging on + ignoreDups map[string]struct{} + + // map from field names to a handle indicating all those with the same handle should have duplication + // checking done across all fields that share that handle + mergedKeys map[string]string + + // map from each handle + key() value to what list it came from + keysToValues map[handleKey]reflect.Value + + // map from each handle + key() to the list it came from + keysToLists map[handleKey]string +} + +// returns if this field should not do duplicate checking/merging +func (s structInfo) ignoreField(name string) bool { + _, ignore := s.ignoreDups[name] + return ignore +} + +// getChildEntryByKey takes the name of a field (not handle) in the parent and a key and looks that entry +// up in the child. It will look up across all slices that share the same handle. It return the value and +// name of the field in the child it was found in. The bool indicates whether it was found. +func (s structInfo) getChildEntryByKey(fieldName, key string) (reflect.Value, string, bool) { + handle := fieldName + if tmp, ok := s.mergedKeys[fieldName]; ok { + handle = tmp + } + + hkey := handleKey{ + handle: handle, + key: key, + } + if v, ok := s.keysToValues[hkey]; ok { + return v, s.keysToLists[hkey], true + } + return reflect.Value{}, "", false +} + +func newStructInfo(parent, child reflect.Value) structInfo { + ignoreDups := map[string]struct{}{} + if ignorer, ok := parent.Interface().(util.IgnoresDups); ok { + ignoreDups = ignorer.IgnoreDuplicates() + } + + mergedKeys := map[string]string{} + if merger, ok := parent.Interface().(util.MergesKeys); ok { + mergedKeys = merger.MergedKeys() + } + + keysToValues := map[handleKey]reflect.Value{} + keysToLists := map[handleKey]string{} + for i := 0; i < child.NumField(); i++ { + field := child.Field(i) + if field.Kind() != reflect.Slice { + continue + } + + fieldName := child.Type().Field(i).Name + if _, ok := ignoreDups[fieldName]; ok { + continue + } + + handle := fieldName + if tmp, ok := mergedKeys[handle]; ok { + handle = tmp + } + + for j := 0; j < field.Len(); j++ { + v := field.Index(j) + hkey := handleKey{ + handle: handle, + key: util.CallKey(v), + } + keysToValues[hkey] = v + keysToLists[hkey] = fieldName + } + } + + return structInfo{ + ignoreDups: ignoreDups, + mergedKeys: mergedKeys, + keysToValues: keysToValues, + keysToLists: keysToLists, + } +} + +// MergeStruct is intended for use by config/vX_Y/ packages only. They should expose their own Merge() that is properly +// typed. Use that one instead. +// parent and child MUST be the same type +func MergeStruct(parent, child reflect.Value) reflect.Value { + // use New() so it's settable, addr-able, etc + result := reflect.New(parent.Type()).Elem() + info := newStructInfo(parent, child) + + for i := 0; i < parent.NumField(); i++ { + fieldName := parent.Type().Field(i).Name + parentField := parent.Field(i) + childField := child.Field(i) + resultField := result.Field(i) + + kind := parentField.Kind() + switch { + case util.IsPrimitive(kind): + resultField.Set(childField) + case kind == reflect.Ptr && childField.IsNil(): + resultField.Set(parentField) + case kind == reflect.Ptr && !childField.IsNil(): + resultField.Set(childField) + case kind == reflect.Struct: + resultField.Set(MergeStruct(parentField, childField)) + case kind == reflect.Slice && info.ignoreField(fieldName): + if parentField.Len()+childField.Len() == 0 { + continue + } + resultField.Set(reflect.AppendSlice(parentField, childField)) + case kind == reflect.Slice && !info.ignoreField(fieldName): + // ooph, this is a doosey + maxlen := parentField.Len() + childField.Len() + if maxlen == 0 { + continue + } + resultField.Set(reflect.MakeSlice(parentField.Type(), 0, parentField.Len()+childField.Len())) + parentKeys := getKeySet(parentField) + + for i := 0; i < parentField.Len(); i++ { + parentItem := parentField.Index(i) + key := util.CallKey(parentItem) + + if childItem, childList, ok := info.getChildEntryByKey(fieldName, key); ok { + if childList == fieldName { + // case 1: in child config in same list + if childItem.Kind() == reflect.Struct { + appendToSlice(resultField, MergeStruct(parentItem, childItem)) + } else if util.IsPrimitive(childItem.Kind()) { + appendToSlice(resultField, childItem) + } else { + panic("List of pointers or slices or something else weird") + } + } else { + // case 2: in child config in different list. Do nothing since it'll be handled iterating over that list + } + } else { + // case 3: not in child config, append it + appendToSlice(resultField, parentItem) + } + } + for i := 0; i < childField.Len(); i++ { + childItem := childField.Index(i) + key := util.CallKey(childItem) + if _, alreadyMerged := parentKeys[key]; !alreadyMerged { + // We only check the parentMap for this field. If the parent had a matching entry in a differnt field + // then it would be skipped as case 2 above + appendToSlice(resultField, childItem) + } + } + default: + panic("unreachable code reached") + } + } + + return result +} + +// getKeySet takes a value of a slice and returns the set of all the Key() values in that slice +func getKeySet(list reflect.Value) map[string]struct{} { + m := map[string]struct{}{} + for i := 0; i < list.Len(); i++ { + m[util.CallKey(list.Index(i))] = struct{}{} + } + return m +} diff --git a/vendor/github.com/coreos/ignition/config/shared/errors/errors.go b/vendor/github.com/coreos/ignition/config/shared/errors/errors.go index f2d1ddf2866..6fe8f66d2ec 100644 --- a/vendor/github.com/coreos/ignition/config/shared/errors/errors.go +++ b/vendor/github.com/coreos/ignition/config/shared/errors/errors.go @@ -22,51 +22,52 @@ import ( var ( // Parsing / general errors - ErrInvalid = errors.New("config is not valid") - ErrCloudConfig = errors.New("not a config (found coreos-cloudconfig)") - ErrEmpty = errors.New("not a config (empty)") - ErrUnknownVersion = errors.New("unsupported config version") - ErrScript = errors.New("not a config (found coreos-cloudinit script)") - ErrDeprecated = errors.New("config format deprecated") - ErrCompressionInvalid = errors.New("invalid compression method") + ErrInvalid = errors.New("config is not valid") + ErrEmpty = errors.New("not a config (empty)") // Ignition section errors - ErrOldVersion = errors.New("incorrect config version (too old)") - ErrNewVersion = errors.New("incorrect config version (too new)") ErrInvalidVersion = errors.New("invalid config version (couldn't parse)") + ErrUnknownVersion = errors.New("unsupported config version") + + ErrDeprecated = errors.New("config format deprecated") + ErrCompressionInvalid = errors.New("invalid compression method") // Storage section errors - ErrPermissionsUnset = errors.New("permissions unset, defaulting to 0000") - ErrDiskDeviceRequired = errors.New("disk device is required") - ErrPartitionNumbersCollide = errors.New("partition numbers collide") - ErrPartitionsOverlap = errors.New("partitions overlap") - ErrPartitionsMisaligned = errors.New("partitions misaligned") - ErrAppendAndOverwrite = errors.New("cannot set both append and overwrite to true") - ErrFilesystemInvalidFormat = errors.New("invalid filesystem format") - ErrFilesystemNoMountPath = errors.New("filesystem is missing mount or path") - ErrFilesystemMountAndPath = errors.New("filesystem has both mount and path defined") - ErrUsedCreateAndMountOpts = errors.New("cannot use both create object and mount-level options field") - ErrUsedCreateAndWipeFilesystem = errors.New("cannot use both create object and wipeFilesystem field") - ErrWarningCreateDeprecated = errors.New("the create object has been deprecated in favor of mount-level options") - ErrExt4LabelTooLong = errors.New("filesystem labels cannot be longer than 16 characters when using ext4") - ErrBtrfsLabelTooLong = errors.New("filesystem labels cannot be longer than 256 characters when using btrfs") - ErrXfsLabelTooLong = errors.New("filesystem labels cannot be longer than 12 characters when using xfs") - ErrSwapLabelTooLong = errors.New("filesystem labels cannot be longer than 15 characters when using swap") - ErrVfatLabelTooLong = errors.New("filesystem labels cannot be longer than 11 characters when using vfat") - ErrFileIllegalMode = errors.New("illegal file mode") - ErrNoFilesystem = errors.New("no filesystem specified") - ErrBothIDAndNameSet = errors.New("cannot set both id and name") - ErrLabelTooLong = errors.New("partition labels may not exceed 36 characters") - ErrDoesntMatchGUIDRegex = errors.New("doesn't match the form \"01234567-89AB-CDEF-EDCB-A98765432101\"") - ErrLabelContainsColon = errors.New("partition label will be truncated to text before the colon") - ErrPathRelative = errors.New("path not absolute") - ErrSparesUnsupportedForLevel = errors.New("spares unsupported for arrays with a level greater than 0") - ErrUnrecognizedRaidLevel = errors.New("unrecognized raid level") - ErrShouldNotExistWithOthers = errors.New("shouldExist specified false with other options also specified") - ErrZeroesWithShouldNotExist = errors.New("shouldExist is false for a partition and other partition(s) has start or size 0") + ErrFilePermissionsUnset = errors.New("permissions unset, defaulting to 0644") + ErrDirectoryPermissionsUnset = errors.New("permissions unset, defaulting to 0755") + ErrDiskDeviceRequired = errors.New("disk device is required") + ErrPartitionNumbersCollide = errors.New("partition numbers collide") + ErrPartitionsOverlap = errors.New("partitions overlap") + ErrPartitionsMisaligned = errors.New("partitions misaligned") + ErrAppendAndOverwrite = errors.New("cannot set both append and overwrite to true") + ErrFilesystemInvalidFormat = errors.New("invalid filesystem format") + ErrLabelNeedsFormat = errors.New("filesystem must specify format if label is specified") + ErrFormatNilWithOthers = errors.New("format cannot be empty when path, label, uuid, or options are specified") + ErrExt4LabelTooLong = errors.New("filesystem labels cannot be longer than 16 characters when using ext4") + ErrBtrfsLabelTooLong = errors.New("filesystem labels cannot be longer than 256 characters when using btrfs") + ErrXfsLabelTooLong = errors.New("filesystem labels cannot be longer than 12 characters when using xfs") + ErrSwapLabelTooLong = errors.New("filesystem labels cannot be longer than 15 characters when using swap") + ErrVfatLabelTooLong = errors.New("filesystem labels cannot be longer than 11 characters when using vfat") + ErrFileIllegalMode = errors.New("illegal file mode") + ErrNoFilesystem = errors.New("no filesystem specified") + ErrBothIDAndNameSet = errors.New("cannot set both id and name") + ErrLabelTooLong = errors.New("partition labels may not exceed 36 characters") + ErrDoesntMatchGUIDRegex = errors.New("doesn't match the form \"01234567-89AB-CDEF-EDCB-A98765432101\"") + ErrLabelContainsColon = errors.New("partition label will be truncated to text before the colon") + ErrNoPath = errors.New("path not specified") + ErrPathRelative = errors.New("path not absolute") + ErrDirtyPath = errors.New("path is not fully simplified") + ErrSparesUnsupportedForLevel = errors.New("spares unsupported for arrays with a level greater than 0") + ErrUnrecognizedRaidLevel = errors.New("unrecognized raid level") + ErrShouldNotExistWithOthers = errors.New("shouldExist specified false with other options also specified") + ErrZeroesWithShouldNotExist = errors.New("shouldExist is false for a partition and other partition(s) has start or size 0") + ErrPartitionsUnitsMismatch = errors.New("cannot mix MBs and sectors within a disk") + ErrSizeDeprecated = errors.New("size is deprecated; use sizeMB instead") + ErrStartDeprecated = errors.New("start is deprecated; use startMB instead") + ErrNeedLabelOrNumber = errors.New("a partition number >= 1 or a label must be specified") + ErrDuplicateLabels = errors.New("cannot use the same partition label twice") // Passwd section errors - ErrPasswdCreateDeprecated = errors.New("the create object has been deprecated in favor of user-level options") ErrPasswdCreateAndGecos = errors.New("cannot use both the create object and the user-level gecos field") ErrPasswdCreateAndGroups = errors.New("cannot use both the create object and the user-level groups field") ErrPasswdCreateAndHomeDir = errors.New("cannot use both the create object and the user-level homeDir field") @@ -78,18 +79,20 @@ var ( ErrPasswdCreateAndSystem = errors.New("cannot use both the create object and the user-level system field") ErrPasswdCreateAndUID = errors.New("cannot use both the create object and the user-level uid field") - // Systemd and Networkd section errors - ErrInvalidSystemdExt = errors.New("invalid systemd unit extension") - ErrInvalidSystemdDropinExt = errors.New("invalid systemd drop-in extension") - ErrInvalidNetworkdExt = errors.New("invalid networkd unit extension") - ErrInvalidNetworkdDropinExt = errors.New("invalid networkd drop-in extension") + // Systemd section errors + ErrInvalidSystemdExt = errors.New("invalid systemd unit extension") + ErrInvalidSystemdDropinExt = errors.New("invalid systemd drop-in extension") // Misc errors - ErrInvalidScheme = errors.New("invalid url scheme") - ErrInvalidUrl = errors.New("unable to parse url") - ErrHashMalformed = errors.New("malformed hash specifier") - ErrHashWrongSize = errors.New("incorrect size for hash sum") - ErrHashUnrecognized = errors.New("unrecognized hash function") + ErrInvalidScheme = errors.New("invalid url scheme") + ErrInvalidUrl = errors.New("unable to parse url") + ErrHashMalformed = errors.New("malformed hash specifier") + ErrHashWrongSize = errors.New("incorrect size for hash sum") + ErrHashUnrecognized = errors.New("unrecognized hash function") + ErrEngineConfiguration = errors.New("engine incorrectly configured") + + // AWS S3 specific errors + ErrInvalidS3ObjectVersionId = errors.New("invalid S3 object VersionId") ) // NewNoInstallSectionError produces an error indicating the given unit, named diff --git a/vendor/github.com/coreos/ignition/config/v2_0/types/path.go b/vendor/github.com/coreos/ignition/config/util/interfaces.go similarity index 54% rename from vendor/github.com/coreos/ignition/config/v2_0/types/path.go rename to vendor/github.com/coreos/ignition/config/util/interfaces.go index dcf35f80756..857de8234ef 100644 --- a/vendor/github.com/coreos/ignition/config/v2_0/types/path.go +++ b/vendor/github.com/coreos/ignition/config/util/interfaces.go @@ -1,4 +1,4 @@ -// Copyright 2016 CoreOS, Inc. +// Copyright 2019 Red Hat, Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -12,24 +12,28 @@ // See the License for the specific language governing permissions and // limitations under the License. -package types +package util import ( - "path" - - "github.com/coreos/ignition/config/shared/errors" - "github.com/coreos/ignition/config/validate/report" + "reflect" ) -type Path string +type MergesKeys interface { + MergedKeys() map[string]string +} + +type IgnoresDups interface { + IgnoreDuplicates() map[string]struct{} +} -func (p Path) MarshalJSON() ([]byte, error) { - return []byte(`"` + string(p) + `"`), nil +type Keyed interface { + Key() string } -func (p Path) Validate() report.Report { - if !path.IsAbs(string(p)) { - return report.ReportFromError(errors.ErrPathRelative, report.EntryError) +// CallKey is a helper to call the Key() function since this needs to happen a lot +func CallKey(v reflect.Value) string { + if v.Kind() == reflect.String { + return v.Convert(reflect.TypeOf("")).Interface().(string) } - return report.Report{} + return v.Interface().(Keyed).Key() } diff --git a/vendor/github.com/coreos/ignition/config/util/parsingErrors.go b/vendor/github.com/coreos/ignition/config/util/parsingErrors.go index 6b6b114dafc..3a1865b2273 100644 --- a/vendor/github.com/coreos/ignition/config/util/parsingErrors.go +++ b/vendor/github.com/coreos/ignition/config/util/parsingErrors.go @@ -15,35 +15,24 @@ package util import ( - "bytes" - "errors" - - configErrors "github.com/coreos/ignition/config/shared/errors" - "github.com/coreos/ignition/config/v2_3_experimental/types" + "github.com/coreos/ignition/config/shared/errors" "github.com/coreos/ignition/config/validate/report" + "github.com/coreos/ignition/config/validate/util" json "github.com/ajeddeloh/go-json" - "go4.org/errorutil" -) - -var ( - ErrValidConfig = errors.New("HandleParseErrors called with a valid config") ) -// HandleParseErrors will attempt to unmarshal an invalid rawConfig into the -// latest config struct, so as to generate a report.Report from the errors. It -// will always return an error. This is called after config/v* parse functions -// chain has failed to parse a config. -func HandleParseErrors(rawConfig []byte) (report.Report, error) { - config := types.Config{} - err := json.Unmarshal(rawConfig, &config) +// HandleParseErrors will attempt to unmarshal an invalid rawConfig into "to". +// If it fails to unmarsh it will generate a report.Report from the errors. +func HandleParseErrors(rawConfig []byte, to interface{}) (report.Report, error) { + err := json.Unmarshal(rawConfig, to) if err == nil { - return report.Report{}, ErrValidConfig + return report.Report{}, nil } // Handle json syntax and type errors first, since they are fatal but have offset info if serr, ok := err.(*json.SyntaxError); ok { - line, col, highlight := errorutil.HighlightBytePosition(bytes.NewReader(rawConfig), serr.Offset) + line, col, highlight := util.Highlight(rawConfig, serr.Offset) return report.Report{ Entries: []report.Entry{{ Kind: report.EntryError, @@ -53,11 +42,11 @@ func HandleParseErrors(rawConfig []byte) (report.Report, error) { Highlight: highlight, }}, }, - configErrors.ErrInvalid + errors.ErrInvalid } if terr, ok := err.(*json.UnmarshalTypeError); ok { - line, col, highlight := errorutil.HighlightBytePosition(bytes.NewReader(rawConfig), terr.Offset) + line, col, highlight := util.Highlight(rawConfig, terr.Offset) return report.Report{ Entries: []report.Entry{{ Kind: report.EntryError, @@ -67,8 +56,8 @@ func HandleParseErrors(rawConfig []byte) (report.Report, error) { Highlight: highlight, }}, }, - configErrors.ErrInvalid + errors.ErrInvalid } - return report.ReportFromError(err, report.EntryError), err + return report.ReportFromError(err, report.EntryError), errors.ErrInvalid } diff --git a/vendor/github.com/coreos/ignition/config/util/reflection.go b/vendor/github.com/coreos/ignition/config/util/reflection.go new file mode 100644 index 00000000000..561a8706bad --- /dev/null +++ b/vendor/github.com/coreos/ignition/config/util/reflection.go @@ -0,0 +1,55 @@ +// Copyright 2019 Red Hat, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package util + +import ( + "reflect" +) + +func IsPrimitive(k reflect.Kind) bool { + switch k { + case reflect.Bool, + reflect.Int, + reflect.Int8, + reflect.Int16, + reflect.Int32, + reflect.Int64, + reflect.Uint, + reflect.Uint8, + reflect.Uint16, + reflect.Uint32, + reflect.Uint64, + reflect.Uintptr, + reflect.Float32, + reflect.Float64, + reflect.Complex64, + reflect.Complex128, + reflect.String: + return true + default: + return false + } +} + +func IsInvalidInConfig(k reflect.Kind) bool { + switch { + case IsPrimitive(k): + return false + case k == reflect.Ptr || k == reflect.Slice || k == reflect.Struct: + return false + default: + return true + } +} diff --git a/vendor/github.com/coreos/ignition/config/v1/cloudinit.go b/vendor/github.com/coreos/ignition/config/v1/cloudinit.go deleted file mode 100644 index 7cfeb455938..00000000000 --- a/vendor/github.com/coreos/ignition/config/v1/cloudinit.go +++ /dev/null @@ -1,53 +0,0 @@ -// Copyright 2015 CoreOS, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// These functions are copied from github.com/coreos/coreos-cloudinit/config. - -package v1 - -import ( - "bytes" - "compress/gzip" - "io/ioutil" - "strings" - "unicode" -) - -func isCloudConfig(userdata []byte) bool { - header := strings.SplitN(string(decompressIfGzipped(userdata)), "\n", 2)[0] - - // Trim trailing whitespaces - header = strings.TrimRightFunc(header, unicode.IsSpace) - - return (header == "#cloud-config") -} - -func isScript(userdata []byte) bool { - header := strings.SplitN(string(decompressIfGzipped(userdata)), "\n", 2)[0] - return strings.HasPrefix(header, "#!") -} - -func decompressIfGzipped(data []byte) []byte { - if reader, err := gzip.NewReader(bytes.NewReader(data)); err == nil { - uncompressedData, err := ioutil.ReadAll(reader) - reader.Close() - if err == nil { - return uncompressedData - } else { - return data - } - } else { - return data - } -} diff --git a/vendor/github.com/coreos/ignition/config/v1/types/config.go b/vendor/github.com/coreos/ignition/config/v1/types/config.go deleted file mode 100644 index f9215699cbd..00000000000 --- a/vendor/github.com/coreos/ignition/config/v1/types/config.go +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright 2016 CoreOS, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package types - -const ( - Version = 1 -) - -type Config struct { - Version int `json:"ignitionVersion"` - Storage Storage `json:"storage,omitempty"` - Systemd Systemd `json:"systemd,omitempty"` - Networkd Networkd `json:"networkd,omitempty"` - Passwd Passwd `json:"passwd,omitempty"` -} diff --git a/vendor/github.com/coreos/ignition/config/v1/types/disk.go b/vendor/github.com/coreos/ignition/config/v1/types/disk.go deleted file mode 100644 index 62517856dc0..00000000000 --- a/vendor/github.com/coreos/ignition/config/v1/types/disk.go +++ /dev/null @@ -1,123 +0,0 @@ -// Copyright 2016 CoreOS, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package types - -import ( - "github.com/coreos/ignition/config/shared/errors" - "github.com/coreos/ignition/config/validate/report" -) - -type Disk struct { - Device Path `json:"device,omitempty"` - WipeTable bool `json:"wipeTable,omitempty"` - Partitions []Partition `json:"partitions,omitempty"` -} - -func (n Disk) Validate() report.Report { - r := report.Report{} - if len(n.Device) == 0 { - r.Add(report.Entry{ - Kind: report.EntryError, - Message: errors.ErrDiskDeviceRequired.Error(), - }) - } - if n.partitionNumbersCollide() { - r.Add(report.Entry{ - Kind: report.EntryError, - Message: errors.ErrPartitionNumbersCollide.Error(), - }) - } - if n.partitionsOverlap() { - r.Add(report.Entry{ - Kind: report.EntryError, - Message: errors.ErrPartitionsOverlap.Error(), - }) - } - if n.partitionsMisaligned() { - r.Add(report.Entry{ - Kind: report.EntryError, - Message: errors.ErrPartitionsMisaligned.Error(), - }) - } - // Disks which get to this point will likely succeed in sgdisk - return r -} - -// partitionNumbersCollide returns true if partition numbers in n.Partitions are not unique. -func (n Disk) partitionNumbersCollide() bool { - m := map[int][]Partition{} - for _, p := range n.Partitions { - m[p.Number] = append(m[p.Number], p) - } - for _, n := range m { - if len(n) > 1 { - // TODO(vc): return information describing the collision for logging - return true - } - } - return false -} - -// end returns the last sector of a partition. -func (p Partition) end() PartitionDimension { - if p.Size == 0 { - // a size of 0 means "fill available", just return the start as the end for those. - return p.Start - } - return p.Start + p.Size - 1 -} - -// partitionsOverlap returns true if any explicitly dimensioned partitions overlap -func (n Disk) partitionsOverlap() bool { - for _, p := range n.Partitions { - // Starts of 0 are placed by sgdisk into the "largest available block" at that time. - // We aren't going to check those for overlap since we don't have the disk geometry. - if p.Start == 0 { - continue - } - - for _, o := range n.Partitions { - if p == o || o.Start == 0 { - continue - } - - // is p.Start within o? - if p.Start >= o.Start && p.Start <= o.end() { - return true - } - - // is p.end() within o? - if p.end() >= o.Start && p.end() <= o.end() { - return true - } - - // do p.Start and p.end() straddle o? - if p.Start < o.Start && p.end() > o.end() { - return true - } - } - } - return false -} - -// partitionsMisaligned returns true if any of the partitions don't start on a 2048-sector (1MiB) boundary. -func (n Disk) partitionsMisaligned() bool { - for _, p := range n.Partitions { - if (p.Start & (2048 - 1)) != 0 { - return true - } - } - return false -} diff --git a/vendor/github.com/coreos/ignition/config/v1/types/filesystem.go b/vendor/github.com/coreos/ignition/config/v1/types/filesystem.go deleted file mode 100644 index 7986bd724cc..00000000000 --- a/vendor/github.com/coreos/ignition/config/v1/types/filesystem.go +++ /dev/null @@ -1,45 +0,0 @@ -// Copyright 2016 CoreOS, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package types - -import ( - "github.com/coreos/ignition/config/shared/errors" - "github.com/coreos/ignition/config/validate/report" -) - -type Filesystem struct { - Device Path `json:"device,omitempty"` - Format FilesystemFormat `json:"format,omitempty"` - Create *FilesystemCreate `json:"create,omitempty"` - Files []File `json:"files,omitempty"` -} - -type FilesystemCreate struct { - Force bool `json:"force,omitempty"` - Options MkfsOptions `json:"options,omitempty"` -} - -type FilesystemFormat string - -func (f FilesystemFormat) Validate() report.Report { - switch f { - case "ext4", "btrfs", "xfs": - return report.Report{} - default: - return report.ReportFromError(errors.ErrFilesystemInvalidFormat, report.EntryError) - } -} - -type MkfsOptions []string diff --git a/vendor/github.com/coreos/ignition/config/v1/types/group.go b/vendor/github.com/coreos/ignition/config/v1/types/group.go deleted file mode 100644 index 27e51048870..00000000000 --- a/vendor/github.com/coreos/ignition/config/v1/types/group.go +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2016 CoreOS, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package types - -type Group struct { - Name string `json:"name,omitempty"` - Gid *uint `json:"gid,omitempty"` - PasswordHash string `json:"passwordHash,omitempty"` - System bool `json:"system,omitempty"` -} diff --git a/vendor/github.com/coreos/ignition/config/v1/types/networkd.go b/vendor/github.com/coreos/ignition/config/v1/types/networkd.go deleted file mode 100644 index 470c721106a..00000000000 --- a/vendor/github.com/coreos/ignition/config/v1/types/networkd.go +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright 2016 CoreOS, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package types - -type Networkd struct { - Units []NetworkdUnit `json:"units,omitempty"` -} diff --git a/vendor/github.com/coreos/ignition/config/v1/types/partition.go b/vendor/github.com/coreos/ignition/config/v1/types/partition.go deleted file mode 100644 index 16270de2cf8..00000000000 --- a/vendor/github.com/coreos/ignition/config/v1/types/partition.go +++ /dev/null @@ -1,60 +0,0 @@ -// Copyright 2016 CoreOS, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package types - -import ( - "fmt" - "regexp" - - "github.com/coreos/ignition/config/shared/errors" - "github.com/coreos/ignition/config/validate/report" -) - -type Partition struct { - Label PartitionLabel `json:"label,omitempty"` - Number int `json:"number"` - Size PartitionDimension `json:"size"` - Start PartitionDimension `json:"start"` - TypeGUID PartitionTypeGUID `json:"typeGuid,omitempty"` -} - -type PartitionLabel string - -func (n PartitionLabel) Validate() report.Report { - // http://en.wikipedia.org/wiki/GUID_Partition_Table#Partition_entries: - // 56 (0x38) 72 bytes Partition name (36 UTF-16LE code units) - - // XXX(vc): note GPT calls it a name, we're using label for consistency - // with udev naming /dev/disk/by-partlabel/*. - if len(string(n)) > 36 { - return report.ReportFromError(errors.ErrLabelTooLong, report.EntryError) - } - return report.Report{} -} - -type PartitionDimension uint64 - -type PartitionTypeGUID string - -func (d PartitionTypeGUID) Validate() report.Report { - ok, err := regexp.MatchString("^(|[[:xdigit:]]{8}-[[:xdigit:]]{4}-[[:xdigit:]]{4}-[[:xdigit:]]{4}-[[:xdigit:]]{12})$", string(d)) - if err != nil { - return report.ReportFromError(fmt.Errorf("error matching type-guid regexp: %v", err), report.EntryError) - } - if !ok { - return report.ReportFromError(fmt.Errorf(`partition type-guid must have the form "01234567-89AB-CDEF-EDCB-A98765432101", got: %q`, string(d)), report.EntryError) - } - return report.Report{} -} diff --git a/vendor/github.com/coreos/ignition/config/v1/types/path.go b/vendor/github.com/coreos/ignition/config/v1/types/path.go deleted file mode 100644 index e37341c1ace..00000000000 --- a/vendor/github.com/coreos/ignition/config/v1/types/path.go +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright 2016 CoreOS, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package types - -import ( - "path" - - "github.com/coreos/ignition/config/shared/errors" - "github.com/coreos/ignition/config/validate/report" -) - -type Path string - -func (d Path) Validate() report.Report { - if !path.IsAbs(string(d)) { - return report.ReportFromError(errors.ErrPathRelative, report.EntryError) - } - return report.Report{} -} diff --git a/vendor/github.com/coreos/ignition/config/v1/types/raid.go b/vendor/github.com/coreos/ignition/config/v1/types/raid.go deleted file mode 100644 index 329b123e6d0..00000000000 --- a/vendor/github.com/coreos/ignition/config/v1/types/raid.go +++ /dev/null @@ -1,44 +0,0 @@ -// Copyright 2016 CoreOS, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package types - -import ( - "github.com/coreos/ignition/config/shared/errors" - "github.com/coreos/ignition/config/validate/report" -) - -type Raid struct { - Name string `json:"name"` - Level string `json:"level"` - Devices []Path `json:"devices,omitempty"` - Spares int `json:"spares,omitempty"` -} - -func (n Raid) Validate() report.Report { - switch n.Level { - case "linear", "raid0", "0", "stripe": - if n.Spares != 0 { - return report.ReportFromError(errors.ErrSparesUnsupportedForLevel, report.EntryError) - } - case "raid1", "1", "mirror": - case "raid4", "4": - case "raid5", "5": - case "raid6", "6": - case "raid10", "10": - default: - return report.ReportFromError(errors.ErrUnrecognizedRaidLevel, report.EntryError) - } - return report.Report{} -} diff --git a/vendor/github.com/coreos/ignition/config/v1/types/storage.go b/vendor/github.com/coreos/ignition/config/v1/types/storage.go deleted file mode 100644 index 2649751a7d0..00000000000 --- a/vendor/github.com/coreos/ignition/config/v1/types/storage.go +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2016 CoreOS, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package types - -type Storage struct { - Disks []Disk `json:"disks,omitempty"` - Arrays []Raid `json:"raid,omitempty"` - Filesystems []Filesystem `json:"filesystems,omitempty"` -} diff --git a/vendor/github.com/coreos/ignition/config/v1/types/unit.go b/vendor/github.com/coreos/ignition/config/v1/types/unit.go deleted file mode 100644 index 5e983cc1456..00000000000 --- a/vendor/github.com/coreos/ignition/config/v1/types/unit.go +++ /dev/null @@ -1,73 +0,0 @@ -// Copyright 2016 CoreOS, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package types - -import ( - "path" - - "github.com/coreos/ignition/config/shared/errors" - "github.com/coreos/ignition/config/validate/report" -) - -type SystemdUnit struct { - Name SystemdUnitName `json:"name,omitempty"` - Enable bool `json:"enable,omitempty"` - Mask bool `json:"mask,omitempty"` - Contents string `json:"contents,omitempty"` - DropIns []SystemdUnitDropIn `json:"dropins,omitempty"` -} - -type SystemdUnitDropIn struct { - Name SystemdUnitDropInName `json:"name,omitempty"` - Contents string `json:"contents,omitempty"` -} - -type SystemdUnitName string - -func (n SystemdUnitName) Validate() report.Report { - switch path.Ext(string(n)) { - case ".service", ".socket", ".device", ".mount", ".automount", ".swap", ".target", ".path", ".timer", ".snapshot", ".slice", ".scope": - return report.Report{} - default: - return report.ReportFromError(errors.ErrInvalidSystemdExt, report.EntryError) - } -} - -type SystemdUnitDropInName string - -func (n SystemdUnitDropInName) Validate() report.Report { - switch path.Ext(string(n)) { - case ".conf": - return report.Report{} - default: - return report.ReportFromError(errors.ErrInvalidSystemdDropinExt, report.EntryError) - } -} - -type NetworkdUnit struct { - Name NetworkdUnitName `json:"name,omitempty"` - Contents string `json:"contents,omitempty"` -} - -type NetworkdUnitName string - -func (n NetworkdUnitName) Validate() report.Report { - switch path.Ext(string(n)) { - case ".link", ".netdev", ".network": - return report.Report{} - default: - return report.ReportFromError(errors.ErrInvalidNetworkdExt, report.EntryError) - } -} diff --git a/vendor/github.com/coreos/ignition/config/v1/types/user.go b/vendor/github.com/coreos/ignition/config/v1/types/user.go deleted file mode 100644 index f6653e27494..00000000000 --- a/vendor/github.com/coreos/ignition/config/v1/types/user.go +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright 2016 CoreOS, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package types - -type User struct { - Name string `json:"name,omitempty"` - PasswordHash string `json:"passwordHash,omitempty"` - SSHAuthorizedKeys []string `json:"sshAuthorizedKeys,omitempty"` - Create *UserCreate `json:"create,omitempty"` -} - -type UserCreate struct { - Uid *uint `json:"uid,omitempty"` - GECOS string `json:"gecos,omitempty"` - Homedir string `json:"homeDir,omitempty"` - NoCreateHome bool `json:"noCreateHome,omitempty"` - PrimaryGroup string `json:"primaryGroup,omitempty"` - Groups []string `json:"groups,omitempty"` - NoUserGroup bool `json:"noUserGroup,omitempty"` - System bool `json:"system,omitempty"` - NoLogInit bool `json:"noLogInit,omitempty"` - Shell string `json:"shell,omitempty"` -} diff --git a/vendor/github.com/coreos/ignition/config/v2_0/append.go b/vendor/github.com/coreos/ignition/config/v2_0/append.go deleted file mode 100644 index cee6bc412e2..00000000000 --- a/vendor/github.com/coreos/ignition/config/v2_0/append.go +++ /dev/null @@ -1,73 +0,0 @@ -// Copyright 2016 CoreOS, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package v2_0 - -import ( - "reflect" - - "github.com/coreos/ignition/config/v2_0/types" -) - -// Append appends newConfig to oldConfig and returns the result. Appending one -// config to another is accomplished by iterating over every field in the -// config structure, appending slices, recursively appending structs, and -// overwriting old values with new values for all other types. -func Append(oldConfig, newConfig types.Config) types.Config { - vOld := reflect.ValueOf(oldConfig) - vNew := reflect.ValueOf(newConfig) - - vResult := appendStruct(vOld, vNew) - - return vResult.Interface().(types.Config) -} - -// appendStruct is an internal helper function to AppendConfig. Given two values -// of structures (assumed to be the same type), recursively iterate over every -// field in the struct, appending slices, recursively appending structs, and -// overwriting old values with the new for all other types. Individual fields -// are able to override their merge strategy using the "merge" tag. Accepted -// values are "new" or "old": "new" uses the new value, "old" uses the old -// value. These are currently only used for "ignition.config" and -// "ignition.version". -func appendStruct(vOld, vNew reflect.Value) reflect.Value { - tOld := vOld.Type() - vRes := reflect.New(tOld) - - for i := 0; i < tOld.NumField(); i++ { - vfOld := vOld.Field(i) - vfNew := vNew.Field(i) - vfRes := vRes.Elem().Field(i) - - switch tOld.Field(i).Tag.Get("merge") { - case "old": - vfRes.Set(vfOld) - continue - case "new": - vfRes.Set(vfNew) - continue - } - - switch vfOld.Type().Kind() { - case reflect.Struct: - vfRes.Set(appendStruct(vfOld, vfNew)) - case reflect.Slice: - vfRes.Set(reflect.AppendSlice(vfOld, vfNew)) - default: - vfRes.Set(vfNew) - } - } - - return vRes.Elem() -} diff --git a/vendor/github.com/coreos/ignition/config/v2_0/cloudinit.go b/vendor/github.com/coreos/ignition/config/v2_0/cloudinit.go deleted file mode 100644 index 9e1f2ad0e7c..00000000000 --- a/vendor/github.com/coreos/ignition/config/v2_0/cloudinit.go +++ /dev/null @@ -1,53 +0,0 @@ -// Copyright 2015 CoreOS, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// These functions are copied from github.com/coreos/coreos-cloudinit/config. - -package v2_0 - -import ( - "bytes" - "compress/gzip" - "io/ioutil" - "strings" - "unicode" -) - -func isCloudConfig(userdata []byte) bool { - header := strings.SplitN(string(decompressIfGzipped(userdata)), "\n", 2)[0] - - // Trim trailing whitespaces - header = strings.TrimRightFunc(header, unicode.IsSpace) - - return (header == "#cloud-config") -} - -func isScript(userdata []byte) bool { - header := strings.SplitN(string(decompressIfGzipped(userdata)), "\n", 2)[0] - return strings.HasPrefix(header, "#!") -} - -func decompressIfGzipped(data []byte) []byte { - if reader, err := gzip.NewReader(bytes.NewReader(data)); err == nil { - uncompressedData, err := ioutil.ReadAll(reader) - reader.Close() - if err == nil { - return uncompressedData - } else { - return data - } - } else { - return data - } -} diff --git a/vendor/github.com/coreos/ignition/config/v2_0/config.go b/vendor/github.com/coreos/ignition/config/v2_0/config.go deleted file mode 100644 index f1385bf1ca9..00000000000 --- a/vendor/github.com/coreos/ignition/config/v2_0/config.go +++ /dev/null @@ -1,70 +0,0 @@ -// Copyright 2015 CoreOS, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package v2_0 - -import ( - "github.com/coreos/ignition/config/shared/errors" - "github.com/coreos/ignition/config/v1" - "github.com/coreos/ignition/config/v2_0/types" - "github.com/coreos/ignition/config/validate" - "github.com/coreos/ignition/config/validate/report" - - json "github.com/ajeddeloh/go-json" - "github.com/coreos/go-semver/semver" -) - -// Parse parses the raw config into a types.Config struct and generates a report of any -// errors, warnings, info, and deprecations it encountered -func Parse(rawConfig []byte) (types.Config, report.Report, error) { - if isEmpty(rawConfig) { - return types.Config{}, report.Report{}, errors.ErrEmpty - } else if isCloudConfig(rawConfig) { - return types.Config{}, report.Report{}, errors.ErrCloudConfig - } else if isScript(rawConfig) { - return types.Config{}, report.Report{}, errors.ErrScript - } - - var err error - var config types.Config - - err = json.Unmarshal(rawConfig, &config) - - if err != nil || semver.Version(config.Ignition.Version).LessThan(types.MaxVersion) { - // We can fail unmarshaling if it's an older config. Attempt to parse - // it as such. - config, rpt, err := v1.Parse(rawConfig) - if err != nil { - return types.Config{}, rpt, err - } - - rpt.Merge(report.ReportFromError(errors.ErrDeprecated, report.EntryDeprecated)) - return TranslateFromV1(config), rpt, err - } - - if semver.Version(config.Ignition.Version) != types.MaxVersion { - return types.Config{}, report.Report{}, errors.ErrUnknownVersion - } - - rpt := validate.ValidateConfig(rawConfig, config) - if rpt.IsFatal() { - return types.Config{}, rpt, errors.ErrInvalid - } - - return config, rpt, nil -} - -func isEmpty(userdata []byte) bool { - return len(userdata) == 0 -} diff --git a/vendor/github.com/coreos/ignition/config/v2_0/translate.go b/vendor/github.com/coreos/ignition/config/v2_0/translate.go deleted file mode 100644 index 832adce566d..00000000000 --- a/vendor/github.com/coreos/ignition/config/v2_0/translate.go +++ /dev/null @@ -1,173 +0,0 @@ -// Copyright 2018 CoreOS, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package v2_0 - -import ( - "fmt" - - v1 "github.com/coreos/ignition/config/v1/types" - "github.com/coreos/ignition/config/v2_0/types" - "github.com/vincent-petithory/dataurl" -) - -func TranslateFromV1(old v1.Config) types.Config { - config := types.Config{ - Ignition: types.Ignition{ - Version: types.IgnitionVersion(types.MaxVersion), - }, - } - - for _, oldDisk := range old.Storage.Disks { - disk := types.Disk{ - Device: types.Path(oldDisk.Device), - WipeTable: oldDisk.WipeTable, - } - - for _, oldPartition := range oldDisk.Partitions { - disk.Partitions = append(disk.Partitions, types.Partition{ - Label: types.PartitionLabel(oldPartition.Label), - Number: oldPartition.Number, - Size: types.PartitionDimension(oldPartition.Size), - Start: types.PartitionDimension(oldPartition.Start), - TypeGUID: types.PartitionTypeGUID(oldPartition.TypeGUID), - }) - } - - config.Storage.Disks = append(config.Storage.Disks, disk) - } - - for _, oldArray := range old.Storage.Arrays { - array := types.Raid{ - Name: oldArray.Name, - Level: oldArray.Level, - Spares: oldArray.Spares, - } - - for _, oldDevice := range oldArray.Devices { - array.Devices = append(array.Devices, types.Path(oldDevice)) - } - - config.Storage.Arrays = append(config.Storage.Arrays, array) - } - - for i, oldFilesystem := range old.Storage.Filesystems { - filesystem := types.Filesystem{ - Name: fmt.Sprintf("_translate-filesystem-%d", i), - Mount: &types.FilesystemMount{ - Device: types.Path(oldFilesystem.Device), - Format: types.FilesystemFormat(oldFilesystem.Format), - }, - } - - if oldFilesystem.Create != nil { - filesystem.Mount.Create = &types.FilesystemCreate{ - Force: oldFilesystem.Create.Force, - Options: types.MkfsOptions(oldFilesystem.Create.Options), - } - } - - config.Storage.Filesystems = append(config.Storage.Filesystems, filesystem) - - for _, oldFile := range oldFilesystem.Files { - file := types.File{ - Filesystem: filesystem.Name, - Path: types.Path(oldFile.Path), - User: types.FileUser{Id: oldFile.Uid}, - Group: types.FileGroup{Id: oldFile.Gid}, - Mode: types.FileMode(oldFile.Mode), - Contents: types.FileContents{ - Source: types.Url{ - Scheme: "data", - Opaque: "," + dataurl.EscapeString(oldFile.Contents), - }, - }, - } - - config.Storage.Files = append(config.Storage.Files, file) - } - } - - for _, oldUnit := range old.Systemd.Units { - unit := types.SystemdUnit{ - Name: types.SystemdUnitName(oldUnit.Name), - Enable: oldUnit.Enable, - Mask: oldUnit.Mask, - Contents: oldUnit.Contents, - } - - for _, oldDropIn := range oldUnit.DropIns { - unit.DropIns = append(unit.DropIns, types.SystemdUnitDropIn{ - Name: types.SystemdUnitDropInName(oldDropIn.Name), - Contents: oldDropIn.Contents, - }) - } - - config.Systemd.Units = append(config.Systemd.Units, unit) - } - - for _, oldUnit := range old.Networkd.Units { - config.Networkd.Units = append(config.Networkd.Units, types.NetworkdUnit{ - Name: types.NetworkdUnitName(oldUnit.Name), - Contents: oldUnit.Contents, - }) - } - - for _, oldUser := range old.Passwd.Users { - user := types.User{ - Name: oldUser.Name, - PasswordHash: oldUser.PasswordHash, - SSHAuthorizedKeys: oldUser.SSHAuthorizedKeys, - } - - if oldUser.Create != nil { - var uid *uint - if oldUser.Create.Uid != nil { - tmp := uint(*oldUser.Create.Uid) - uid = &tmp - } - - user.Create = &types.UserCreate{ - Uid: uid, - GECOS: oldUser.Create.GECOS, - Homedir: oldUser.Create.Homedir, - NoCreateHome: oldUser.Create.NoCreateHome, - PrimaryGroup: oldUser.Create.PrimaryGroup, - Groups: oldUser.Create.Groups, - NoUserGroup: oldUser.Create.NoUserGroup, - System: oldUser.Create.System, - NoLogInit: oldUser.Create.NoLogInit, - Shell: oldUser.Create.Shell, - } - } - - config.Passwd.Users = append(config.Passwd.Users, user) - } - - for _, oldGroup := range old.Passwd.Groups { - var gid *uint - if oldGroup.Gid != nil { - tmp := uint(*oldGroup.Gid) - gid = &tmp - } - config.Passwd.Groups = append(config.Passwd.Groups, types.Group{ - Name: oldGroup.Name, - Gid: gid, - PasswordHash: oldGroup.PasswordHash, - System: oldGroup.System, - }) - } - - return config -} diff --git a/vendor/github.com/coreos/ignition/config/v2_0/types/compression.go b/vendor/github.com/coreos/ignition/config/v2_0/types/compression.go deleted file mode 100644 index f56e5b9c80b..00000000000 --- a/vendor/github.com/coreos/ignition/config/v2_0/types/compression.go +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright 2016 CoreOS, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package types - -import ( - "github.com/coreos/ignition/config/shared/errors" - "github.com/coreos/ignition/config/validate/report" -) - -type Compression string - -func (c Compression) Validate() report.Report { - switch c { - case "", "gzip": - default: - return report.ReportFromError(errors.ErrCompressionInvalid, report.EntryError) - } - return report.Report{} -} diff --git a/vendor/github.com/coreos/ignition/config/v2_0/types/config.go b/vendor/github.com/coreos/ignition/config/v2_0/types/config.go deleted file mode 100644 index 38551589175..00000000000 --- a/vendor/github.com/coreos/ignition/config/v2_0/types/config.go +++ /dev/null @@ -1,87 +0,0 @@ -// Copyright 2015 CoreOS, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package types - -import ( - "fmt" - - "github.com/coreos/go-semver/semver" - - "github.com/coreos/ignition/config/validate/report" -) - -var ( - MaxVersion = semver.Version{ - Major: 2, - Minor: 0, - } -) - -type Config struct { - Ignition Ignition `json:"ignition"` - Storage Storage `json:"storage,omitempty"` - Systemd Systemd `json:"systemd,omitempty"` - Networkd Networkd `json:"networkd,omitempty"` - Passwd Passwd `json:"passwd,omitempty"` -} - -func (c Config) Validate() report.Report { - r := report.Report{} - rules := []rule{ - checkFilesFilesystems, - checkDuplicateFilesystems, - } - - for _, rule := range rules { - rule(c, &r) - } - return r -} - -type rule func(cfg Config, report *report.Report) - -func checkFilesFilesystems(cfg Config, r *report.Report) { - filesystems := map[string]struct{}{"root": {}} - for _, filesystem := range cfg.Storage.Filesystems { - filesystems[filesystem.Name] = struct{}{} - } - for _, file := range cfg.Storage.Files { - if file.Filesystem == "" { - // Filesystem was not specified. This is an error, but its handled in types.File's Validate, not here - continue - } - _, ok := filesystems[file.Filesystem] - if !ok { - r.Add(report.Entry{ - Kind: report.EntryWarning, - Message: fmt.Sprintf("File %q references nonexistent filesystem %q. (This is ok if it is defined in a referenced config)", - file.Path, file.Filesystem), - }) - } - } -} - -func checkDuplicateFilesystems(cfg Config, r *report.Report) { - filesystems := map[string]struct{}{"root": {}} - for _, filesystem := range cfg.Storage.Filesystems { - if _, ok := filesystems[filesystem.Name]; ok { - r.Add(report.Entry{ - Kind: report.EntryWarning, - Message: fmt.Sprintf("Filesystem %q shadows exising filesystem definition", filesystem.Name), - }) - } - filesystems[filesystem.Name] = struct{}{} - } -} diff --git a/vendor/github.com/coreos/ignition/config/v2_0/types/disk.go b/vendor/github.com/coreos/ignition/config/v2_0/types/disk.go deleted file mode 100644 index b68c5c930ed..00000000000 --- a/vendor/github.com/coreos/ignition/config/v2_0/types/disk.go +++ /dev/null @@ -1,126 +0,0 @@ -// Copyright 2016 CoreOS, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package types - -import ( - "github.com/coreos/ignition/config/shared/errors" - "github.com/coreos/ignition/config/validate/report" -) - -type Disk struct { - Device Path `json:"device,omitempty"` - WipeTable bool `json:"wipeTable,omitempty"` - Partitions []Partition `json:"partitions,omitempty"` -} - -func (n Disk) Validate() report.Report { - r := report.Report{} - if len(n.Device) == 0 { - r.Add(report.Entry{ - Message: errors.ErrDiskDeviceRequired.Error(), - Kind: report.EntryError, - }) - } - if n.partitionNumbersCollide() { - r.Add(report.Entry{ - Message: errors.ErrPartitionNumbersCollide.Error(), - Kind: report.EntryError, - }) - } - if n.partitionsOverlap() { - r.Add(report.Entry{ - Message: errors.ErrPartitionsOverlap.Error(), - Kind: report.EntryError, - }) - } - if n.partitionsMisaligned() { - r.Add(report.Entry{ - Message: errors.ErrPartitionsMisaligned.Error(), - Kind: report.EntryError, - }) - } - // Disks which have no errors at this point will likely succeed in sgdisk - return r -} - -// partitionNumbersCollide returns true if partition numbers in n.Partitions are not unique. -func (n Disk) partitionNumbersCollide() bool { - m := map[int][]Partition{} - for _, p := range n.Partitions { - if p.Number != 0 { - // a number of 0 means next available number, multiple devices can specify this - m[p.Number] = append(m[p.Number], p) - } - } - for _, n := range m { - if len(n) > 1 { - // TODO(vc): return information describing the collision for logging - return true - } - } - return false -} - -// end returns the last sector of a partition. -func (p Partition) end() PartitionDimension { - if p.Size == 0 { - // a size of 0 means "fill available", just return the start as the end for those. - return p.Start - } - return p.Start + p.Size - 1 -} - -// partitionsOverlap returns true if any explicitly dimensioned partitions overlap -func (n Disk) partitionsOverlap() bool { - for _, p := range n.Partitions { - // Starts of 0 are placed by sgdisk into the "largest available block" at that time. - // We aren't going to check those for overlap since we don't have the disk geometry. - if p.Start == 0 { - continue - } - - for _, o := range n.Partitions { - if p == o || o.Start == 0 { - continue - } - - // is p.Start within o? - if p.Start >= o.Start && p.Start <= o.end() { - return true - } - - // is p.end() within o? - if p.end() >= o.Start && p.end() <= o.end() { - return true - } - - // do p.Start and p.end() straddle o? - if p.Start < o.Start && p.end() > o.end() { - return true - } - } - } - return false -} - -// partitionsMisaligned returns true if any of the partitions don't start on a 2048-sector (1MiB) boundary. -func (n Disk) partitionsMisaligned() bool { - for _, p := range n.Partitions { - if (p.Start & (2048 - 1)) != 0 { - return true - } - } - return false -} diff --git a/vendor/github.com/coreos/ignition/config/v2_0/types/file.go b/vendor/github.com/coreos/ignition/config/v2_0/types/file.go deleted file mode 100644 index 8d3e79054de..00000000000 --- a/vendor/github.com/coreos/ignition/config/v2_0/types/file.go +++ /dev/null @@ -1,61 +0,0 @@ -// Copyright 2016 CoreOS, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package types - -import ( - "os" - - "github.com/coreos/ignition/config/shared/errors" - "github.com/coreos/ignition/config/validate/report" -) - -type File struct { - Filesystem string `json:"filesystem,omitempty"` - Path Path `json:"path,omitempty"` - Contents FileContents `json:"contents,omitempty"` - Mode FileMode `json:"mode,omitempty"` - User FileUser `json:"user,omitempty"` - Group FileGroup `json:"group,omitempty"` -} - -func (f File) Validate() report.Report { - if f.Filesystem == "" { - return report.ReportFromError(errors.ErrNoFilesystem, report.EntryError) - } - return report.Report{} -} - -type FileUser struct { - Id int `json:"id,omitempty"` -} - -type FileGroup struct { - Id int `json:"id,omitempty"` -} - -type FileContents struct { - Compression Compression `json:"compression,omitempty"` - Source Url `json:"source,omitempty"` - Verification Verification `json:"verification,omitempty"` -} - -type FileMode os.FileMode - -func (m FileMode) Validate() report.Report { - if (m &^ 07777) != 0 { - return report.ReportFromError(errors.ErrFileIllegalMode, report.EntryError) - } - return report.Report{} -} diff --git a/vendor/github.com/coreos/ignition/config/v2_0/types/filesystem.go b/vendor/github.com/coreos/ignition/config/v2_0/types/filesystem.go deleted file mode 100644 index e3572711da8..00000000000 --- a/vendor/github.com/coreos/ignition/config/v2_0/types/filesystem.go +++ /dev/null @@ -1,60 +0,0 @@ -// Copyright 2016 CoreOS, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package types - -import ( - "github.com/coreos/ignition/config/shared/errors" - "github.com/coreos/ignition/config/validate/report" -) - -type Filesystem struct { - Name string `json:"name,omitempty"` - Mount *FilesystemMount `json:"mount,omitempty"` - Path *Path `json:"path,omitempty"` -} - -type FilesystemMount struct { - Device Path `json:"device,omitempty"` - Format FilesystemFormat `json:"format,omitempty"` - Create *FilesystemCreate `json:"create,omitempty"` -} - -type FilesystemCreate struct { - Force bool `json:"force,omitempty"` - Options MkfsOptions `json:"options,omitempty"` -} - -func (f Filesystem) Validate() report.Report { - if f.Mount == nil && f.Path == nil { - return report.ReportFromError(errors.ErrFilesystemNoMountPath, report.EntryError) - } - if f.Mount != nil && f.Path != nil { - return report.ReportFromError(errors.ErrFilesystemMountAndPath, report.EntryError) - } - return report.Report{} -} - -type FilesystemFormat string - -func (f FilesystemFormat) Validate() report.Report { - switch f { - case "ext4", "btrfs", "xfs": - return report.Report{} - default: - return report.ReportFromError(errors.ErrFilesystemInvalidFormat, report.EntryError) - } -} - -type MkfsOptions []string diff --git a/vendor/github.com/coreos/ignition/config/v2_0/types/group.go b/vendor/github.com/coreos/ignition/config/v2_0/types/group.go deleted file mode 100644 index 27e51048870..00000000000 --- a/vendor/github.com/coreos/ignition/config/v2_0/types/group.go +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2016 CoreOS, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package types - -type Group struct { - Name string `json:"name,omitempty"` - Gid *uint `json:"gid,omitempty"` - PasswordHash string `json:"passwordHash,omitempty"` - System bool `json:"system,omitempty"` -} diff --git a/vendor/github.com/coreos/ignition/config/v2_0/types/hash.go b/vendor/github.com/coreos/ignition/config/v2_0/types/hash.go deleted file mode 100644 index 628524dc6d1..00000000000 --- a/vendor/github.com/coreos/ignition/config/v2_0/types/hash.go +++ /dev/null @@ -1,72 +0,0 @@ -// Copyright 2016 CoreOS, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package types - -import ( - "crypto" - "encoding/hex" - "encoding/json" - "strings" - - "github.com/coreos/ignition/config/shared/errors" - "github.com/coreos/ignition/config/validate/report" -) - -type Hash struct { - Function string - Sum string -} - -func (h *Hash) UnmarshalJSON(data []byte) error { - var th string - if err := json.Unmarshal(data, &th); err != nil { - return err - } - - parts := strings.SplitN(th, "-", 2) - if len(parts) != 2 { - return errors.ErrHashMalformed - } - - h.Function = parts[0] - h.Sum = parts[1] - - return nil -} - -func (h Hash) MarshalJSON() ([]byte, error) { - return []byte(`"` + h.Function + "-" + h.Sum + `"`), nil -} - -func (h Hash) String() string { - bytes, _ := h.MarshalJSON() - return string(bytes) -} - -func (h Hash) Validate() report.Report { - var hash crypto.Hash - switch h.Function { - case "sha512": - hash = crypto.SHA512 - default: - return report.ReportFromError(errors.ErrHashUnrecognized, report.EntryError) - } - - if len(h.Sum) != hex.EncodedLen(hash.Size()) { - return report.ReportFromError(errors.ErrHashWrongSize, report.EntryError) - } - - return report.Report{} -} diff --git a/vendor/github.com/coreos/ignition/config/v2_0/types/ignition.go b/vendor/github.com/coreos/ignition/config/v2_0/types/ignition.go deleted file mode 100644 index deeb822d09e..00000000000 --- a/vendor/github.com/coreos/ignition/config/v2_0/types/ignition.go +++ /dev/null @@ -1,64 +0,0 @@ -// Copyright 2015 CoreOS, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package types - -import ( - "encoding/json" - - "github.com/coreos/go-semver/semver" - - "github.com/coreos/ignition/config/shared/errors" - "github.com/coreos/ignition/config/validate/report" -) - -type Ignition struct { - Version IgnitionVersion `json:"version,omitempty" merge:"old"` - Config IgnitionConfig `json:"config,omitempty" merge:"new"` -} - -type IgnitionConfig struct { - Append []ConfigReference `json:"append,omitempty"` - Replace *ConfigReference `json:"replace,omitempty"` -} - -type ConfigReference struct { - Source Url `json:"source,omitempty"` - Verification Verification `json:"verification,omitempty"` -} - -type IgnitionVersion semver.Version - -func (v *IgnitionVersion) UnmarshalJSON(data []byte) error { - tv := semver.Version(*v) - if err := json.Unmarshal(data, &tv); err != nil { - return err - } - *v = IgnitionVersion(tv) - return nil -} - -func (v IgnitionVersion) MarshalJSON() ([]byte, error) { - return semver.Version(v).MarshalJSON() -} - -func (v IgnitionVersion) Validate() report.Report { - if MaxVersion.Major > v.Major { - return report.ReportFromError(errors.ErrOldVersion, report.EntryError) - } - if MaxVersion.LessThan(semver.Version(v)) { - return report.ReportFromError(errors.ErrNewVersion, report.EntryError) - } - return report.Report{} -} diff --git a/vendor/github.com/coreos/ignition/config/v2_0/types/networkd.go b/vendor/github.com/coreos/ignition/config/v2_0/types/networkd.go deleted file mode 100644 index 470c721106a..00000000000 --- a/vendor/github.com/coreos/ignition/config/v2_0/types/networkd.go +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright 2016 CoreOS, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package types - -type Networkd struct { - Units []NetworkdUnit `json:"units,omitempty"` -} diff --git a/vendor/github.com/coreos/ignition/config/v2_0/types/partition.go b/vendor/github.com/coreos/ignition/config/v2_0/types/partition.go deleted file mode 100644 index c36545d4a63..00000000000 --- a/vendor/github.com/coreos/ignition/config/v2_0/types/partition.go +++ /dev/null @@ -1,64 +0,0 @@ -// Copyright 2016 CoreOS, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package types - -import ( - "fmt" - "regexp" - "strings" - - "github.com/coreos/ignition/config/shared/errors" - "github.com/coreos/ignition/config/validate/report" -) - -type Partition struct { - Label PartitionLabel `json:"label,omitempty"` - Number int `json:"number"` - Size PartitionDimension `json:"size"` - Start PartitionDimension `json:"start"` - TypeGUID PartitionTypeGUID `json:"typeGuid,omitempty"` -} - -type PartitionLabel string - -func (n PartitionLabel) Validate() report.Report { - // http://en.wikipedia.org/wiki/GUID_Partition_Table#Partition_entries: - // 56 (0x38) 72 bytes Partition name (36 UTF-16LE code units) - - // XXX(vc): note GPT calls it a name, we're using label for consistency - // with udev naming /dev/disk/by-partlabel/*. - if len(string(n)) > 36 { - return report.ReportFromError(errors.ErrLabelTooLong, report.EntryError) - } - if strings.Contains(string(n), ":") { - return report.ReportFromError(errors.ErrLabelContainsColon, report.EntryWarning) - } - return report.Report{} -} - -type PartitionDimension uint64 - -type PartitionTypeGUID string - -func (d PartitionTypeGUID) Validate() report.Report { - ok, err := regexp.MatchString("^(|[[:xdigit:]]{8}-[[:xdigit:]]{4}-[[:xdigit:]]{4}-[[:xdigit:]]{4}-[[:xdigit:]]{12})$", string(d)) - if err != nil { - return report.ReportFromError(fmt.Errorf("error matching type-guid regexp: %v", err), report.EntryError) - } - if !ok { - return report.ReportFromError(errors.ErrDoesntMatchGUIDRegex, report.EntryError) - } - return report.Report{} -} diff --git a/vendor/github.com/coreos/ignition/config/v2_0/types/passwd.go b/vendor/github.com/coreos/ignition/config/v2_0/types/passwd.go deleted file mode 100644 index 0ffff43bb84..00000000000 --- a/vendor/github.com/coreos/ignition/config/v2_0/types/passwd.go +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright 2016 CoreOS, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package types - -type Passwd struct { - Users []User `json:"users,omitempty"` - Groups []Group `json:"groups,omitempty"` -} diff --git a/vendor/github.com/coreos/ignition/config/v2_0/types/raid.go b/vendor/github.com/coreos/ignition/config/v2_0/types/raid.go deleted file mode 100644 index 329b123e6d0..00000000000 --- a/vendor/github.com/coreos/ignition/config/v2_0/types/raid.go +++ /dev/null @@ -1,44 +0,0 @@ -// Copyright 2016 CoreOS, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package types - -import ( - "github.com/coreos/ignition/config/shared/errors" - "github.com/coreos/ignition/config/validate/report" -) - -type Raid struct { - Name string `json:"name"` - Level string `json:"level"` - Devices []Path `json:"devices,omitempty"` - Spares int `json:"spares,omitempty"` -} - -func (n Raid) Validate() report.Report { - switch n.Level { - case "linear", "raid0", "0", "stripe": - if n.Spares != 0 { - return report.ReportFromError(errors.ErrSparesUnsupportedForLevel, report.EntryError) - } - case "raid1", "1", "mirror": - case "raid4", "4": - case "raid5", "5": - case "raid6", "6": - case "raid10", "10": - default: - return report.ReportFromError(errors.ErrUnrecognizedRaidLevel, report.EntryError) - } - return report.Report{} -} diff --git a/vendor/github.com/coreos/ignition/config/v2_0/types/storage.go b/vendor/github.com/coreos/ignition/config/v2_0/types/storage.go deleted file mode 100644 index bd7343778a9..00000000000 --- a/vendor/github.com/coreos/ignition/config/v2_0/types/storage.go +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2016 CoreOS, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package types - -type Storage struct { - Disks []Disk `json:"disks,omitempty"` - Arrays []Raid `json:"raid,omitempty"` - Filesystems []Filesystem `json:"filesystems,omitempty"` - Files []File `json:"files,omitempty"` -} diff --git a/vendor/github.com/coreos/ignition/config/v2_0/types/systemd.go b/vendor/github.com/coreos/ignition/config/v2_0/types/systemd.go deleted file mode 100644 index 97194b91150..00000000000 --- a/vendor/github.com/coreos/ignition/config/v2_0/types/systemd.go +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright 2016 CoreOS, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package types - -type Systemd struct { - Units []SystemdUnit `json:"units,omitempty"` -} diff --git a/vendor/github.com/coreos/ignition/config/v2_0/types/unit.go b/vendor/github.com/coreos/ignition/config/v2_0/types/unit.go deleted file mode 100644 index 06d99f26616..00000000000 --- a/vendor/github.com/coreos/ignition/config/v2_0/types/unit.go +++ /dev/null @@ -1,115 +0,0 @@ -// Copyright 2016 CoreOS, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package types - -import ( - "fmt" - "path" - "strings" - - "github.com/coreos/go-systemd/unit" - - "github.com/coreos/ignition/config/shared/errors" - "github.com/coreos/ignition/config/shared/validations" - "github.com/coreos/ignition/config/validate/report" -) - -type SystemdUnit struct { - Name SystemdUnitName `json:"name,omitempty"` - Enable bool `json:"enable,omitempty"` - Mask bool `json:"mask,omitempty"` - Contents string `json:"contents,omitempty"` - DropIns []SystemdUnitDropIn `json:"dropins,omitempty"` -} - -func (u SystemdUnit) Validate() report.Report { - r := report.Report{} - opts, err := validateUnitContent(u.Contents) - if err != nil { - return report.ReportFromError(err, report.EntryError) - } - - r.Merge(validations.ValidateInstallSection(string(u.Name), u.Enable, u.Contents == "", opts)) - - return r -} - -type SystemdUnitDropIn struct { - Name SystemdUnitDropInName `json:"name,omitempty"` - Contents string `json:"contents,omitempty"` -} - -func (u SystemdUnitDropIn) Validate() report.Report { - if _, err := validateUnitContent(u.Contents); err != nil { - return report.ReportFromError(err, report.EntryError) - } - - return report.Report{} -} - -type SystemdUnitName string - -func (n SystemdUnitName) Validate() report.Report { - switch path.Ext(string(n)) { - case ".service", ".socket", ".device", ".mount", ".automount", ".swap", ".target", ".path", ".timer", ".snapshot", ".slice", ".scope": - return report.Report{} - default: - return report.ReportFromError(errors.ErrInvalidSystemdExt, report.EntryError) - } -} - -type SystemdUnitDropInName string - -func (n SystemdUnitDropInName) Validate() report.Report { - switch path.Ext(string(n)) { - case ".conf": - return report.Report{} - default: - return report.ReportFromError(errors.ErrInvalidSystemdDropinExt, report.EntryError) - } -} - -type NetworkdUnit struct { - Name NetworkdUnitName `json:"name,omitempty"` - Contents string `json:"contents,omitempty"` -} - -func (u NetworkdUnit) Validate() report.Report { - if _, err := validateUnitContent(u.Contents); err != nil { - return report.ReportFromError(err, report.EntryError) - } - - return report.Report{} -} - -type NetworkdUnitName string - -func (n NetworkdUnitName) Validate() report.Report { - switch path.Ext(string(n)) { - case ".link", ".netdev", ".network": - return report.Report{} - default: - return report.ReportFromError(errors.ErrInvalidNetworkdExt, report.EntryError) - } -} - -func validateUnitContent(content string) ([]*unit.UnitOption, error) { - c := strings.NewReader(content) - opts, err := unit.Deserialize(c) - if err != nil { - return nil, fmt.Errorf("invalid unit content: %s", err) - } - return opts, nil -} diff --git a/vendor/github.com/coreos/ignition/config/v2_0/types/url.go b/vendor/github.com/coreos/ignition/config/v2_0/types/url.go deleted file mode 100644 index b8ed96118be..00000000000 --- a/vendor/github.com/coreos/ignition/config/v2_0/types/url.go +++ /dev/null @@ -1,69 +0,0 @@ -// Copyright 2016 CoreOS, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package types - -import ( - "encoding/json" - "net/url" - - "github.com/vincent-petithory/dataurl" - - "github.com/coreos/ignition/config/shared/errors" - "github.com/coreos/ignition/config/validate/report" -) - -type Url url.URL - -func (u *Url) UnmarshalJSON(data []byte) error { - var tu string - if err := json.Unmarshal(data, &tu); err != nil { - return err - } - - pu, err := url.Parse(tu) - if err != nil { - return errors.ErrInvalidUrl - } - - *u = Url(*pu) - return nil -} - -func (u Url) MarshalJSON() ([]byte, error) { - return []byte(`"` + u.String() + `"`), nil -} - -func (u Url) String() string { - tu := url.URL(u) - return (&tu).String() -} - -func (u Url) Validate() report.Report { - // Empty url is valid, indicates an empty file - if u.String() == "" { - return report.Report{} - } - switch url.URL(u).Scheme { - case "http", "https", "oem": - return report.Report{} - case "data": - if _, err := dataurl.DecodeString(u.String()); err != nil { - return report.ReportFromError(err, report.EntryError) - } - return report.Report{} - default: - return report.ReportFromError(errors.ErrInvalidScheme, report.EntryError) - } -} diff --git a/vendor/github.com/coreos/ignition/config/v2_0/types/user.go b/vendor/github.com/coreos/ignition/config/v2_0/types/user.go deleted file mode 100644 index f6653e27494..00000000000 --- a/vendor/github.com/coreos/ignition/config/v2_0/types/user.go +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright 2016 CoreOS, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package types - -type User struct { - Name string `json:"name,omitempty"` - PasswordHash string `json:"passwordHash,omitempty"` - SSHAuthorizedKeys []string `json:"sshAuthorizedKeys,omitempty"` - Create *UserCreate `json:"create,omitempty"` -} - -type UserCreate struct { - Uid *uint `json:"uid,omitempty"` - GECOS string `json:"gecos,omitempty"` - Homedir string `json:"homeDir,omitempty"` - NoCreateHome bool `json:"noCreateHome,omitempty"` - PrimaryGroup string `json:"primaryGroup,omitempty"` - Groups []string `json:"groups,omitempty"` - NoUserGroup bool `json:"noUserGroup,omitempty"` - System bool `json:"system,omitempty"` - NoLogInit bool `json:"noLogInit,omitempty"` - Shell string `json:"shell,omitempty"` -} diff --git a/vendor/github.com/coreos/ignition/config/v2_0/types/verification.go b/vendor/github.com/coreos/ignition/config/v2_0/types/verification.go deleted file mode 100644 index b7cef403e87..00000000000 --- a/vendor/github.com/coreos/ignition/config/v2_0/types/verification.go +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright 2016 CoreOS, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package types - -type Verification struct { - Hash *Hash `json:"hash,omitempty"` -} diff --git a/vendor/github.com/coreos/ignition/config/v2_1/append.go b/vendor/github.com/coreos/ignition/config/v2_1/append.go deleted file mode 100644 index b1517b73106..00000000000 --- a/vendor/github.com/coreos/ignition/config/v2_1/append.go +++ /dev/null @@ -1,72 +0,0 @@ -// Copyright 2016 CoreOS, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package v2_1 - -import ( - "reflect" - - "github.com/coreos/ignition/config/v2_1/types" -) - -// Append appends newConfig to oldConfig and returns the result. Appending one -// config to another is accomplished by iterating over every field in the -// config structure, appending slices, recursively appending structs, and -// overwriting old values with new values for all other types. -func Append(oldConfig, newConfig types.Config) types.Config { - vOld := reflect.ValueOf(oldConfig) - vNew := reflect.ValueOf(newConfig) - - vResult := appendStruct(vOld, vNew) - - return vResult.Interface().(types.Config) -} - -// appendStruct is an internal helper function to AppendConfig. Given two values -// of structures (assumed to be the same type), recursively iterate over every -// field in the struct, appending slices, recursively appending structs, and -// overwriting old values with the new for all other types. Some individual -// struct fields have alternate merge strategies, determined by the field name. -// Currently these fields are "ignition.version", which uses the old value, and -// "ignition.config" which uses the new value. -func appendStruct(vOld, vNew reflect.Value) reflect.Value { - tOld := vOld.Type() - vRes := reflect.New(tOld) - - for i := 0; i < tOld.NumField(); i++ { - vfOld := vOld.Field(i) - vfNew := vNew.Field(i) - vfRes := vRes.Elem().Field(i) - - switch tOld.Field(i).Name { - case "Version": - vfRes.Set(vfOld) - continue - case "Config": - vfRes.Set(vfNew) - continue - } - - switch vfOld.Type().Kind() { - case reflect.Struct: - vfRes.Set(appendStruct(vfOld, vfNew)) - case reflect.Slice: - vfRes.Set(reflect.AppendSlice(vfOld, vfNew)) - default: - vfRes.Set(vfNew) - } - } - - return vRes.Elem() -} diff --git a/vendor/github.com/coreos/ignition/config/v2_1/cloudinit.go b/vendor/github.com/coreos/ignition/config/v2_1/cloudinit.go deleted file mode 100644 index a019320f41d..00000000000 --- a/vendor/github.com/coreos/ignition/config/v2_1/cloudinit.go +++ /dev/null @@ -1,53 +0,0 @@ -// Copyright 2015 CoreOS, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// These functions are copied from github.com/coreos/coreos-cloudinit/config. - -package v2_1 - -import ( - "bytes" - "compress/gzip" - "io/ioutil" - "strings" - "unicode" -) - -func isCloudConfig(userdata []byte) bool { - header := strings.SplitN(string(decompressIfGzipped(userdata)), "\n", 2)[0] - - // Trim trailing whitespaces - header = strings.TrimRightFunc(header, unicode.IsSpace) - - return (header == "#cloud-config") -} - -func isScript(userdata []byte) bool { - header := strings.SplitN(string(decompressIfGzipped(userdata)), "\n", 2)[0] - return strings.HasPrefix(header, "#!") -} - -func decompressIfGzipped(data []byte) []byte { - if reader, err := gzip.NewReader(bytes.NewReader(data)); err == nil { - uncompressedData, err := ioutil.ReadAll(reader) - reader.Close() - if err == nil { - return uncompressedData - } else { - return data - } - } else { - return data - } -} diff --git a/vendor/github.com/coreos/ignition/config/v2_1/config.go b/vendor/github.com/coreos/ignition/config/v2_1/config.go deleted file mode 100644 index 3fd271dd7e9..00000000000 --- a/vendor/github.com/coreos/ignition/config/v2_1/config.go +++ /dev/null @@ -1,68 +0,0 @@ -// Copyright 2015 CoreOS, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package v2_1 - -import ( - "github.com/coreos/go-semver/semver" - "github.com/coreos/ignition/config/shared/errors" - "github.com/coreos/ignition/config/v2_0" - "github.com/coreos/ignition/config/v2_1/types" - "github.com/coreos/ignition/config/validate" - "github.com/coreos/ignition/config/validate/report" - - json "github.com/ajeddeloh/go-json" -) - -func Parse(rawConfig []byte) (types.Config, report.Report, error) { - if isEmpty(rawConfig) { - return types.Config{}, report.Report{}, errors.ErrEmpty - } else if isCloudConfig(rawConfig) { - return types.Config{}, report.Report{}, errors.ErrCloudConfig - } else if isScript(rawConfig) { - return types.Config{}, report.Report{}, errors.ErrScript - } - - var err error - var config types.Config - - err = json.Unmarshal(rawConfig, &config) - - version, semverErr := semver.NewVersion(config.Ignition.Version) - - if err != nil || semverErr != nil || version.LessThan(types.MaxVersion) { - // We can fail unmarshaling if it's an older config. Attempt to parse - // it as such. - config, rpt, err := v2_0.Parse(rawConfig) - if err != nil { - return types.Config{}, rpt, err - } - return TranslateFromV2_0(config), rpt, err - } - - if *version != types.MaxVersion { - return types.Config{}, report.Report{}, errors.ErrUnknownVersion - } - - rpt := validate.ValidateConfig(rawConfig, config) - if rpt.IsFatal() { - return types.Config{}, rpt, errors.ErrInvalid - } - - return config, rpt, nil -} - -func isEmpty(userdata []byte) bool { - return len(userdata) == 0 -} diff --git a/vendor/github.com/coreos/ignition/config/v2_1/translate.go b/vendor/github.com/coreos/ignition/config/v2_1/translate.go deleted file mode 100644 index e6b80dd1222..00000000000 --- a/vendor/github.com/coreos/ignition/config/v2_1/translate.go +++ /dev/null @@ -1,236 +0,0 @@ -// Copyright 2018 CoreOS, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package v2_1 - -import ( - "strings" - - "github.com/coreos/ignition/config/util" - v2_0 "github.com/coreos/ignition/config/v2_0/types" - "github.com/coreos/ignition/config/v2_1/types" -) - -// golang-- -func translateV2_0MkfsOptionsTov2_1OptionSlice(opts v2_0.MkfsOptions) []types.CreateOption { - newOpts := make([]types.CreateOption, len(opts)) - for i, o := range opts { - newOpts[i] = types.CreateOption(o) - } - return newOpts -} - -// golang-- -func translateStringSliceTov2_1SSHAuthorizedKeySlice(keys []string) []types.SSHAuthorizedKey { - newKeys := make([]types.SSHAuthorizedKey, len(keys)) - for i, k := range keys { - newKeys[i] = types.SSHAuthorizedKey(k) - } - return newKeys -} - -// golang-- -func translateStringSliceTov2_1UsercreateGroupSlice(groups []string) []types.UsercreateGroup { - var newGroups []types.UsercreateGroup - for _, g := range groups { - newGroups = append(newGroups, types.UsercreateGroup(g)) - } - return newGroups -} - -func TranslateFromV2_0(old v2_0.Config) types.Config { - translateVerification := func(old v2_0.Verification) types.Verification { - var ver types.Verification - if old.Hash != nil { - // .String() here is a wrapper around MarshalJSON, which will put the hash in quotes - h := strings.Trim(old.Hash.String(), "\"") - ver.Hash = &h - } - return ver - } - translateConfigReference := func(old v2_0.ConfigReference) types.ConfigReference { - return types.ConfigReference{ - Source: old.Source.String(), - Verification: translateVerification(old.Verification), - } - } - - config := types.Config{ - Ignition: types.Ignition{ - Version: types.MaxVersion.String(), - }, - } - - if old.Ignition.Config.Replace != nil { - ref := translateConfigReference(*old.Ignition.Config.Replace) - config.Ignition.Config.Replace = &ref - } - - for _, oldAppend := range old.Ignition.Config.Append { - config.Ignition.Config.Append = - append(config.Ignition.Config.Append, translateConfigReference(oldAppend)) - } - - for _, oldDisk := range old.Storage.Disks { - disk := types.Disk{ - Device: string(oldDisk.Device), - WipeTable: oldDisk.WipeTable, - } - - for _, oldPartition := range oldDisk.Partitions { - disk.Partitions = append(disk.Partitions, types.Partition{ - Label: string(oldPartition.Label), - Number: oldPartition.Number, - Size: int(oldPartition.Size), - Start: int(oldPartition.Start), - TypeGUID: string(oldPartition.TypeGUID), - }) - } - - config.Storage.Disks = append(config.Storage.Disks, disk) - } - - for _, oldArray := range old.Storage.Arrays { - array := types.Raid{ - Name: oldArray.Name, - Level: oldArray.Level, - Spares: oldArray.Spares, - } - - for _, oldDevice := range oldArray.Devices { - array.Devices = append(array.Devices, types.Device(oldDevice)) - } - - config.Storage.Raid = append(config.Storage.Raid, array) - } - - for _, oldFilesystem := range old.Storage.Filesystems { - filesystem := types.Filesystem{ - Name: oldFilesystem.Name, - } - - if oldFilesystem.Mount != nil { - filesystem.Mount = &types.Mount{ - Device: string(oldFilesystem.Mount.Device), - Format: string(oldFilesystem.Mount.Format), - } - - if oldFilesystem.Mount.Create != nil { - filesystem.Mount.Create = &types.Create{ - Force: oldFilesystem.Mount.Create.Force, - Options: translateV2_0MkfsOptionsTov2_1OptionSlice(oldFilesystem.Mount.Create.Options), - } - } - } - - if oldFilesystem.Path != nil { - p := string(*oldFilesystem.Path) - filesystem.Path = &p - } - - config.Storage.Filesystems = append(config.Storage.Filesystems, filesystem) - } - - for _, oldFile := range old.Storage.Files { - file := types.File{ - Node: types.Node{ - Filesystem: oldFile.Filesystem, - Path: string(oldFile.Path), - User: types.NodeUser{ID: util.IntToPtr(oldFile.User.Id)}, - Group: types.NodeGroup{ID: util.IntToPtr(oldFile.Group.Id)}, - }, - FileEmbedded1: types.FileEmbedded1{ - Mode: int(oldFile.Mode), - Contents: types.FileContents{ - Compression: string(oldFile.Contents.Compression), - Source: oldFile.Contents.Source.String(), - Verification: translateVerification(oldFile.Contents.Verification), - }, - }, - } - - config.Storage.Files = append(config.Storage.Files, file) - } - - for _, oldUnit := range old.Systemd.Units { - unit := types.Unit{ - Name: string(oldUnit.Name), - Enable: oldUnit.Enable, - Mask: oldUnit.Mask, - Contents: oldUnit.Contents, - } - - for _, oldDropIn := range oldUnit.DropIns { - unit.Dropins = append(unit.Dropins, types.Dropin{ - Name: string(oldDropIn.Name), - Contents: oldDropIn.Contents, - }) - } - - config.Systemd.Units = append(config.Systemd.Units, unit) - } - - for _, oldUnit := range old.Networkd.Units { - config.Networkd.Units = append(config.Networkd.Units, types.Networkdunit{ - Name: string(oldUnit.Name), - Contents: oldUnit.Contents, - }) - } - - for _, oldUser := range old.Passwd.Users { - user := types.PasswdUser{ - Name: oldUser.Name, - PasswordHash: util.StrToPtr(oldUser.PasswordHash), - SSHAuthorizedKeys: translateStringSliceTov2_1SSHAuthorizedKeySlice(oldUser.SSHAuthorizedKeys), - } - - if oldUser.Create != nil { - var u *int - if oldUser.Create.Uid != nil { - tmp := int(*oldUser.Create.Uid) - u = &tmp - } - user.Create = &types.Usercreate{ - UID: u, - Gecos: oldUser.Create.GECOS, - HomeDir: oldUser.Create.Homedir, - NoCreateHome: oldUser.Create.NoCreateHome, - PrimaryGroup: oldUser.Create.PrimaryGroup, - Groups: translateStringSliceTov2_1UsercreateGroupSlice(oldUser.Create.Groups), - NoUserGroup: oldUser.Create.NoUserGroup, - System: oldUser.Create.System, - NoLogInit: oldUser.Create.NoLogInit, - Shell: oldUser.Create.Shell, - } - } - - config.Passwd.Users = append(config.Passwd.Users, user) - } - - for _, oldGroup := range old.Passwd.Groups { - var g *int - if oldGroup.Gid != nil { - tmp := int(*oldGroup.Gid) - g = &tmp - } - config.Passwd.Groups = append(config.Passwd.Groups, types.PasswdGroup{ - Name: oldGroup.Name, - Gid: g, - PasswordHash: oldGroup.PasswordHash, - System: oldGroup.System, - }) - } - - return config -} diff --git a/vendor/github.com/coreos/ignition/config/v2_1/types/config.go b/vendor/github.com/coreos/ignition/config/v2_1/types/config.go deleted file mode 100644 index 0e83bc6ad10..00000000000 --- a/vendor/github.com/coreos/ignition/config/v2_1/types/config.go +++ /dev/null @@ -1,91 +0,0 @@ -// Copyright 2015 CoreOS, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package types - -import ( - "fmt" - - "github.com/coreos/go-semver/semver" - - "github.com/coreos/ignition/config/validate/report" -) - -var ( - MaxVersion = semver.Version{ - Major: 2, - Minor: 1, - } -) - -func (c Config) Validate() report.Report { - r := report.Report{} - rules := []rule{ - checkFilesFilesystems, - checkDuplicateFilesystems, - } - - for _, rule := range rules { - rule(c, &r) - } - return r -} - -type rule func(cfg Config, report *report.Report) - -func checkNodeFilesystems(node Node, filesystems map[string]struct{}, nodeType string) report.Report { - r := report.Report{} - if node.Filesystem == "" { - // Filesystem was not specified. This is an error, but its handled in types.File's Validate, not here - return r - } - _, ok := filesystems[node.Filesystem] - if !ok { - r.Add(report.Entry{ - Kind: report.EntryWarning, - Message: fmt.Sprintf("%v %q references nonexistent filesystem %q. (This is ok if it is defined in a referenced config)", - nodeType, node.Path, node.Filesystem), - }) - } - return r -} - -func checkFilesFilesystems(cfg Config, r *report.Report) { - filesystems := map[string]struct{}{"root": {}} - for _, filesystem := range cfg.Storage.Filesystems { - filesystems[filesystem.Name] = struct{}{} - } - for _, file := range cfg.Storage.Files { - r.Merge(checkNodeFilesystems(file.Node, filesystems, "File")) - } - for _, link := range cfg.Storage.Links { - r.Merge(checkNodeFilesystems(link.Node, filesystems, "Link")) - } - for _, dir := range cfg.Storage.Directories { - r.Merge(checkNodeFilesystems(dir.Node, filesystems, "Directory")) - } -} - -func checkDuplicateFilesystems(cfg Config, r *report.Report) { - filesystems := map[string]struct{}{"root": {}} - for _, filesystem := range cfg.Storage.Filesystems { - if _, ok := filesystems[filesystem.Name]; ok { - r.Add(report.Entry{ - Kind: report.EntryWarning, - Message: fmt.Sprintf("Filesystem %q shadows exising filesystem definition", filesystem.Name), - }) - } - filesystems[filesystem.Name] = struct{}{} - } -} diff --git a/vendor/github.com/coreos/ignition/config/v2_1/types/disk.go b/vendor/github.com/coreos/ignition/config/v2_1/types/disk.go deleted file mode 100644 index f0af504a171..00000000000 --- a/vendor/github.com/coreos/ignition/config/v2_1/types/disk.go +++ /dev/null @@ -1,128 +0,0 @@ -// Copyright 2016 CoreOS, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package types - -import ( - "github.com/coreos/ignition/config/shared/errors" - "github.com/coreos/ignition/config/validate/report" -) - -func (n Disk) Validate() report.Report { - return report.Report{} -} - -func (n Disk) ValidateDevice() report.Report { - if len(n.Device) == 0 { - return report.ReportFromError(errors.ErrDiskDeviceRequired, report.EntryError) - } - if err := validatePath(string(n.Device)); err != nil { - return report.ReportFromError(err, report.EntryError) - } - return report.Report{} -} - -func (n Disk) ValidatePartitions() report.Report { - r := report.Report{} - if n.partitionNumbersCollide() { - r.Add(report.Entry{ - Message: errors.ErrPartitionNumbersCollide.Error(), - Kind: report.EntryError, - }) - } - if n.partitionsOverlap() { - r.Add(report.Entry{ - Message: errors.ErrPartitionsOverlap.Error(), - Kind: report.EntryError, - }) - } - if n.partitionsMisaligned() { - r.Add(report.Entry{ - Message: errors.ErrPartitionsMisaligned.Error(), - Kind: report.EntryError, - }) - } - // Disks which have no errors at this point will likely succeed in sgdisk - return r -} - -// partitionNumbersCollide returns true if partition numbers in n.Partitions are not unique. -func (n Disk) partitionNumbersCollide() bool { - m := map[int][]Partition{} - for _, p := range n.Partitions { - if p.Number != 0 { - // a number of 0 means next available number, multiple devices can specify this - m[p.Number] = append(m[p.Number], p) - } - } - for _, n := range m { - if len(n) > 1 { - // TODO(vc): return information describing the collision for logging - return true - } - } - return false -} - -// end returns the last sector of a partition. -func (p Partition) end() int { - if p.Size == 0 { - // a size of 0 means "fill available", just return the start as the end for those. - return p.Start - } - return p.Start + p.Size - 1 -} - -// partitionsOverlap returns true if any explicitly dimensioned partitions overlap -func (n Disk) partitionsOverlap() bool { - for _, p := range n.Partitions { - // Starts of 0 are placed by sgdisk into the "largest available block" at that time. - // We aren't going to check those for overlap since we don't have the disk geometry. - if p.Start == 0 { - continue - } - - for _, o := range n.Partitions { - if p == o || o.Start == 0 { - continue - } - - // is p.Start within o? - if p.Start >= o.Start && p.Start <= o.end() { - return true - } - - // is p.end() within o? - if p.end() >= o.Start && p.end() <= o.end() { - return true - } - - // do p.Start and p.end() straddle o? - if p.Start < o.Start && p.end() > o.end() { - return true - } - } - } - return false -} - -// partitionsMisaligned returns true if any of the partitions don't start on a 2048-sector (1MiB) boundary. -func (n Disk) partitionsMisaligned() bool { - for _, p := range n.Partitions { - if (p.Start & (2048 - 1)) != 0 { - return true - } - } - return false -} diff --git a/vendor/github.com/coreos/ignition/config/v2_1/types/filesystem.go b/vendor/github.com/coreos/ignition/config/v2_1/types/filesystem.go deleted file mode 100644 index a2e43ffda1d..00000000000 --- a/vendor/github.com/coreos/ignition/config/v2_1/types/filesystem.go +++ /dev/null @@ -1,144 +0,0 @@ -// Copyright 2016 CoreOS, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package types - -import ( - "github.com/coreos/ignition/config/shared/errors" - "github.com/coreos/ignition/config/validate/report" -) - -func (f Filesystem) Validate() report.Report { - r := report.Report{} - if f.Mount == nil && f.Path == nil { - r.Add(report.Entry{ - Message: errors.ErrFilesystemNoMountPath.Error(), - Kind: report.EntryError, - }) - } - if f.Mount != nil { - if f.Path != nil { - r.Add(report.Entry{ - Message: errors.ErrFilesystemMountAndPath.Error(), - Kind: report.EntryError, - }) - } - if f.Mount.Create != nil { - if f.Mount.WipeFilesystem { - r.Add(report.Entry{ - Message: errors.ErrUsedCreateAndWipeFilesystem.Error(), - Kind: report.EntryError, - }) - } - if len(f.Mount.Options) > 0 { - r.Add(report.Entry{ - Message: errors.ErrUsedCreateAndMountOpts.Error(), - Kind: report.EntryError, - }) - } - r.Add(report.Entry{ - Message: errors.ErrWarningCreateDeprecated.Error(), - Kind: report.EntryWarning, - }) - } - } - return r -} - -func (f Filesystem) ValidatePath() report.Report { - r := report.Report{} - if f.Path != nil && validatePath(*f.Path) != nil { - r.Add(report.Entry{ - Message: errors.ErrPathRelative.Error(), - Kind: report.EntryError, - }) - } - return r -} - -func (m Mount) Validate() report.Report { - r := report.Report{} - switch m.Format { - case "ext4", "btrfs", "xfs", "swap", "vfat": - default: - r.Add(report.Entry{ - Message: errors.ErrFilesystemInvalidFormat.Error(), - Kind: report.EntryError, - }) - } - return r -} - -func (m Mount) ValidateDevice() report.Report { - r := report.Report{} - if err := validatePath(m.Device); err != nil { - r.Add(report.Entry{ - Message: err.Error(), - Kind: report.EntryError, - }) - } - return r -} - -func (m Mount) ValidateLabel() report.Report { - r := report.Report{} - if m.Label == nil { - return r - } - switch m.Format { - case "ext4": - if len(*m.Label) > 16 { - // source: man mkfs.ext4 - r.Add(report.Entry{ - Message: errors.ErrExt4LabelTooLong.Error(), - Kind: report.EntryError, - }) - } - case "btrfs": - if len(*m.Label) > 256 { - // source: man mkfs.btrfs - r.Add(report.Entry{ - Message: errors.ErrBtrfsLabelTooLong.Error(), - Kind: report.EntryError, - }) - } - case "xfs": - if len(*m.Label) > 12 { - // source: man mkfs.xfs - r.Add(report.Entry{ - Message: errors.ErrXfsLabelTooLong.Error(), - Kind: report.EntryError, - }) - } - case "swap": - // mkswap's man page does not state a limit on label size, but through - // experimentation it appears that mkswap will truncate long labels to - // 15 characters, so let's enforce that. - if len(*m.Label) > 15 { - r.Add(report.Entry{ - Message: errors.ErrSwapLabelTooLong.Error(), - Kind: report.EntryError, - }) - } - case "vfat": - if len(*m.Label) > 11 { - // source: man mkfs.fat - r.Add(report.Entry{ - Message: errors.ErrVfatLabelTooLong.Error(), - Kind: report.EntryError, - }) - } - } - return r -} diff --git a/vendor/github.com/coreos/ignition/config/v2_1/types/link.go b/vendor/github.com/coreos/ignition/config/v2_1/types/link.go deleted file mode 100644 index f0284425282..00000000000 --- a/vendor/github.com/coreos/ignition/config/v2_1/types/link.go +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright 2017 CoreOS, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package types - -import ( - "github.com/coreos/ignition/config/validate/report" -) - -func (s LinkEmbedded1) ValidateTarget() report.Report { - r := report.Report{} - if !s.Hard { - err := validatePath(s.Target) - if err != nil { - r.Add(report.Entry{ - Message: err.Error(), - Kind: report.EntryError, - }) - } - } - return r -} diff --git a/vendor/github.com/coreos/ignition/config/v2_1/types/mode.go b/vendor/github.com/coreos/ignition/config/v2_1/types/mode.go deleted file mode 100644 index 12d4188e95f..00000000000 --- a/vendor/github.com/coreos/ignition/config/v2_1/types/mode.go +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright 2017 CoreOS, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package types - -import ( - "github.com/coreos/ignition/config/shared/errors" -) - -func validateMode(m int) error { - if m < 0 || m > 07777 { - return errors.ErrFileIllegalMode - } - return nil -} diff --git a/vendor/github.com/coreos/ignition/config/v2_1/types/node.go b/vendor/github.com/coreos/ignition/config/v2_1/types/node.go deleted file mode 100644 index 50badfdfb92..00000000000 --- a/vendor/github.com/coreos/ignition/config/v2_1/types/node.go +++ /dev/null @@ -1,73 +0,0 @@ -// Copyright 2016 CoreOS, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package types - -import ( - "path/filepath" - - "github.com/coreos/ignition/config/shared/errors" - "github.com/coreos/ignition/config/validate/report" -) - -func (n Node) ValidateFilesystem() report.Report { - r := report.Report{} - if n.Filesystem == "" { - r.Add(report.Entry{ - Message: errors.ErrNoFilesystem.Error(), - Kind: report.EntryError, - }) - } - return r -} - -func (n Node) ValidatePath() report.Report { - r := report.Report{} - if err := validatePath(n.Path); err != nil { - r.Add(report.Entry{ - Message: err.Error(), - Kind: report.EntryError, - }) - } - return r -} - -func (n Node) Depth() int { - count := 0 - for p := filepath.Clean(string(n.Path)); p != "/"; count++ { - p = filepath.Dir(p) - } - return count -} - -func (nu NodeUser) Validate() report.Report { - r := report.Report{} - if nu.ID != nil && nu.Name != "" { - r.Add(report.Entry{ - Message: errors.ErrBothIDAndNameSet.Error(), - Kind: report.EntryError, - }) - } - return r -} -func (ng NodeGroup) Validate() report.Report { - r := report.Report{} - if ng.ID != nil && ng.Name != "" { - r.Add(report.Entry{ - Message: errors.ErrBothIDAndNameSet.Error(), - Kind: report.EntryError, - }) - } - return r -} diff --git a/vendor/github.com/coreos/ignition/config/v2_1/types/partition.go b/vendor/github.com/coreos/ignition/config/v2_1/types/partition.go deleted file mode 100644 index 084dce7ce23..00000000000 --- a/vendor/github.com/coreos/ignition/config/v2_1/types/partition.go +++ /dev/null @@ -1,77 +0,0 @@ -// Copyright 2016 CoreOS, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package types - -import ( - "fmt" - "regexp" - "strings" - - "github.com/coreos/ignition/config/shared/errors" - "github.com/coreos/ignition/config/validate/report" -) - -const ( - guidRegexStr = "^(|[[:xdigit:]]{8}-[[:xdigit:]]{4}-[[:xdigit:]]{4}-[[:xdigit:]]{4}-[[:xdigit:]]{12})$" -) - -func (p Partition) ValidateLabel() report.Report { - r := report.Report{} - // http://en.wikipedia.org/wiki/GUID_Partition_Table#Partition_entries: - // 56 (0x38) 72 bytes Partition name (36 UTF-16LE code units) - - // XXX(vc): note GPT calls it a name, we're using label for consistency - // with udev naming /dev/disk/by-partlabel/*. - if len(p.Label) > 36 { - r.Add(report.Entry{ - Message: errors.ErrLabelTooLong.Error(), - Kind: report.EntryError, - }) - } - - // sgdisk uses colons for delimitting compound arguments and does not allow escaping them. - if strings.Contains(p.Label, ":") { - r.Add(report.Entry{ - Message: errors.ErrLabelContainsColon.Error(), - Kind: report.EntryWarning, - }) - } - return r -} - -func (p Partition) ValidateTypeGUID() report.Report { - return validateGUID(p.TypeGUID) -} - -func (p Partition) ValidateGUID() report.Report { - return validateGUID(p.GUID) -} - -func validateGUID(guid string) report.Report { - r := report.Report{} - ok, err := regexp.MatchString(guidRegexStr, guid) - if err != nil { - r.Add(report.Entry{ - Message: fmt.Sprintf("error matching guid regexp: %v", err), - Kind: report.EntryError, - }) - } else if !ok { - r.Add(report.Entry{ - Message: errors.ErrDoesntMatchGUIDRegex.Error(), - Kind: report.EntryError, - }) - } - return r -} diff --git a/vendor/github.com/coreos/ignition/config/v2_1/types/passwd.go b/vendor/github.com/coreos/ignition/config/v2_1/types/passwd.go deleted file mode 100644 index 10508c56c06..00000000000 --- a/vendor/github.com/coreos/ignition/config/v2_1/types/passwd.go +++ /dev/null @@ -1,67 +0,0 @@ -// Copyright 2017 CoreOS, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package types - -import ( - "github.com/coreos/ignition/config/shared/errors" - "github.com/coreos/ignition/config/validate/report" -) - -func (p PasswdUser) Validate() report.Report { - r := report.Report{} - if p.Create != nil { - r.Add(report.Entry{ - Message: errors.ErrPasswdCreateDeprecated.Error(), - Kind: report.EntryWarning, - }) - addErr := func(err error) { - r.Add(report.Entry{ - Message: err.Error(), - Kind: report.EntryError, - }) - } - if p.Gecos != "" { - addErr(errors.ErrPasswdCreateAndGecos) - } - if len(p.Groups) > 0 { - addErr(errors.ErrPasswdCreateAndGroups) - } - if p.HomeDir != "" { - addErr(errors.ErrPasswdCreateAndHomeDir) - } - if p.NoCreateHome { - addErr(errors.ErrPasswdCreateAndNoCreateHome) - } - if p.NoLogInit { - addErr(errors.ErrPasswdCreateAndNoLogInit) - } - if p.NoUserGroup { - addErr(errors.ErrPasswdCreateAndNoUserGroup) - } - if p.PrimaryGroup != "" { - addErr(errors.ErrPasswdCreateAndPrimaryGroup) - } - if p.Shell != "" { - addErr(errors.ErrPasswdCreateAndShell) - } - if p.System { - addErr(errors.ErrPasswdCreateAndSystem) - } - if p.UID != nil { - addErr(errors.ErrPasswdCreateAndUID) - } - } - return r -} diff --git a/vendor/github.com/coreos/ignition/config/v2_1/types/path.go b/vendor/github.com/coreos/ignition/config/v2_1/types/path.go deleted file mode 100644 index 780607c31ab..00000000000 --- a/vendor/github.com/coreos/ignition/config/v2_1/types/path.go +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright 2016 CoreOS, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package types - -import ( - "path" - - "github.com/coreos/ignition/config/shared/errors" -) - -func validatePath(p string) error { - if !path.IsAbs(p) { - return errors.ErrPathRelative - } - return nil -} diff --git a/vendor/github.com/coreos/ignition/config/v2_1/types/raid.go b/vendor/github.com/coreos/ignition/config/v2_1/types/raid.go deleted file mode 100644 index 3aceaa9faa1..00000000000 --- a/vendor/github.com/coreos/ignition/config/v2_1/types/raid.go +++ /dev/null @@ -1,57 +0,0 @@ -// Copyright 2016 CoreOS, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package types - -import ( - "github.com/coreos/ignition/config/shared/errors" - "github.com/coreos/ignition/config/validate/report" -) - -func (n Raid) ValidateLevel() report.Report { - r := report.Report{} - switch n.Level { - case "linear", "raid0", "0", "stripe": - if n.Spares != 0 { - r.Add(report.Entry{ - Message: errors.ErrSparesUnsupportedForLevel.Error(), - Kind: report.EntryError, - }) - } - case "raid1", "1", "mirror": - case "raid4", "4": - case "raid5", "5": - case "raid6", "6": - case "raid10", "10": - default: - r.Add(report.Entry{ - Message: errors.ErrUnrecognizedRaidLevel.Error(), - Kind: report.EntryError, - }) - } - return r -} - -func (n Raid) ValidateDevices() report.Report { - r := report.Report{} - for _, d := range n.Devices { - if err := validatePath(string(d)); err != nil { - r.Add(report.Entry{ - Message: errors.ErrPathRelative.Error(), - Kind: report.EntryError, - }) - } - } - return r -} diff --git a/vendor/github.com/coreos/ignition/config/v2_1/types/schema.go b/vendor/github.com/coreos/ignition/config/v2_1/types/schema.go deleted file mode 100644 index e0caed5e6e2..00000000000 --- a/vendor/github.com/coreos/ignition/config/v2_1/types/schema.go +++ /dev/null @@ -1,221 +0,0 @@ -package types - -// generated by "schematyper --package=types schema/ignition.json -o config/types/schema.go --root-type=Config" -- DO NOT EDIT - -type Config struct { - Ignition Ignition `json:"ignition"` - Networkd Networkd `json:"networkd,omitempty"` - Passwd Passwd `json:"passwd,omitempty"` - Storage Storage `json:"storage,omitempty"` - Systemd Systemd `json:"systemd,omitempty"` -} - -type ConfigReference struct { - Source string `json:"source,omitempty"` - Verification Verification `json:"verification,omitempty"` -} - -type Create struct { - Force bool `json:"force,omitempty"` - Options []CreateOption `json:"options,omitempty"` -} - -type CreateOption string - -type Device string - -type Directory struct { - Node - DirectoryEmbedded1 -} - -type DirectoryEmbedded1 struct { - Mode int `json:"mode,omitempty"` -} - -type Disk struct { - Device string `json:"device,omitempty"` - Partitions []Partition `json:"partitions,omitempty"` - WipeTable bool `json:"wipeTable,omitempty"` -} - -type Dropin struct { - Contents string `json:"contents,omitempty"` - Name string `json:"name,omitempty"` -} - -type File struct { - Node - FileEmbedded1 -} - -type FileContents struct { - Compression string `json:"compression,omitempty"` - Source string `json:"source,omitempty"` - Verification Verification `json:"verification,omitempty"` -} - -type FileEmbedded1 struct { - Contents FileContents `json:"contents,omitempty"` - Mode int `json:"mode,omitempty"` -} - -type Filesystem struct { - Mount *Mount `json:"mount,omitempty"` - Name string `json:"name,omitempty"` - Path *string `json:"path,omitempty"` -} - -type Ignition struct { - Config IgnitionConfig `json:"config,omitempty"` - Timeouts Timeouts `json:"timeouts,omitempty"` - Version string `json:"version,omitempty"` -} - -type IgnitionConfig struct { - Append []ConfigReference `json:"append,omitempty"` - Replace *ConfigReference `json:"replace,omitempty"` -} - -type Link struct { - Node - LinkEmbedded1 -} - -type LinkEmbedded1 struct { - Hard bool `json:"hard,omitempty"` - Target string `json:"target,omitempty"` -} - -type Mount struct { - Create *Create `json:"create,omitempty"` - Device string `json:"device,omitempty"` - Format string `json:"format,omitempty"` - Label *string `json:"label,omitempty"` - Options []MountOption `json:"options,omitempty"` - UUID *string `json:"uuid,omitempty"` - WipeFilesystem bool `json:"wipeFilesystem,omitempty"` -} - -type MountOption string - -type Networkd struct { - Units []Networkdunit `json:"units,omitempty"` -} - -type Networkdunit struct { - Contents string `json:"contents,omitempty"` - Name string `json:"name,omitempty"` -} - -type Node struct { - Filesystem string `json:"filesystem,omitempty"` - Group NodeGroup `json:"group,omitempty"` - Path string `json:"path,omitempty"` - User NodeUser `json:"user,omitempty"` -} - -type NodeGroup struct { - ID *int `json:"id,omitempty"` - Name string `json:"name,omitempty"` -} - -type NodeUser struct { - ID *int `json:"id,omitempty"` - Name string `json:"name,omitempty"` -} - -type Partition struct { - GUID string `json:"guid,omitempty"` - Label string `json:"label,omitempty"` - Number int `json:"number,omitempty"` - Size int `json:"size,omitempty"` - Start int `json:"start,omitempty"` - TypeGUID string `json:"typeGuid,omitempty"` -} - -type Passwd struct { - Groups []PasswdGroup `json:"groups,omitempty"` - Users []PasswdUser `json:"users,omitempty"` -} - -type PasswdGroup struct { - Gid *int `json:"gid,omitempty"` - Name string `json:"name,omitempty"` - PasswordHash string `json:"passwordHash,omitempty"` - System bool `json:"system,omitempty"` -} - -type PasswdUser struct { - Create *Usercreate `json:"create,omitempty"` - Gecos string `json:"gecos,omitempty"` - Groups []PasswdUserGroup `json:"groups,omitempty"` - HomeDir string `json:"homeDir,omitempty"` - Name string `json:"name,omitempty"` - NoCreateHome bool `json:"noCreateHome,omitempty"` - NoLogInit bool `json:"noLogInit,omitempty"` - NoUserGroup bool `json:"noUserGroup,omitempty"` - PasswordHash *string `json:"passwordHash,omitempty"` - PrimaryGroup string `json:"primaryGroup,omitempty"` - SSHAuthorizedKeys []SSHAuthorizedKey `json:"sshAuthorizedKeys,omitempty"` - Shell string `json:"shell,omitempty"` - System bool `json:"system,omitempty"` - UID *int `json:"uid,omitempty"` -} - -type PasswdUserGroup string - -type Raid struct { - Devices []Device `json:"devices,omitempty"` - Level string `json:"level,omitempty"` - Name string `json:"name,omitempty"` - Spares int `json:"spares,omitempty"` -} - -type SSHAuthorizedKey string - -type Storage struct { - Directories []Directory `json:"directories,omitempty"` - Disks []Disk `json:"disks,omitempty"` - Files []File `json:"files,omitempty"` - Filesystems []Filesystem `json:"filesystems,omitempty"` - Links []Link `json:"links,omitempty"` - Raid []Raid `json:"raid,omitempty"` -} - -type Systemd struct { - Units []Unit `json:"units,omitempty"` -} - -type Timeouts struct { - HTTPResponseHeaders *int `json:"httpResponseHeaders,omitempty"` - HTTPTotal *int `json:"httpTotal,omitempty"` -} - -type Unit struct { - Contents string `json:"contents,omitempty"` - Dropins []Dropin `json:"dropins,omitempty"` - Enable bool `json:"enable,omitempty"` - Enabled *bool `json:"enabled,omitempty"` - Mask bool `json:"mask,omitempty"` - Name string `json:"name,omitempty"` -} - -type Usercreate struct { - Gecos string `json:"gecos,omitempty"` - Groups []UsercreateGroup `json:"groups,omitempty"` - HomeDir string `json:"homeDir,omitempty"` - NoCreateHome bool `json:"noCreateHome,omitempty"` - NoLogInit bool `json:"noLogInit,omitempty"` - NoUserGroup bool `json:"noUserGroup,omitempty"` - PrimaryGroup string `json:"primaryGroup,omitempty"` - Shell string `json:"shell,omitempty"` - System bool `json:"system,omitempty"` - UID *int `json:"uid,omitempty"` -} - -type UsercreateGroup string - -type Verification struct { - Hash *string `json:"hash,omitempty"` -} diff --git a/vendor/github.com/coreos/ignition/config/v2_1/types/url.go b/vendor/github.com/coreos/ignition/config/v2_1/types/url.go deleted file mode 100644 index 0fdc4a170ef..00000000000 --- a/vendor/github.com/coreos/ignition/config/v2_1/types/url.go +++ /dev/null @@ -1,45 +0,0 @@ -// Copyright 2016 CoreOS, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package types - -import ( - "net/url" - - "github.com/coreos/ignition/config/shared/errors" - "github.com/vincent-petithory/dataurl" -) - -func validateURL(s string) error { - // Empty url is valid, indicates an empty file - if s == "" { - return nil - } - u, err := url.Parse(s) - if err != nil { - return errors.ErrInvalidUrl - } - - switch u.Scheme { - case "http", "https", "oem", "tftp", "s3": - return nil - case "data": - if _, err := dataurl.DecodeString(s); err != nil { - return err - } - return nil - default: - return errors.ErrInvalidScheme - } -} diff --git a/vendor/github.com/coreos/ignition/config/v2_2/append.go b/vendor/github.com/coreos/ignition/config/v2_2/append.go deleted file mode 100644 index cf28f40905d..00000000000 --- a/vendor/github.com/coreos/ignition/config/v2_2/append.go +++ /dev/null @@ -1,76 +0,0 @@ -// Copyright 2016 CoreOS, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package v2_2 - -import ( - "reflect" - - "github.com/coreos/ignition/config/v2_2/types" -) - -// Append appends newConfig to oldConfig and returns the result. Appending one -// config to another is accomplished by iterating over every field in the -// config structure, appending slices, recursively appending structs, and -// overwriting old values with new values for all other types. -func Append(oldConfig, newConfig types.Config) types.Config { - vOld := reflect.ValueOf(oldConfig) - vNew := reflect.ValueOf(newConfig) - - vResult := appendStruct(vOld, vNew) - - return vResult.Interface().(types.Config) -} - -// appendStruct is an internal helper function to AppendConfig. Given two values -// of structures (assumed to be the same type), recursively iterate over every -// field in the struct, appending slices, recursively appending structs, and -// overwriting old values with the new for all other types. Some individual -// struct fields have alternate merge strategies, determined by the field name. -// Currently these fields are "ignition.version", which uses the old value, and -// "ignition.config" which uses the new value. -func appendStruct(vOld, vNew reflect.Value) reflect.Value { - tOld := vOld.Type() - vRes := reflect.New(tOld) - - for i := 0; i < tOld.NumField(); i++ { - vfOld := vOld.Field(i) - vfNew := vNew.Field(i) - vfRes := vRes.Elem().Field(i) - - switch tOld.Field(i).Name { - case "Version": - vfRes.Set(vfOld) - continue - case "Config": - vfRes.Set(vfNew) - continue - } - - switch vfOld.Type().Kind() { - case reflect.Struct: - vfRes.Set(appendStruct(vfOld, vfNew)) - case reflect.Slice: - vfRes.Set(reflect.AppendSlice(vfOld, vfNew)) - default: - if vfNew.Kind() == reflect.Ptr && vfNew.IsNil() { - vfRes.Set(vfOld) - } else { - vfRes.Set(vfNew) - } - } - } - - return vRes.Elem() -} diff --git a/vendor/github.com/coreos/ignition/config/v2_2/cloudinit.go b/vendor/github.com/coreos/ignition/config/v2_2/cloudinit.go deleted file mode 100644 index 36a54393245..00000000000 --- a/vendor/github.com/coreos/ignition/config/v2_2/cloudinit.go +++ /dev/null @@ -1,53 +0,0 @@ -// Copyright 2015 CoreOS, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// These functions are copied from github.com/coreos/coreos-cloudinit/config. - -package v2_2 - -import ( - "bytes" - "compress/gzip" - "io/ioutil" - "strings" - "unicode" -) - -func isCloudConfig(userdata []byte) bool { - header := strings.SplitN(string(decompressIfGzipped(userdata)), "\n", 2)[0] - - // Trim trailing whitespaces - header = strings.TrimRightFunc(header, unicode.IsSpace) - - return (header == "#cloud-config") -} - -func isScript(userdata []byte) bool { - header := strings.SplitN(string(decompressIfGzipped(userdata)), "\n", 2)[0] - return strings.HasPrefix(header, "#!") -} - -func decompressIfGzipped(data []byte) []byte { - if reader, err := gzip.NewReader(bytes.NewReader(data)); err == nil { - uncompressedData, err := ioutil.ReadAll(reader) - reader.Close() - if err == nil { - return uncompressedData - } else { - return data - } - } else { - return data - } -} diff --git a/vendor/github.com/coreos/ignition/config/v2_2/config.go b/vendor/github.com/coreos/ignition/config/v2_2/config.go deleted file mode 100644 index c934a9e4a38..00000000000 --- a/vendor/github.com/coreos/ignition/config/v2_2/config.go +++ /dev/null @@ -1,71 +0,0 @@ -// Copyright 2015 CoreOS, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package v2_2 - -import ( - "github.com/coreos/ignition/config/shared/errors" - "github.com/coreos/ignition/config/v2_1" - "github.com/coreos/ignition/config/v2_2/types" - "github.com/coreos/ignition/config/validate" - "github.com/coreos/ignition/config/validate/report" - - json "github.com/ajeddeloh/go-json" - "github.com/coreos/go-semver/semver" -) - -// Parse parses the raw config into a types.Config struct and generates a report of any -// errors, warnings, info, and deprecations it encountered. Unlike config.Parse, -// it does not attempt to translate the config. -func Parse(rawConfig []byte) (types.Config, report.Report, error) { - if isEmpty(rawConfig) { - return types.Config{}, report.Report{}, errors.ErrEmpty - } else if isCloudConfig(rawConfig) { - return types.Config{}, report.Report{}, errors.ErrCloudConfig - } else if isScript(rawConfig) { - return types.Config{}, report.Report{}, errors.ErrScript - } - - var err error - var config types.Config - - err = json.Unmarshal(rawConfig, &config) - - version, semverErr := semver.NewVersion(config.Ignition.Version) - - if err != nil || semverErr != nil || version.LessThan(types.MaxVersion) { - // We can fail unmarshaling if it's an older config. Attempt to parse - // it as such. - config, rpt, err := v2_1.Parse(rawConfig) - if err != nil { - return types.Config{}, rpt, err - } - return TranslateFromV2_1(config), rpt, err - } - - if *version != types.MaxVersion { - return types.Config{}, report.Report{}, errors.ErrUnknownVersion - } - - rpt := validate.ValidateConfig(rawConfig, config) - if rpt.IsFatal() { - return types.Config{}, rpt, errors.ErrInvalid - } - - return config, rpt, nil -} - -func isEmpty(userdata []byte) bool { - return len(userdata) == 0 -} diff --git a/vendor/github.com/coreos/ignition/config/v2_2/translate.go b/vendor/github.com/coreos/ignition/config/v2_2/translate.go deleted file mode 100644 index 56a6b33fc94..00000000000 --- a/vendor/github.com/coreos/ignition/config/v2_2/translate.go +++ /dev/null @@ -1,354 +0,0 @@ -// Copyright 2018 CoreOS, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package v2_2 - -import ( - "github.com/coreos/ignition/config/util" - v2_1 "github.com/coreos/ignition/config/v2_1/types" - "github.com/coreos/ignition/config/v2_2/types" -) - -// golang-- -func translateStringSliceToV2_2SSHAuthorizedKeySlice(keys []string) []types.SSHAuthorizedKey { - newKeys := make([]types.SSHAuthorizedKey, len(keys)) - for i, k := range keys { - newKeys[i] = types.SSHAuthorizedKey(k) - } - return newKeys -} - -// golang-- -func translateStringSliceToV2_2UsercreateGroupSlice(groups []string) []types.UsercreateGroup { - var newGroups []types.UsercreateGroup - for _, g := range groups { - newGroups = append(newGroups, types.UsercreateGroup(g)) - } - return newGroups -} - -func TranslateFromV2_1(old v2_1.Config) types.Config { - translateConfigReference := func(old *v2_1.ConfigReference) *types.ConfigReference { - if old == nil { - return nil - } - return &types.ConfigReference{ - Source: old.Source, - Verification: types.Verification{ - Hash: old.Verification.Hash, - }, - } - } - translateConfigReferenceSlice := func(old []v2_1.ConfigReference) []types.ConfigReference { - var res []types.ConfigReference - for _, c := range old { - res = append(res, *translateConfigReference(&c)) - } - return res - } - translateNetworkdUnitSlice := func(old []v2_1.Networkdunit) []types.Networkdunit { - var res []types.Networkdunit - for _, u := range old { - res = append(res, types.Networkdunit{ - Contents: u.Contents, - Name: u.Name, - }) - } - return res - } - translatePasswdGroupSlice := func(old []v2_1.PasswdGroup) []types.PasswdGroup { - var res []types.PasswdGroup - for _, g := range old { - res = append(res, types.PasswdGroup{ - Gid: g.Gid, - Name: g.Name, - PasswordHash: g.PasswordHash, - System: g.System, - }) - } - return res - } - translatePasswdUsercreateGroupSlice := func(old []v2_1.UsercreateGroup) []types.UsercreateGroup { - var res []types.UsercreateGroup - for _, g := range old { - res = append(res, types.UsercreateGroup(g)) - } - return res - } - translatePasswdUsercreate := func(old *v2_1.Usercreate) *types.Usercreate { - if old == nil { - return nil - } - return &types.Usercreate{ - Gecos: old.Gecos, - Groups: translatePasswdUsercreateGroupSlice(old.Groups), - HomeDir: old.HomeDir, - NoCreateHome: old.NoCreateHome, - NoLogInit: old.NoLogInit, - NoUserGroup: old.NoUserGroup, - PrimaryGroup: old.PrimaryGroup, - Shell: old.Shell, - System: old.System, - UID: old.UID, - } - } - translatePasswdUserGroupSlice := func(old []v2_1.PasswdUserGroup) []types.Group { - var res []types.Group - for _, g := range old { - res = append(res, types.Group(g)) - } - return res - } - translatePasswdSSHAuthorizedKeySlice := func(old []v2_1.SSHAuthorizedKey) []types.SSHAuthorizedKey { - res := make([]types.SSHAuthorizedKey, len(old)) - for i, k := range old { - res[i] = types.SSHAuthorizedKey(k) - } - return res - } - translatePasswdUserSlice := func(old []v2_1.PasswdUser) []types.PasswdUser { - var res []types.PasswdUser - for _, u := range old { - res = append(res, types.PasswdUser{ - Create: translatePasswdUsercreate(u.Create), - Gecos: u.Gecos, - Groups: translatePasswdUserGroupSlice(u.Groups), - HomeDir: u.HomeDir, - Name: u.Name, - NoCreateHome: u.NoCreateHome, - NoLogInit: u.NoLogInit, - NoUserGroup: u.NoUserGroup, - PasswordHash: u.PasswordHash, - PrimaryGroup: u.PrimaryGroup, - SSHAuthorizedKeys: translatePasswdSSHAuthorizedKeySlice(u.SSHAuthorizedKeys), - Shell: u.Shell, - System: u.System, - UID: u.UID, - }) - } - return res - } - translateNodeGroup := func(old v2_1.NodeGroup) *types.NodeGroup { - return &types.NodeGroup{ - ID: old.ID, - Name: old.Name, - } - } - translateNodeUser := func(old v2_1.NodeUser) *types.NodeUser { - return &types.NodeUser{ - ID: old.ID, - Name: old.Name, - } - } - translateNode := func(old v2_1.Node) types.Node { - return types.Node{ - Filesystem: old.Filesystem, - Group: translateNodeGroup(old.Group), - Path: old.Path, - User: translateNodeUser(old.User), - } - } - translateDirectorySlice := func(old []v2_1.Directory) []types.Directory { - var res []types.Directory - for _, x := range old { - res = append(res, types.Directory{ - Node: translateNode(x.Node), - DirectoryEmbedded1: types.DirectoryEmbedded1{ - Mode: util.IntToPtr(x.DirectoryEmbedded1.Mode), - }, - }) - } - return res - } - translatePartitionSlice := func(old []v2_1.Partition) []types.Partition { - var res []types.Partition - for _, x := range old { - res = append(res, types.Partition{ - GUID: x.GUID, - Label: x.Label, - Number: x.Number, - Size: x.Size, - Start: x.Start, - TypeGUID: x.TypeGUID, - }) - } - return res - } - translateDiskSlice := func(old []v2_1.Disk) []types.Disk { - var res []types.Disk - for _, x := range old { - res = append(res, types.Disk{ - Device: x.Device, - Partitions: translatePartitionSlice(x.Partitions), - WipeTable: x.WipeTable, - }) - } - return res - } - translateFileSlice := func(old []v2_1.File) []types.File { - var res []types.File - for _, x := range old { - res = append(res, types.File{ - Node: translateNode(x.Node), - FileEmbedded1: types.FileEmbedded1{ - Contents: types.FileContents{ - Compression: x.Contents.Compression, - Source: x.Contents.Source, - Verification: types.Verification{ - Hash: x.Contents.Verification.Hash, - }, - }, - Mode: util.IntToPtr(x.Mode), - }, - }) - } - return res - } - translateMountCreateOptionSlice := func(old []v2_1.CreateOption) []types.CreateOption { - var res []types.CreateOption - for _, x := range old { - res = append(res, types.CreateOption(x)) - } - return res - } - translateMountCreate := func(old *v2_1.Create) *types.Create { - if old == nil { - return nil - } - return &types.Create{ - Force: old.Force, - Options: translateMountCreateOptionSlice(old.Options), - } - } - translateMountOptionSlice := func(old []v2_1.MountOption) []types.MountOption { - var res []types.MountOption - for _, x := range old { - res = append(res, types.MountOption(x)) - } - return res - } - translateMount := func(old *v2_1.Mount) *types.Mount { - if old == nil { - return nil - } - return &types.Mount{ - Create: translateMountCreate(old.Create), - Device: old.Device, - Format: old.Format, - Label: old.Label, - Options: translateMountOptionSlice(old.Options), - UUID: old.UUID, - WipeFilesystem: old.WipeFilesystem, - } - } - translateFilesystemSlice := func(old []v2_1.Filesystem) []types.Filesystem { - var res []types.Filesystem - for _, x := range old { - res = append(res, types.Filesystem{ - Mount: translateMount(x.Mount), - Name: x.Name, - Path: x.Path, - }) - } - return res - } - translateLinkSlice := func(old []v2_1.Link) []types.Link { - var res []types.Link - for _, x := range old { - res = append(res, types.Link{ - Node: translateNode(x.Node), - LinkEmbedded1: types.LinkEmbedded1{ - Hard: x.Hard, - Target: x.Target, - }, - }) - } - return res - } - translateDeviceSlice := func(old []v2_1.Device) []types.Device { - var res []types.Device - for _, x := range old { - res = append(res, types.Device(x)) - } - return res - } - translateRaidSlice := func(old []v2_1.Raid) []types.Raid { - var res []types.Raid - for _, x := range old { - res = append(res, types.Raid{ - Devices: translateDeviceSlice(x.Devices), - Level: x.Level, - Name: x.Name, - Spares: x.Spares, - }) - } - return res - } - translateSystemdDropinSlice := func(old []v2_1.Dropin) []types.SystemdDropin { - var res []types.SystemdDropin - for _, x := range old { - res = append(res, types.SystemdDropin{ - Contents: x.Contents, - Name: x.Name, - }) - } - return res - } - translateSystemdUnitSlice := func(old []v2_1.Unit) []types.Unit { - var res []types.Unit - for _, x := range old { - res = append(res, types.Unit{ - Contents: x.Contents, - Dropins: translateSystemdDropinSlice(x.Dropins), - Enable: x.Enable, - Enabled: x.Enabled, - Mask: x.Mask, - Name: x.Name, - }) - } - return res - } - config := types.Config{ - Ignition: types.Ignition{ - Version: types.MaxVersion.String(), - Timeouts: types.Timeouts{ - HTTPResponseHeaders: old.Ignition.Timeouts.HTTPResponseHeaders, - HTTPTotal: old.Ignition.Timeouts.HTTPTotal, - }, - Config: types.IgnitionConfig{ - Replace: translateConfigReference(old.Ignition.Config.Replace), - Append: translateConfigReferenceSlice(old.Ignition.Config.Append), - }, - }, - Networkd: types.Networkd{ - Units: translateNetworkdUnitSlice(old.Networkd.Units), - }, - Passwd: types.Passwd{ - Groups: translatePasswdGroupSlice(old.Passwd.Groups), - Users: translatePasswdUserSlice(old.Passwd.Users), - }, - Storage: types.Storage{ - Directories: translateDirectorySlice(old.Storage.Directories), - Disks: translateDiskSlice(old.Storage.Disks), - Files: translateFileSlice(old.Storage.Files), - Filesystems: translateFilesystemSlice(old.Storage.Filesystems), - Links: translateLinkSlice(old.Storage.Links), - Raid: translateRaidSlice(old.Storage.Raid), - }, - Systemd: types.Systemd{ - Units: translateSystemdUnitSlice(old.Systemd.Units), - }, - } - return config -} diff --git a/vendor/github.com/coreos/ignition/config/v2_2/types/config.go b/vendor/github.com/coreos/ignition/config/v2_2/types/config.go deleted file mode 100644 index b1fcfcd9911..00000000000 --- a/vendor/github.com/coreos/ignition/config/v2_2/types/config.go +++ /dev/null @@ -1,91 +0,0 @@ -// Copyright 2015 CoreOS, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package types - -import ( - "fmt" - - "github.com/coreos/go-semver/semver" - - "github.com/coreos/ignition/config/validate/report" -) - -var ( - MaxVersion = semver.Version{ - Major: 2, - Minor: 2, - } -) - -func (c Config) Validate() report.Report { - r := report.Report{} - rules := []rule{ - checkFilesFilesystems, - checkDuplicateFilesystems, - } - - for _, rule := range rules { - rule(c, &r) - } - return r -} - -type rule func(cfg Config, report *report.Report) - -func checkNodeFilesystems(node Node, filesystems map[string]struct{}, nodeType string) report.Report { - r := report.Report{} - if node.Filesystem == "" { - // Filesystem was not specified. This is an error, but its handled in types.File's Validate, not here - return r - } - _, ok := filesystems[node.Filesystem] - if !ok { - r.Add(report.Entry{ - Kind: report.EntryWarning, - Message: fmt.Sprintf("%v %q references nonexistent filesystem %q. (This is ok if it is defined in a referenced config)", - nodeType, node.Path, node.Filesystem), - }) - } - return r -} - -func checkFilesFilesystems(cfg Config, r *report.Report) { - filesystems := map[string]struct{}{"root": {}} - for _, filesystem := range cfg.Storage.Filesystems { - filesystems[filesystem.Name] = struct{}{} - } - for _, file := range cfg.Storage.Files { - r.Merge(checkNodeFilesystems(file.Node, filesystems, "File")) - } - for _, link := range cfg.Storage.Links { - r.Merge(checkNodeFilesystems(link.Node, filesystems, "Link")) - } - for _, dir := range cfg.Storage.Directories { - r.Merge(checkNodeFilesystems(dir.Node, filesystems, "Directory")) - } -} - -func checkDuplicateFilesystems(cfg Config, r *report.Report) { - filesystems := map[string]struct{}{"root": {}} - for _, filesystem := range cfg.Storage.Filesystems { - if _, ok := filesystems[filesystem.Name]; ok { - r.Add(report.Entry{ - Kind: report.EntryWarning, - Message: fmt.Sprintf("Filesystem %q shadows exising filesystem definition", filesystem.Name), - }) - } - filesystems[filesystem.Name] = struct{}{} - } -} diff --git a/vendor/github.com/coreos/ignition/config/v2_2/types/directory.go b/vendor/github.com/coreos/ignition/config/v2_2/types/directory.go deleted file mode 100644 index 9fdc732a644..00000000000 --- a/vendor/github.com/coreos/ignition/config/v2_2/types/directory.go +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright 2017 CoreOS, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package types - -import ( - "github.com/coreos/ignition/config/shared/errors" - "github.com/coreos/ignition/config/validate/report" -) - -func (d Directory) ValidateMode() report.Report { - r := report.Report{} - if err := validateMode(d.Mode); err != nil { - r.Add(report.Entry{ - Message: err.Error(), - Kind: report.EntryError, - }) - } - if d.Mode == nil { - r.Add(report.Entry{ - Message: errors.ErrPermissionsUnset.Error(), - Kind: report.EntryWarning, - }) - } - return r -} diff --git a/vendor/github.com/coreos/ignition/config/v2_2/types/disk.go b/vendor/github.com/coreos/ignition/config/v2_2/types/disk.go deleted file mode 100644 index f0af504a171..00000000000 --- a/vendor/github.com/coreos/ignition/config/v2_2/types/disk.go +++ /dev/null @@ -1,128 +0,0 @@ -// Copyright 2016 CoreOS, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package types - -import ( - "github.com/coreos/ignition/config/shared/errors" - "github.com/coreos/ignition/config/validate/report" -) - -func (n Disk) Validate() report.Report { - return report.Report{} -} - -func (n Disk) ValidateDevice() report.Report { - if len(n.Device) == 0 { - return report.ReportFromError(errors.ErrDiskDeviceRequired, report.EntryError) - } - if err := validatePath(string(n.Device)); err != nil { - return report.ReportFromError(err, report.EntryError) - } - return report.Report{} -} - -func (n Disk) ValidatePartitions() report.Report { - r := report.Report{} - if n.partitionNumbersCollide() { - r.Add(report.Entry{ - Message: errors.ErrPartitionNumbersCollide.Error(), - Kind: report.EntryError, - }) - } - if n.partitionsOverlap() { - r.Add(report.Entry{ - Message: errors.ErrPartitionsOverlap.Error(), - Kind: report.EntryError, - }) - } - if n.partitionsMisaligned() { - r.Add(report.Entry{ - Message: errors.ErrPartitionsMisaligned.Error(), - Kind: report.EntryError, - }) - } - // Disks which have no errors at this point will likely succeed in sgdisk - return r -} - -// partitionNumbersCollide returns true if partition numbers in n.Partitions are not unique. -func (n Disk) partitionNumbersCollide() bool { - m := map[int][]Partition{} - for _, p := range n.Partitions { - if p.Number != 0 { - // a number of 0 means next available number, multiple devices can specify this - m[p.Number] = append(m[p.Number], p) - } - } - for _, n := range m { - if len(n) > 1 { - // TODO(vc): return information describing the collision for logging - return true - } - } - return false -} - -// end returns the last sector of a partition. -func (p Partition) end() int { - if p.Size == 0 { - // a size of 0 means "fill available", just return the start as the end for those. - return p.Start - } - return p.Start + p.Size - 1 -} - -// partitionsOverlap returns true if any explicitly dimensioned partitions overlap -func (n Disk) partitionsOverlap() bool { - for _, p := range n.Partitions { - // Starts of 0 are placed by sgdisk into the "largest available block" at that time. - // We aren't going to check those for overlap since we don't have the disk geometry. - if p.Start == 0 { - continue - } - - for _, o := range n.Partitions { - if p == o || o.Start == 0 { - continue - } - - // is p.Start within o? - if p.Start >= o.Start && p.Start <= o.end() { - return true - } - - // is p.end() within o? - if p.end() >= o.Start && p.end() <= o.end() { - return true - } - - // do p.Start and p.end() straddle o? - if p.Start < o.Start && p.end() > o.end() { - return true - } - } - } - return false -} - -// partitionsMisaligned returns true if any of the partitions don't start on a 2048-sector (1MiB) boundary. -func (n Disk) partitionsMisaligned() bool { - for _, p := range n.Partitions { - if (p.Start & (2048 - 1)) != 0 { - return true - } - } - return false -} diff --git a/vendor/github.com/coreos/ignition/config/v2_2/types/file.go b/vendor/github.com/coreos/ignition/config/v2_2/types/file.go deleted file mode 100644 index b235d16c094..00000000000 --- a/vendor/github.com/coreos/ignition/config/v2_2/types/file.go +++ /dev/null @@ -1,69 +0,0 @@ -// Copyright 2016 CoreOS, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package types - -import ( - "github.com/coreos/ignition/config/shared/errors" - "github.com/coreos/ignition/config/validate/report" -) - -func (f File) Validate() report.Report { - if f.Overwrite != nil && *f.Overwrite && f.Append { - return report.ReportFromError(errors.ErrAppendAndOverwrite, report.EntryError) - } - return report.Report{} -} - -func (f File) ValidateMode() report.Report { - r := report.Report{} - if err := validateMode(f.Mode); err != nil { - r.Add(report.Entry{ - Message: err.Error(), - Kind: report.EntryError, - }) - } - if f.Mode == nil { - r.Add(report.Entry{ - Message: errors.ErrPermissionsUnset.Error(), - Kind: report.EntryWarning, - }) - } - return r -} - -func (fc FileContents) ValidateCompression() report.Report { - r := report.Report{} - switch fc.Compression { - case "", "gzip": - default: - r.Add(report.Entry{ - Message: errors.ErrCompressionInvalid.Error(), - Kind: report.EntryError, - }) - } - return r -} - -func (fc FileContents) ValidateSource() report.Report { - r := report.Report{} - err := validateURL(fc.Source) - if err != nil { - r.Add(report.Entry{ - Message: err.Error(), - Kind: report.EntryError, - }) - } - return r -} diff --git a/vendor/github.com/coreos/ignition/config/v2_2/types/filesystem.go b/vendor/github.com/coreos/ignition/config/v2_2/types/filesystem.go deleted file mode 100644 index a2e43ffda1d..00000000000 --- a/vendor/github.com/coreos/ignition/config/v2_2/types/filesystem.go +++ /dev/null @@ -1,144 +0,0 @@ -// Copyright 2016 CoreOS, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package types - -import ( - "github.com/coreos/ignition/config/shared/errors" - "github.com/coreos/ignition/config/validate/report" -) - -func (f Filesystem) Validate() report.Report { - r := report.Report{} - if f.Mount == nil && f.Path == nil { - r.Add(report.Entry{ - Message: errors.ErrFilesystemNoMountPath.Error(), - Kind: report.EntryError, - }) - } - if f.Mount != nil { - if f.Path != nil { - r.Add(report.Entry{ - Message: errors.ErrFilesystemMountAndPath.Error(), - Kind: report.EntryError, - }) - } - if f.Mount.Create != nil { - if f.Mount.WipeFilesystem { - r.Add(report.Entry{ - Message: errors.ErrUsedCreateAndWipeFilesystem.Error(), - Kind: report.EntryError, - }) - } - if len(f.Mount.Options) > 0 { - r.Add(report.Entry{ - Message: errors.ErrUsedCreateAndMountOpts.Error(), - Kind: report.EntryError, - }) - } - r.Add(report.Entry{ - Message: errors.ErrWarningCreateDeprecated.Error(), - Kind: report.EntryWarning, - }) - } - } - return r -} - -func (f Filesystem) ValidatePath() report.Report { - r := report.Report{} - if f.Path != nil && validatePath(*f.Path) != nil { - r.Add(report.Entry{ - Message: errors.ErrPathRelative.Error(), - Kind: report.EntryError, - }) - } - return r -} - -func (m Mount) Validate() report.Report { - r := report.Report{} - switch m.Format { - case "ext4", "btrfs", "xfs", "swap", "vfat": - default: - r.Add(report.Entry{ - Message: errors.ErrFilesystemInvalidFormat.Error(), - Kind: report.EntryError, - }) - } - return r -} - -func (m Mount) ValidateDevice() report.Report { - r := report.Report{} - if err := validatePath(m.Device); err != nil { - r.Add(report.Entry{ - Message: err.Error(), - Kind: report.EntryError, - }) - } - return r -} - -func (m Mount) ValidateLabel() report.Report { - r := report.Report{} - if m.Label == nil { - return r - } - switch m.Format { - case "ext4": - if len(*m.Label) > 16 { - // source: man mkfs.ext4 - r.Add(report.Entry{ - Message: errors.ErrExt4LabelTooLong.Error(), - Kind: report.EntryError, - }) - } - case "btrfs": - if len(*m.Label) > 256 { - // source: man mkfs.btrfs - r.Add(report.Entry{ - Message: errors.ErrBtrfsLabelTooLong.Error(), - Kind: report.EntryError, - }) - } - case "xfs": - if len(*m.Label) > 12 { - // source: man mkfs.xfs - r.Add(report.Entry{ - Message: errors.ErrXfsLabelTooLong.Error(), - Kind: report.EntryError, - }) - } - case "swap": - // mkswap's man page does not state a limit on label size, but through - // experimentation it appears that mkswap will truncate long labels to - // 15 characters, so let's enforce that. - if len(*m.Label) > 15 { - r.Add(report.Entry{ - Message: errors.ErrSwapLabelTooLong.Error(), - Kind: report.EntryError, - }) - } - case "vfat": - if len(*m.Label) > 11 { - // source: man mkfs.fat - r.Add(report.Entry{ - Message: errors.ErrVfatLabelTooLong.Error(), - Kind: report.EntryError, - }) - } - } - return r -} diff --git a/vendor/github.com/coreos/ignition/config/v2_2/types/ignition.go b/vendor/github.com/coreos/ignition/config/v2_2/types/ignition.go deleted file mode 100644 index bddf4958338..00000000000 --- a/vendor/github.com/coreos/ignition/config/v2_2/types/ignition.go +++ /dev/null @@ -1,52 +0,0 @@ -// Copyright 2015 CoreOS, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package types - -import ( - "github.com/coreos/go-semver/semver" - - "github.com/coreos/ignition/config/shared/errors" - "github.com/coreos/ignition/config/validate/report" -) - -func (c ConfigReference) ValidateSource() report.Report { - r := report.Report{} - err := validateURL(c.Source) - if err != nil { - r.Add(report.Entry{ - Message: err.Error(), - Kind: report.EntryError, - }) - } - return r -} - -func (v Ignition) Semver() (*semver.Version, error) { - return semver.NewVersion(v.Version) -} - -func (v Ignition) Validate() report.Report { - tv, err := v.Semver() - if err != nil { - return report.ReportFromError(errors.ErrInvalidVersion, report.EntryError) - } - if MaxVersion.Major > tv.Major { - return report.ReportFromError(errors.ErrOldVersion, report.EntryError) - } - if MaxVersion.LessThan(*tv) { - return report.ReportFromError(errors.ErrNewVersion, report.EntryError) - } - return report.Report{} -} diff --git a/vendor/github.com/coreos/ignition/config/v2_2/types/link.go b/vendor/github.com/coreos/ignition/config/v2_2/types/link.go deleted file mode 100644 index f0284425282..00000000000 --- a/vendor/github.com/coreos/ignition/config/v2_2/types/link.go +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright 2017 CoreOS, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package types - -import ( - "github.com/coreos/ignition/config/validate/report" -) - -func (s LinkEmbedded1) ValidateTarget() report.Report { - r := report.Report{} - if !s.Hard { - err := validatePath(s.Target) - if err != nil { - r.Add(report.Entry{ - Message: err.Error(), - Kind: report.EntryError, - }) - } - } - return r -} diff --git a/vendor/github.com/coreos/ignition/config/v2_2/types/node.go b/vendor/github.com/coreos/ignition/config/v2_2/types/node.go deleted file mode 100644 index 50badfdfb92..00000000000 --- a/vendor/github.com/coreos/ignition/config/v2_2/types/node.go +++ /dev/null @@ -1,73 +0,0 @@ -// Copyright 2016 CoreOS, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package types - -import ( - "path/filepath" - - "github.com/coreos/ignition/config/shared/errors" - "github.com/coreos/ignition/config/validate/report" -) - -func (n Node) ValidateFilesystem() report.Report { - r := report.Report{} - if n.Filesystem == "" { - r.Add(report.Entry{ - Message: errors.ErrNoFilesystem.Error(), - Kind: report.EntryError, - }) - } - return r -} - -func (n Node) ValidatePath() report.Report { - r := report.Report{} - if err := validatePath(n.Path); err != nil { - r.Add(report.Entry{ - Message: err.Error(), - Kind: report.EntryError, - }) - } - return r -} - -func (n Node) Depth() int { - count := 0 - for p := filepath.Clean(string(n.Path)); p != "/"; count++ { - p = filepath.Dir(p) - } - return count -} - -func (nu NodeUser) Validate() report.Report { - r := report.Report{} - if nu.ID != nil && nu.Name != "" { - r.Add(report.Entry{ - Message: errors.ErrBothIDAndNameSet.Error(), - Kind: report.EntryError, - }) - } - return r -} -func (ng NodeGroup) Validate() report.Report { - r := report.Report{} - if ng.ID != nil && ng.Name != "" { - r.Add(report.Entry{ - Message: errors.ErrBothIDAndNameSet.Error(), - Kind: report.EntryError, - }) - } - return r -} diff --git a/vendor/github.com/coreos/ignition/config/v2_2/types/partition.go b/vendor/github.com/coreos/ignition/config/v2_2/types/partition.go deleted file mode 100644 index 084dce7ce23..00000000000 --- a/vendor/github.com/coreos/ignition/config/v2_2/types/partition.go +++ /dev/null @@ -1,77 +0,0 @@ -// Copyright 2016 CoreOS, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package types - -import ( - "fmt" - "regexp" - "strings" - - "github.com/coreos/ignition/config/shared/errors" - "github.com/coreos/ignition/config/validate/report" -) - -const ( - guidRegexStr = "^(|[[:xdigit:]]{8}-[[:xdigit:]]{4}-[[:xdigit:]]{4}-[[:xdigit:]]{4}-[[:xdigit:]]{12})$" -) - -func (p Partition) ValidateLabel() report.Report { - r := report.Report{} - // http://en.wikipedia.org/wiki/GUID_Partition_Table#Partition_entries: - // 56 (0x38) 72 bytes Partition name (36 UTF-16LE code units) - - // XXX(vc): note GPT calls it a name, we're using label for consistency - // with udev naming /dev/disk/by-partlabel/*. - if len(p.Label) > 36 { - r.Add(report.Entry{ - Message: errors.ErrLabelTooLong.Error(), - Kind: report.EntryError, - }) - } - - // sgdisk uses colons for delimitting compound arguments and does not allow escaping them. - if strings.Contains(p.Label, ":") { - r.Add(report.Entry{ - Message: errors.ErrLabelContainsColon.Error(), - Kind: report.EntryWarning, - }) - } - return r -} - -func (p Partition) ValidateTypeGUID() report.Report { - return validateGUID(p.TypeGUID) -} - -func (p Partition) ValidateGUID() report.Report { - return validateGUID(p.GUID) -} - -func validateGUID(guid string) report.Report { - r := report.Report{} - ok, err := regexp.MatchString(guidRegexStr, guid) - if err != nil { - r.Add(report.Entry{ - Message: fmt.Sprintf("error matching guid regexp: %v", err), - Kind: report.EntryError, - }) - } else if !ok { - r.Add(report.Entry{ - Message: errors.ErrDoesntMatchGUIDRegex.Error(), - Kind: report.EntryError, - }) - } - return r -} diff --git a/vendor/github.com/coreos/ignition/config/v2_2/types/passwd.go b/vendor/github.com/coreos/ignition/config/v2_2/types/passwd.go deleted file mode 100644 index 10508c56c06..00000000000 --- a/vendor/github.com/coreos/ignition/config/v2_2/types/passwd.go +++ /dev/null @@ -1,67 +0,0 @@ -// Copyright 2017 CoreOS, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package types - -import ( - "github.com/coreos/ignition/config/shared/errors" - "github.com/coreos/ignition/config/validate/report" -) - -func (p PasswdUser) Validate() report.Report { - r := report.Report{} - if p.Create != nil { - r.Add(report.Entry{ - Message: errors.ErrPasswdCreateDeprecated.Error(), - Kind: report.EntryWarning, - }) - addErr := func(err error) { - r.Add(report.Entry{ - Message: err.Error(), - Kind: report.EntryError, - }) - } - if p.Gecos != "" { - addErr(errors.ErrPasswdCreateAndGecos) - } - if len(p.Groups) > 0 { - addErr(errors.ErrPasswdCreateAndGroups) - } - if p.HomeDir != "" { - addErr(errors.ErrPasswdCreateAndHomeDir) - } - if p.NoCreateHome { - addErr(errors.ErrPasswdCreateAndNoCreateHome) - } - if p.NoLogInit { - addErr(errors.ErrPasswdCreateAndNoLogInit) - } - if p.NoUserGroup { - addErr(errors.ErrPasswdCreateAndNoUserGroup) - } - if p.PrimaryGroup != "" { - addErr(errors.ErrPasswdCreateAndPrimaryGroup) - } - if p.Shell != "" { - addErr(errors.ErrPasswdCreateAndShell) - } - if p.System { - addErr(errors.ErrPasswdCreateAndSystem) - } - if p.UID != nil { - addErr(errors.ErrPasswdCreateAndUID) - } - } - return r -} diff --git a/vendor/github.com/coreos/ignition/config/v2_2/types/path.go b/vendor/github.com/coreos/ignition/config/v2_2/types/path.go deleted file mode 100644 index 780607c31ab..00000000000 --- a/vendor/github.com/coreos/ignition/config/v2_2/types/path.go +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright 2016 CoreOS, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package types - -import ( - "path" - - "github.com/coreos/ignition/config/shared/errors" -) - -func validatePath(p string) error { - if !path.IsAbs(p) { - return errors.ErrPathRelative - } - return nil -} diff --git a/vendor/github.com/coreos/ignition/config/v2_2/types/schema.go b/vendor/github.com/coreos/ignition/config/v2_2/types/schema.go deleted file mode 100644 index 4b32b337b3a..00000000000 --- a/vendor/github.com/coreos/ignition/config/v2_2/types/schema.go +++ /dev/null @@ -1,246 +0,0 @@ -package types - -// generated by "schematyper --package=types schema/ignition.json -o config/types/schema.go --root-type=Config" -- DO NOT EDIT - -type CaReference struct { - Source string `json:"source,omitempty"` - Verification Verification `json:"verification,omitempty"` -} - -type Config struct { - Ignition Ignition `json:"ignition"` - Networkd Networkd `json:"networkd,omitempty"` - Passwd Passwd `json:"passwd,omitempty"` - Storage Storage `json:"storage,omitempty"` - Systemd Systemd `json:"systemd,omitempty"` -} - -type ConfigReference struct { - Source string `json:"source,omitempty"` - Verification Verification `json:"verification,omitempty"` -} - -type Create struct { - Force bool `json:"force,omitempty"` - Options []CreateOption `json:"options,omitempty"` -} - -type CreateOption string - -type Device string - -type Directory struct { - Node - DirectoryEmbedded1 -} - -type DirectoryEmbedded1 struct { - Mode *int `json:"mode,omitempty"` -} - -type Disk struct { - Device string `json:"device,omitempty"` - Partitions []Partition `json:"partitions,omitempty"` - WipeTable bool `json:"wipeTable,omitempty"` -} - -type File struct { - Node - FileEmbedded1 -} - -type FileContents struct { - Compression string `json:"compression,omitempty"` - Source string `json:"source,omitempty"` - Verification Verification `json:"verification,omitempty"` -} - -type FileEmbedded1 struct { - Append bool `json:"append,omitempty"` - Contents FileContents `json:"contents,omitempty"` - Mode *int `json:"mode,omitempty"` -} - -type Filesystem struct { - Mount *Mount `json:"mount,omitempty"` - Name string `json:"name,omitempty"` - Path *string `json:"path,omitempty"` -} - -type Group string - -type Ignition struct { - Config IgnitionConfig `json:"config,omitempty"` - Security Security `json:"security,omitempty"` - Timeouts Timeouts `json:"timeouts,omitempty"` - Version string `json:"version,omitempty"` -} - -type IgnitionConfig struct { - Append []ConfigReference `json:"append,omitempty"` - Replace *ConfigReference `json:"replace,omitempty"` -} - -type Link struct { - Node - LinkEmbedded1 -} - -type LinkEmbedded1 struct { - Hard bool `json:"hard,omitempty"` - Target string `json:"target,omitempty"` -} - -type Mount struct { - Create *Create `json:"create,omitempty"` - Device string `json:"device,omitempty"` - Format string `json:"format,omitempty"` - Label *string `json:"label,omitempty"` - Options []MountOption `json:"options,omitempty"` - UUID *string `json:"uuid,omitempty"` - WipeFilesystem bool `json:"wipeFilesystem,omitempty"` -} - -type MountOption string - -type Networkd struct { - Units []Networkdunit `json:"units,omitempty"` -} - -type NetworkdDropin struct { - Contents string `json:"contents,omitempty"` - Name string `json:"name,omitempty"` -} - -type Networkdunit struct { - Contents string `json:"contents,omitempty"` - Dropins []NetworkdDropin `json:"dropins,omitempty"` - Name string `json:"name,omitempty"` -} - -type Node struct { - Filesystem string `json:"filesystem,omitempty"` - Group *NodeGroup `json:"group,omitempty"` - Overwrite *bool `json:"overwrite,omitempty"` - Path string `json:"path,omitempty"` - User *NodeUser `json:"user,omitempty"` -} - -type NodeGroup struct { - ID *int `json:"id,omitempty"` - Name string `json:"name,omitempty"` -} - -type NodeUser struct { - ID *int `json:"id,omitempty"` - Name string `json:"name,omitempty"` -} - -type Partition struct { - GUID string `json:"guid,omitempty"` - Label string `json:"label,omitempty"` - Number int `json:"number,omitempty"` - Size int `json:"size,omitempty"` - Start int `json:"start,omitempty"` - TypeGUID string `json:"typeGuid,omitempty"` -} - -type Passwd struct { - Groups []PasswdGroup `json:"groups,omitempty"` - Users []PasswdUser `json:"users,omitempty"` -} - -type PasswdGroup struct { - Gid *int `json:"gid,omitempty"` - Name string `json:"name,omitempty"` - PasswordHash string `json:"passwordHash,omitempty"` - System bool `json:"system,omitempty"` -} - -type PasswdUser struct { - Create *Usercreate `json:"create,omitempty"` - Gecos string `json:"gecos,omitempty"` - Groups []Group `json:"groups,omitempty"` - HomeDir string `json:"homeDir,omitempty"` - Name string `json:"name,omitempty"` - NoCreateHome bool `json:"noCreateHome,omitempty"` - NoLogInit bool `json:"noLogInit,omitempty"` - NoUserGroup bool `json:"noUserGroup,omitempty"` - PasswordHash *string `json:"passwordHash,omitempty"` - PrimaryGroup string `json:"primaryGroup,omitempty"` - SSHAuthorizedKeys []SSHAuthorizedKey `json:"sshAuthorizedKeys,omitempty"` - Shell string `json:"shell,omitempty"` - System bool `json:"system,omitempty"` - UID *int `json:"uid,omitempty"` -} - -type Raid struct { - Devices []Device `json:"devices,omitempty"` - Level string `json:"level,omitempty"` - Name string `json:"name,omitempty"` - Options []RaidOption `json:"options,omitempty"` - Spares int `json:"spares,omitempty"` -} - -type RaidOption string - -type SSHAuthorizedKey string - -type Security struct { - TLS TLS `json:"tls,omitempty"` -} - -type Storage struct { - Directories []Directory `json:"directories,omitempty"` - Disks []Disk `json:"disks,omitempty"` - Files []File `json:"files,omitempty"` - Filesystems []Filesystem `json:"filesystems,omitempty"` - Links []Link `json:"links,omitempty"` - Raid []Raid `json:"raid,omitempty"` -} - -type Systemd struct { - Units []Unit `json:"units,omitempty"` -} - -type SystemdDropin struct { - Contents string `json:"contents,omitempty"` - Name string `json:"name,omitempty"` -} - -type TLS struct { - CertificateAuthorities []CaReference `json:"certificateAuthorities,omitempty"` -} - -type Timeouts struct { - HTTPResponseHeaders *int `json:"httpResponseHeaders,omitempty"` - HTTPTotal *int `json:"httpTotal,omitempty"` -} - -type Unit struct { - Contents string `json:"contents,omitempty"` - Dropins []SystemdDropin `json:"dropins,omitempty"` - Enable bool `json:"enable,omitempty"` - Enabled *bool `json:"enabled,omitempty"` - Mask bool `json:"mask,omitempty"` - Name string `json:"name,omitempty"` -} - -type Usercreate struct { - Gecos string `json:"gecos,omitempty"` - Groups []UsercreateGroup `json:"groups,omitempty"` - HomeDir string `json:"homeDir,omitempty"` - NoCreateHome bool `json:"noCreateHome,omitempty"` - NoLogInit bool `json:"noLogInit,omitempty"` - NoUserGroup bool `json:"noUserGroup,omitempty"` - PrimaryGroup string `json:"primaryGroup,omitempty"` - Shell string `json:"shell,omitempty"` - System bool `json:"system,omitempty"` - UID *int `json:"uid,omitempty"` -} - -type UsercreateGroup string - -type Verification struct { - Hash *string `json:"hash,omitempty"` -} diff --git a/vendor/github.com/coreos/ignition/config/v2_2/types/unit.go b/vendor/github.com/coreos/ignition/config/v2_2/types/unit.go deleted file mode 100644 index 70fe1179a45..00000000000 --- a/vendor/github.com/coreos/ignition/config/v2_2/types/unit.go +++ /dev/null @@ -1,131 +0,0 @@ -// Copyright 2016 CoreOS, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package types - -import ( - "fmt" - "path" - "strings" - - "github.com/coreos/go-systemd/unit" - - "github.com/coreos/ignition/config/shared/errors" - "github.com/coreos/ignition/config/shared/validations" - "github.com/coreos/ignition/config/validate/report" -) - -func (u Unit) ValidateContents() report.Report { - r := report.Report{} - opts, err := validateUnitContent(u.Contents) - if err != nil { - r.Add(report.Entry{ - Message: err.Error(), - Kind: report.EntryError, - }) - } - - isEnabled := u.Enable || (u.Enabled != nil && *u.Enabled) - r.Merge(validations.ValidateInstallSection(u.Name, isEnabled, u.Contents == "", opts)) - - return r -} - -func (u Unit) ValidateName() report.Report { - r := report.Report{} - switch path.Ext(u.Name) { - case ".service", ".socket", ".device", ".mount", ".automount", ".swap", ".target", ".path", ".timer", ".snapshot", ".slice", ".scope": - default: - r.Add(report.Entry{ - Message: errors.ErrInvalidSystemdExt.Error(), - Kind: report.EntryError, - }) - } - return r -} - -func (d SystemdDropin) Validate() report.Report { - r := report.Report{} - - if _, err := validateUnitContent(d.Contents); err != nil { - r.Add(report.Entry{ - Message: err.Error(), - Kind: report.EntryError, - }) - } - - switch path.Ext(d.Name) { - case ".conf": - default: - r.Add(report.Entry{ - Message: errors.ErrInvalidSystemdDropinExt.Error(), - Kind: report.EntryError, - }) - } - - return r -} - -func (u Networkdunit) Validate() report.Report { - r := report.Report{} - - if _, err := validateUnitContent(u.Contents); err != nil { - r.Add(report.Entry{ - Message: err.Error(), - Kind: report.EntryError, - }) - } - - switch path.Ext(u.Name) { - case ".link", ".netdev", ".network": - default: - r.Add(report.Entry{ - Message: errors.ErrInvalidNetworkdExt.Error(), - Kind: report.EntryError, - }) - } - - return r -} - -func (d NetworkdDropin) Validate() report.Report { - r := report.Report{} - - if _, err := validateUnitContent(d.Contents); err != nil { - r.Add(report.Entry{ - Message: err.Error(), - Kind: report.EntryError, - }) - } - - switch path.Ext(d.Name) { - case ".conf": - default: - r.Add(report.Entry{ - Message: errors.ErrInvalidNetworkdDropinExt.Error(), - Kind: report.EntryError, - }) - } - - return r -} - -func validateUnitContent(content string) ([]*unit.UnitOption, error) { - c := strings.NewReader(content) - opts, err := unit.Deserialize(c) - if err != nil { - return nil, fmt.Errorf("invalid unit content: %s", err) - } - return opts, nil -} diff --git a/vendor/github.com/coreos/ignition/config/v2_2/types/verification.go b/vendor/github.com/coreos/ignition/config/v2_2/types/verification.go deleted file mode 100644 index 51e7d1550a3..00000000000 --- a/vendor/github.com/coreos/ignition/config/v2_2/types/verification.go +++ /dev/null @@ -1,77 +0,0 @@ -// Copyright 2016 CoreOS, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package types - -import ( - "crypto" - "encoding/hex" - "strings" - - "github.com/coreos/ignition/config/shared/errors" - "github.com/coreos/ignition/config/validate/report" -) - -// HashParts will return the sum and function (in that order) of the hash stored -// in this Verification, or an error if there is an issue during parsing. -func (v Verification) HashParts() (string, string, error) { - if v.Hash == nil { - // The hash can be nil - return "", "", nil - } - parts := strings.SplitN(*v.Hash, "-", 2) - if len(parts) != 2 { - return "", "", errors.ErrHashMalformed - } - - return parts[0], parts[1], nil -} - -func (v Verification) Validate() report.Report { - r := report.Report{} - - if v.Hash == nil { - // The hash can be nil - return r - } - - function, sum, err := v.HashParts() - if err != nil { - r.Add(report.Entry{ - Message: err.Error(), - Kind: report.EntryError, - }) - return r - } - var hash crypto.Hash - switch function { - case "sha512": - hash = crypto.SHA512 - default: - r.Add(report.Entry{ - Message: errors.ErrHashUnrecognized.Error(), - Kind: report.EntryError, - }) - return r - } - - if len(sum) != hex.EncodedLen(hash.Size()) { - r.Add(report.Entry{ - Message: errors.ErrHashWrongSize.Error(), - Kind: report.EntryError, - }) - } - - return r -} diff --git a/vendor/github.com/coreos/ignition/config/v2_3_experimental/types/ca.go b/vendor/github.com/coreos/ignition/config/v2_3_experimental/types/ca.go deleted file mode 100644 index 7440e1e2f3b..00000000000 --- a/vendor/github.com/coreos/ignition/config/v2_3_experimental/types/ca.go +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright 2018 CoreOS, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package types - -import ( - "github.com/coreos/ignition/config/validate/report" -) - -func (c CaReference) ValidateSource() report.Report { - err := validateURL(c.Source) - if err != nil { - return report.ReportFromError(err, report.EntryError) - } - return report.Report{} -} diff --git a/vendor/github.com/coreos/ignition/config/v2_3_experimental/types/config.go b/vendor/github.com/coreos/ignition/config/v2_3_experimental/types/config.go deleted file mode 100644 index cfef0ed9dac..00000000000 --- a/vendor/github.com/coreos/ignition/config/v2_3_experimental/types/config.go +++ /dev/null @@ -1,92 +0,0 @@ -// Copyright 2015 CoreOS, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package types - -import ( - "fmt" - - "github.com/coreos/go-semver/semver" - - "github.com/coreos/ignition/config/validate/report" -) - -var ( - MaxVersion = semver.Version{ - Major: 2, - Minor: 3, - PreRelease: "experimental", - } -) - -func (c Config) Validate() report.Report { - r := report.Report{} - rules := []rule{ - checkFilesFilesystems, - checkDuplicateFilesystems, - } - - for _, rule := range rules { - rule(c, &r) - } - return r -} - -type rule func(cfg Config, report *report.Report) - -func checkNodeFilesystems(node Node, filesystems map[string]struct{}, nodeType string) report.Report { - r := report.Report{} - if node.Filesystem == "" { - // Filesystem was not specified. This is an error, but its handled in types.File's Validate, not here - return r - } - _, ok := filesystems[node.Filesystem] - if !ok { - r.Add(report.Entry{ - Kind: report.EntryWarning, - Message: fmt.Sprintf("%v %q references nonexistent filesystem %q. (This is ok if it is defined in a referenced config)", - nodeType, node.Path, node.Filesystem), - }) - } - return r -} - -func checkFilesFilesystems(cfg Config, r *report.Report) { - filesystems := map[string]struct{}{"root": {}} - for _, filesystem := range cfg.Storage.Filesystems { - filesystems[filesystem.Name] = struct{}{} - } - for _, file := range cfg.Storage.Files { - r.Merge(checkNodeFilesystems(file.Node, filesystems, "File")) - } - for _, link := range cfg.Storage.Links { - r.Merge(checkNodeFilesystems(link.Node, filesystems, "Link")) - } - for _, dir := range cfg.Storage.Directories { - r.Merge(checkNodeFilesystems(dir.Node, filesystems, "Directory")) - } -} - -func checkDuplicateFilesystems(cfg Config, r *report.Report) { - filesystems := map[string]struct{}{"root": {}} - for _, filesystem := range cfg.Storage.Filesystems { - if _, ok := filesystems[filesystem.Name]; ok { - r.Add(report.Entry{ - Kind: report.EntryWarning, - Message: fmt.Sprintf("Filesystem %q shadows exising filesystem definition", filesystem.Name), - }) - } - filesystems[filesystem.Name] = struct{}{} - } -} diff --git a/vendor/github.com/coreos/ignition/config/v2_3_experimental/types/directory.go b/vendor/github.com/coreos/ignition/config/v2_3_experimental/types/directory.go deleted file mode 100644 index 9fdc732a644..00000000000 --- a/vendor/github.com/coreos/ignition/config/v2_3_experimental/types/directory.go +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright 2017 CoreOS, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package types - -import ( - "github.com/coreos/ignition/config/shared/errors" - "github.com/coreos/ignition/config/validate/report" -) - -func (d Directory) ValidateMode() report.Report { - r := report.Report{} - if err := validateMode(d.Mode); err != nil { - r.Add(report.Entry{ - Message: err.Error(), - Kind: report.EntryError, - }) - } - if d.Mode == nil { - r.Add(report.Entry{ - Message: errors.ErrPermissionsUnset.Error(), - Kind: report.EntryWarning, - }) - } - return r -} diff --git a/vendor/github.com/coreos/ignition/config/v2_3_experimental/types/file.go b/vendor/github.com/coreos/ignition/config/v2_3_experimental/types/file.go deleted file mode 100644 index 1897dc42c80..00000000000 --- a/vendor/github.com/coreos/ignition/config/v2_3_experimental/types/file.go +++ /dev/null @@ -1,71 +0,0 @@ -// Copyright 2016 CoreOS, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package types - -import ( - "fmt" - - "github.com/coreos/ignition/config/shared/errors" - "github.com/coreos/ignition/config/validate/report" -) - -func (f File) Validate() report.Report { - if f.Overwrite != nil && *f.Overwrite && f.Append { - return report.ReportFromError(errors.ErrAppendAndOverwrite, report.EntryError) - } - return report.Report{} -} - -func (f File) ValidateMode() report.Report { - r := report.Report{} - if err := validateMode(f.Mode); err != nil { - r.Add(report.Entry{ - Message: err.Error(), - Kind: report.EntryError, - }) - } - if f.Mode == nil { - r.Add(report.Entry{ - Message: errors.ErrPermissionsUnset.Error(), - Kind: report.EntryWarning, - }) - } - return r -} - -func (fc FileContents) ValidateCompression() report.Report { - r := report.Report{} - switch fc.Compression { - case "", "gzip": - default: - r.Add(report.Entry{ - Message: errors.ErrCompressionInvalid.Error(), - Kind: report.EntryError, - }) - } - return r -} - -func (fc FileContents) ValidateSource() report.Report { - r := report.Report{} - err := validateURL(fc.Source) - if err != nil { - r.Add(report.Entry{ - Message: fmt.Sprintf("invalid url %q: %v", fc.Source, err), - Kind: report.EntryError, - }) - } - return r -} diff --git a/vendor/github.com/coreos/ignition/config/v2_3_experimental/types/filesystem.go b/vendor/github.com/coreos/ignition/config/v2_3_experimental/types/filesystem.go deleted file mode 100644 index 2e847da69d0..00000000000 --- a/vendor/github.com/coreos/ignition/config/v2_3_experimental/types/filesystem.go +++ /dev/null @@ -1,146 +0,0 @@ -// Copyright 2016 CoreOS, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package types - -import ( - "fmt" - - "github.com/coreos/ignition/config/shared/errors" - "github.com/coreos/ignition/config/validate/report" -) - -func (f Filesystem) Validate() report.Report { - r := report.Report{} - if f.Mount == nil && f.Path == nil { - r.Add(report.Entry{ - Message: errors.ErrFilesystemNoMountPath.Error(), - Kind: report.EntryError, - }) - } - if f.Mount != nil { - if f.Path != nil { - r.Add(report.Entry{ - Message: errors.ErrFilesystemMountAndPath.Error(), - Kind: report.EntryError, - }) - } - if f.Mount.Create != nil { - if f.Mount.WipeFilesystem { - r.Add(report.Entry{ - Message: errors.ErrUsedCreateAndWipeFilesystem.Error(), - Kind: report.EntryError, - }) - } - if len(f.Mount.Options) > 0 { - r.Add(report.Entry{ - Message: errors.ErrUsedCreateAndMountOpts.Error(), - Kind: report.EntryError, - }) - } - r.Add(report.Entry{ - Message: errors.ErrWarningCreateDeprecated.Error(), - Kind: report.EntryWarning, - }) - } - } - return r -} - -func (f Filesystem) ValidatePath() report.Report { - r := report.Report{} - if f.Path != nil && validatePath(*f.Path) != nil { - r.Add(report.Entry{ - Message: fmt.Sprintf("filesystem %q: path not absolute", f.Name), - Kind: report.EntryError, - }) - } - return r -} - -func (m Mount) Validate() report.Report { - r := report.Report{} - switch m.Format { - case "ext4", "btrfs", "xfs", "swap", "vfat": - default: - r.Add(report.Entry{ - Message: errors.ErrFilesystemInvalidFormat.Error(), - Kind: report.EntryError, - }) - } - return r -} - -func (m Mount) ValidateDevice() report.Report { - r := report.Report{} - if err := validatePath(m.Device); err != nil { - r.Add(report.Entry{ - Message: err.Error(), - Kind: report.EntryError, - }) - } - return r -} - -func (m Mount) ValidateLabel() report.Report { - r := report.Report{} - if m.Label == nil { - return r - } - switch m.Format { - case "ext4": - if len(*m.Label) > 16 { - // source: man mkfs.ext4 - r.Add(report.Entry{ - Message: errors.ErrExt4LabelTooLong.Error(), - Kind: report.EntryError, - }) - } - case "btrfs": - if len(*m.Label) > 256 { - // source: man mkfs.btrfs - r.Add(report.Entry{ - Message: errors.ErrBtrfsLabelTooLong.Error(), - Kind: report.EntryError, - }) - } - case "xfs": - if len(*m.Label) > 12 { - // source: man mkfs.xfs - r.Add(report.Entry{ - Message: errors.ErrXfsLabelTooLong.Error(), - Kind: report.EntryError, - }) - } - case "swap": - // mkswap's man page does not state a limit on label size, but through - // experimentation it appears that mkswap will truncate long labels to - // 15 characters, so let's enforce that. - if len(*m.Label) > 15 { - r.Add(report.Entry{ - Message: errors.ErrSwapLabelTooLong.Error(), - Kind: report.EntryError, - }) - } - case "vfat": - if len(*m.Label) > 11 { - // source: man mkfs.fat - r.Add(report.Entry{ - Message: errors.ErrVfatLabelTooLong.Error(), - Kind: report.EntryError, - }) - } - } - return r -} diff --git a/vendor/github.com/coreos/ignition/config/v2_3_experimental/types/ignition.go b/vendor/github.com/coreos/ignition/config/v2_3_experimental/types/ignition.go deleted file mode 100644 index bddf4958338..00000000000 --- a/vendor/github.com/coreos/ignition/config/v2_3_experimental/types/ignition.go +++ /dev/null @@ -1,52 +0,0 @@ -// Copyright 2015 CoreOS, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package types - -import ( - "github.com/coreos/go-semver/semver" - - "github.com/coreos/ignition/config/shared/errors" - "github.com/coreos/ignition/config/validate/report" -) - -func (c ConfigReference) ValidateSource() report.Report { - r := report.Report{} - err := validateURL(c.Source) - if err != nil { - r.Add(report.Entry{ - Message: err.Error(), - Kind: report.EntryError, - }) - } - return r -} - -func (v Ignition) Semver() (*semver.Version, error) { - return semver.NewVersion(v.Version) -} - -func (v Ignition) Validate() report.Report { - tv, err := v.Semver() - if err != nil { - return report.ReportFromError(errors.ErrInvalidVersion, report.EntryError) - } - if MaxVersion.Major > tv.Major { - return report.ReportFromError(errors.ErrOldVersion, report.EntryError) - } - if MaxVersion.LessThan(*tv) { - return report.ReportFromError(errors.ErrNewVersion, report.EntryError) - } - return report.Report{} -} diff --git a/vendor/github.com/coreos/ignition/config/v2_3_experimental/types/mode.go b/vendor/github.com/coreos/ignition/config/v2_3_experimental/types/mode.go deleted file mode 100644 index d06045d6753..00000000000 --- a/vendor/github.com/coreos/ignition/config/v2_3_experimental/types/mode.go +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright 2017 CoreOS, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package types - -import ( - "github.com/coreos/ignition/config/shared/errors" -) - -func validateMode(m *int) error { - if m != nil && (*m < 0 || *m > 07777) { - return errors.ErrFileIllegalMode - } - return nil -} diff --git a/vendor/github.com/coreos/ignition/config/v2_3_experimental/types/node.go b/vendor/github.com/coreos/ignition/config/v2_3_experimental/types/node.go deleted file mode 100644 index 50badfdfb92..00000000000 --- a/vendor/github.com/coreos/ignition/config/v2_3_experimental/types/node.go +++ /dev/null @@ -1,73 +0,0 @@ -// Copyright 2016 CoreOS, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package types - -import ( - "path/filepath" - - "github.com/coreos/ignition/config/shared/errors" - "github.com/coreos/ignition/config/validate/report" -) - -func (n Node) ValidateFilesystem() report.Report { - r := report.Report{} - if n.Filesystem == "" { - r.Add(report.Entry{ - Message: errors.ErrNoFilesystem.Error(), - Kind: report.EntryError, - }) - } - return r -} - -func (n Node) ValidatePath() report.Report { - r := report.Report{} - if err := validatePath(n.Path); err != nil { - r.Add(report.Entry{ - Message: err.Error(), - Kind: report.EntryError, - }) - } - return r -} - -func (n Node) Depth() int { - count := 0 - for p := filepath.Clean(string(n.Path)); p != "/"; count++ { - p = filepath.Dir(p) - } - return count -} - -func (nu NodeUser) Validate() report.Report { - r := report.Report{} - if nu.ID != nil && nu.Name != "" { - r.Add(report.Entry{ - Message: errors.ErrBothIDAndNameSet.Error(), - Kind: report.EntryError, - }) - } - return r -} -func (ng NodeGroup) Validate() report.Report { - r := report.Report{} - if ng.ID != nil && ng.Name != "" { - r.Add(report.Entry{ - Message: errors.ErrBothIDAndNameSet.Error(), - Kind: report.EntryError, - }) - } - return r -} diff --git a/vendor/github.com/coreos/ignition/config/v2_3_experimental/types/passwd.go b/vendor/github.com/coreos/ignition/config/v2_3_experimental/types/passwd.go deleted file mode 100644 index 10508c56c06..00000000000 --- a/vendor/github.com/coreos/ignition/config/v2_3_experimental/types/passwd.go +++ /dev/null @@ -1,67 +0,0 @@ -// Copyright 2017 CoreOS, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package types - -import ( - "github.com/coreos/ignition/config/shared/errors" - "github.com/coreos/ignition/config/validate/report" -) - -func (p PasswdUser) Validate() report.Report { - r := report.Report{} - if p.Create != nil { - r.Add(report.Entry{ - Message: errors.ErrPasswdCreateDeprecated.Error(), - Kind: report.EntryWarning, - }) - addErr := func(err error) { - r.Add(report.Entry{ - Message: err.Error(), - Kind: report.EntryError, - }) - } - if p.Gecos != "" { - addErr(errors.ErrPasswdCreateAndGecos) - } - if len(p.Groups) > 0 { - addErr(errors.ErrPasswdCreateAndGroups) - } - if p.HomeDir != "" { - addErr(errors.ErrPasswdCreateAndHomeDir) - } - if p.NoCreateHome { - addErr(errors.ErrPasswdCreateAndNoCreateHome) - } - if p.NoLogInit { - addErr(errors.ErrPasswdCreateAndNoLogInit) - } - if p.NoUserGroup { - addErr(errors.ErrPasswdCreateAndNoUserGroup) - } - if p.PrimaryGroup != "" { - addErr(errors.ErrPasswdCreateAndPrimaryGroup) - } - if p.Shell != "" { - addErr(errors.ErrPasswdCreateAndShell) - } - if p.System { - addErr(errors.ErrPasswdCreateAndSystem) - } - if p.UID != nil { - addErr(errors.ErrPasswdCreateAndUID) - } - } - return r -} diff --git a/vendor/github.com/coreos/ignition/config/v2_3_experimental/types/raid.go b/vendor/github.com/coreos/ignition/config/v2_3_experimental/types/raid.go deleted file mode 100644 index 3aceaa9faa1..00000000000 --- a/vendor/github.com/coreos/ignition/config/v2_3_experimental/types/raid.go +++ /dev/null @@ -1,57 +0,0 @@ -// Copyright 2016 CoreOS, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package types - -import ( - "github.com/coreos/ignition/config/shared/errors" - "github.com/coreos/ignition/config/validate/report" -) - -func (n Raid) ValidateLevel() report.Report { - r := report.Report{} - switch n.Level { - case "linear", "raid0", "0", "stripe": - if n.Spares != 0 { - r.Add(report.Entry{ - Message: errors.ErrSparesUnsupportedForLevel.Error(), - Kind: report.EntryError, - }) - } - case "raid1", "1", "mirror": - case "raid4", "4": - case "raid5", "5": - case "raid6", "6": - case "raid10", "10": - default: - r.Add(report.Entry{ - Message: errors.ErrUnrecognizedRaidLevel.Error(), - Kind: report.EntryError, - }) - } - return r -} - -func (n Raid) ValidateDevices() report.Report { - r := report.Report{} - for _, d := range n.Devices { - if err := validatePath(string(d)); err != nil { - r.Add(report.Entry{ - Message: errors.ErrPathRelative.Error(), - Kind: report.EntryError, - }) - } - } - return r -} diff --git a/vendor/github.com/coreos/ignition/config/v2_3_experimental/types/schema.go b/vendor/github.com/coreos/ignition/config/v2_3_experimental/types/schema.go deleted file mode 100644 index 73424c546ef..00000000000 --- a/vendor/github.com/coreos/ignition/config/v2_3_experimental/types/schema.go +++ /dev/null @@ -1,248 +0,0 @@ -package types - -// generated by "schematyper --package=types schema/ignition.json -o internal/config/types/schema.go --root-type=Config" -- DO NOT EDIT - -type CaReference struct { - Source string `json:"source,omitempty"` - Verification Verification `json:"verification,omitempty"` -} - -type Config struct { - Ignition Ignition `json:"ignition"` - Networkd Networkd `json:"networkd,omitempty"` - Passwd Passwd `json:"passwd,omitempty"` - Storage Storage `json:"storage,omitempty"` - Systemd Systemd `json:"systemd,omitempty"` -} - -type ConfigReference struct { - Source string `json:"source,omitempty"` - Verification Verification `json:"verification,omitempty"` -} - -type Create struct { - Force bool `json:"force,omitempty"` - Options []CreateOption `json:"options,omitempty"` -} - -type CreateOption string - -type Device string - -type Directory struct { - Node - DirectoryEmbedded1 -} - -type DirectoryEmbedded1 struct { - Mode *int `json:"mode,omitempty"` -} - -type Disk struct { - Device string `json:"device,omitempty"` - Partitions []Partition `json:"partitions,omitempty"` - WipeTable bool `json:"wipeTable,omitempty"` -} - -type File struct { - Node - FileEmbedded1 -} - -type FileContents struct { - Compression string `json:"compression,omitempty"` - Source string `json:"source,omitempty"` - Verification Verification `json:"verification,omitempty"` -} - -type FileEmbedded1 struct { - Append bool `json:"append,omitempty"` - Contents FileContents `json:"contents,omitempty"` - Mode *int `json:"mode,omitempty"` -} - -type Filesystem struct { - Mount *Mount `json:"mount,omitempty"` - Name string `json:"name,omitempty"` - Path *string `json:"path,omitempty"` -} - -type Group string - -type Ignition struct { - Config IgnitionConfig `json:"config,omitempty"` - Security Security `json:"security,omitempty"` - Timeouts Timeouts `json:"timeouts,omitempty"` - Version string `json:"version,omitempty"` -} - -type IgnitionConfig struct { - Append []ConfigReference `json:"append,omitempty"` - Replace *ConfigReference `json:"replace,omitempty"` -} - -type Link struct { - Node - LinkEmbedded1 -} - -type LinkEmbedded1 struct { - Hard bool `json:"hard,omitempty"` - Target string `json:"target,omitempty"` -} - -type Mount struct { - Create *Create `json:"create,omitempty"` - Device string `json:"device,omitempty"` - Format string `json:"format,omitempty"` - Label *string `json:"label,omitempty"` - Options []MountOption `json:"options,omitempty"` - UUID *string `json:"uuid,omitempty"` - WipeFilesystem bool `json:"wipeFilesystem,omitempty"` -} - -type MountOption string - -type Networkd struct { - Units []Networkdunit `json:"units,omitempty"` -} - -type NetworkdDropin struct { - Contents string `json:"contents,omitempty"` - Name string `json:"name,omitempty"` -} - -type Networkdunit struct { - Contents string `json:"contents,omitempty"` - Dropins []NetworkdDropin `json:"dropins,omitempty"` - Name string `json:"name,omitempty"` -} - -type Node struct { - Filesystem string `json:"filesystem,omitempty"` - Group *NodeGroup `json:"group,omitempty"` - Overwrite *bool `json:"overwrite,omitempty"` - Path string `json:"path,omitempty"` - User *NodeUser `json:"user,omitempty"` -} - -type NodeGroup struct { - ID *int `json:"id,omitempty"` - Name string `json:"name,omitempty"` -} - -type NodeUser struct { - ID *int `json:"id,omitempty"` - Name string `json:"name,omitempty"` -} - -type Partition struct { - GUID string `json:"guid,omitempty"` - Label *string `json:"label,omitempty"` - Number int `json:"number,omitempty"` - ShouldExist *bool `json:"shouldExist,omitempty"` - Size *int `json:"size,omitempty"` - Start *int `json:"start,omitempty"` - TypeGUID string `json:"typeGuid,omitempty"` - WipePartitionEntry bool `json:"wipePartitionEntry,omitempty"` -} - -type Passwd struct { - Groups []PasswdGroup `json:"groups,omitempty"` - Users []PasswdUser `json:"users,omitempty"` -} - -type PasswdGroup struct { - Gid *int `json:"gid,omitempty"` - Name string `json:"name,omitempty"` - PasswordHash string `json:"passwordHash,omitempty"` - System bool `json:"system,omitempty"` -} - -type PasswdUser struct { - Create *Usercreate `json:"create,omitempty"` - Gecos string `json:"gecos,omitempty"` - Groups []Group `json:"groups,omitempty"` - HomeDir string `json:"homeDir,omitempty"` - Name string `json:"name,omitempty"` - NoCreateHome bool `json:"noCreateHome,omitempty"` - NoLogInit bool `json:"noLogInit,omitempty"` - NoUserGroup bool `json:"noUserGroup,omitempty"` - PasswordHash *string `json:"passwordHash,omitempty"` - PrimaryGroup string `json:"primaryGroup,omitempty"` - SSHAuthorizedKeys []SSHAuthorizedKey `json:"sshAuthorizedKeys,omitempty"` - Shell string `json:"shell,omitempty"` - System bool `json:"system,omitempty"` - UID *int `json:"uid,omitempty"` -} - -type Raid struct { - Devices []Device `json:"devices,omitempty"` - Level string `json:"level,omitempty"` - Name string `json:"name,omitempty"` - Options []RaidOption `json:"options,omitempty"` - Spares int `json:"spares,omitempty"` -} - -type RaidOption string - -type SSHAuthorizedKey string - -type Security struct { - TLS TLS `json:"tls,omitempty"` -} - -type Storage struct { - Directories []Directory `json:"directories,omitempty"` - Disks []Disk `json:"disks,omitempty"` - Files []File `json:"files,omitempty"` - Filesystems []Filesystem `json:"filesystems,omitempty"` - Links []Link `json:"links,omitempty"` - Raid []Raid `json:"raid,omitempty"` -} - -type Systemd struct { - Units []Unit `json:"units,omitempty"` -} - -type SystemdDropin struct { - Contents string `json:"contents,omitempty"` - Name string `json:"name,omitempty"` -} - -type TLS struct { - CertificateAuthorities []CaReference `json:"certificateAuthorities,omitempty"` -} - -type Timeouts struct { - HTTPResponseHeaders *int `json:"httpResponseHeaders,omitempty"` - HTTPTotal *int `json:"httpTotal,omitempty"` -} - -type Unit struct { - Contents string `json:"contents,omitempty"` - Dropins []SystemdDropin `json:"dropins,omitempty"` - Enable bool `json:"enable,omitempty"` - Enabled *bool `json:"enabled,omitempty"` - Mask bool `json:"mask,omitempty"` - Name string `json:"name,omitempty"` -} - -type Usercreate struct { - Gecos string `json:"gecos,omitempty"` - Groups []UsercreateGroup `json:"groups,omitempty"` - HomeDir string `json:"homeDir,omitempty"` - NoCreateHome bool `json:"noCreateHome,omitempty"` - NoLogInit bool `json:"noLogInit,omitempty"` - NoUserGroup bool `json:"noUserGroup,omitempty"` - PrimaryGroup string `json:"primaryGroup,omitempty"` - Shell string `json:"shell,omitempty"` - System bool `json:"system,omitempty"` - UID *int `json:"uid,omitempty"` -} - -type UsercreateGroup string - -type Verification struct { - Hash *string `json:"hash,omitempty"` -} diff --git a/vendor/github.com/coreos/ignition/config/v2_3_experimental/types/unit.go b/vendor/github.com/coreos/ignition/config/v2_3_experimental/types/unit.go deleted file mode 100644 index 70fe1179a45..00000000000 --- a/vendor/github.com/coreos/ignition/config/v2_3_experimental/types/unit.go +++ /dev/null @@ -1,131 +0,0 @@ -// Copyright 2016 CoreOS, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package types - -import ( - "fmt" - "path" - "strings" - - "github.com/coreos/go-systemd/unit" - - "github.com/coreos/ignition/config/shared/errors" - "github.com/coreos/ignition/config/shared/validations" - "github.com/coreos/ignition/config/validate/report" -) - -func (u Unit) ValidateContents() report.Report { - r := report.Report{} - opts, err := validateUnitContent(u.Contents) - if err != nil { - r.Add(report.Entry{ - Message: err.Error(), - Kind: report.EntryError, - }) - } - - isEnabled := u.Enable || (u.Enabled != nil && *u.Enabled) - r.Merge(validations.ValidateInstallSection(u.Name, isEnabled, u.Contents == "", opts)) - - return r -} - -func (u Unit) ValidateName() report.Report { - r := report.Report{} - switch path.Ext(u.Name) { - case ".service", ".socket", ".device", ".mount", ".automount", ".swap", ".target", ".path", ".timer", ".snapshot", ".slice", ".scope": - default: - r.Add(report.Entry{ - Message: errors.ErrInvalidSystemdExt.Error(), - Kind: report.EntryError, - }) - } - return r -} - -func (d SystemdDropin) Validate() report.Report { - r := report.Report{} - - if _, err := validateUnitContent(d.Contents); err != nil { - r.Add(report.Entry{ - Message: err.Error(), - Kind: report.EntryError, - }) - } - - switch path.Ext(d.Name) { - case ".conf": - default: - r.Add(report.Entry{ - Message: errors.ErrInvalidSystemdDropinExt.Error(), - Kind: report.EntryError, - }) - } - - return r -} - -func (u Networkdunit) Validate() report.Report { - r := report.Report{} - - if _, err := validateUnitContent(u.Contents); err != nil { - r.Add(report.Entry{ - Message: err.Error(), - Kind: report.EntryError, - }) - } - - switch path.Ext(u.Name) { - case ".link", ".netdev", ".network": - default: - r.Add(report.Entry{ - Message: errors.ErrInvalidNetworkdExt.Error(), - Kind: report.EntryError, - }) - } - - return r -} - -func (d NetworkdDropin) Validate() report.Report { - r := report.Report{} - - if _, err := validateUnitContent(d.Contents); err != nil { - r.Add(report.Entry{ - Message: err.Error(), - Kind: report.EntryError, - }) - } - - switch path.Ext(d.Name) { - case ".conf": - default: - r.Add(report.Entry{ - Message: errors.ErrInvalidNetworkdDropinExt.Error(), - Kind: report.EntryError, - }) - } - - return r -} - -func validateUnitContent(content string) ([]*unit.UnitOption, error) { - c := strings.NewReader(content) - opts, err := unit.Deserialize(c) - if err != nil { - return nil, fmt.Errorf("invalid unit content: %s", err) - } - return opts, nil -} diff --git a/vendor/github.com/coreos/ignition/config/v2_3_experimental/types/url.go b/vendor/github.com/coreos/ignition/config/v2_3_experimental/types/url.go deleted file mode 100644 index 2e90ff6d07b..00000000000 --- a/vendor/github.com/coreos/ignition/config/v2_3_experimental/types/url.go +++ /dev/null @@ -1,46 +0,0 @@ -// Copyright 2016 CoreOS, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package types - -import ( - "net/url" - - "github.com/vincent-petithory/dataurl" - - "github.com/coreos/ignition/config/shared/errors" -) - -func validateURL(s string) error { - // Empty url is valid, indicates an empty file - if s == "" { - return nil - } - u, err := url.Parse(s) - if err != nil { - return errors.ErrInvalidUrl - } - - switch u.Scheme { - case "http", "https", "oem", "tftp", "s3": - return nil - case "data": - if _, err := dataurl.DecodeString(s); err != nil { - return err - } - return nil - default: - return errors.ErrInvalidScheme - } -} diff --git a/vendor/github.com/coreos/ignition/config/v2_3_experimental/types/verification.go b/vendor/github.com/coreos/ignition/config/v2_3_experimental/types/verification.go deleted file mode 100644 index 51e7d1550a3..00000000000 --- a/vendor/github.com/coreos/ignition/config/v2_3_experimental/types/verification.go +++ /dev/null @@ -1,77 +0,0 @@ -// Copyright 2016 CoreOS, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package types - -import ( - "crypto" - "encoding/hex" - "strings" - - "github.com/coreos/ignition/config/shared/errors" - "github.com/coreos/ignition/config/validate/report" -) - -// HashParts will return the sum and function (in that order) of the hash stored -// in this Verification, or an error if there is an issue during parsing. -func (v Verification) HashParts() (string, string, error) { - if v.Hash == nil { - // The hash can be nil - return "", "", nil - } - parts := strings.SplitN(*v.Hash, "-", 2) - if len(parts) != 2 { - return "", "", errors.ErrHashMalformed - } - - return parts[0], parts[1], nil -} - -func (v Verification) Validate() report.Report { - r := report.Report{} - - if v.Hash == nil { - // The hash can be nil - return r - } - - function, sum, err := v.HashParts() - if err != nil { - r.Add(report.Entry{ - Message: err.Error(), - Kind: report.EntryError, - }) - return r - } - var hash crypto.Hash - switch function { - case "sha512": - hash = crypto.SHA512 - default: - r.Add(report.Entry{ - Message: errors.ErrHashUnrecognized.Error(), - Kind: report.EntryError, - }) - return r - } - - if len(sum) != hex.EncodedLen(hash.Size()) { - r.Add(report.Entry{ - Message: errors.ErrHashWrongSize.Error(), - Kind: report.EntryError, - }) - } - - return r -} diff --git a/vendor/github.com/coreos/ignition/config/v1/config.go b/vendor/github.com/coreos/ignition/config/v3_0/config.go similarity index 64% rename from vendor/github.com/coreos/ignition/config/v1/config.go rename to vendor/github.com/coreos/ignition/config/v3_0/config.go index 21e79f81e54..78d6494943c 100644 --- a/vendor/github.com/coreos/ignition/config/v1/config.go +++ b/vendor/github.com/coreos/ignition/config/v3_0/config.go @@ -12,38 +12,45 @@ // See the License for the specific language governing permissions and // limitations under the License. -package v1 +package v3_0 import ( + "reflect" + + "github.com/coreos/ignition/config/merge" "github.com/coreos/ignition/config/shared/errors" "github.com/coreos/ignition/config/util" - "github.com/coreos/ignition/config/v1/types" + "github.com/coreos/ignition/config/v3_0/types" "github.com/coreos/ignition/config/validate" "github.com/coreos/ignition/config/validate/report" - json "github.com/ajeddeloh/go-json" + "github.com/coreos/go-semver/semver" ) +func Merge(parent, child types.Config) types.Config { + vParent := reflect.ValueOf(parent) + vChild := reflect.ValueOf(child) + + vRes := merge.MergeStruct(vParent, vChild) + res := vRes.Interface().(types.Config) + return res +} + +// Parse parses the raw config into a types.Config struct and generates a report of any +// errors, warnings, info, and deprecations it encountered func Parse(rawConfig []byte) (types.Config, report.Report, error) { if isEmpty(rawConfig) { return types.Config{}, report.Report{}, errors.ErrEmpty - } else if isCloudConfig(rawConfig) { - return types.Config{}, report.Report{}, errors.ErrCloudConfig - } else if isScript(rawConfig) { - return types.Config{}, report.Report{}, errors.ErrScript } - var err error var config types.Config - - err = json.Unmarshal(rawConfig, &config) - if err != nil { - rpt, err := util.HandleParseErrors(rawConfig) - // HandleParseErrors always returns an error + if rpt, err := util.HandleParseErrors(rawConfig, &config); err != nil { return types.Config{}, rpt, err } - if config.Version != types.Version { + version, err := semver.NewVersion(config.Ignition.Version) + + if err != nil || *version != types.MaxVersion { return types.Config{}, report.Report{}, errors.ErrUnknownVersion } @@ -51,6 +58,7 @@ func Parse(rawConfig []byte) (types.Config, report.Report, error) { if rpt.IsFatal() { return types.Config{}, rpt, errors.ErrInvalid } + return config, rpt, nil } diff --git a/vendor/github.com/coreos/ignition/config/v2_2/types/ca.go b/vendor/github.com/coreos/ignition/config/v3_0/types/ca.go similarity index 78% rename from vendor/github.com/coreos/ignition/config/v2_2/types/ca.go rename to vendor/github.com/coreos/ignition/config/v3_0/types/ca.go index 7440e1e2f3b..3b8889dea73 100644 --- a/vendor/github.com/coreos/ignition/config/v2_2/types/ca.go +++ b/vendor/github.com/coreos/ignition/config/v3_0/types/ca.go @@ -18,10 +18,11 @@ import ( "github.com/coreos/ignition/config/validate/report" ) -func (c CaReference) ValidateSource() report.Report { - err := validateURL(c.Source) - if err != nil { - return report.ReportFromError(err, report.EntryError) - } - return report.Report{} +func (c CaReference) Key() string { + return c.Source +} + +func (c CaReference) ValidateSource() (r report.Report) { + r.AddOnError(validateURL(c.Source)) + return } diff --git a/vendor/github.com/coreos/ignition/config/v2_3_experimental/types/link.go b/vendor/github.com/coreos/ignition/config/v3_0/types/config.go similarity index 69% rename from vendor/github.com/coreos/ignition/config/v2_3_experimental/types/link.go rename to vendor/github.com/coreos/ignition/config/v3_0/types/config.go index f0284425282..8b6e121f289 100644 --- a/vendor/github.com/coreos/ignition/config/v2_3_experimental/types/link.go +++ b/vendor/github.com/coreos/ignition/config/v3_0/types/config.go @@ -1,4 +1,4 @@ -// Copyright 2017 CoreOS, Inc. +// Copyright 2015 CoreOS, Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -15,19 +15,26 @@ package types import ( + "github.com/coreos/go-semver/semver" + "github.com/coreos/ignition/config/validate/report" ) -func (s LinkEmbedded1) ValidateTarget() report.Report { +var ( + MaxVersion = semver.Version{ + Major: 3, + Minor: 0, + } +) + +func (c Config) Validate() report.Report { r := report.Report{} - if !s.Hard { - err := validatePath(s.Target) - if err != nil { - r.Add(report.Entry{ - Message: err.Error(), - Kind: report.EntryError, - }) - } + rules := []rule{} + + for _, rule := range rules { + rule(c, &r) } return r } + +type rule func(cfg Config, report *report.Report) diff --git a/vendor/github.com/coreos/ignition/config/v2_1/types/directory.go b/vendor/github.com/coreos/ignition/config/v3_0/types/directory.go similarity index 76% rename from vendor/github.com/coreos/ignition/config/v2_1/types/directory.go rename to vendor/github.com/coreos/ignition/config/v3_0/types/directory.go index 16adad05910..eeddcf33335 100644 --- a/vendor/github.com/coreos/ignition/config/v2_1/types/directory.go +++ b/vendor/github.com/coreos/ignition/config/v3_0/types/directory.go @@ -15,16 +15,14 @@ package types import ( + "github.com/coreos/ignition/config/shared/errors" "github.com/coreos/ignition/config/validate/report" ) -func (d Directory) ValidateMode() report.Report { - r := report.Report{} - if err := validateMode(d.Mode); err != nil { - r.Add(report.Entry{ - Message: err.Error(), - Kind: report.EntryError, - }) +func (d Directory) ValidateMode() (r report.Report) { + r.AddOnError(validateMode(d.Mode)) + if d.Mode == nil { + r.AddOnWarning(errors.ErrDirectoryPermissionsUnset) } return r } diff --git a/vendor/github.com/coreos/ignition/config/v2_3_experimental/types/disk.go b/vendor/github.com/coreos/ignition/config/v3_0/types/disk.go similarity index 72% rename from vendor/github.com/coreos/ignition/config/v2_3_experimental/types/disk.go rename to vendor/github.com/coreos/ignition/config/v3_0/types/disk.go index ebffc2cd674..00f8f58adbd 100644 --- a/vendor/github.com/coreos/ignition/config/v2_3_experimental/types/disk.go +++ b/vendor/github.com/coreos/ignition/config/v3_0/types/disk.go @@ -19,48 +19,43 @@ import ( "github.com/coreos/ignition/config/validate/report" ) +func (d Disk) Key() string { + return d.Device +} + func (n Disk) Validate() report.Report { return report.Report{} } -func (n Disk) ValidateDevice() report.Report { +func (n Disk) ValidateDevice() (r report.Report) { if len(n.Device) == 0 { - return report.ReportFromError(errors.ErrDiskDeviceRequired, report.EntryError) - } - if err := validatePath(string(n.Device)); err != nil { - return report.ReportFromError(err, report.EntryError) + r.AddOnError(errors.ErrDiskDeviceRequired) + return } - return report.Report{} + r.AddOnError(validatePath(n.Device)) + return } -func (n Disk) ValidatePartitions() report.Report { - r := report.Report{} +func (n Disk) ValidatePartitions() (r report.Report) { if n.partitionNumbersCollide() { - r.Add(report.Entry{ - Message: errors.ErrPartitionNumbersCollide.Error(), - Kind: report.EntryError, - }) + r.AddOnError(errors.ErrPartitionNumbersCollide) } if n.partitionsOverlap() { - r.Add(report.Entry{ - Message: errors.ErrPartitionsOverlap.Error(), - Kind: report.EntryError, - }) + r.AddOnError(errors.ErrPartitionsOverlap) } if n.partitionsMisaligned() { - r.Add(report.Entry{ - Message: errors.ErrPartitionsMisaligned.Error(), - Kind: report.EntryError, - }) + r.AddOnError(errors.ErrPartitionsMisaligned) } if n.partitionsMixZeroesAndNonexistence() { - r.Add(report.Entry{ - Message: errors.ErrZeroesWithShouldNotExist.Error(), - Kind: report.EntryError, - }) + r.AddOnError(errors.ErrZeroesWithShouldNotExist) + } + if n.partitionsUnitsMismatch() { + r.AddOnError(errors.ErrPartitionsUnitsMismatch) } - // Disks which have no errors at this point will likely succeed in sgdisk - return r + if n.partitionLabelsCollide() { + r.AddOnError(errors.ErrDuplicateLabels) + } + return } // partitionNumbersCollide returns true if partition numbers in n.Partitions are not unique. @@ -81,6 +76,20 @@ func (n Disk) partitionNumbersCollide() bool { return false } +func (d Disk) partitionLabelsCollide() bool { + m := map[string]struct{}{} + for _, p := range d.Partitions { + if p.Label != nil { + // a number of 0 means next available number, multiple devices can specify this + if _, exists := m[*p.Label]; exists { + return true + } + m[*p.Label] = struct{}{} + } + } + return false +} + // end returns the last sector of a partition. Only used by partitionsOverlap. Requires non-nil Start and Size. func (p Partition) end() int { if *p.Size == 0 { @@ -142,3 +151,17 @@ func (n Disk) partitionsMixZeroesAndNonexistence() bool { } return hasZero && hasShouldNotExist } + +func (n Disk) partitionsUnitsMismatch() bool { + partsInMb := false + partsNotInMb := false + for _, p := range n.Partitions { + if p.Size != nil || p.Start != nil { + partsNotInMb = true + } + if p.SizeMiB != nil || p.StartMiB != nil { + partsInMb = true + } + } + return partsInMb && partsNotInMb +} diff --git a/vendor/github.com/coreos/ignition/config/v2_1/types/file.go b/vendor/github.com/coreos/ignition/config/v3_0/types/file.go similarity index 54% rename from vendor/github.com/coreos/ignition/config/v2_1/types/file.go rename to vendor/github.com/coreos/ignition/config/v3_0/types/file.go index ac79cd85854..3d9447f9647 100644 --- a/vendor/github.com/coreos/ignition/config/v2_1/types/file.go +++ b/vendor/github.com/coreos/ignition/config/v3_0/types/file.go @@ -15,42 +15,45 @@ package types import ( + "fmt" + "github.com/coreos/ignition/config/shared/errors" "github.com/coreos/ignition/config/validate/report" ) -func (f File) ValidateMode() report.Report { - r := report.Report{} - if err := validateMode(f.Mode); err != nil { - r.Add(report.Entry{ - Message: err.Error(), - Kind: report.EntryError, - }) +func (f File) ValidateMode() (r report.Report) { + r.AddOnError(validateMode(f.Mode)) + if f.Mode == nil { + r.AddOnWarning(errors.ErrFilePermissionsUnset) } return r } -func (fc FileContents) ValidateCompression() report.Report { - r := report.Report{} - switch fc.Compression { +func (f FileEmbedded1) IgnoreDuplicates() map[string]struct{} { + return map[string]struct{}{ + "Append": {}, + } +} + +func (fc FileContents) ValidateCompression() (r report.Report) { + if fc.Compression == nil { + return + } + switch *fc.Compression { case "", "gzip": default: - r.Add(report.Entry{ - Message: errors.ErrCompressionInvalid.Error(), - Kind: report.EntryError, - }) + r.AddOnError(errors.ErrCompressionInvalid) } - return r + return } -func (fc FileContents) ValidateSource() report.Report { - r := report.Report{} - err := validateURL(fc.Source) +func (fc FileContents) ValidateSource() (r report.Report) { + if fc.Source == nil { + return + } + err := validateURL(*fc.Source) if err != nil { - r.Add(report.Entry{ - Message: err.Error(), - Kind: report.EntryError, - }) + r.AddOnError(fmt.Errorf("invalid url %q: %v", *fc.Source, err)) } - return r + return } diff --git a/vendor/github.com/coreos/ignition/config/v3_0/types/filesystem.go b/vendor/github.com/coreos/ignition/config/v3_0/types/filesystem.go new file mode 100644 index 00000000000..d0e0d07914d --- /dev/null +++ b/vendor/github.com/coreos/ignition/config/v3_0/types/filesystem.go @@ -0,0 +1,102 @@ +// Copyright 2016 CoreOS, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package types + +import ( + "github.com/coreos/ignition/config/shared/errors" + "github.com/coreos/ignition/config/validate/report" +) + +func (f Filesystem) Key() string { + return f.Device +} + +func (f Filesystem) IgnoreDuplicates() map[string]struct{} { + return map[string]struct{}{ + "Options": {}, + } +} + +func (f Filesystem) ValidatePath() (r report.Report) { + if f.Path == nil || *f.Path == "" { + return + } + r.AddOnError(validatePath(*f.Path)) + return +} + +func (f Filesystem) ValidateDevice() (r report.Report) { + r.AddOnError(validatePath(f.Device)) + return +} + +func (f Filesystem) ValidateFormat() (r report.Report) { + if f.Format == nil || *f.Format == "" { + if (f.Path == nil || *f.Path == "") && + (f.Label == nil || *f.Label == "") && + (f.UUID == nil || *f.UUID == "") && + len(f.Options) == 0 { + return + } + r.AddOnError(errors.ErrFormatNilWithOthers) + return + } + switch *f.Format { + case "ext4", "btrfs", "xfs", "swap", "vfat": + default: + r.AddOnError(errors.ErrFilesystemInvalidFormat) + } + return +} + +func (f Filesystem) ValidateLabel() (r report.Report) { + if f.Label == nil || *f.Label == "" { + return + } + if f.Format == nil || *f.Format == "" { + r.AddOnError(errors.ErrLabelNeedsFormat) + return + } + switch *f.Format { + case "ext4": + if len(*f.Label) > 16 { + // source: man mkfs.ext4 + r.AddOnError(errors.ErrExt4LabelTooLong) + } + case "btrfs": + if len(*f.Label) > 256 { + // source: man mkfs.btrfs + r.AddOnError(errors.ErrBtrfsLabelTooLong) + } + case "xfs": + if len(*f.Label) > 12 { + // source: man mkfs.xfs + r.AddOnError(errors.ErrXfsLabelTooLong) + } + case "swap": + // mkswap's man page does not state a limit on label size, but through + // experimentation it appears that mkswap will truncate long labels to + // 15 characters, so let's enforce that. + if len(*f.Label) > 15 { + r.AddOnError(errors.ErrSwapLabelTooLong) + } + case "vfat": + if len(*f.Label) > 11 { + // source: man mkfs.fat + r.AddOnError(errors.ErrVfatLabelTooLong) + } + } + return +} diff --git a/vendor/github.com/coreos/ignition/config/v2_1/types/ignition.go b/vendor/github.com/coreos/ignition/config/v3_0/types/ignition.go similarity index 71% rename from vendor/github.com/coreos/ignition/config/v2_1/types/ignition.go rename to vendor/github.com/coreos/ignition/config/v3_0/types/ignition.go index bddf4958338..067af88c930 100644 --- a/vendor/github.com/coreos/ignition/config/v2_1/types/ignition.go +++ b/vendor/github.com/coreos/ignition/config/v3_0/types/ignition.go @@ -21,16 +21,19 @@ import ( "github.com/coreos/ignition/config/validate/report" ) -func (c ConfigReference) ValidateSource() report.Report { - r := report.Report{} - err := validateURL(c.Source) - if err != nil { - r.Add(report.Entry{ - Message: err.Error(), - Kind: report.EntryError, - }) +func (c ConfigReference) Key() string { + if c.Source == nil { + return "" + } + return *c.Source +} + +func (c ConfigReference) ValidateSource() (r report.Report) { + if c.Source == nil { + return } - return r + r.AddOnError(validateURL(*c.Source)) + return } func (v Ignition) Semver() (*semver.Version, error) { @@ -42,11 +45,9 @@ func (v Ignition) Validate() report.Report { if err != nil { return report.ReportFromError(errors.ErrInvalidVersion, report.EntryError) } - if MaxVersion.Major > tv.Major { - return report.ReportFromError(errors.ErrOldVersion, report.EntryError) - } - if MaxVersion.LessThan(*tv) { - return report.ReportFromError(errors.ErrNewVersion, report.EntryError) + + if MaxVersion != *tv { + return report.ReportFromError(errors.ErrUnknownVersion, report.EntryError) } return report.Report{} } diff --git a/vendor/github.com/coreos/ignition/config/v2_2/types/mode.go b/vendor/github.com/coreos/ignition/config/v3_0/types/mode.go similarity index 100% rename from vendor/github.com/coreos/ignition/config/v2_2/types/mode.go rename to vendor/github.com/coreos/ignition/config/v3_0/types/mode.go diff --git a/vendor/github.com/coreos/ignition/config/v1/types/file.go b/vendor/github.com/coreos/ignition/config/v3_0/types/node.go similarity index 54% rename from vendor/github.com/coreos/ignition/config/v1/types/file.go rename to vendor/github.com/coreos/ignition/config/v3_0/types/node.go index 8775c19fd5e..9336fc89782 100644 --- a/vendor/github.com/coreos/ignition/config/v1/types/file.go +++ b/vendor/github.com/coreos/ignition/config/v3_0/types/node.go @@ -15,25 +15,38 @@ package types import ( - "os" + "path/filepath" "github.com/coreos/ignition/config/shared/errors" "github.com/coreos/ignition/config/validate/report" ) -type FileMode os.FileMode +func (n Node) Key() string { + return n.Path +} + +func (n Node) ValidatePath() (r report.Report) { + r.AddOnError(validatePath(n.Path)) + return +} -type File struct { - Path Path `json:"path,omitempty"` - Contents string `json:"contents,omitempty"` - Mode FileMode `json:"mode,omitempty"` - Uid int `json:"uid,omitempty"` - Gid int `json:"gid,omitempty"` +func (n Node) Depth() int { + count := 0 + for p := filepath.Clean(string(n.Path)); p != "/"; count++ { + p = filepath.Dir(p) + } + return count } -func (m FileMode) Validate() report.Report { - if (m &^ 07777) != 0 { - return report.ReportFromError(errors.ErrFileIllegalMode, report.EntryError) +func (nu NodeUser) Validate() (r report.Report) { + if nu.ID != nil && (nu.Name != nil && *nu.Name != "") { + r.AddOnError(errors.ErrBothIDAndNameSet) + } + return +} +func (ng NodeGroup) Validate() (r report.Report) { + if ng.ID != nil && (ng.Name != nil && *ng.Name != "") { + r.AddOnError(errors.ErrBothIDAndNameSet) } - return report.Report{} + return } diff --git a/vendor/github.com/coreos/ignition/config/v2_3_experimental/types/partition.go b/vendor/github.com/coreos/ignition/config/v3_0/types/partition.go similarity index 56% rename from vendor/github.com/coreos/ignition/config/v2_3_experimental/types/partition.go rename to vendor/github.com/coreos/ignition/config/v3_0/types/partition.go index 4e962b6391a..1169e7d272b 100644 --- a/vendor/github.com/coreos/ignition/config/v2_3_experimental/types/partition.go +++ b/vendor/github.com/coreos/ignition/config/v3_0/types/partition.go @@ -27,18 +27,45 @@ const ( guidRegexStr = "^(|[[:xdigit:]]{8}-[[:xdigit:]]{4}-[[:xdigit:]]{4}-[[:xdigit:]]{4}-[[:xdigit:]]{12})$" ) -func (p Partition) Validate() report.Report { +func (p Partition) Key() string { + if p.Number != 0 { + return fmt.Sprintf("number:%d", p.Number) + } else { + return fmt.Sprintf("label:%s", *p.Label) + } +} + +func (p Partition) Validate() (r report.Report) { + if (p.Start != nil || p.Size != nil) && (p.StartMiB != nil || p.SizeMiB != nil) { + r.AddOnError(errors.ErrPartitionsUnitsMismatch) + } if p.ShouldExist != nil && !*p.ShouldExist && - (p.Label != nil || p.TypeGUID != "" || p.GUID != "" || p.Start != nil || p.Size != nil) { - return report.ReportFromError(errors.ErrShouldNotExistWithOthers, report.EntryError) + (p.Label != nil || (p.TypeGUID != nil && *p.TypeGUID != "") || (p.GUID != nil && *p.GUID != "") || p.Start != nil || p.Size != nil) { + r.AddOnError(errors.ErrShouldNotExistWithOthers) } - return report.Report{} + if p.Number == 0 && p.Label == nil { + r.AddOnError(errors.ErrNeedLabelOrNumber) + } + return } -func (p Partition) ValidateLabel() report.Report { - r := report.Report{} +func (p Partition) ValidateSize() (r report.Report) { + if p.Size != nil { + r.AddOnDeprecated(errors.ErrSizeDeprecated) + } + return +} + +func (p Partition) ValidateStart() (r report.Report) { + if p.Start != nil { + r.AddOnDeprecated(errors.ErrStartDeprecated) + } + return +} + +func (p Partition) ValidateLabel() (r report.Report) { if p.Label == nil { - return r + return } // http://en.wikipedia.org/wiki/GUID_Partition_Table#Partition_entries: // 56 (0x38) 72 bytes Partition name (36 UTF-16LE code units) @@ -46,20 +73,14 @@ func (p Partition) ValidateLabel() report.Report { // XXX(vc): note GPT calls it a name, we're using label for consistency // with udev naming /dev/disk/by-partlabel/*. if len(*p.Label) > 36 { - r.Add(report.Entry{ - Message: errors.ErrLabelTooLong.Error(), - Kind: report.EntryError, - }) + r.AddOnError(errors.ErrLabelTooLong) } // sgdisk uses colons for delimitting compound arguments and does not allow escaping them. if strings.Contains(*p.Label, ":") { - r.Add(report.Entry{ - Message: errors.ErrLabelContainsColon.Error(), - Kind: report.EntryWarning, - }) + r.AddOnError(errors.ErrLabelContainsColon) } - return r + return } func (p Partition) ValidateTypeGUID() report.Report { @@ -70,19 +91,16 @@ func (p Partition) ValidateGUID() report.Report { return validateGUID(p.GUID) } -func validateGUID(guid string) report.Report { - r := report.Report{} +func validateGUID(guidPointer *string) (r report.Report) { + if guidPointer == nil { + return + } + guid := *guidPointer ok, err := regexp.MatchString(guidRegexStr, guid) if err != nil { - r.Add(report.Entry{ - Message: fmt.Sprintf("error matching guid regexp: %v", err), - Kind: report.EntryError, - }) + r.AddOnError(fmt.Errorf("error matching guid regexp: %v", err)) } else if !ok { - r.Add(report.Entry{ - Message: errors.ErrDoesntMatchGUIDRegex.Error(), - Kind: report.EntryError, - }) + r.AddOnError(errors.ErrDoesntMatchGUIDRegex) } return r } diff --git a/vendor/github.com/coreos/ignition/config/v1/types/passwd.go b/vendor/github.com/coreos/ignition/config/v3_0/types/passwd.go similarity index 81% rename from vendor/github.com/coreos/ignition/config/v1/types/passwd.go rename to vendor/github.com/coreos/ignition/config/v3_0/types/passwd.go index 0ffff43bb84..ff25eac3815 100644 --- a/vendor/github.com/coreos/ignition/config/v1/types/passwd.go +++ b/vendor/github.com/coreos/ignition/config/v3_0/types/passwd.go @@ -1,4 +1,4 @@ -// Copyright 2016 CoreOS, Inc. +// Copyright 2017 CoreOS, Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,7 +14,10 @@ package types -type Passwd struct { - Users []User `json:"users,omitempty"` - Groups []Group `json:"groups,omitempty"` +func (p PasswdUser) Key() string { + return p.Name +} + +func (g PasswdGroup) Key() string { + return g.Name } diff --git a/vendor/github.com/coreos/ignition/config/v2_3_experimental/types/path.go b/vendor/github.com/coreos/ignition/config/v3_0/types/path.go similarity index 88% rename from vendor/github.com/coreos/ignition/config/v2_3_experimental/types/path.go rename to vendor/github.com/coreos/ignition/config/v3_0/types/path.go index 780607c31ab..193120176ca 100644 --- a/vendor/github.com/coreos/ignition/config/v2_3_experimental/types/path.go +++ b/vendor/github.com/coreos/ignition/config/v3_0/types/path.go @@ -21,8 +21,14 @@ import ( ) func validatePath(p string) error { + if p == "" { + return errors.ErrNoPath + } if !path.IsAbs(p) { return errors.ErrPathRelative } + if path.Clean(p) != p { + return errors.ErrDirtyPath + } return nil } diff --git a/vendor/github.com/coreos/ignition/config/v2_2/types/raid.go b/vendor/github.com/coreos/ignition/config/v3_0/types/raid.go similarity index 66% rename from vendor/github.com/coreos/ignition/config/v2_2/types/raid.go rename to vendor/github.com/coreos/ignition/config/v3_0/types/raid.go index 3aceaa9faa1..4e05b7b9458 100644 --- a/vendor/github.com/coreos/ignition/config/v2_2/types/raid.go +++ b/vendor/github.com/coreos/ignition/config/v3_0/types/raid.go @@ -19,15 +19,21 @@ import ( "github.com/coreos/ignition/config/validate/report" ) -func (n Raid) ValidateLevel() report.Report { - r := report.Report{} +func (r Raid) Key() string { + return r.Name +} + +func (r Raid) IgnoreDuplicates() map[string]struct{} { + return map[string]struct{}{ + "Options": {}, + } +} + +func (n Raid) ValidateLevel() (r report.Report) { switch n.Level { case "linear", "raid0", "0", "stripe": - if n.Spares != 0 { - r.Add(report.Entry{ - Message: errors.ErrSparesUnsupportedForLevel.Error(), - Kind: report.EntryError, - }) + if n.Spares != nil && *n.Spares != 0 { + r.AddOnError(errors.ErrSparesUnsupportedForLevel) } case "raid1", "1", "mirror": case "raid4", "4": @@ -35,23 +41,16 @@ func (n Raid) ValidateLevel() report.Report { case "raid6", "6": case "raid10", "10": default: - r.Add(report.Entry{ - Message: errors.ErrUnrecognizedRaidLevel.Error(), - Kind: report.EntryError, - }) + r.AddOnError(errors.ErrUnrecognizedRaidLevel) } return r } -func (n Raid) ValidateDevices() report.Report { - r := report.Report{} +func (n Raid) ValidateDevices() (r report.Report) { for _, d := range n.Devices { if err := validatePath(string(d)); err != nil { - r.Add(report.Entry{ - Message: errors.ErrPathRelative.Error(), - Kind: report.EntryError, - }) + r.AddOnError(errors.ErrPathRelative) } } - return r + return } diff --git a/vendor/github.com/coreos/ignition/config/v3_0/types/schema.go b/vendor/github.com/coreos/ignition/config/v3_0/types/schema.go new file mode 100644 index 00000000000..a00a27e9d2f --- /dev/null +++ b/vendor/github.com/coreos/ignition/config/v3_0/types/schema.go @@ -0,0 +1,203 @@ +package types + +// generated by "schematyper --package=types config/v3_0/schema/ignition.json -o config/v3_0/types/schema.go --root-type=Config" -- DO NOT EDIT + +type CaReference struct { + Source string `json:"source"` + Verification Verification `json:"verification,omitempty"` +} + +type Config struct { + Ignition Ignition `json:"ignition"` + Passwd Passwd `json:"passwd,omitempty"` + Storage Storage `json:"storage,omitempty"` + Systemd Systemd `json:"systemd,omitempty"` +} + +type ConfigReference struct { + Source *string `json:"source"` + Verification Verification `json:"verification,omitempty"` +} + +type Device string + +type Directory struct { + Node + DirectoryEmbedded1 +} + +type DirectoryEmbedded1 struct { + Mode *int `json:"mode,omitempty"` +} + +type Disk struct { + Device string `json:"device"` + Partitions []Partition `json:"partitions,omitempty"` + WipeTable *bool `json:"wipeTable,omitempty"` +} + +type Dropin struct { + Contents *string `json:"contents,omitempty"` + Name string `json:"name"` +} + +type File struct { + Node + FileEmbedded1 +} + +type FileContents struct { + Compression *string `json:"compression,omitempty"` + Source *string `json:"source,omitempty"` + Verification Verification `json:"verification,omitempty"` +} + +type FileEmbedded1 struct { + Append []FileContents `json:"append,omitempty"` + Contents FileContents `json:"contents,omitempty"` + Mode *int `json:"mode,omitempty"` +} + +type Filesystem struct { + Device string `json:"device"` + Format *string `json:"format,omitempty"` + Label *string `json:"label,omitempty"` + Options []FilesystemOption `json:"options,omitempty"` + Path *string `json:"path,omitempty"` + UUID *string `json:"uuid,omitempty"` + WipeFilesystem *bool `json:"wipeFilesystem,omitempty"` +} + +type FilesystemOption string + +type Group string + +type Ignition struct { + Config IgnitionConfig `json:"config,omitempty"` + Security Security `json:"security,omitempty"` + Timeouts Timeouts `json:"timeouts,omitempty"` + Version string `json:"version,omitempty"` +} + +type IgnitionConfig struct { + Merge []ConfigReference `json:"merge,omitempty"` + Replace ConfigReference `json:"replace,omitempty"` +} + +type Link struct { + Node + LinkEmbedded1 +} + +type LinkEmbedded1 struct { + Hard *bool `json:"hard,omitempty"` + Target string `json:"target"` +} + +type Node struct { + Group NodeGroup `json:"group,omitempty"` + Overwrite *bool `json:"overwrite,omitempty"` + Path string `json:"path"` + User NodeUser `json:"user,omitempty"` +} + +type NodeGroup struct { + ID *int `json:"id,omitempty"` + Name *string `json:"name,omitempty"` +} + +type NodeUser struct { + ID *int `json:"id,omitempty"` + Name *string `json:"name,omitempty"` +} + +type Partition struct { + GUID *string `json:"guid,omitempty"` + Label *string `json:"label,omitempty"` + Number int `json:"number,omitempty"` + ShouldExist *bool `json:"shouldExist,omitempty"` + Size *int `json:"size,omitempty"` + SizeMiB *int `json:"sizeMiB,omitempty"` + Start *int `json:"start,omitempty"` + StartMiB *int `json:"startMiB,omitempty"` + TypeGUID *string `json:"typeGuid,omitempty"` + WipePartitionEntry *bool `json:"wipePartitionEntry,omitempty"` +} + +type Passwd struct { + Groups []PasswdGroup `json:"groups,omitempty"` + Users []PasswdUser `json:"users,omitempty"` +} + +type PasswdGroup struct { + Gid *int `json:"gid,omitempty"` + Name string `json:"name"` + PasswordHash *string `json:"passwordHash,omitempty"` + System *bool `json:"system,omitempty"` +} + +type PasswdUser struct { + Gecos *string `json:"gecos,omitempty"` + Groups []Group `json:"groups,omitempty"` + HomeDir *string `json:"homeDir,omitempty"` + Name string `json:"name"` + NoCreateHome *bool `json:"noCreateHome,omitempty"` + NoLogInit *bool `json:"noLogInit,omitempty"` + NoUserGroup *bool `json:"noUserGroup,omitempty"` + PasswordHash *string `json:"passwordHash,omitempty"` + PrimaryGroup *string `json:"primaryGroup,omitempty"` + SSHAuthorizedKeys []SSHAuthorizedKey `json:"sshAuthorizedKeys,omitempty"` + Shell *string `json:"shell,omitempty"` + System *bool `json:"system,omitempty"` + UID *int `json:"uid,omitempty"` +} + +type Raid struct { + Devices []Device `json:"devices"` + Level string `json:"level"` + Name string `json:"name"` + Options []RaidOption `json:"options,omitempty"` + Spares *int `json:"spares,omitempty"` +} + +type RaidOption string + +type SSHAuthorizedKey string + +type Security struct { + TLS TLS `json:"tls,omitempty"` +} + +type Storage struct { + Directories []Directory `json:"directories,omitempty"` + Disks []Disk `json:"disks,omitempty"` + Files []File `json:"files,omitempty"` + Filesystems []Filesystem `json:"filesystems,omitempty"` + Links []Link `json:"links,omitempty"` + Raid []Raid `json:"raid,omitempty"` +} + +type Systemd struct { + Units []Unit `json:"units,omitempty"` +} + +type TLS struct { + CertificateAuthorities []CaReference `json:"certificateAuthorities,omitempty"` +} + +type Timeouts struct { + HTTPResponseHeaders *int `json:"httpResponseHeaders,omitempty"` + HTTPTotal *int `json:"httpTotal,omitempty"` +} + +type Unit struct { + Contents *string `json:"contents,omitempty"` + Dropins []Dropin `json:"dropins,omitempty"` + Enabled *bool `json:"enabled,omitempty"` + Mask *bool `json:"mask,omitempty"` + Name string `json:"name"` +} + +type Verification struct { + Hash *string `json:"hash,omitempty"` +} diff --git a/vendor/github.com/coreos/ignition/config/v1/types/systemd.go b/vendor/github.com/coreos/ignition/config/v3_0/types/storage.go similarity index 75% rename from vendor/github.com/coreos/ignition/config/v1/types/systemd.go rename to vendor/github.com/coreos/ignition/config/v3_0/types/storage.go index 97194b91150..d9a4c554a16 100644 --- a/vendor/github.com/coreos/ignition/config/v1/types/systemd.go +++ b/vendor/github.com/coreos/ignition/config/v3_0/types/storage.go @@ -1,4 +1,4 @@ -// Copyright 2016 CoreOS, Inc. +// Copyright 2019 Red Hat, Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,6 +14,10 @@ package types -type Systemd struct { - Units []SystemdUnit `json:"units,omitempty"` +func (s Storage) MergedKeys() map[string]string { + return map[string]string{ + "Directories": "Node", + "Files": "Node", + "Links": "Node", + } } diff --git a/vendor/github.com/coreos/ignition/config/v2_1/types/unit.go b/vendor/github.com/coreos/ignition/config/v3_0/types/unit.go similarity index 51% rename from vendor/github.com/coreos/ignition/config/v2_1/types/unit.go rename to vendor/github.com/coreos/ignition/config/v3_0/types/unit.go index 07e6fe6f5cc..9f6d1a98181 100644 --- a/vendor/github.com/coreos/ignition/config/v2_1/types/unit.go +++ b/vendor/github.com/coreos/ignition/config/v3_0/types/unit.go @@ -26,81 +26,53 @@ import ( "github.com/coreos/ignition/config/validate/report" ) -func (u Unit) ValidateContents() report.Report { - r := report.Report{} +func (u Unit) Key() string { + return u.Name +} + +func (d Dropin) Key() string { + return d.Name +} + +func (u Unit) ValidateContents() (r report.Report) { opts, err := validateUnitContent(u.Contents) - if err != nil { - r.Add(report.Entry{ - Message: err.Error(), - Kind: report.EntryError, - }) - } + r.AddOnError(err) - isEnabled := u.Enable || (u.Enabled != nil && *u.Enabled) - r.Merge(validations.ValidateInstallSection(u.Name, isEnabled, u.Contents == "", opts)) + isEnabled := u.Enabled != nil && *u.Enabled + r.Merge(validations.ValidateInstallSection(u.Name, isEnabled, (u.Contents == nil || *u.Contents == ""), opts)) return r } -func (u Unit) ValidateName() report.Report { - r := report.Report{} +func (u Unit) ValidateName() (r report.Report) { switch path.Ext(u.Name) { case ".service", ".socket", ".device", ".mount", ".automount", ".swap", ".target", ".path", ".timer", ".snapshot", ".slice", ".scope": default: - r.Add(report.Entry{ - Message: errors.ErrInvalidSystemdExt.Error(), - Kind: report.EntryError, - }) + r.AddOnError(errors.ErrInvalidSystemdExt) } - return r + return } func (d Dropin) Validate() report.Report { r := report.Report{} - if _, err := validateUnitContent(d.Contents); err != nil { - r.Add(report.Entry{ - Message: err.Error(), - Kind: report.EntryError, - }) - } + _, err := validateUnitContent(d.Contents) + r.AddOnError(err) switch path.Ext(d.Name) { case ".conf": default: - r.Add(report.Entry{ - Message: errors.ErrInvalidSystemdDropinExt.Error(), - Kind: report.EntryError, - }) + r.AddOnError(errors.ErrInvalidSystemdDropinExt) } return r } -func (u Networkdunit) Validate() report.Report { - r := report.Report{} - - if _, err := validateUnitContent(u.Contents); err != nil { - r.Add(report.Entry{ - Message: err.Error(), - Kind: report.EntryError, - }) - } - - switch path.Ext(u.Name) { - case ".link", ".netdev", ".network": - default: - r.Add(report.Entry{ - Message: errors.ErrInvalidNetworkdExt.Error(), - Kind: report.EntryError, - }) +func validateUnitContent(content *string) ([]*unit.UnitOption, error) { + if content == nil { + return []*unit.UnitOption{}, nil } - - return r -} - -func validateUnitContent(content string) ([]*unit.UnitOption, error) { - c := strings.NewReader(content) + c := strings.NewReader(*content) opts, err := unit.Deserialize(c) if err != nil { return nil, fmt.Errorf("invalid unit content: %s", err) diff --git a/vendor/github.com/coreos/ignition/config/v2_2/types/url.go b/vendor/github.com/coreos/ignition/config/v3_0/types/url.go similarity index 85% rename from vendor/github.com/coreos/ignition/config/v2_2/types/url.go rename to vendor/github.com/coreos/ignition/config/v3_0/types/url.go index 2e90ff6d07b..008cf68bd0e 100644 --- a/vendor/github.com/coreos/ignition/config/v2_2/types/url.go +++ b/vendor/github.com/coreos/ignition/config/v3_0/types/url.go @@ -33,7 +33,14 @@ func validateURL(s string) error { } switch u.Scheme { - case "http", "https", "oem", "tftp", "s3": + case "http", "https", "tftp": + return nil + case "s3": + if v, ok := u.Query()["versionId"]; ok { + if len(v) == 0 || v[0] == "" { + return errors.ErrInvalidS3ObjectVersionId + } + } return nil case "data": if _, err := dataurl.DecodeString(s); err != nil { diff --git a/vendor/github.com/coreos/ignition/config/v2_1/types/verification.go b/vendor/github.com/coreos/ignition/config/v3_0/types/verification.go similarity index 77% rename from vendor/github.com/coreos/ignition/config/v2_1/types/verification.go rename to vendor/github.com/coreos/ignition/config/v3_0/types/verification.go index 51e7d1550a3..5b9a81efe5b 100644 --- a/vendor/github.com/coreos/ignition/config/v2_1/types/verification.go +++ b/vendor/github.com/coreos/ignition/config/v3_0/types/verification.go @@ -38,40 +38,29 @@ func (v Verification) HashParts() (string, string, error) { return parts[0], parts[1], nil } -func (v Verification) Validate() report.Report { - r := report.Report{} - +func (v Verification) Validate() (r report.Report) { if v.Hash == nil { // The hash can be nil - return r + return } function, sum, err := v.HashParts() if err != nil { - r.Add(report.Entry{ - Message: err.Error(), - Kind: report.EntryError, - }) - return r + r.AddOnError(err) + return } var hash crypto.Hash switch function { case "sha512": hash = crypto.SHA512 default: - r.Add(report.Entry{ - Message: errors.ErrHashUnrecognized.Error(), - Kind: report.EntryError, - }) - return r + r.AddOnError(errors.ErrHashUnrecognized) + return } if len(sum) != hex.EncodedLen(hash.Size()) { - r.Add(report.Entry{ - Message: errors.ErrHashWrongSize.Error(), - Kind: report.EntryError, - }) + r.AddOnError(errors.ErrHashWrongSize) } - return r + return } diff --git a/vendor/github.com/coreos/ignition/config/validate/astjson/node.go b/vendor/github.com/coreos/ignition/config/validate/astjson/node.go index 6735fa0ab3f..85279e50a21 100644 --- a/vendor/github.com/coreos/ignition/config/validate/astjson/node.go +++ b/vendor/github.com/coreos/ignition/config/validate/astjson/node.go @@ -15,11 +15,9 @@ package astjson import ( - "io" - json "github.com/ajeddeloh/go-json" "github.com/coreos/ignition/config/validate/astnode" - "go4.org/errorutil" + "github.com/coreos/ignition/config/validate/util" ) type JsonNode json.Node @@ -28,11 +26,11 @@ func FromJsonRoot(n json.Node) JsonNode { return JsonNode(n) } -func (n JsonNode) ValueLineCol(source io.ReadSeeker) (int, int, string) { +func (n JsonNode) ValueLineCol(source []byte) (int, int, string) { return posFromOffset(n.End, source) } -func (n JsonNode) KeyLineCol(source io.ReadSeeker) (int, int, string) { +func (n JsonNode) KeyLineCol(source []byte) (int, int, string) { return posFromOffset(n.KeyEnd, source) } @@ -63,11 +61,9 @@ func (n JsonNode) Tag() string { } // wrapper for errorutil that handles missing sources sanely and resets the reader afterwards -func posFromOffset(offset int, source io.ReadSeeker) (int, int, string) { +func posFromOffset(offset int, source []byte) (int, int, string) { if source == nil { return 0, 0, "" } - line, col, highlight := errorutil.HighlightBytePosition(source, int64(offset)) - source.Seek(0, 0) // Reset the reader to the start so the next call isn't relative to this position - return line, col, highlight + return util.Highlight(source, int64(offset)) } diff --git a/vendor/github.com/coreos/ignition/config/validate/astnode/astnode.go b/vendor/github.com/coreos/ignition/config/validate/astnode/astnode.go index d1c1d9c2420..db19d09fc0b 100644 --- a/vendor/github.com/coreos/ignition/config/validate/astnode/astnode.go +++ b/vendor/github.com/coreos/ignition/config/validate/astnode/astnode.go @@ -14,20 +14,16 @@ package astnode -import ( - "io" -) - // AstNode abstracts the differences between yaml and json nodes, providing a // common interface type AstNode interface { // ValueLineCol returns the line, column, and highlight string of the value of // this node in the source. - ValueLineCol(source io.ReadSeeker) (int, int, string) + ValueLineCol(source []byte) (int, int, string) // KeyLineCol returns the line, column, and highlight string of the key for the // value of this node in the source. - KeyLineCol(source io.ReadSeeker) (int, int, string) + KeyLineCol(source []byte) (int, int, string) // LiteralValue returns the value of this node. LiteralValue() interface{} diff --git a/vendor/github.com/coreos/ignition/config/validate/report/report.go b/vendor/github.com/coreos/ignition/config/validate/report/report.go index e0d4fed8dc8..18aec1ef9dc 100644 --- a/vendor/github.com/coreos/ignition/config/validate/report/report.go +++ b/vendor/github.com/coreos/ignition/config/validate/report/report.go @@ -43,6 +43,33 @@ func ReportFromError(err error, severity entryKind) Report { } } +// Helpers to cut verbosity +func (r *Report) addFromError(err error, severity entryKind) { + if err == nil { + return + } + r.Add(Entry{ + Kind: severity, + Message: err.Error(), + }) +} + +func (r *Report) AddOnError(err error) { + r.addFromError(err, EntryError) +} + +func (r *Report) AddOnWarning(err error) { + r.addFromError(err, EntryWarning) +} + +func (r *Report) AddOnInfo(err error) { + r.addFromError(err, EntryInfo) +} + +func (r *Report) AddOnDeprecated(err error) { + r.addFromError(err, EntryDeprecated) +} + // Sort sorts the entries by line number, then column number func (r *Report) Sort() { sort.Sort(entries(r.Entries)) diff --git a/vendor/github.com/coreos/ignition/config/validate/util/highlight.go b/vendor/github.com/coreos/ignition/config/validate/util/highlight.go new file mode 100644 index 00000000000..f1560e1b4cc --- /dev/null +++ b/vendor/github.com/coreos/ignition/config/validate/util/highlight.go @@ -0,0 +1,43 @@ +// Copyright 2015 Red Hat, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package util + +import ( + "fmt" + "strings" +) + +func Highlight(srcb []byte, offset int64) (int, int, string) { + src := string(srcb) + + startOfLine := strings.LastIndex(src[:offset], "\n") + 1 + if startOfLine == len(src) { + startOfLine-- + } + + endOfLine := strings.Index(src[offset:], "\n") + if endOfLine == -1 { + endOfLine = len(src) - 1 + } else { + endOfLine += int(offset) + } + + line := strings.Count(src[:offset], "\n") + 1 + col := int(offset) - startOfLine + 1 + + lineh := strings.Replace(src[startOfLine:endOfLine], "\t", " ", -1) + highlight := fmt.Sprintf("%s\n%s^\n", lineh, strings.Repeat(" ", col-1)) + return line, col, highlight +} diff --git a/vendor/github.com/coreos/ignition/config/validate/validate.go b/vendor/github.com/coreos/ignition/config/validate/validate.go index 12f9bf205fa..bcb92895e58 100644 --- a/vendor/github.com/coreos/ignition/config/validate/validate.go +++ b/vendor/github.com/coreos/ignition/config/validate/validate.go @@ -15,13 +15,12 @@ package validate import ( - "bytes" "fmt" - "io" "reflect" "strings" json "github.com/ajeddeloh/go-json" + "github.com/coreos/ignition/config/util" "github.com/coreos/ignition/config/validate/astjson" "github.com/coreos/ignition/config/validate/astnode" "github.com/coreos/ignition/config/validate/report" @@ -44,7 +43,7 @@ func ValidateConfig(rawConfig []byte, config interface{}) report.Report { }) r.Merge(ValidateWithoutSource(configValue)) } else { - r.Merge(Validate(configValue, astjson.FromJsonRoot(ast), bytes.NewReader(rawConfig), true)) + r.Merge(Validate(configValue, astjson.FromJsonRoot(ast), rawConfig, true)) } return r } @@ -52,7 +51,7 @@ func ValidateConfig(rawConfig []byte, config interface{}) report.Report { // Validate walks down a struct tree calling Validate on every node that implements it, building // A report of all the errors, warnings, info, and deprecations it encounters. If checkUnusedKeys // is true, Validate will generate warnings for unused keys in the ast, otherwise it will not. -func Validate(vObj reflect.Value, ast astnode.AstNode, source io.ReadSeeker, checkUnusedKeys bool) (r report.Report) { +func Validate(vObj reflect.Value, ast astnode.AstNode, source []byte, checkUnusedKeys bool) (r report.Report) { if !vObj.IsValid() { return } @@ -134,7 +133,7 @@ func getFields(vObj reflect.Value) []field { return ret } -func validateStruct(vObj reflect.Value, ast astnode.AstNode, source io.ReadSeeker, checkUnusedKeys bool) report.Report { +func validateStruct(vObj reflect.Value, ast astnode.AstNode, source []byte, checkUnusedKeys bool) report.Report { r := report.Report{} // isFromObject will be true if this struct was unmarshalled from a JSON object. @@ -149,12 +148,28 @@ func validateStruct(vObj reflect.Value, ast astnode.AstNode, source io.ReadSeeke // Maintain a list of all the tags in the struct for fuzzy matching later. tags := []string{} + // We need to do duplication checking at the struct level even though its lists that can't have duplicates. + // This is because some parts (i.e. links, files, dirs) can't have duplicates across the sum of all their members. + // map of field names to sets of strings from Key() + dupLists := map[string]map[string]struct{}{} + // List of fields that are lists that cannot include duplicates across themselves. Use the first element in the list + // to refer to the collective set + mergedKeys := map[string]string{} + if merger, ok := vObj.Interface().(util.MergesKeys); ok { + mergedKeys = merger.MergedKeys() + } + + ignoreDupsList := map[string]struct{}{} + if ignorer, ok := vObj.Interface().(util.IgnoresDups); ok { + ignoreDupsList = ignorer.IgnoreDuplicates() + } + for _, f := range getFields(vObj) { // Default to nil astnode.AstNode if the field's corrosponding node cannot be found. var sub_node astnode.AstNode // Default to passing a nil source if the field's corrosponding node cannot be found. // This ensures the line numbers reported from all sub-structs are 0 and will be changed by AddPosition - var src io.ReadSeeker + var src []byte // Try to determine the json.Node that corrosponds with the struct field if isFromObject { @@ -194,6 +209,48 @@ func validateStruct(vObj reflect.Value, ast astnode.AstNode, source io.ReadSeeke sub_report := Validate(f.Value, sub_node, src, checkUnusedKeys) sub_report.AddPosition(line, col, highlight) + + // duplicate checking time + if f.Value.Kind() == reflect.Slice { + // get the correct list of dups + dupListKey := f.Type.Name + if k, ok := mergedKeys[dupListKey]; ok { + dupListKey = k + } + if dupLists[dupListKey] == nil { + dupLists[dupListKey] = map[string]struct{}{} + } + + if _, ignored := ignoreDupsList[f.Type.Name]; !ignored { + for i := 0; i < f.Value.Len(); i++ { + key := "" + if f.Value.Index(i).Kind() == reflect.String { + key = f.Value.Index(i).Convert(reflect.TypeOf("")).Interface().(string) + } else { + key = f.Value.Index(i).Interface().(util.Keyed).Key() + } + if _, alreadyDefined := dupLists[dupListKey][key]; alreadyDefined { + // duplicate entry! + line, col, highlight := 0, 0, "" + if sub_node != nil { + sub_sub_node, ok := sub_node.SliceChild(i) + if sub_sub_node != nil && ok { + line, col, highlight = sub_sub_node.ValueLineCol(src) + } + } + sub_report.Add(report.Entry{ + Message: fmt.Sprintf("Entry defined by %q is already defined in this config", key), + Kind: report.EntryError, + Line: line, + Column: col, + Highlight: highlight, + }) + } + dupLists[dupListKey][key] = struct{}{} + } + } + } + r.Merge(sub_report) } if !isFromObject || !checkUnusedKeys { diff --git a/vendor/github.com/openshift/machine-config-operator/README.md b/vendor/github.com/openshift/machine-config-operator/README.md new file mode 120000 index 00000000000..0e01b4308c1 --- /dev/null +++ b/vendor/github.com/openshift/machine-config-operator/README.md @@ -0,0 +1 @@ +docs/README.md \ No newline at end of file diff --git a/vendor/github.com/openshift/machine-config-operator/pkg/apis/machineconfiguration.openshift.io/v1/helpers.go b/vendor/github.com/openshift/machine-config-operator/pkg/apis/machineconfiguration.openshift.io/v1/helpers.go index bb08fe9721a..562685928cd 100644 --- a/vendor/github.com/openshift/machine-config-operator/pkg/apis/machineconfiguration.openshift.io/v1/helpers.go +++ b/vendor/github.com/openshift/machine-config-operator/pkg/apis/machineconfiguration.openshift.io/v1/helpers.go @@ -1,9 +1,10 @@ package v1 import ( + "fmt" "sort" - ignv2_2 "github.com/coreos/ignition/config/v2_2" + ign "github.com/coreos/ignition/config/v3_0" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) @@ -11,22 +12,21 @@ import ( // MergeMachineConfigs combines multiple machineconfig objects into one object. // It sorts all the configs in increasing order of their name. // It uses the Ign config from first object as base and appends all the rest. -// It only uses the OSImageURL from first object and ignores it from rest. -func MergeMachineConfigs(configs []*MachineConfig) *MachineConfig { +// It uses only the OSImageURL provided by the CVO and ignores any MC provided OSImageURL. +func MergeMachineConfigs(configs []*MachineConfig, osImageURL string) *MachineConfig { if len(configs) == 0 { return nil } sort.Slice(configs, func(i, j int) bool { return configs[i].Name < configs[j].Name }) - outOSImageURL := configs[0].Spec.OSImageURL outIgn := configs[0].Spec.Config for idx := 1; idx < len(configs); idx++ { - outIgn = ignv2_2.Append(outIgn, configs[idx].Spec.Config) + outIgn = ign.Merge(outIgn, configs[idx].Spec.Config) } return &MachineConfig{ Spec: MachineConfigSpec{ - OSImageURL: outOSImageURL, + OSImageURL: osImageURL, Config: outIgn, }, } @@ -65,17 +65,17 @@ func SetMachineConfigPoolCondition(status *MachineConfigPoolStatus, condition Ma if currentCond != nil && currentCond.Status == condition.Status { condition.LastTransitionTime = currentCond.LastTransitionTime } - newConditions := filterOutCondition(status.Conditions, condition.Type) + newConditions := filterOutMachineConfigPoolCondition(status.Conditions, condition.Type) status.Conditions = append(newConditions, condition) } // RemoveMachineConfigPoolCondition removes the MachineConfigPool condition with the provided type. func RemoveMachineConfigPoolCondition(status *MachineConfigPoolStatus, condType MachineConfigPoolConditionType) { - status.Conditions = filterOutCondition(status.Conditions, condType) + status.Conditions = filterOutMachineConfigPoolCondition(status.Conditions, condType) } // filterOutCondition returns a new slice of MachineConfigPool conditions without conditions with the provided type. -func filterOutCondition(conditions []MachineConfigPoolCondition, condType MachineConfigPoolConditionType) []MachineConfigPoolCondition { +func filterOutMachineConfigPoolCondition(conditions []MachineConfigPoolCondition, condType MachineConfigPoolConditionType) []MachineConfigPoolCondition { var newConditions []MachineConfigPoolCondition for _, c := range conditions { if c.Type == condType { @@ -85,3 +85,139 @@ func filterOutCondition(conditions []MachineConfigPoolCondition, condType Machin } return newConditions } + +// IsMachineConfigPoolConditionTrue returns true when the conditionType is present and set to `ConditionTrue` +func IsMachineConfigPoolConditionTrue(conditions []MachineConfigPoolCondition, conditionType MachineConfigPoolConditionType) bool { + return IsMachineConfigPoolConditionPresentAndEqual(conditions, conditionType, corev1.ConditionTrue) +} + +// IsMachineConfigPoolConditionFalse returns true when the conditionType is present and set to `ConditionFalse` +func IsMachineConfigPoolConditionFalse(conditions []MachineConfigPoolCondition, conditionType MachineConfigPoolConditionType) bool { + return IsMachineConfigPoolConditionPresentAndEqual(conditions, conditionType, corev1.ConditionFalse) +} + +// IsMachineConfigPoolConditionPresentAndEqual returns true when conditionType is present and equal to status. +func IsMachineConfigPoolConditionPresentAndEqual(conditions []MachineConfigPoolCondition, conditionType MachineConfigPoolConditionType, status corev1.ConditionStatus) bool { + for _, condition := range conditions { + if condition.Type == conditionType { + return condition.Status == status + } + } + return false +} + +// NewKubeletConfigCondition returns an instance of a KubeletConfigCondition +func NewKubeletConfigCondition(condType KubeletConfigStatusConditionType, status corev1.ConditionStatus, message string) *KubeletConfigCondition { + return &KubeletConfigCondition{ + Type: condType, + Status: status, + LastTransitionTime: metav1.Now(), + Message: message, + } +} + +// NewContainerRuntimeConfigCondition returns an instance of a ContainerRuntimeConfigCondition +func NewContainerRuntimeConfigCondition(condType ContainerRuntimeConfigStatusConditionType, status corev1.ConditionStatus, message string) *ContainerRuntimeConfigCondition { + return &ContainerRuntimeConfigCondition{ + Type: condType, + Status: status, + LastTransitionTime: metav1.Now(), + Message: message, + } +} + +// NewControllerConfigStatusCondition creates a new ControllerConfigStatus condition. +func NewControllerConfigStatusCondition(condType ControllerConfigStatusConditionType, status corev1.ConditionStatus, reason, message string) *ControllerConfigStatusCondition { + return &ControllerConfigStatusCondition{ + Type: condType, + Status: status, + LastTransitionTime: metav1.Now(), + Reason: reason, + Message: message, + } +} + +// GetControllerConfigStatusCondition returns the condition with the provided type. +func GetControllerConfigStatusCondition(status ControllerConfigStatus, condType ControllerConfigStatusConditionType) *ControllerConfigStatusCondition { + for i := range status.Conditions { + c := status.Conditions[i] + if c.Type == condType { + return &c + } + } + return nil +} + +// SetControllerConfigStatusCondition updates the ControllerConfigStatus to include the provided condition. If the condition that +// we are about to add already exists and has the same status and reason then we are not going to update. +func SetControllerConfigStatusCondition(status *ControllerConfigStatus, condition ControllerConfigStatusCondition) { + currentCond := GetControllerConfigStatusCondition(*status, condition.Type) + if currentCond != nil && currentCond.Status == condition.Status && currentCond.Reason == condition.Reason { + return + } + // Do not update lastTransitionTime if the status of the condition doesn't change. + if currentCond != nil && currentCond.Status == condition.Status { + condition.LastTransitionTime = currentCond.LastTransitionTime + } + newConditions := filterOutControllerConfigStatusCondition(status.Conditions, condition.Type) + status.Conditions = append(newConditions, condition) +} + +// RemoveControllerConfigStatusCondition removes the ControllerConfigStatus condition with the provided type. +func RemoveControllerConfigStatusCondition(status *ControllerConfigStatus, condType ControllerConfigStatusConditionType) { + status.Conditions = filterOutControllerConfigStatusCondition(status.Conditions, condType) +} + +// filterOutCondition returns a new slice of ControllerConfigStatus conditions without conditions with the provided type. +func filterOutControllerConfigStatusCondition(conditions []ControllerConfigStatusCondition, condType ControllerConfigStatusConditionType) []ControllerConfigStatusCondition { + var newConditions []ControllerConfigStatusCondition + for _, c := range conditions { + if c.Type == condType { + continue + } + newConditions = append(newConditions, c) + } + return newConditions +} + +// IsControllerConfigStatusConditionTrue returns true when the conditionType is present and set to `ConditionTrue` +func IsControllerConfigStatusConditionTrue(conditions []ControllerConfigStatusCondition, conditionType ControllerConfigStatusConditionType) bool { + return IsControllerConfigStatusConditionPresentAndEqual(conditions, conditionType, corev1.ConditionTrue) +} + +// IsControllerConfigStatusConditionFalse returns true when the conditionType is present and set to `ConditionFalse` +func IsControllerConfigStatusConditionFalse(conditions []ControllerConfigStatusCondition, conditionType ControllerConfigStatusConditionType) bool { + return IsControllerConfigStatusConditionPresentAndEqual(conditions, conditionType, corev1.ConditionFalse) +} + +// IsControllerConfigStatusConditionPresentAndEqual returns true when conditionType is present and equal to status. +func IsControllerConfigStatusConditionPresentAndEqual(conditions []ControllerConfigStatusCondition, conditionType ControllerConfigStatusConditionType, status corev1.ConditionStatus) bool { + for _, condition := range conditions { + if condition.Type == conditionType { + return condition.Status == status + } + } + return false +} + +// IsControllerConfigCompleted checks whether a ControllerConfig is completed by the Template Controller +func IsControllerConfigCompleted(cc *ControllerConfig, ccGetter func(string) (*ControllerConfig, error)) error { + cur, err := ccGetter(cc.GetName()) + if err != nil { + return err + } + + if cur.Generation != cur.Status.ObservedGeneration { + return fmt.Errorf("status for ControllerConfig %s is being reported for %d, expecting it for %d", cc.GetName(), cur.Status.ObservedGeneration, cur.Generation) + } + + completed := IsControllerConfigStatusConditionTrue(cur.Status.Conditions, TemplateContollerCompleted) + running := IsControllerConfigStatusConditionTrue(cur.Status.Conditions, TemplateContollerRunning) + failing := IsControllerConfigStatusConditionTrue(cur.Status.Conditions, TemplateContollerFailing) + if completed && + !running && + !failing { + return nil + } + return fmt.Errorf("ControllerConfig has not completed: completed(%v) running(%v) failing(%v)", completed, running, failing) +} diff --git a/vendor/github.com/openshift/machine-config-operator/pkg/apis/machineconfiguration.openshift.io/v1/machineconfig.deepcopy.go b/vendor/github.com/openshift/machine-config-operator/pkg/apis/machineconfiguration.openshift.io/v1/machineconfig.deepcopy.go index fa05fa6255b..4a876e3369f 100644 --- a/vendor/github.com/openshift/machine-config-operator/pkg/apis/machineconfiguration.openshift.io/v1/machineconfig.deepcopy.go +++ b/vendor/github.com/openshift/machine-config-operator/pkg/apis/machineconfiguration.openshift.io/v1/machineconfig.deepcopy.go @@ -1,8 +1,8 @@ package v1 import ( - ignv2_2 "github.com/coreos/ignition/config/v2_2" - ignv2_2types "github.com/coreos/ignition/config/v2_2/types" + ign "github.com/coreos/ignition/config/v3_0" + igntypes "github.com/coreos/ignition/config/v3_0/types" runtime "k8s.io/apimachinery/pkg/runtime" ) @@ -37,13 +37,12 @@ func (in *MachineConfigSpec) DeepCopyInto(out *MachineConfigSpec) { return } -func deepCopyIgnConfig(in ignv2_2types.Config) ignv2_2types.Config { - var out ignv2_2types.Config +func deepCopyIgnConfig(in igntypes.Config) igntypes.Config { + var out igntypes.Config - // https://github.com/coreos/ignition/blob/d19b2021cf397de7c31774c13805bbc3aa655646/config/v2_2/append.go#L41 out.Ignition.Version = in.Ignition.Version - return ignv2_2.Append(out, in) + return ign.Merge(out, in) } // DeepCopy copying the receiver, creating a new MachineConfigSpec. diff --git a/vendor/github.com/openshift/machine-config-operator/pkg/apis/machineconfiguration.openshift.io/v1/register.go b/vendor/github.com/openshift/machine-config-operator/pkg/apis/machineconfiguration.openshift.io/v1/register.go index c911c24e89e..f54abb21219 100644 --- a/vendor/github.com/openshift/machine-config-operator/pkg/apis/machineconfiguration.openshift.io/v1/register.go +++ b/vendor/github.com/openshift/machine-config-operator/pkg/apis/machineconfiguration.openshift.io/v1/register.go @@ -40,8 +40,12 @@ func init() { func addKnownTypes(scheme *runtime.Scheme) error { scheme.AddKnownTypes(SchemeGroupVersion, &MCOConfig{}, + &ContainerRuntimeConfig{}, + &ContainerRuntimeConfigList{}, &ControllerConfig{}, &ControllerConfigList{}, + &KubeletConfig{}, + &KubeletConfigList{}, &MachineConfig{}, &MachineConfigList{}, &MachineConfigPool{}, diff --git a/vendor/github.com/openshift/machine-config-operator/pkg/apis/machineconfiguration.openshift.io/v1/types.go b/vendor/github.com/openshift/machine-config-operator/pkg/apis/machineconfiguration.openshift.io/v1/types.go index efed650e1ac..d4c4c1f46c1 100644 --- a/vendor/github.com/openshift/machine-config-operator/pkg/apis/machineconfiguration.openshift.io/v1/types.go +++ b/vendor/github.com/openshift/machine-config-operator/pkg/apis/machineconfiguration.openshift.io/v1/types.go @@ -1,10 +1,12 @@ package v1 import ( - ignv2_2types "github.com/coreos/ignition/config/v2_2/types" + igntypes "github.com/coreos/ignition/config/v3_0/types" corev1 "k8s.io/api/core/v1" + "k8s.io/apimachinery/pkg/api/resource" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/util/intstr" + kubeletconfigv1beta1 "k8s.io/kubelet/config/v1beta1" ) // CustomResourceDefinition for MCOConfig @@ -50,17 +52,6 @@ type MCOConfig struct { // MCOConfigSpec is the spec for MCOConfig resource. type MCOConfigSpec struct { - ClusterDNSIP string `json:"clusterDNSIP"` - CloudProviderConfig string `json:"cloudProviderConfig"` - ClusterName string `json:"clusterName"` - - // The openshift platform, e.g. "libvirt" or "aws" - Platform string `json:"platform"` - - BaseDomain string `json:"baseDomain"` - - // Size of the initial etcd cluster. - EtcdInitialCount int `json:"etcdInitialCount"` } // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object @@ -103,36 +94,84 @@ type MCOConfigList struct { // // +genclient -// +genclient:noStatus +// +genclient:nonNamespaced // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object // ControllerConfig describes configuration for MachineConfigController. +// This is currently only used to drive the machineconfigs generated by the TemplateController. type ControllerConfig struct { metav1.TypeMeta `json:",inline"` metav1.ObjectMeta `json:"metadata,omitempty"` - Spec ControllerConfigSpec `json:"spec"` + Spec ControllerConfigSpec `json:"spec"` + Status ControllerConfigStatus `json:"status"` } // ControllerConfigSpec is the spec for ControllerConfig resource. type ControllerConfigSpec struct { ClusterDNSIP string `json:"clusterDNSIP"` CloudProviderConfig string `json:"cloudProviderConfig"` - ClusterName string `json:"clusterName"` - // The openshift platform, e.g. "libvirt" or "aws" + // The openshift platform, e.g. "libvirt", "openstack", "aws", or "none" Platform string `json:"platform"` - BaseDomain string `json:"baseDomain"` - - // Size of the initial etcd cluster. - EtcdInitialCount int `json:"etcdInitialCount"` + EtcdDiscoveryDomain string `json:"etcdDiscoveryDomain"` // CAs EtcdCAData []byte `json:"etcdCAData"` RootCAData []byte `json:"rootCAData"` + + // PullSecret is the default pull secret that needs to be installed + // on all machines. + PullSecret *corev1.ObjectReference `json:"pullSecret,omitempty"` + + // Public SSH + SSHKey string `json:"sshKey"` + + // Images is map of images that are used by the controller. + Images map[string]string `json:"images"` + + // Sourced from configmap/machine-config-osimageurl + OSImageURL string `json:"osImageURL"` +} + +// ControllerConfigStatus is the status for ControllerConfig +type ControllerConfigStatus struct { + // The generation observed by the controller. + ObservedGeneration int64 `json:"observedGeneration,omitempty"` + + // Represents the latest available observations of current state. + Conditions []ControllerConfigStatusCondition `json:"conditions"` } +// ControllerConfigStatusCondition contains condition information for ControllerConfigStatus +type ControllerConfigStatusCondition struct { + // type specifies the state of the operator's reconciliation functionality. + Type ControllerConfigStatusConditionType `json:"type"` + + // status of the condition, one of True, False, Unknown. + Status corev1.ConditionStatus `json:"status"` + + // lastTransitionTime is the time of the last update to the current status object. + LastTransitionTime metav1.Time `json:"lastTransitionTime"` + + // reason is the reason for the condition's last transition. Reasons are CamelCase + Reason string `json:"reason,omitempty"` + + // message provides additional information about the current condition. + // This is only to be consumed by humans. + Message string `json:"message,omitempty"` +} + +// ControllerConfigStatusConditionType valid conditions of a machineconfigpool +type ControllerConfigStatusConditionType string + +const ( + TemplateContollerRunning ControllerConfigStatusConditionType = "TemplateContollerRunning" + TemplateContollerCompleted ControllerConfigStatusConditionType = "TemplateContollerCompleted" + TemplateContollerFailing ControllerConfigStatusConditionType = "TemplateContollerFailing" +) + // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object // ControllerConfigList is a list of ControllerConfig resources @@ -191,7 +230,7 @@ type MachineConfigSpec struct { // fetch the OS. OSImageURL string `json:"osImageURL"` // Config is a Ignition Config object. - Config ignv2_2types.Config `json:"config"` + Config igntypes.Config `json:"config"` } // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object @@ -255,7 +294,7 @@ type MachineConfigPoolSpec struct { // Label selector for Machines. MachineSelector *metav1.LabelSelector `json:"machineSelector,omitempty"` - // If true, changes to this machine pool should be stopped. + // If true, changes to this machine config pool should be stopped. // This includes generating new desiredMachineConfig and update of machines. Paused bool `json:"paused"` @@ -269,10 +308,10 @@ type MachineConfigPoolStatus struct { // The generation observed by the controller. ObservedGeneration int64 `json:"observedGeneration,omitempty"` - // The current MachineConfig object for the machine pool. - CurrentMachineConfig string `json:"currentMachineConfig"` + // The current MachineConfig object for the machine config pool. + Configuration MachineConfigPoolStatusConfiguration `json:"configuration"` - // Total number of machines in the machine pool. + // Total number of machines in the machine config pool. MachineCount int32 `json:"machineCount"` // Total number of machines targeted by the pool that have the CurrentMachineConfig as their config. @@ -289,6 +328,16 @@ type MachineConfigPoolStatus struct { Conditions []MachineConfigPoolCondition `json:"conditions"` } +// MachineConfigPoolStatusConfiguration stores the current configuration for the pool, and +// optionally also stores the list of machineconfig objects used to generate the configuration. +type MachineConfigPoolStatusConfiguration struct { + corev1.ObjectReference + + // source is the list of machineconfigs that were used to generate the single machineconfig object specified in `content`. + // +optional + Source []corev1.ObjectReference `json:"source,omitempty"` +} + // MachineConfigPoolCondition contains condition information for an MachineConfigPool. type MachineConfigPoolCondition struct { // Type of the condition, currently ('Done', 'Updating', 'Failed'). @@ -321,9 +370,6 @@ const ( // When at least one of machine is not either not updated or is in the process of updating // to the desired machine config. MachineConfigPoolUpdating MachineConfigPoolConditionType = "Updating" - // MachineConfigPoolDegraded means the update for one of the machine is not progressing - // due to an error - MachineConfigPoolDegraded MachineConfigPoolConditionType = "Degraded" ) // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object @@ -335,3 +381,205 @@ type MachineConfigPoolList struct { Items []MachineConfigPool `json:"items"` } + +// CustomResourceDefinition for KubeletConfig +// apiVersion: apiextensions.k8s.io/v1beta1 +// kind: CustomResourceDefinition +// metadata: +// # name must match the spec fields below, and be in the form: . +// name: kubeletconfigs.machineconfiguration.openshift.io +// spec: +// # group name to use for REST API: /apis// +// group: machineconfiguration.openshift.io +// # list of versions supported by this CustomResourceDefinition +// versions: +// - name: v1 +// # Each version can be enabled/disabled by Served flag. +// served: true +// # One and only one version must be marked as the storage version. +// storage: true +// # either Namespaced or Cluster +// scope: Cluster +// names: +// # plural name to be used in the URL: /apis/// +// plural: kubeletconfigs +// # singular name to be used as an alias on the CLI and for display +// singular: kubeletconfig +// # kind is normally the CamelCased singular type. Your resource manifests use this. +// kind: KubeletConfig +// # shortNames allow shorter string to match your resource on the CLI +// shortNames: +// + +// +genclient +// +genclient:nonNamespaced +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// KubeletConfig describes a customized Kubelet configuration. +type KubeletConfig struct { + metav1.TypeMeta `json:",inline"` + metav1.ObjectMeta `json:"metadata,omitempty"` + + Spec KubeletConfigSpec `json:"spec,omitempty"` + Status KubeletConfigStatus `json:"status,omitempty"` +} + +// KubeletConfigSpec defines the desired state of KubeletConfig +type KubeletConfigSpec struct { + MachineConfigPoolSelector *metav1.LabelSelector `json:"machineConfigPoolSelector,omitempty"` + KubeletConfig *kubeletconfigv1beta1.KubeletConfiguration `json:"kubeletConfig,omitempty"` +} + +// KubeletConfigStatus defines the observed state of a KubeletConfig +type KubeletConfigStatus struct { + // The generation observed by the controller. + ObservedGeneration int64 `json:"observedGeneration,omitempty"` + + // Represents the latest available observations of current state. + Conditions []KubeletConfigCondition `json:"conditions"` +} + +// KubeletConfigCondition defines the state of the KubeletConfig +type KubeletConfigCondition struct { + // type specifies the state of the operator's reconciliation functionality. + Type KubeletConfigStatusConditionType `json:"type"` + + // status of the condition, one of True, False, Unknown. + Status corev1.ConditionStatus `json:"status"` + + // lastTransitionTime is the time of the last update to the current status object. + LastTransitionTime metav1.Time `json:"lastTransitionTime"` + + // reason is the reason for the condition's last transition. Reasons are CamelCase + Reason string `json:"reason,omitempty"` + + // message provides additional information about the current condition. + // This is only to be consumed by humans. + Message string `json:"message,omitempty"` +} + +// KubeletConfigStatusConditionType is the state of the operator's reconciliation functionality. +type KubeletConfigStatusConditionType string + +const ( + // KubeletConfigSuccess designates a successful application of a KubeletConfig CR. + KubeletConfigSuccess KubeletConfigStatusConditionType = "Success" + + // KubeletConfigFailure designates a failure applying a KubeletConfig CR. + KubeletConfigFailure KubeletConfigStatusConditionType = "Failure" +) + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// KubeletConfigList is a list of KubeletConfig resources +type KubeletConfigList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata"` + + Items []KubeletConfig `json:"items"` +} + +// CustomResourceDefinition for ContainerRuntimeConfig +// apiVersion: apiextensions.k8s.io/v1beta1 +// kind: CustomResourceDefinition +// metadata: +// # name must match the spec fields below, and be in the form: . +// name: containerruntimeconfigs.machineconfiguration.openshift.io +// spec: +// # group name to use for REST API: /apis// +// group: machineconfiguration.openshift.io +// # list of versions supported by this CustomResourceDefinition +// versions: +// - name: v1 +// # Each version can be enabled/disabled by Served flag. +// served: true +// # One and only one version must be marked as the storage version. +// storage: true +// # either Namespaced or Cluster +// scope: Cluster +// names: +// # plural name to be used in the URL: /apis/// +// plural: containerruntimeconfigs +// # singular name to be used as an alias on the CLI and for display +// singular: containerruntimeconfig +// # kind is normally the CamelCased singular type. Your resource manifests use this. +// kind: ContainerRuntimeConfig +// # shortNames allow shorter string to match your resource on the CLI +// shortNames: ['ctrcfg'] +// + +// +genclient +// +genclient:nonNamespaced +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// ContainerRuntimeConfig describes a customized Container Runtime configuration. +type ContainerRuntimeConfig struct { + metav1.TypeMeta `json:",inline"` + metav1.ObjectMeta `json:"metadata,omitempty"` + + Spec ContainerRuntimeConfigSpec `json:"spec,omitempty"` + Status ContainerRuntimeConfigStatus `json:"status,omitempty"` +} + +// ContainerRuntimeConfigSpec defines the desired state of ContainerRuntimeConfig +type ContainerRuntimeConfigSpec struct { + MachineConfigPoolSelector *metav1.LabelSelector `json:"machineConfigPoolSelector,omitempty"` + ContainerRuntimeConfig *ContainerRuntimeConfiguration `json:"containerRuntimeConfig,omitempty"` +} + +// ContainerRuntimeConfiguration defines the tuneables of the container runtime +type ContainerRuntimeConfiguration struct { + PidsLimit int64 `json:"pidsLimit,omitempty"` + LogLevel string `json:"logLevel,omitempty"` + LogSizeMax resource.Quantity `json:"logSizeMax,omitempty"` + OverlaySize resource.Quantity `json:"overlaySize,omitempty"` +} + +// ContainerRuntimeConfigStatus defines the observed state of a ContainerRuntimeConfig +type ContainerRuntimeConfigStatus struct { + // The generation observed by the controller. + ObservedGeneration int64 `json:"observedGeneration,omitempty"` + + // Represents the latest available observations of current state. + Conditions []ContainerRuntimeConfigCondition `json:"conditions"` +} + +// ContainerRuntimeConfigCondition defines the state of the ContainerRuntimeConfig +type ContainerRuntimeConfigCondition struct { + // type specifies the state of the operator's reconciliation functionality. + Type ContainerRuntimeConfigStatusConditionType `json:"type"` + + // status of the condition, one of True, False, Unknown. + Status corev1.ConditionStatus `json:"status"` + + // lastTransitionTime is the time of the last update to the current status object. + LastTransitionTime metav1.Time `json:"lastTransitionTime"` + + // reason is the reason for the condition's last transition. Reasons are CamelCase + Reason string `json:"reason,omitempty"` + + // message provides additional information about the current condition. + // This is only to be consumed by humans. + Message string `json:"message,omitempty"` +} + +// ContainerRuntimeConfigStatusConditionType is the state of the operator's reconciliation functionality. +type ContainerRuntimeConfigStatusConditionType string + +const ( + // ContainerRuntimeConfigSuccess designates a successful application of a ContainerRuntimeConfig CR. + ContainerRuntimeConfigSuccess ContainerRuntimeConfigStatusConditionType = "Success" + + // ContainerRuntimeConfigFailure designates a failure applying a ContainerRuntimeConfig CR. + ContainerRuntimeConfigFailure ContainerRuntimeConfigStatusConditionType = "Failure" +) + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// ContainerRuntimeConfigList is a list of ContainerRuntimeConfig resources +type ContainerRuntimeConfigList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata"` + + Items []ContainerRuntimeConfig `json:"items"` +} diff --git a/vendor/github.com/openshift/machine-config-operator/pkg/apis/machineconfiguration.openshift.io/v1/zz_generated.deepcopy.go b/vendor/github.com/openshift/machine-config-operator/pkg/apis/machineconfiguration.openshift.io/v1/zz_generated.deepcopy.go index 233a630acc1..d6807620b43 100644 --- a/vendor/github.com/openshift/machine-config-operator/pkg/apis/machineconfiguration.openshift.io/v1/zz_generated.deepcopy.go +++ b/vendor/github.com/openshift/machine-config-operator/pkg/apis/machineconfiguration.openshift.io/v1/zz_generated.deepcopy.go @@ -5,17 +5,165 @@ package v1 import ( + corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" runtime "k8s.io/apimachinery/pkg/runtime" intstr "k8s.io/apimachinery/pkg/util/intstr" + v1beta1 "k8s.io/kubelet/config/v1beta1" ) +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ContainerRuntimeConfig) DeepCopyInto(out *ContainerRuntimeConfig) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Spec.DeepCopyInto(&out.Spec) + in.Status.DeepCopyInto(&out.Status) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ContainerRuntimeConfig. +func (in *ContainerRuntimeConfig) DeepCopy() *ContainerRuntimeConfig { + if in == nil { + return nil + } + out := new(ContainerRuntimeConfig) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *ContainerRuntimeConfig) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ContainerRuntimeConfigCondition) DeepCopyInto(out *ContainerRuntimeConfigCondition) { + *out = *in + in.LastTransitionTime.DeepCopyInto(&out.LastTransitionTime) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ContainerRuntimeConfigCondition. +func (in *ContainerRuntimeConfigCondition) DeepCopy() *ContainerRuntimeConfigCondition { + if in == nil { + return nil + } + out := new(ContainerRuntimeConfigCondition) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ContainerRuntimeConfigList) DeepCopyInto(out *ContainerRuntimeConfigList) { + *out = *in + out.TypeMeta = in.TypeMeta + out.ListMeta = in.ListMeta + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]ContainerRuntimeConfig, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ContainerRuntimeConfigList. +func (in *ContainerRuntimeConfigList) DeepCopy() *ContainerRuntimeConfigList { + if in == nil { + return nil + } + out := new(ContainerRuntimeConfigList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *ContainerRuntimeConfigList) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ContainerRuntimeConfigSpec) DeepCopyInto(out *ContainerRuntimeConfigSpec) { + *out = *in + if in.MachineConfigPoolSelector != nil { + in, out := &in.MachineConfigPoolSelector, &out.MachineConfigPoolSelector + *out = new(metav1.LabelSelector) + (*in).DeepCopyInto(*out) + } + if in.ContainerRuntimeConfig != nil { + in, out := &in.ContainerRuntimeConfig, &out.ContainerRuntimeConfig + *out = new(ContainerRuntimeConfiguration) + (*in).DeepCopyInto(*out) + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ContainerRuntimeConfigSpec. +func (in *ContainerRuntimeConfigSpec) DeepCopy() *ContainerRuntimeConfigSpec { + if in == nil { + return nil + } + out := new(ContainerRuntimeConfigSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ContainerRuntimeConfigStatus) DeepCopyInto(out *ContainerRuntimeConfigStatus) { + *out = *in + if in.Conditions != nil { + in, out := &in.Conditions, &out.Conditions + *out = make([]ContainerRuntimeConfigCondition, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ContainerRuntimeConfigStatus. +func (in *ContainerRuntimeConfigStatus) DeepCopy() *ContainerRuntimeConfigStatus { + if in == nil { + return nil + } + out := new(ContainerRuntimeConfigStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ContainerRuntimeConfiguration) DeepCopyInto(out *ContainerRuntimeConfiguration) { + *out = *in + out.LogSizeMax = in.LogSizeMax.DeepCopy() + out.OverlaySize = in.OverlaySize.DeepCopy() + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ContainerRuntimeConfiguration. +func (in *ContainerRuntimeConfiguration) DeepCopy() *ContainerRuntimeConfiguration { + if in == nil { + return nil + } + out := new(ContainerRuntimeConfiguration) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *ControllerConfig) DeepCopyInto(out *ControllerConfig) { *out = *in out.TypeMeta = in.TypeMeta in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) in.Spec.DeepCopyInto(&out.Spec) + in.Status.DeepCopyInto(&out.Status) return } @@ -83,6 +231,18 @@ func (in *ControllerConfigSpec) DeepCopyInto(out *ControllerConfigSpec) { *out = make([]byte, len(*in)) copy(*out, *in) } + if in.PullSecret != nil { + in, out := &in.PullSecret, &out.PullSecret + *out = new(corev1.ObjectReference) + **out = **in + } + if in.Images != nil { + in, out := &in.Images, &out.Images + *out = make(map[string]string, len(*in)) + for key, val := range *in { + (*out)[key] = val + } + } return } @@ -96,6 +256,173 @@ func (in *ControllerConfigSpec) DeepCopy() *ControllerConfigSpec { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ControllerConfigStatus) DeepCopyInto(out *ControllerConfigStatus) { + *out = *in + if in.Conditions != nil { + in, out := &in.Conditions, &out.Conditions + *out = make([]ControllerConfigStatusCondition, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ControllerConfigStatus. +func (in *ControllerConfigStatus) DeepCopy() *ControllerConfigStatus { + if in == nil { + return nil + } + out := new(ControllerConfigStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ControllerConfigStatusCondition) DeepCopyInto(out *ControllerConfigStatusCondition) { + *out = *in + in.LastTransitionTime.DeepCopyInto(&out.LastTransitionTime) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ControllerConfigStatusCondition. +func (in *ControllerConfigStatusCondition) DeepCopy() *ControllerConfigStatusCondition { + if in == nil { + return nil + } + out := new(ControllerConfigStatusCondition) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *KubeletConfig) DeepCopyInto(out *KubeletConfig) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Spec.DeepCopyInto(&out.Spec) + in.Status.DeepCopyInto(&out.Status) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new KubeletConfig. +func (in *KubeletConfig) DeepCopy() *KubeletConfig { + if in == nil { + return nil + } + out := new(KubeletConfig) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *KubeletConfig) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *KubeletConfigCondition) DeepCopyInto(out *KubeletConfigCondition) { + *out = *in + in.LastTransitionTime.DeepCopyInto(&out.LastTransitionTime) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new KubeletConfigCondition. +func (in *KubeletConfigCondition) DeepCopy() *KubeletConfigCondition { + if in == nil { + return nil + } + out := new(KubeletConfigCondition) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *KubeletConfigList) DeepCopyInto(out *KubeletConfigList) { + *out = *in + out.TypeMeta = in.TypeMeta + out.ListMeta = in.ListMeta + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]KubeletConfig, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new KubeletConfigList. +func (in *KubeletConfigList) DeepCopy() *KubeletConfigList { + if in == nil { + return nil + } + out := new(KubeletConfigList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *KubeletConfigList) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *KubeletConfigSpec) DeepCopyInto(out *KubeletConfigSpec) { + *out = *in + if in.MachineConfigPoolSelector != nil { + in, out := &in.MachineConfigPoolSelector, &out.MachineConfigPoolSelector + *out = new(metav1.LabelSelector) + (*in).DeepCopyInto(*out) + } + if in.KubeletConfig != nil { + in, out := &in.KubeletConfig, &out.KubeletConfig + *out = new(v1beta1.KubeletConfiguration) + (*in).DeepCopyInto(*out) + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new KubeletConfigSpec. +func (in *KubeletConfigSpec) DeepCopy() *KubeletConfigSpec { + if in == nil { + return nil + } + out := new(KubeletConfigSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *KubeletConfigStatus) DeepCopyInto(out *KubeletConfigStatus) { + *out = *in + if in.Conditions != nil { + in, out := &in.Conditions, &out.Conditions + *out = make([]KubeletConfigCondition, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new KubeletConfigStatus. +func (in *KubeletConfigStatus) DeepCopy() *KubeletConfigStatus { + if in == nil { + return nil + } + out := new(KubeletConfigStatus) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *MCOConfig) DeepCopyInto(out *MCOConfig) { *out = *in @@ -317,6 +644,7 @@ func (in *MachineConfigPoolSpec) DeepCopy() *MachineConfigPoolSpec { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *MachineConfigPoolStatus) DeepCopyInto(out *MachineConfigPoolStatus) { *out = *in + in.Configuration.DeepCopyInto(&out.Configuration) if in.Conditions != nil { in, out := &in.Conditions, &out.Conditions *out = make([]MachineConfigPoolCondition, len(*in)) @@ -336,3 +664,25 @@ func (in *MachineConfigPoolStatus) DeepCopy() *MachineConfigPoolStatus { in.DeepCopyInto(out) return out } + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *MachineConfigPoolStatusConfiguration) DeepCopyInto(out *MachineConfigPoolStatusConfiguration) { + *out = *in + out.ObjectReference = in.ObjectReference + if in.Source != nil { + in, out := &in.Source, &out.Source + *out = make([]corev1.ObjectReference, len(*in)) + copy(*out, *in) + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MachineConfigPoolStatusConfiguration. +func (in *MachineConfigPoolStatusConfiguration) DeepCopy() *MachineConfigPoolStatusConfiguration { + if in == nil { + return nil + } + out := new(MachineConfigPoolStatusConfiguration) + in.DeepCopyInto(out) + return out +} diff --git a/vendor/go4.org/AUTHORS b/vendor/go4.org/AUTHORS deleted file mode 100644 index d1ad485f52f..00000000000 --- a/vendor/go4.org/AUTHORS +++ /dev/null @@ -1,8 +0,0 @@ -# This is the official list of go4 authors for copyright purposes. -# This is distinct from the CONTRIBUTORS file, which is the list of -# people who have contributed, even if they don't own the copyright on -# their work. - -Mathieu Lonjaret -Daniel Theophanes -Google diff --git a/vendor/go4.org/errorutil/highlight.go b/vendor/go4.org/errorutil/highlight.go deleted file mode 100644 index 1b1efb0f68f..00000000000 --- a/vendor/go4.org/errorutil/highlight.go +++ /dev/null @@ -1,58 +0,0 @@ -/* -Copyright 2011 Google Inc. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -// Package errorutil helps make better error messages. -package errorutil // import "go4.org/errorutil" - -import ( - "bufio" - "bytes" - "fmt" - "io" - "strings" -) - -// HighlightBytePosition takes a reader and the location in bytes of a parse -// error (for instance, from json.SyntaxError.Offset) and returns the line, column, -// and pretty-printed context around the error with an arrow indicating the exact -// position of the syntax error. -func HighlightBytePosition(f io.Reader, pos int64) (line, col int, highlight string) { - line = 1 - br := bufio.NewReader(f) - lastLine := "" - thisLine := new(bytes.Buffer) - for n := int64(0); n < pos; n++ { - b, err := br.ReadByte() - if err != nil { - break - } - if b == '\n' { - lastLine = thisLine.String() - thisLine.Reset() - line++ - col = 1 - } else { - col++ - thisLine.WriteByte(b) - } - } - if line > 1 { - highlight += fmt.Sprintf("%5d: %s\n", line-1, lastLine) - } - highlight += fmt.Sprintf("%5d: %s\n", line, thisLine.String()) - highlight += fmt.Sprintf("%s^\n", strings.Repeat(" ", col+5)) - return -} diff --git a/vendor/go4.org/LICENSE b/vendor/k8s.io/kubelet/LICENSE similarity index 99% rename from vendor/go4.org/LICENSE rename to vendor/k8s.io/kubelet/LICENSE index 8f71f43fee3..d6456956733 100644 --- a/vendor/go4.org/LICENSE +++ b/vendor/k8s.io/kubelet/LICENSE @@ -1,3 +1,4 @@ + Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ @@ -178,7 +179,7 @@ APPENDIX: How to apply the Apache License to your work. To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "{}" + boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a @@ -186,7 +187,7 @@ same "printed page" as the copyright notice for easier identification within third-party archives. - Copyright {yyyy} {name of copyright owner} + Copyright [yyyy] [name of copyright owner] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -199,4 +200,3 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. - diff --git a/vendor/k8s.io/kubelet/config/v1beta1/doc.go b/vendor/k8s.io/kubelet/config/v1beta1/doc.go new file mode 100644 index 00000000000..5644377d6c8 --- /dev/null +++ b/vendor/k8s.io/kubelet/config/v1beta1/doc.go @@ -0,0 +1,21 @@ +/* +Copyright 2018 The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// +k8s:deepcopy-gen=package +// +k8s:openapi-gen=true +// +groupName=kubelet.config.k8s.io + +package v1beta1 // import "k8s.io/kubelet/config/v1beta1" diff --git a/vendor/k8s.io/kubelet/config/v1beta1/register.go b/vendor/k8s.io/kubelet/config/v1beta1/register.go new file mode 100644 index 00000000000..914dfb25fa2 --- /dev/null +++ b/vendor/k8s.io/kubelet/config/v1beta1/register.go @@ -0,0 +1,44 @@ +/* +Copyright 2018 The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package v1beta1 + +import ( + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apimachinery/pkg/runtime/schema" +) + +// GroupName is the group name used in this package +const GroupName = "kubelet.config.k8s.io" + +// SchemeGroupVersion is group version used to register these objects +var SchemeGroupVersion = schema.GroupVersion{Group: GroupName, Version: "v1beta1"} + +var ( + // SchemeBuilder is the scheme builder with scheme init functions to run for this API package + SchemeBuilder = runtime.NewSchemeBuilder(addKnownTypes) + // AddToScheme is a global function that registers this API group & version to a scheme + AddToScheme = SchemeBuilder.AddToScheme +) + +// addKnownTypes registers known types to the given scheme +func addKnownTypes(scheme *runtime.Scheme) error { + scheme.AddKnownTypes(SchemeGroupVersion, + &KubeletConfiguration{}, + &SerializedNodeConfigSource{}, + ) + return nil +} diff --git a/vendor/k8s.io/kubelet/config/v1beta1/types.go b/vendor/k8s.io/kubelet/config/v1beta1/types.go new file mode 100644 index 00000000000..281298f029d --- /dev/null +++ b/vendor/k8s.io/kubelet/config/v1beta1/types.go @@ -0,0 +1,788 @@ +/* +Copyright 2017 The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package v1beta1 + +import ( + "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" +) + +// HairpinMode denotes how the kubelet should configure networking to handle +// hairpin packets. +type HairpinMode string + +// Enum settings for different ways to handle hairpin packets. +const ( + // Set the hairpin flag on the veth of containers in the respective + // container runtime. + HairpinVeth = "hairpin-veth" + // Make the container bridge promiscuous. This will force it to accept + // hairpin packets, even if the flag isn't set on ports of the bridge. + PromiscuousBridge = "promiscuous-bridge" + // Neither of the above. If the kubelet is started in this hairpin mode + // and kube-proxy is running in iptables mode, hairpin packets will be + // dropped by the container bridge. + HairpinNone = "none" +) + +// ResourceChangeDetectionStrategy denotes a mode in which internal +// managers (secret, configmap) are discovering object changes. +type ResourceChangeDetectionStrategy string + +// Enum settings for different strategies of kubelet managers. +const ( + // GetChangeDetectionStrategy is a mode in which kubelet fetches + // necessary objects directly from apiserver. + GetChangeDetectionStrategy ResourceChangeDetectionStrategy = "Get" + // TTLCacheChangeDetectionStrategy is a mode in which kubelet uses + // ttl cache for object directly fetched from apiserver. + TTLCacheChangeDetectionStrategy ResourceChangeDetectionStrategy = "Cache" + // WatchChangeDetectionStrategy is a mode in which kubelet uses + // watches to observe changes to objects that are in its interest. + WatchChangeDetectionStrategy ResourceChangeDetectionStrategy = "Watch" +) + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// KubeletConfiguration contains the configuration for the Kubelet +type KubeletConfiguration struct { + metav1.TypeMeta `json:",inline"` + + // staticPodPath is the path to the directory containing local (static) pods to + // run, or the path to a single static pod file. + // Dynamic Kubelet Config (beta): If dynamically updating this field, consider that + // the set of static pods specified at the new path may be different than the + // ones the Kubelet initially started with, and this may disrupt your node. + // Default: "" + // +optional + StaticPodPath string `json:"staticPodPath,omitempty"` + // syncFrequency is the max period between synchronizing running + // containers and config. + // Dynamic Kubelet Config (beta): If dynamically updating this field, consider that + // shortening this duration may have a negative performance impact, especially + // as the number of Pods on the node increases. Alternatively, increasing this + // duration will result in longer refresh times for ConfigMaps and Secrets. + // Default: "1m" + // +optional + SyncFrequency metav1.Duration `json:"syncFrequency,omitempty"` + // fileCheckFrequency is the duration between checking config files for + // new data + // Dynamic Kubelet Config (beta): If dynamically updating this field, consider that + // shortening the duration will cause the Kubelet to reload local Static Pod + // configurations more frequently, which may have a negative performance impact. + // Default: "20s" + // +optional + FileCheckFrequency metav1.Duration `json:"fileCheckFrequency,omitempty"` + // httpCheckFrequency is the duration between checking http for new data + // Dynamic Kubelet Config (beta): If dynamically updating this field, consider that + // shortening the duration will cause the Kubelet to poll staticPodURL more + // frequently, which may have a negative performance impact. + // Default: "20s" + // +optional + HTTPCheckFrequency metav1.Duration `json:"httpCheckFrequency,omitempty"` + // staticPodURL is the URL for accessing static pods to run + // Dynamic Kubelet Config (beta): If dynamically updating this field, consider that + // the set of static pods specified at the new URL may be different than the + // ones the Kubelet initially started with, and this may disrupt your node. + // Default: "" + // +optional + StaticPodURL string `json:"staticPodURL,omitempty"` + // staticPodURLHeader is a map of slices with HTTP headers to use when accessing the podURL + // Dynamic Kubelet Config (beta): If dynamically updating this field, consider that + // it may disrupt the ability to read the latest set of static pods from StaticPodURL. + // Default: nil + // +optional + StaticPodURLHeader map[string][]string `json:"staticPodURLHeader,omitempty"` + // address is the IP address for the Kubelet to serve on (set to 0.0.0.0 + // for all interfaces). + // Dynamic Kubelet Config (beta): If dynamically updating this field, consider that + // it may disrupt components that interact with the Kubelet server. + // Default: "0.0.0.0" + // +optional + Address string `json:"address,omitempty"` + // port is the port for the Kubelet to serve on. + // Dynamic Kubelet Config (beta): If dynamically updating this field, consider that + // it may disrupt components that interact with the Kubelet server. + // Default: 10250 + // +optional + Port int32 `json:"port,omitempty"` + // readOnlyPort is the read-only port for the Kubelet to serve on with + // no authentication/authorization. + // Dynamic Kubelet Config (beta): If dynamically updating this field, consider that + // it may disrupt components that interact with the Kubelet server. + // Default: 0 (disabled) + // +optional + ReadOnlyPort int32 `json:"readOnlyPort,omitempty"` + // tlsCertFile is the file containing x509 Certificate for HTTPS. (CA cert, + // if any, concatenated after server cert). If tlsCertFile and + // tlsPrivateKeyFile are not provided, a self-signed certificate + // and key are generated for the public address and saved to the directory + // passed to the Kubelet's --cert-dir flag. + // Dynamic Kubelet Config (beta): If dynamically updating this field, consider that + // it may disrupt components that interact with the Kubelet server. + // Default: "" + // +optional + TLSCertFile string `json:"tlsCertFile,omitempty"` + // tlsPrivateKeyFile is the file containing x509 private key matching tlsCertFile + // Dynamic Kubelet Config (beta): If dynamically updating this field, consider that + // it may disrupt components that interact with the Kubelet server. + // Default: "" + // +optional + TLSPrivateKeyFile string `json:"tlsPrivateKeyFile,omitempty"` + // TLSCipherSuites is the list of allowed cipher suites for the server. + // Values are from tls package constants (https://golang.org/pkg/crypto/tls/#pkg-constants). + // Dynamic Kubelet Config (beta): If dynamically updating this field, consider that + // it may disrupt components that interact with the Kubelet server. + // Default: nil + // +optional + TLSCipherSuites []string `json:"tlsCipherSuites,omitempty"` + // TLSMinVersion is the minimum TLS version supported. + // Values are from tls package constants (https://golang.org/pkg/crypto/tls/#pkg-constants). + // Dynamic Kubelet Config (beta): If dynamically updating this field, consider that + // it may disrupt components that interact with the Kubelet server. + // Default: "" + // +optional + TLSMinVersion string `json:"tlsMinVersion,omitempty"` + // rotateCertificates enables client certificate rotation. The Kubelet will request a + // new certificate from the certificates.k8s.io API. This requires an approver to approve the + // certificate signing requests. The RotateKubeletClientCertificate feature + // must be enabled. + // Dynamic Kubelet Config (beta): If dynamically updating this field, consider that + // disabling it may disrupt the Kubelet's ability to authenticate with the API server + // after the current certificate expires. + // Default: false + // +optional + RotateCertificates bool `json:"rotateCertificates,omitempty"` + // serverTLSBootstrap enables server certificate bootstrap. Instead of self + // signing a serving certificate, the Kubelet will request a certificate from + // the certificates.k8s.io API. This requires an approver to approve the + // certificate signing requests. The RotateKubeletServerCertificate feature + // must be enabled. + // Dynamic Kubelet Config (beta): If dynamically updating this field, consider that + // disabling it will stop the renewal of Kubelet server certificates, which can + // disrupt components that interact with the Kubelet server in the long term, + // due to certificate expiration. + // Default: false + // +optional + ServerTLSBootstrap bool `json:"serverTLSBootstrap,omitempty"` + // authentication specifies how requests to the Kubelet's server are authenticated + // Dynamic Kubelet Config (beta): If dynamically updating this field, consider that + // it may disrupt components that interact with the Kubelet server. + // Defaults: + // anonymous: + // enabled: false + // webhook: + // enabled: true + // cacheTTL: "2m" + // +optional + Authentication KubeletAuthentication `json:"authentication"` + // authorization specifies how requests to the Kubelet's server are authorized + // Dynamic Kubelet Config (beta): If dynamically updating this field, consider that + // it may disrupt components that interact with the Kubelet server. + // Defaults: + // mode: Webhook + // webhook: + // cacheAuthorizedTTL: "5m" + // cacheUnauthorizedTTL: "30s" + // +optional + Authorization KubeletAuthorization `json:"authorization"` + // registryPullQPS is the limit of registry pulls per second. + // Set to 0 for no limit. + // Dynamic Kubelet Config (beta): If dynamically updating this field, consider that + // it may impact scalability by changing the amount of traffic produced + // by image pulls. + // Default: 5 + // +optional + RegistryPullQPS *int32 `json:"registryPullQPS,omitempty"` + // registryBurst is the maximum size of bursty pulls, temporarily allows + // pulls to burst to this number, while still not exceeding registryPullQPS. + // Only used if registryPullQPS > 0. + // Dynamic Kubelet Config (beta): If dynamically updating this field, consider that + // it may impact scalability by changing the amount of traffic produced + // by image pulls. + // Default: 10 + // +optional + RegistryBurst int32 `json:"registryBurst,omitempty"` + // eventRecordQPS is the maximum event creations per second. If 0, there + // is no limit enforced. + // Dynamic Kubelet Config (beta): If dynamically updating this field, consider that + // it may impact scalability by changing the amount of traffic produced by + // event creations. + // Default: 5 + // +optional + EventRecordQPS *int32 `json:"eventRecordQPS,omitempty"` + // eventBurst is the maximum size of a burst of event creations, temporarily + // allows event creations to burst to this number, while still not exceeding + // eventRecordQPS. Only used if eventRecordQPS > 0. + // Dynamic Kubelet Config (beta): If dynamically updating this field, consider that + // it may impact scalability by changing the amount of traffic produced by + // event creations. + // Default: 10 + // +optional + EventBurst int32 `json:"eventBurst,omitempty"` + // enableDebuggingHandlers enables server endpoints for log access + // and local running of containers and commands, including the exec, + // attach, logs, and portforward features. + // Dynamic Kubelet Config (beta): If dynamically updating this field, consider that + // disabling it may disrupt components that interact with the Kubelet server. + // Default: true + // +optional + EnableDebuggingHandlers *bool `json:"enableDebuggingHandlers,omitempty"` + // enableContentionProfiling enables lock contention profiling, if enableDebuggingHandlers is true. + // Dynamic Kubelet Config (beta): If dynamically updating this field, consider that + // enabling it may carry a performance impact. + // Default: false + // +optional + EnableContentionProfiling bool `json:"enableContentionProfiling,omitempty"` + // healthzPort is the port of the localhost healthz endpoint (set to 0 to disable) + // Dynamic Kubelet Config (beta): If dynamically updating this field, consider that + // it may disrupt components that monitor Kubelet health. + // Default: 10248 + // +optional + HealthzPort *int32 `json:"healthzPort,omitempty"` + // healthzBindAddress is the IP address for the healthz server to serve on + // Dynamic Kubelet Config (beta): If dynamically updating this field, consider that + // it may disrupt components that monitor Kubelet health. + // Default: "127.0.0.1" + // +optional + HealthzBindAddress string `json:"healthzBindAddress,omitempty"` + // oomScoreAdj is The oom-score-adj value for kubelet process. Values + // must be within the range [-1000, 1000]. + // Dynamic Kubelet Config (beta): If dynamically updating this field, consider that + // it may impact the stability of nodes under memory pressure. + // Default: -999 + // +optional + OOMScoreAdj *int32 `json:"oomScoreAdj,omitempty"` + // clusterDomain is the DNS domain for this cluster. If set, kubelet will + // configure all containers to search this domain in addition to the + // host's search domains. + // Dynamic Kubelet Config (beta): Dynamically updating this field is not recommended, + // as it should be kept in sync with the rest of the cluster. + // Default: "" + // +optional + ClusterDomain string `json:"clusterDomain,omitempty"` + // clusterDNS is a list of IP addresses for the cluster DNS server. If set, + // kubelet will configure all containers to use this for DNS resolution + // instead of the host's DNS servers. + // Dynamic Kubelet Config (beta): If dynamically updating this field, consider that + // changes will only take effect on Pods created after the update. Draining + // the node is recommended before changing this field. + // Default: nil + // +optional + ClusterDNS []string `json:"clusterDNS,omitempty"` + // streamingConnectionIdleTimeout is the maximum time a streaming connection + // can be idle before the connection is automatically closed. + // Dynamic Kubelet Config (beta): If dynamically updating this field, consider that + // it may impact components that rely on infrequent updates over streaming + // connections to the Kubelet server. + // Default: "4h" + // +optional + StreamingConnectionIdleTimeout metav1.Duration `json:"streamingConnectionIdleTimeout,omitempty"` + // nodeStatusUpdateFrequency is the frequency that kubelet posts node + // status to master. Note: be cautious when changing the constant, it + // must work with nodeMonitorGracePeriod in nodecontroller. + // Dynamic Kubelet Config (beta): If dynamically updating this field, consider that + // it may impact node scalability, and also that the node controller's + // nodeMonitorGracePeriod must be set to N*NodeStatusUpdateFrequency, + // where N is the number of retries before the node controller marks + // the node unhealthy. + // Default: "10s" + // +optional + NodeStatusUpdateFrequency metav1.Duration `json:"nodeStatusUpdateFrequency,omitempty"` + // nodeLeaseDurationSeconds is the duration the Kubelet will set on its corresponding Lease, + // when the NodeLease feature is enabled. This feature provides an indicator of node + // health by having the Kublet create and periodically renew a lease, named after the node, + // in the kube-node-lease namespace. If the lease expires, the node can be considered unhealthy. + // The lease is currently renewed every 10s, per KEP-0009. In the future, the lease renewal interval + // may be set based on the lease duration. + // Requires the NodeLease feature gate to be enabled. + // Dynamic Kubelet Config (beta): If dynamically updating this field, consider that + // decreasing the duration may reduce tolerance for issues that temporarily prevent + // the Kubelet from renewing the lease (e.g. a short-lived network issue). + // Default: 40 + // +optional + NodeLeaseDurationSeconds int32 `json:"nodeLeaseDurationSeconds,omitempty"` + // imageMinimumGCAge is the minimum age for an unused image before it is + // garbage collected. + // Dynamic Kubelet Config (beta): If dynamically updating this field, consider that + // it may trigger or delay garbage collection, and may change the image overhead + // on the node. + // Default: "2m" + // +optional + ImageMinimumGCAge metav1.Duration `json:"imageMinimumGCAge,omitempty"` + // imageGCHighThresholdPercent is the percent of disk usage after which + // image garbage collection is always run. The percent is calculated as + // this field value out of 100. + // Dynamic Kubelet Config (beta): If dynamically updating this field, consider that + // it may trigger or delay garbage collection, and may change the image overhead + // on the node. + // Default: 85 + // +optional + ImageGCHighThresholdPercent *int32 `json:"imageGCHighThresholdPercent,omitempty"` + // imageGCLowThresholdPercent is the percent of disk usage before which + // image garbage collection is never run. Lowest disk usage to garbage + // collect to. The percent is calculated as this field value out of 100. + // Dynamic Kubelet Config (beta): If dynamically updating this field, consider that + // it may trigger or delay garbage collection, and may change the image overhead + // on the node. + // Default: 80 + // +optional + ImageGCLowThresholdPercent *int32 `json:"imageGCLowThresholdPercent,omitempty"` + // How frequently to calculate and cache volume disk usage for all pods + // Dynamic Kubelet Config (beta): If dynamically updating this field, consider that + // shortening the period may carry a performance impact. + // Default: "1m" + // +optional + VolumeStatsAggPeriod metav1.Duration `json:"volumeStatsAggPeriod,omitempty"` + // kubeletCgroups is the absolute name of cgroups to isolate the kubelet in + // Dynamic Kubelet Config (beta): This field should not be updated without a full node + // reboot. It is safest to keep this value the same as the local config. + // Default: "" + // +optional + KubeletCgroups string `json:"kubeletCgroups,omitempty"` + // systemCgroups is absolute name of cgroups in which to place + // all non-kernel processes that are not already in a container. Empty + // for no container. Rolling back the flag requires a reboot. + // Dynamic Kubelet Config (beta): This field should not be updated without a full node + // reboot. It is safest to keep this value the same as the local config. + // Default: "" + // +optional + SystemCgroups string `json:"systemCgroups,omitempty"` + // cgroupRoot is the root cgroup to use for pods. This is handled by the + // container runtime on a best effort basis. + // Dynamic Kubelet Config (beta): This field should not be updated without a full node + // reboot. It is safest to keep this value the same as the local config. + // Default: "" + // +optional + CgroupRoot string `json:"cgroupRoot,omitempty"` + // Enable QoS based Cgroup hierarchy: top level cgroups for QoS Classes + // And all Burstable and BestEffort pods are brought up under their + // specific top level QoS cgroup. + // Dynamic Kubelet Config (beta): This field should not be updated without a full node + // reboot. It is safest to keep this value the same as the local config. + // Default: true + // +optional + CgroupsPerQOS *bool `json:"cgroupsPerQOS,omitempty"` + // driver that the kubelet uses to manipulate cgroups on the host (cgroupfs or systemd) + // Dynamic Kubelet Config (beta): This field should not be updated without a full node + // reboot. It is safest to keep this value the same as the local config. + // Default: "cgroupfs" + // +optional + CgroupDriver string `json:"cgroupDriver,omitempty"` + // CPUManagerPolicy is the name of the policy to use. + // Requires the CPUManager feature gate to be enabled. + // Dynamic Kubelet Config (beta): This field should not be updated without a full node + // reboot. It is safest to keep this value the same as the local config. + // Default: "none" + // +optional + CPUManagerPolicy string `json:"cpuManagerPolicy,omitempty"` + // CPU Manager reconciliation period. + // Requires the CPUManager feature gate to be enabled. + // Dynamic Kubelet Config (beta): If dynamically updating this field, consider that + // shortening the period may carry a performance impact. + // Default: "10s" + // +optional + CPUManagerReconcilePeriod metav1.Duration `json:"cpuManagerReconcilePeriod,omitempty"` + // qosReserved is a set of resource name to percentage pairs that specify + // the minimum percentage of a resource reserved for exclusive use by the + // guaranteed QoS tier. + // Currently supported resources: "memory" + // Requires the QOSReserved feature gate to be enabled. + // Dynamic Kubelet Config (beta): This field should not be updated without a full node + // reboot. It is safest to keep this value the same as the local config. + // Default: nil + // +optional + QOSReserved map[string]string `json:"qosReserved,omitempty"` + // runtimeRequestTimeout is the timeout for all runtime requests except long running + // requests - pull, logs, exec and attach. + // Dynamic Kubelet Config (beta): If dynamically updating this field, consider that + // it may disrupt components that interact with the Kubelet server. + // Default: "2m" + // +optional + RuntimeRequestTimeout metav1.Duration `json:"runtimeRequestTimeout,omitempty"` + // hairpinMode specifies how the Kubelet should configure the container + // bridge for hairpin packets. + // Setting this flag allows endpoints in a Service to loadbalance back to + // themselves if they should try to access their own Service. Values: + // "promiscuous-bridge": make the container bridge promiscuous. + // "hairpin-veth": set the hairpin flag on container veth interfaces. + // "none": do nothing. + // Generally, one must set --hairpin-mode=hairpin-veth to achieve hairpin NAT, + // because promiscuous-bridge assumes the existence of a container bridge named cbr0. + // Dynamic Kubelet Config (beta): If dynamically updating this field, consider that + // it may require a node reboot, depending on the network plugin. + // Default: "promiscuous-bridge" + // +optional + HairpinMode string `json:"hairpinMode,omitempty"` + // maxPods is the number of pods that can run on this Kubelet. + // Dynamic Kubelet Config (beta): If dynamically updating this field, consider that + // changes may cause Pods to fail admission on Kubelet restart, and may change + // the value reported in Node.Status.Capacity[v1.ResourcePods], thus affecting + // future scheduling decisions. Increasing this value may also decrease performance, + // as more Pods can be packed into a single node. + // Default: 110 + // +optional + MaxPods int32 `json:"maxPods,omitempty"` + // The CIDR to use for pod IP addresses, only used in standalone mode. + // In cluster mode, this is obtained from the master. + // Dynamic Kubelet Config (beta): This field should always be set to the empty default. + // It should only set for standalone Kubelets, which cannot use Dynamic Kubelet Config. + // Default: "" + // +optional + PodCIDR string `json:"podCIDR,omitempty"` + // PodPidsLimit is the maximum number of pids in any pod. + // Requires the SupportPodPidsLimit feature gate to be enabled. + // Dynamic Kubelet Config (beta): If dynamically updating this field, consider that + // lowering it may prevent container processes from forking after the change. + // Default: -1 + // +optional + PodPidsLimit *int64 `json:"podPidsLimit,omitempty"` + // ResolverConfig is the resolver configuration file used as the basis + // for the container DNS resolution configuration. + // Dynamic Kubelet Config (beta): If dynamically updating this field, consider that + // changes will only take effect on Pods created after the update. Draining + // the node is recommended before changing this field. + // Default: "/etc/resolv.conf" + // +optional + ResolverConfig string `json:"resolvConf,omitempty"` + // cpuCFSQuota enables CPU CFS quota enforcement for containers that + // specify CPU limits. + // Dynamic Kubelet Config (beta): If dynamically updating this field, consider that + // disabling it may reduce node stability. + // Default: true + // +optional + CPUCFSQuota *bool `json:"cpuCFSQuota,omitempty"` + // CPUCFSQuotaPeriod is the CPU CFS quota period value, cpu.cfs_period_us. + // Dynamic Kubelet Config (beta): If dynamically updating this field, consider that + // limits set for containers will result in different cpu.cfs_quota settings. This + // will trigger container restarts on the node being reconfigured. + // Default: "100ms" + // +optional + CPUCFSQuotaPeriod *metav1.Duration `json:"cpuCFSQuotaPeriod,omitempty"` + // maxOpenFiles is Number of files that can be opened by Kubelet process. + // Dynamic Kubelet Config (beta): If dynamically updating this field, consider that + // it may impact the ability of the Kubelet to interact with the node's filesystem. + // Default: 1000000 + // +optional + MaxOpenFiles int64 `json:"maxOpenFiles,omitempty"` + // contentType is contentType of requests sent to apiserver. + // Dynamic Kubelet Config (beta): If dynamically updating this field, consider that + // it may impact the ability for the Kubelet to communicate with the API server. + // If the Kubelet loses contact with the API server due to a change to this field, + // the change cannot be reverted via dynamic Kubelet config. + // Default: "application/vnd.kubernetes.protobuf" + // +optional + ContentType string `json:"contentType,omitempty"` + // kubeAPIQPS is the QPS to use while talking with kubernetes apiserver + // Dynamic Kubelet Config (beta): If dynamically updating this field, consider that + // it may impact scalability by changing the amount of traffic the Kubelet + // sends to the API server. + // Default: 5 + // +optional + KubeAPIQPS *int32 `json:"kubeAPIQPS,omitempty"` + // kubeAPIBurst is the burst to allow while talking with kubernetes apiserver + // Dynamic Kubelet Config (beta): If dynamically updating this field, consider that + // it may impact scalability by changing the amount of traffic the Kubelet + // sends to the API server. + // Default: 10 + // +optional + KubeAPIBurst int32 `json:"kubeAPIBurst,omitempty"` + // serializeImagePulls when enabled, tells the Kubelet to pull images one + // at a time. We recommend *not* changing the default value on nodes that + // run docker daemon with version < 1.9 or an Aufs storage backend. + // Issue #10959 has more details. + // Dynamic Kubelet Config (beta): If dynamically updating this field, consider that + // it may impact the performance of image pulls. + // Default: true + // +optional + SerializeImagePulls *bool `json:"serializeImagePulls,omitempty"` + // Map of signal names to quantities that defines hard eviction thresholds. For example: {"memory.available": "300Mi"}. + // To explicitly disable, pass a 0% or 100% threshold on an arbitrary resource. + // Dynamic Kubelet Config (beta): If dynamically updating this field, consider that + // it may trigger or delay Pod evictions. + // Default: + // memory.available: "100Mi" + // nodefs.available: "10%" + // nodefs.inodesFree: "5%" + // imagefs.available: "15%" + // +optional + EvictionHard map[string]string `json:"evictionHard,omitempty"` + // Map of signal names to quantities that defines soft eviction thresholds. + // For example: {"memory.available": "300Mi"}. + // Dynamic Kubelet Config (beta): If dynamically updating this field, consider that + // it may trigger or delay Pod evictions, and may change the allocatable reported + // by the node. + // Default: nil + // +optional + EvictionSoft map[string]string `json:"evictionSoft,omitempty"` + // Map of signal names to quantities that defines grace periods for each soft eviction signal. + // For example: {"memory.available": "30s"}. + // Dynamic Kubelet Config (beta): If dynamically updating this field, consider that + // it may trigger or delay Pod evictions. + // Default: nil + // +optional + EvictionSoftGracePeriod map[string]string `json:"evictionSoftGracePeriod,omitempty"` + // Duration for which the kubelet has to wait before transitioning out of an eviction pressure condition. + // Dynamic Kubelet Config (beta): If dynamically updating this field, consider that + // lowering it may decrease the stability of the node when the node is overcommitted. + // Default: "5m" + // +optional + EvictionPressureTransitionPeriod metav1.Duration `json:"evictionPressureTransitionPeriod,omitempty"` + // Maximum allowed grace period (in seconds) to use when terminating pods in + // response to a soft eviction threshold being met. This value effectively caps + // the Pod's TerminationGracePeriodSeconds value during soft evictions. + // Note: Due to issue #64530, the behavior has a bug where this value currently just + // overrides the grace period during soft eviction, which can increase the grace + // period from what is set on the Pod. This bug will be fixed in a future release. + // Dynamic Kubelet Config (beta): If dynamically updating this field, consider that + // lowering it decreases the amount of time Pods will have to gracefully clean + // up before being killed during a soft eviction. + // Default: 0 + // +optional + EvictionMaxPodGracePeriod int32 `json:"evictionMaxPodGracePeriod,omitempty"` + // Map of signal names to quantities that defines minimum reclaims, which describe the minimum + // amount of a given resource the kubelet will reclaim when performing a pod eviction while + // that resource is under pressure. For example: {"imagefs.available": "2Gi"} + // Dynamic Kubelet Config (beta): If dynamically updating this field, consider that + // it may change how well eviction can manage resource pressure. + // Default: nil + // +optional + EvictionMinimumReclaim map[string]string `json:"evictionMinimumReclaim,omitempty"` + // podsPerCore is the maximum number of pods per core. Cannot exceed MaxPods. + // If 0, this field is ignored. + // Dynamic Kubelet Config (beta): If dynamically updating this field, consider that + // changes may cause Pods to fail admission on Kubelet restart, and may change + // the value reported in Node.Status.Capacity[v1.ResourcePods], thus affecting + // future scheduling decisions. Increasing this value may also decrease performance, + // as more Pods can be packed into a single node. + // Default: 0 + // +optional + PodsPerCore int32 `json:"podsPerCore,omitempty"` + // enableControllerAttachDetach enables the Attach/Detach controller to + // manage attachment/detachment of volumes scheduled to this node, and + // disables kubelet from executing any attach/detach operations + // Dynamic Kubelet Config (beta): If dynamically updating this field, consider that + // changing which component is responsible for volume management on a live node + // may result in volumes refusing to detach if the node is not drained prior to + // the update, and if Pods are scheduled to the node before the + // volumes.kubernetes.io/controller-managed-attach-detach annotation is updated by the + // Kubelet. In general, it is safest to leave this value set the same as local config. + // Default: true + // +optional + EnableControllerAttachDetach *bool `json:"enableControllerAttachDetach,omitempty"` + // protectKernelDefaults, if true, causes the Kubelet to error if kernel + // flags are not as it expects. Otherwise the Kubelet will attempt to modify + // kernel flags to match its expectation. + // Dynamic Kubelet Config (beta): If dynamically updating this field, consider that + // enabling it may cause the Kubelet to crash-loop if the Kernel is not configured as + // Kubelet expects. + // Default: false + // +optional + ProtectKernelDefaults bool `json:"protectKernelDefaults,omitempty"` + // If true, Kubelet ensures a set of iptables rules are present on host. + // These rules will serve as utility rules for various components, e.g. KubeProxy. + // The rules will be created based on IPTablesMasqueradeBit and IPTablesDropBit. + // Dynamic Kubelet Config (beta): If dynamically updating this field, consider that + // disabling it will prevent the Kubelet from healing locally misconfigured iptables rules. + // Default: true + // +optional + MakeIPTablesUtilChains *bool `json:"makeIPTablesUtilChains,omitempty"` + // iptablesMasqueradeBit is the bit of the iptables fwmark space to mark for SNAT + // Values must be within the range [0, 31]. Must be different from other mark bits. + // Warning: Please match the value of the corresponding parameter in kube-proxy. + // TODO: clean up IPTablesMasqueradeBit in kube-proxy + // Dynamic Kubelet Config (beta): If dynamically updating this field, consider that + // it needs to be coordinated with other components, like kube-proxy, and the update + // will only be effective if MakeIPTablesUtilChains is enabled. + // Default: 14 + // +optional + IPTablesMasqueradeBit *int32 `json:"iptablesMasqueradeBit,omitempty"` + // iptablesDropBit is the bit of the iptables fwmark space to mark for dropping packets. + // Values must be within the range [0, 31]. Must be different from other mark bits. + // Dynamic Kubelet Config (beta): If dynamically updating this field, consider that + // it needs to be coordinated with other components, like kube-proxy, and the update + // will only be effective if MakeIPTablesUtilChains is enabled. + // Default: 15 + // +optional + IPTablesDropBit *int32 `json:"iptablesDropBit,omitempty"` + // featureGates is a map of feature names to bools that enable or disable alpha/experimental + // features. This field modifies piecemeal the built-in default values from + // "k8s.io/kubernetes/pkg/features/kube_features.go". + // Dynamic Kubelet Config (beta): If dynamically updating this field, consider the + // documentation for the features you are enabling or disabling. While we + // encourage feature developers to make it possible to dynamically enable + // and disable features, some changes may require node reboots, and some + // features may require careful coordination to retroactively disable. + // Default: nil + // +optional + FeatureGates map[string]bool `json:"featureGates,omitempty"` + // failSwapOn tells the Kubelet to fail to start if swap is enabled on the node. + // Dynamic Kubelet Config (beta): If dynamically updating this field, consider that + // setting it to true will cause the Kubelet to crash-loop if swap is enabled. + // Default: true + // +optional + FailSwapOn *bool `json:"failSwapOn,omitempty"` + // A quantity defines the maximum size of the container log file before it is rotated. + // For example: "5Mi" or "256Ki". + // Dynamic Kubelet Config (beta): If dynamically updating this field, consider that + // it may trigger log rotation. + // Default: "10Mi" + // +optional + ContainerLogMaxSize string `json:"containerLogMaxSize,omitempty"` + // Maximum number of container log files that can be present for a container. + // Dynamic Kubelet Config (beta): If dynamically updating this field, consider that + // lowering it may cause log files to be deleted. + // Default: 5 + // +optional + ContainerLogMaxFiles *int32 `json:"containerLogMaxFiles,omitempty"` + // ConfigMapAndSecretChangeDetectionStrategy is a mode in which + // config map and secret managers are running. + // Default: "Watching" + // +optional + ConfigMapAndSecretChangeDetectionStrategy ResourceChangeDetectionStrategy `json:"configMapAndSecretChangeDetectionStrategy,omitempty"` + + /* the following fields are meant for Node Allocatable */ + + // systemReserved is a set of ResourceName=ResourceQuantity (e.g. cpu=200m,memory=150G) + // pairs that describe resources reserved for non-kubernetes components. + // Currently only cpu and memory are supported. + // See http://kubernetes.io/docs/user-guide/compute-resources for more detail. + // Dynamic Kubelet Config (beta): If dynamically updating this field, consider that + // it may not be possible to increase the reserved resources, because this + // requires resizing cgroups. Always look for a NodeAllocatableEnforced event + // after updating this field to ensure that the update was successful. + // Default: nil + // +optional + SystemReserved map[string]string `json:"systemReserved,omitempty"` + // A set of ResourceName=ResourceQuantity (e.g. cpu=200m,memory=150G) pairs + // that describe resources reserved for kubernetes system components. + // Currently cpu, memory and local storage for root file system are supported. + // See http://kubernetes.io/docs/user-guide/compute-resources for more detail. + // Dynamic Kubelet Config (beta): If dynamically updating this field, consider that + // it may not be possible to increase the reserved resources, because this + // requires resizing cgroups. Always look for a NodeAllocatableEnforced event + // after updating this field to ensure that the update was successful. + // Default: nil + // +optional + KubeReserved map[string]string `json:"kubeReserved,omitempty"` + // This flag helps kubelet identify absolute name of top level cgroup used to enforce `SystemReserved` compute resource reservation for OS system daemons. + // Refer to [Node Allocatable](https://git.k8s.io/community/contributors/design-proposals/node/node-allocatable.md) doc for more information. + // Dynamic Kubelet Config (beta): This field should not be updated without a full node + // reboot. It is safest to keep this value the same as the local config. + // Default: "" + // +optional + SystemReservedCgroup string `json:"systemReservedCgroup,omitempty"` + // This flag helps kubelet identify absolute name of top level cgroup used to enforce `KubeReserved` compute resource reservation for Kubernetes node system daemons. + // Refer to [Node Allocatable](https://git.k8s.io/community/contributors/design-proposals/node/node-allocatable.md) doc for more information. + // Dynamic Kubelet Config (beta): This field should not be updated without a full node + // reboot. It is safest to keep this value the same as the local config. + // Default: "" + // +optional + KubeReservedCgroup string `json:"kubeReservedCgroup,omitempty"` + // This flag specifies the various Node Allocatable enforcements that Kubelet needs to perform. + // This flag accepts a list of options. Acceptable options are `none`, `pods`, `system-reserved` & `kube-reserved`. + // If `none` is specified, no other options may be specified. + // Refer to [Node Allocatable](https://git.k8s.io/community/contributors/design-proposals/node/node-allocatable.md) doc for more information. + // Dynamic Kubelet Config (beta): If dynamically updating this field, consider that + // removing enforcements may reduce the stability of the node. Alternatively, adding + // enforcements may reduce the stability of components which were using more than + // the reserved amount of resources; for example, enforcing kube-reserved may cause + // Kubelets to OOM if it uses more than the reserved resources, and enforcing system-reserved + // may cause system daemons to OOM if they use more than the reserved resources. + // Default: ["pods"] + // +optional + EnforceNodeAllocatable []string `json:"enforceNodeAllocatable,omitempty"` +} + +type KubeletAuthorizationMode string + +const ( + // KubeletAuthorizationModeAlwaysAllow authorizes all authenticated requests + KubeletAuthorizationModeAlwaysAllow KubeletAuthorizationMode = "AlwaysAllow" + // KubeletAuthorizationModeWebhook uses the SubjectAccessReview API to determine authorization + KubeletAuthorizationModeWebhook KubeletAuthorizationMode = "Webhook" +) + +type KubeletAuthorization struct { + // mode is the authorization mode to apply to requests to the kubelet server. + // Valid values are AlwaysAllow and Webhook. + // Webhook mode uses the SubjectAccessReview API to determine authorization. + // +optional + Mode KubeletAuthorizationMode `json:"mode,omitempty"` + + // webhook contains settings related to Webhook authorization. + // +optional + Webhook KubeletWebhookAuthorization `json:"webhook"` +} + +type KubeletWebhookAuthorization struct { + // cacheAuthorizedTTL is the duration to cache 'authorized' responses from the webhook authorizer. + // +optional + CacheAuthorizedTTL metav1.Duration `json:"cacheAuthorizedTTL,omitempty"` + // cacheUnauthorizedTTL is the duration to cache 'unauthorized' responses from the webhook authorizer. + // +optional + CacheUnauthorizedTTL metav1.Duration `json:"cacheUnauthorizedTTL,omitempty"` +} + +type KubeletAuthentication struct { + // x509 contains settings related to x509 client certificate authentication + // +optional + X509 KubeletX509Authentication `json:"x509"` + // webhook contains settings related to webhook bearer token authentication + // +optional + Webhook KubeletWebhookAuthentication `json:"webhook"` + // anonymous contains settings related to anonymous authentication + // +optional + Anonymous KubeletAnonymousAuthentication `json:"anonymous"` +} + +type KubeletX509Authentication struct { + // clientCAFile is the path to a PEM-encoded certificate bundle. If set, any request presenting a client certificate + // signed by one of the authorities in the bundle is authenticated with a username corresponding to the CommonName, + // and groups corresponding to the Organization in the client certificate. + // +optional + ClientCAFile string `json:"clientCAFile,omitempty"` +} + +type KubeletWebhookAuthentication struct { + // enabled allows bearer token authentication backed by the tokenreviews.authentication.k8s.io API + // +optional + Enabled *bool `json:"enabled,omitempty"` + // cacheTTL enables caching of authentication results + // +optional + CacheTTL metav1.Duration `json:"cacheTTL,omitempty"` +} + +type KubeletAnonymousAuthentication struct { + // enabled allows anonymous requests to the kubelet server. + // Requests that are not rejected by another authentication method are treated as anonymous requests. + // Anonymous requests have a username of system:anonymous, and a group name of system:unauthenticated. + // +optional + Enabled *bool `json:"enabled,omitempty"` +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// SerializedNodeConfigSource allows us to serialize v1.NodeConfigSource. +// This type is used internally by the Kubelet for tracking checkpointed dynamic configs. +// It exists in the kubeletconfig API group because it is classified as a versioned input to the Kubelet. +type SerializedNodeConfigSource struct { + metav1.TypeMeta `json:",inline"` + // Source is the source that we are serializing + // +optional + Source v1.NodeConfigSource `json:"source,omitempty" protobuf:"bytes,1,opt,name=source"` +} diff --git a/vendor/k8s.io/kubelet/config/v1beta1/zz_generated.deepcopy.go b/vendor/k8s.io/kubelet/config/v1beta1/zz_generated.deepcopy.go new file mode 100644 index 00000000000..37be9cb1843 --- /dev/null +++ b/vendor/k8s.io/kubelet/config/v1beta1/zz_generated.deepcopy.go @@ -0,0 +1,383 @@ +// +build !ignore_autogenerated + +/* +Copyright The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by deepcopy-gen. DO NOT EDIT. + +package v1beta1 + +import ( + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" +) + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *KubeletAnonymousAuthentication) DeepCopyInto(out *KubeletAnonymousAuthentication) { + *out = *in + if in.Enabled != nil { + in, out := &in.Enabled, &out.Enabled + *out = new(bool) + **out = **in + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new KubeletAnonymousAuthentication. +func (in *KubeletAnonymousAuthentication) DeepCopy() *KubeletAnonymousAuthentication { + if in == nil { + return nil + } + out := new(KubeletAnonymousAuthentication) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *KubeletAuthentication) DeepCopyInto(out *KubeletAuthentication) { + *out = *in + out.X509 = in.X509 + in.Webhook.DeepCopyInto(&out.Webhook) + in.Anonymous.DeepCopyInto(&out.Anonymous) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new KubeletAuthentication. +func (in *KubeletAuthentication) DeepCopy() *KubeletAuthentication { + if in == nil { + return nil + } + out := new(KubeletAuthentication) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *KubeletAuthorization) DeepCopyInto(out *KubeletAuthorization) { + *out = *in + out.Webhook = in.Webhook + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new KubeletAuthorization. +func (in *KubeletAuthorization) DeepCopy() *KubeletAuthorization { + if in == nil { + return nil + } + out := new(KubeletAuthorization) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *KubeletConfiguration) DeepCopyInto(out *KubeletConfiguration) { + *out = *in + out.TypeMeta = in.TypeMeta + out.SyncFrequency = in.SyncFrequency + out.FileCheckFrequency = in.FileCheckFrequency + out.HTTPCheckFrequency = in.HTTPCheckFrequency + if in.StaticPodURLHeader != nil { + in, out := &in.StaticPodURLHeader, &out.StaticPodURLHeader + *out = make(map[string][]string, len(*in)) + for key, val := range *in { + var outVal []string + if val == nil { + (*out)[key] = nil + } else { + in, out := &val, &outVal + *out = make([]string, len(*in)) + copy(*out, *in) + } + (*out)[key] = outVal + } + } + if in.TLSCipherSuites != nil { + in, out := &in.TLSCipherSuites, &out.TLSCipherSuites + *out = make([]string, len(*in)) + copy(*out, *in) + } + in.Authentication.DeepCopyInto(&out.Authentication) + out.Authorization = in.Authorization + if in.RegistryPullQPS != nil { + in, out := &in.RegistryPullQPS, &out.RegistryPullQPS + *out = new(int32) + **out = **in + } + if in.EventRecordQPS != nil { + in, out := &in.EventRecordQPS, &out.EventRecordQPS + *out = new(int32) + **out = **in + } + if in.EnableDebuggingHandlers != nil { + in, out := &in.EnableDebuggingHandlers, &out.EnableDebuggingHandlers + *out = new(bool) + **out = **in + } + if in.HealthzPort != nil { + in, out := &in.HealthzPort, &out.HealthzPort + *out = new(int32) + **out = **in + } + if in.OOMScoreAdj != nil { + in, out := &in.OOMScoreAdj, &out.OOMScoreAdj + *out = new(int32) + **out = **in + } + if in.ClusterDNS != nil { + in, out := &in.ClusterDNS, &out.ClusterDNS + *out = make([]string, len(*in)) + copy(*out, *in) + } + out.StreamingConnectionIdleTimeout = in.StreamingConnectionIdleTimeout + out.NodeStatusUpdateFrequency = in.NodeStatusUpdateFrequency + out.ImageMinimumGCAge = in.ImageMinimumGCAge + if in.ImageGCHighThresholdPercent != nil { + in, out := &in.ImageGCHighThresholdPercent, &out.ImageGCHighThresholdPercent + *out = new(int32) + **out = **in + } + if in.ImageGCLowThresholdPercent != nil { + in, out := &in.ImageGCLowThresholdPercent, &out.ImageGCLowThresholdPercent + *out = new(int32) + **out = **in + } + out.VolumeStatsAggPeriod = in.VolumeStatsAggPeriod + if in.CgroupsPerQOS != nil { + in, out := &in.CgroupsPerQOS, &out.CgroupsPerQOS + *out = new(bool) + **out = **in + } + out.CPUManagerReconcilePeriod = in.CPUManagerReconcilePeriod + if in.QOSReserved != nil { + in, out := &in.QOSReserved, &out.QOSReserved + *out = make(map[string]string, len(*in)) + for key, val := range *in { + (*out)[key] = val + } + } + out.RuntimeRequestTimeout = in.RuntimeRequestTimeout + if in.PodPidsLimit != nil { + in, out := &in.PodPidsLimit, &out.PodPidsLimit + *out = new(int64) + **out = **in + } + if in.CPUCFSQuota != nil { + in, out := &in.CPUCFSQuota, &out.CPUCFSQuota + *out = new(bool) + **out = **in + } + if in.CPUCFSQuotaPeriod != nil { + in, out := &in.CPUCFSQuotaPeriod, &out.CPUCFSQuotaPeriod + *out = new(v1.Duration) + **out = **in + } + if in.KubeAPIQPS != nil { + in, out := &in.KubeAPIQPS, &out.KubeAPIQPS + *out = new(int32) + **out = **in + } + if in.SerializeImagePulls != nil { + in, out := &in.SerializeImagePulls, &out.SerializeImagePulls + *out = new(bool) + **out = **in + } + if in.EvictionHard != nil { + in, out := &in.EvictionHard, &out.EvictionHard + *out = make(map[string]string, len(*in)) + for key, val := range *in { + (*out)[key] = val + } + } + if in.EvictionSoft != nil { + in, out := &in.EvictionSoft, &out.EvictionSoft + *out = make(map[string]string, len(*in)) + for key, val := range *in { + (*out)[key] = val + } + } + if in.EvictionSoftGracePeriod != nil { + in, out := &in.EvictionSoftGracePeriod, &out.EvictionSoftGracePeriod + *out = make(map[string]string, len(*in)) + for key, val := range *in { + (*out)[key] = val + } + } + out.EvictionPressureTransitionPeriod = in.EvictionPressureTransitionPeriod + if in.EvictionMinimumReclaim != nil { + in, out := &in.EvictionMinimumReclaim, &out.EvictionMinimumReclaim + *out = make(map[string]string, len(*in)) + for key, val := range *in { + (*out)[key] = val + } + } + if in.EnableControllerAttachDetach != nil { + in, out := &in.EnableControllerAttachDetach, &out.EnableControllerAttachDetach + *out = new(bool) + **out = **in + } + if in.MakeIPTablesUtilChains != nil { + in, out := &in.MakeIPTablesUtilChains, &out.MakeIPTablesUtilChains + *out = new(bool) + **out = **in + } + if in.IPTablesMasqueradeBit != nil { + in, out := &in.IPTablesMasqueradeBit, &out.IPTablesMasqueradeBit + *out = new(int32) + **out = **in + } + if in.IPTablesDropBit != nil { + in, out := &in.IPTablesDropBit, &out.IPTablesDropBit + *out = new(int32) + **out = **in + } + if in.FeatureGates != nil { + in, out := &in.FeatureGates, &out.FeatureGates + *out = make(map[string]bool, len(*in)) + for key, val := range *in { + (*out)[key] = val + } + } + if in.FailSwapOn != nil { + in, out := &in.FailSwapOn, &out.FailSwapOn + *out = new(bool) + **out = **in + } + if in.ContainerLogMaxFiles != nil { + in, out := &in.ContainerLogMaxFiles, &out.ContainerLogMaxFiles + *out = new(int32) + **out = **in + } + if in.SystemReserved != nil { + in, out := &in.SystemReserved, &out.SystemReserved + *out = make(map[string]string, len(*in)) + for key, val := range *in { + (*out)[key] = val + } + } + if in.KubeReserved != nil { + in, out := &in.KubeReserved, &out.KubeReserved + *out = make(map[string]string, len(*in)) + for key, val := range *in { + (*out)[key] = val + } + } + if in.EnforceNodeAllocatable != nil { + in, out := &in.EnforceNodeAllocatable, &out.EnforceNodeAllocatable + *out = make([]string, len(*in)) + copy(*out, *in) + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new KubeletConfiguration. +func (in *KubeletConfiguration) DeepCopy() *KubeletConfiguration { + if in == nil { + return nil + } + out := new(KubeletConfiguration) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *KubeletConfiguration) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *KubeletWebhookAuthentication) DeepCopyInto(out *KubeletWebhookAuthentication) { + *out = *in + if in.Enabled != nil { + in, out := &in.Enabled, &out.Enabled + *out = new(bool) + **out = **in + } + out.CacheTTL = in.CacheTTL + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new KubeletWebhookAuthentication. +func (in *KubeletWebhookAuthentication) DeepCopy() *KubeletWebhookAuthentication { + if in == nil { + return nil + } + out := new(KubeletWebhookAuthentication) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *KubeletWebhookAuthorization) DeepCopyInto(out *KubeletWebhookAuthorization) { + *out = *in + out.CacheAuthorizedTTL = in.CacheAuthorizedTTL + out.CacheUnauthorizedTTL = in.CacheUnauthorizedTTL + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new KubeletWebhookAuthorization. +func (in *KubeletWebhookAuthorization) DeepCopy() *KubeletWebhookAuthorization { + if in == nil { + return nil + } + out := new(KubeletWebhookAuthorization) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *KubeletX509Authentication) DeepCopyInto(out *KubeletX509Authentication) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new KubeletX509Authentication. +func (in *KubeletX509Authentication) DeepCopy() *KubeletX509Authentication { + if in == nil { + return nil + } + out := new(KubeletX509Authentication) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *SerializedNodeConfigSource) DeepCopyInto(out *SerializedNodeConfigSource) { + *out = *in + out.TypeMeta = in.TypeMeta + in.Source.DeepCopyInto(&out.Source) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SerializedNodeConfigSource. +func (in *SerializedNodeConfigSource) DeepCopy() *SerializedNodeConfigSource { + if in == nil { + return nil + } + out := new(SerializedNodeConfigSource) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *SerializedNodeConfigSource) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +}