![Kostiantyn Kalynovskyi](/assets/img/avatar_default.png)
Add NewBundleByPath function, that would return bundle built from the specified path argument Add CurrentContextEntryPoint method of the config object, that would allow easily get kustomize root path based on clusterType and phase. You can also leave phase arg empty string, which would try to return bundle for all phases Introduce changes to config pakage objects: - Manifest: SubPath: this is relative path to the root of the repository that contains directories with sites (SiteNames) PrimaryRepositoryName: this is a string that must correspond to a key of the Repositories map of manifest object, which is used to derive primary repository Repositories object is a map, map keys correspond to names of the directories where `document pull` command will download repositories defined in manifest prepended by manifest.TargetPath. Introduce new config method CurrentContextEntryPoint(), method takes TargetPath, PrimaryRepo.URL, SubPath, and clusterType and phase constructs a path to the entry point out of which the DocumentBundle should be build, and returns it to the caller. After that caller can build a bundle out of it, the bundle will contain documents relevant to particular cluster-type and phase. All objects that depend on bundle interface are updated to use the CurrentContextEntryPoint() method of the config object Relates-To: #99 Closes: #99 Change-Id: I99320c4cb626841d46f4c298b583e9af90b1dce4
118 lines
3.1 KiB
Go
118 lines
3.1 KiB
Go
/*
|
|
Copyright 2014 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 config
|
|
|
|
const (
|
|
DefaultTestPrimaryRepo = "primary"
|
|
)
|
|
|
|
// NewConfig returns a newly initialized Config object
|
|
func NewConfig() *Config {
|
|
return &Config{
|
|
Kind: AirshipConfigKind,
|
|
APIVersion: AirshipConfigAPIVersion,
|
|
Clusters: make(map[string]*ClusterPurpose),
|
|
AuthInfos: make(map[string]*AuthInfo),
|
|
Contexts: map[string]*Context{
|
|
AirshipDefaultContext: {
|
|
Manifest: AirshipDefaultManifest,
|
|
},
|
|
},
|
|
Manifests: map[string]*Manifest{
|
|
AirshipDefaultManifest: {
|
|
Repositories: map[string]*Repository{
|
|
DefaultTestPrimaryRepo: {
|
|
URLString: AirshipDefaultManifestRepoLocation,
|
|
CheckoutOptions: &RepoCheckout{
|
|
CommitHash: "master",
|
|
Branch: "master",
|
|
RemoteRef: "master",
|
|
},
|
|
},
|
|
},
|
|
TargetPath: "/tmp/" + AirshipDefaultManifest,
|
|
PrimaryRepositoryName: DefaultTestPrimaryRepo,
|
|
SubPath: AirshipDefaultManifestRepo + "/manifests/site",
|
|
},
|
|
},
|
|
ModulesConfig: &Modules{
|
|
BootstrapInfo: map[string]*Bootstrap{
|
|
AirshipDefaultContext: {
|
|
Container: &Container{
|
|
Volume: "/srv/iso:/config",
|
|
Image: AirshipDefaultBootstrapImage,
|
|
ContainerRuntime: "docker",
|
|
},
|
|
Builder: &Builder{
|
|
UserDataFileName: "user-data",
|
|
NetworkConfigFileName: "network-config",
|
|
OutputMetadataFileName: "output-metadata.yaml",
|
|
},
|
|
RemoteDirect: &RemoteDirect{
|
|
RemoteType: AirshipDefaultRemoteType,
|
|
IsoURL: AirshipDefaultIsoURL,
|
|
},
|
|
},
|
|
},
|
|
},
|
|
}
|
|
}
|
|
|
|
// NewContext is a convenience function that returns a new Context
|
|
func NewContext() *Context {
|
|
return &Context{}
|
|
}
|
|
|
|
// NewCluster is a convenience function that returns a new Cluster
|
|
func NewCluster() *Cluster {
|
|
return &Cluster{}
|
|
}
|
|
|
|
// NewManifest is a convenience function that returns a new Manifest
|
|
// object with non-nil maps
|
|
func NewManifest() *Manifest {
|
|
return &Manifest{
|
|
PrimaryRepositoryName: DefaultTestPrimaryRepo,
|
|
Repositories: map[string]*Repository{DefaultTestPrimaryRepo: NewRepository()},
|
|
}
|
|
}
|
|
|
|
func NewRepository() *Repository {
|
|
return &Repository{}
|
|
}
|
|
|
|
func NewAuthInfo() *AuthInfo {
|
|
return &AuthInfo{}
|
|
}
|
|
|
|
func NewModules() *Modules {
|
|
return &Modules{
|
|
BootstrapInfo: make(map[string]*Bootstrap),
|
|
}
|
|
}
|
|
|
|
// NewClusterPurpose is a convenience function that returns a new ClusterPurpose
|
|
func NewClusterPurpose() *ClusterPurpose {
|
|
return &ClusterPurpose{
|
|
ClusterTypes: make(map[string]*Cluster),
|
|
}
|
|
}
|
|
|
|
func NewClusterComplexName() *ClusterComplexName {
|
|
return &ClusterComplexName{}
|
|
}
|