// Generate generates the metadata.yaml file.
Generate generates the metadata.yaml file.
// Generate generates the metadata . yaml file .
func (m *Metadata) Generate(parents asset.Parents) error {
	installConfig := &installconfig.InstallConfig{}
	cluster := &cluster.Cluster{}
	parents.Get(installConfig, cluster)
	m.metadata = &types.ClusterMetadata{
		ClusterName: installConfig.Config.ObjectMeta.Name,
	}
	switch {
	case installConfig.Config.Platform.AWS != nil:
		m.metadata.ClusterPlatformMetadata.AWS = &types.ClusterAWSPlatformMetadata{
			Region: installConfig.Config.Platform.AWS.Region,
			Identifier: map[string]string{
				"tectonicClusterID": installConfig.Config.ClusterID,
			},
		}
	case installConfig.Config.Platform.OpenStack != nil:
		m.metadata.ClusterPlatformMetadata.OpenStack = &types.ClusterOpenStackPlatformMetadata{
			Region: installConfig.Config.Platform.OpenStack.Region,
			Identifier: map[string]string{
				"tectonicClusterID": installConfig.Config.ClusterID,
			},
		}
	case installConfig.Config.Platform.Libvirt != nil:
		m.metadata.ClusterPlatformMetadata.Libvirt = &types.ClusterLibvirtPlatformMetadata{
			URI: installConfig.Config.Platform.Libvirt.URI,
		}
	default:
		return fmt.Errorf("no known platform")
	}
	data, err := json.Marshal(m.metadata)
	if err != nil {
		return errors.Wrap(err, "failed to Marshal ClusterMetadata")
	}
	m.file = &asset.File{
		Filename: MetadataFilename,
		Data:     data,
	}
	return nil
}
func ( m * Metadata ) Generate ( parents asset . Parents ) error { installConfig := & installconfig . InstallConfig { } cluster := & cluster . Cluster { } parents . Get ( installConfig , cluster ) m . metadata = & types . ClusterMetadata { ClusterName : installConfig . Config . ObjectMeta . Name , } switch { case installConfig . Config . Platform . AWS != nil : m . metadata . ClusterPlatformMetadata . AWS = & types . ClusterAWSPlatformMetadata { Region : installConfig . Config . Platform . AWS . Region , Identifier : map [ string ] string { " " : installConfig . Config . ClusterID , } , } case installConfig . Config . Platform . OpenStack != nil : m . metadata . ClusterPlatformMetadata . OpenStack = & types . ClusterOpenStackPlatformMetadata { Region : installConfig . Config . Platform . OpenStack . Region , Identifier : map [ string ] string { " " : installConfig . Config . ClusterID , } , } case installConfig . Config . Platform . Libvirt != nil : m . metadata . ClusterPlatformMetadata . Libvirt = & types . ClusterLibvirtPlatformMetadata { URI : installConfig . Config . Platform . Libvirt . URI , } default : return fmt . Errorf ( " " ) } data , err := json . Marshal ( m . metadata ) if err != nil { return errors . Wrap ( err , " " ) } m . file = & asset . File { Filename : MetadataFilename , Data : data , } return nil }
Generate generates the metadata.yaml file.
Generate generates the metadata . yaml file .