// generateRelease generates the Helm charts and other release artifacts for a
// service controller and release version
generateRelease generates the Helm charts and other release artifacts for a
service controller and release version
// generateRelease generates the Helm charts and other release artifacts for a // service controller and release version
func generateRelease(cmd *cobra.Command, args []string) error {
	if len(args) != 2 {
		return fmt.Errorf("please specify the service alias and the release version to generate release artifacts for")
	}
	svcAlias := strings.ToLower(args[0])
	if optReleaseOutputPath == "" {
		optReleaseOutputPath = filepath.Join(optServicesDir, svcAlias)
	}
	releaseVersion := strings.ToLower(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)
		}
	}
	g, err := generate.New(
		sdkAPI, "", optGeneratorConfigPath, ackgenerate.DefaultConfig,
	)
	if err != nil {
		return err
	}
	ts, err := ackgenerate.Release(
		g, optTemplateDirs,
		releaseVersion, optImageRepository, optServiceAccountName,
	)
	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(optReleaseOutputPath, 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 generateRelease ( cmd * cobra . Command , args [ ] string ) error { if len ( args ) != 2 { return fmt . Errorf ( " " ) } svcAlias := strings . ToLower ( args [ 0 ] ) if optReleaseOutputPath == " " { optReleaseOutputPath = filepath . Join ( optServicesDir , svcAlias ) } releaseVersion := strings . ToLower ( 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 ) } } g , err := generate . New ( sdkAPI , " " , optGeneratorConfigPath , ackgenerate . DefaultConfig , ) if err != nil { return err } ts , err := ackgenerate . Release ( g , optTemplateDirs , releaseVersion , optImageRepository , optServiceAccountName , ) 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 ( optReleaseOutputPath , 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 }
generateRelease generates the Helm charts and other release artifacts for a
service controller and release version
generateRelease generates the Helm charts and other release artifacts for a service controller and release version
// TODO(jaypipes): We could do some git-fu here to verify that the release // version supplied hasn't been used (as a Git tag) before... // retry with serviceID