// generateOLMAssets generates all assets necessary for delivering the
// service controllers via operator lifecycle manager ("OLM").
generateOLMAssets generates all assets necessary for delivering the
service controllers via operator lifecycle manager ("OLM").
// generateOLMAssets generates all assets necessary for delivering the // service controllers via operator lifecycle manager ( " OLM " ) .
func generateOLMAssets(cmd *cobra.Command, args []string) error {
	if len(args) != 2 {
		return fmt.Errorf(
			"please specify the service alias and version " +
				"for the AWS service API to generate",
		)
	}
	svcAlias := strings.ToLower(args[0])
	if optOutputPath == "" {
		optOutputPath = filepath.Join(optServicesDir, svcAlias)
	}
	version := args[1]
	if err := ensureSDKRepo(optCacheDir); err != nil {
		return err
	}
	sdkHelper := ackmodel.NewSDKHelper(sdkDir)
	sdkAPI, err := sdkHelper.API(svcAlias)
	if err != nil {
		newSvcAlias, err := FallBackFindServiceID(sdkDir, svcAlias)
		if err != nil {
			return err
		}
		sdkAPI, err = sdkHelper.API(newSvcAlias) 
		if err != nil {
			return fmt.Errorf("service %s not found", svcAlias)
		}
	}
	latestAPIVersion, err = getLatestAPIVersion()
	if err != nil {
		return err
	}
	g, err := generate.New(
		sdkAPI, latestAPIVersion, optGeneratorConfigPath, ackgenerate.DefaultConfig,
	)
	if err != nil {
		return err
	}
	if optOLMConfigPath == "" {
		optOLMConfigPath = strings.Join([]string{svcAlias, olmConfigFileSuffix}, "-")
	}
	svcConfigYAML, err := ioutil.ReadFile(optOLMConfigPath)
	if err != nil {
		fmt.Println("unable to read configuration file at path:", optOLMConfigPath)
		return err
	}
	svcConf := olmgenerate.DefaultServiceConfig()
	if err = yaml.Unmarshal(svcConfigYAML, &svcConf); err != nil {
		fmt.Println("unable to convert olm configuration file to data instance")
		return err
	}
	commonMeta := olmgenerate.CommonMetadata{}
	if !optDisableCommonLinks {
		commonMeta.Links = olmgenerate.CommonLinks
	}
	if !optDisableCommonKeywords {
		commonMeta.Keywords = olmgenerate.CommonKeywords
	}
	ts, err := olmgenerate.BundleAssets(g, commonMeta, svcConf, version, optTemplateDirs)
	if err != nil {
		return err
	}
	if err = ts.Execute(); err != nil {
		return err
	}
	for path, contents := range ts.Executed() {
		if optDryRun {
			fmt.Printf("============================= %s ======================================\n", path)
			fmt.Println(strings.TrimSpace(contents.String()))
			continue
		}
		outPath := filepath.Join(optOutputPath, path)
		outDir := filepath.Dir(outPath)
		if _, err := ensureDir(outDir); err != nil {
			return err
		}
		if err = ioutil.WriteFile(outPath, contents.Bytes(), 0666); err != nil {
			return err
		}
	}
	return nil
}
func generateOLMAssets ( cmd * cobra . Command , args [ ] string ) error { if len ( args ) != 2 { return fmt . Errorf ( " " + " " , ) } svcAlias := strings . ToLower ( args [ 0 ] ) if optOutputPath == " " { optOutputPath = filepath . Join ( optServicesDir , svcAlias ) } version := args [ 1 ] if err := ensureSDKRepo ( optCacheDir ) ; err != nil { return err } sdkHelper := ackmodel . NewSDKHelper ( sdkDir ) sdkAPI , err := sdkHelper . API ( svcAlias ) if err != nil { newSvcAlias , err := FallBackFindServiceID ( sdkDir , svcAlias ) if err != nil { return err } sdkAPI , err = sdkHelper . API ( newSvcAlias ) if err != nil { return fmt . Errorf ( " " , svcAlias ) } } latestAPIVersion , err = getLatestAPIVersion ( ) if err != nil { return err } g , err := generate . New ( sdkAPI , latestAPIVersion , optGeneratorConfigPath , ackgenerate . DefaultConfig , ) if err != nil { return err } if optOLMConfigPath == " " { optOLMConfigPath = strings . Join ( [ ] string { svcAlias , olmConfigFileSuffix } , " " ) } svcConfigYAML , err := ioutil . ReadFile ( optOLMConfigPath ) if err != nil { fmt . Println ( " " , optOLMConfigPath ) return err } svcConf := olmgenerate . DefaultServiceConfig ( ) if err = yaml . Unmarshal ( svcConfigYAML , & svcConf ) ; err != nil { fmt . Println ( " " ) return err } commonMeta := olmgenerate . CommonMetadata { } if ! optDisableCommonLinks { commonMeta . Links = olmgenerate . CommonLinks } if ! optDisableCommonKeywords { commonMeta . Keywords = olmgenerate . CommonKeywords } ts , err := olmgenerate . BundleAssets ( g , commonMeta , svcConf , version , optTemplateDirs ) if err != nil { return err } if err = ts . Execute ( ) ; err != nil { return err } for path , contents := range ts . Executed ( ) { if optDryRun { fmt . Printf ( " \n " , path ) fmt . Println ( strings . TrimSpace ( contents . String ( ) ) ) continue } outPath := filepath . Join ( optOutputPath , path ) outDir := filepath . Dir ( outPath ) if _ , err := ensureDir ( outDir ) ; err != nil { return err } if err = ioutil . WriteFile ( outPath , contents . Bytes ( ) , 0666 ) ; err != nil { return err } } return nil }
generateOLMAssets generates all assets necessary for delivering the
service controllers via operator lifecycle manager ("OLM").
generateOLMAssets generates all assets necessary for delivering the service controllers via operator lifecycle manager ( " OLM " ) .
// get the generator inputs // retry with serviceID // read the configuration from file // set the base metadata and then override values as // defined by the service config. // prepare the common metadata // generate templates