forked from vmware-tanzu/tanzu-framework
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Generate Package Custom Resource when Package Bundle is Created (vmwa…
…re-tanzu#2199) * generate Package CR when package bundle is generated Signed-off-by: Harish Yayi <yharish991@gmail.com> * Address golang-ci lint failed checks Signed-off-by: F. Gold <fgold@vmware.com> * Fix bug and pick up subversion from package values or flag Signed-off-by: F. Gold <fgold@vmware.com> Co-authored-by: Harish Yayi <yharish991@gmail.com>
- Loading branch information
1 parent
115e8c5
commit c03154b
Showing
9 changed files
with
156 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
// Copyright 2022 VMware, Inc. All Rights Reserved. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package cmd | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
"path/filepath" | ||
|
||
"gopkg.in/yaml.v2" | ||
|
||
"github.com/vmware-tanzu/tanzu-framework/hack/packages/package-tools/constants" | ||
) | ||
|
||
func readPackageValues(projectRootDir string) (PackageValues, error) { | ||
var packageValues PackageValues | ||
|
||
packageValuesData, err := os.ReadFile(filepath.Join(projectRootDir, constants.PackageValuesFilePath)) | ||
if err != nil { | ||
return PackageValues{}, fmt.Errorf("couldn't read file %s: %w", packageValuesFile, err) | ||
} | ||
|
||
if err := yaml.Unmarshal(packageValuesData, &packageValues); err != nil { | ||
return PackageValues{}, fmt.Errorf("error while unmarshaling: %w", err) | ||
} | ||
|
||
return packageValues, nil | ||
} | ||
|
||
// getPackageFromPackageValues returns the package definition from the package-values.yaml file. | ||
func getPackageFromPackageValues(projectRootDir, packageName string) (Package, error) { | ||
packageValues, err := readPackageValues(projectRootDir) | ||
if err != nil { | ||
return Package{}, err | ||
} | ||
|
||
for i := range packageValues.Repositories { | ||
packages := packageValues.Repositories[i].Packages | ||
for _, pkg := range packages { | ||
if pkg.Name == packageName { | ||
return pkg, nil | ||
} | ||
} | ||
} | ||
return Package{}, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 18 additions & 8 deletions
26
hack/packages/templates/repo-utils/package-helpers.lib.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters