Skip to content

Commit

Permalink
nowait to wait
Browse files Browse the repository at this point in the history
Signed-off-by: Austin Abro <[email protected]>
  • Loading branch information
AustinAbro321 committed Aug 8, 2024
1 parent a867d60 commit 50bc505
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 12 deletions.
2 changes: 1 addition & 1 deletion src/api/v1alpha1/package.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const (
ZarfInitConfig ZarfPackageKind = "ZarfInitConfig"
// ZarfPackageConfig is the default kind of Zarf package, primarily used during `zarf package`.
ZarfPackageConfig ZarfPackageKind = "ZarfPackageConfig"
ApiVersion string = "zarf.dev/v1alpha1"
APIVersion string = "zarf.dev/v1alpha1"
)

// ZarfPackage the top-level structure of a Zarf config file.
Expand Down
6 changes: 3 additions & 3 deletions src/api/v1beta1/component.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ type ZarfComponent struct {
// Determines the default Y/N state for installing this component on package deploy.
Default bool `json:"default,omitempty"`

// Do not prompt user to install this component.
// Do not prompt user to install this component. (Defaults to false)
Optional *bool `json:"optional,omitempty"`

// Filter when this component is included in package creation or deployment.
Expand Down Expand Up @@ -178,11 +178,11 @@ type ZarfManifest struct {
Namespace string `json:"namespace,omitempty"`
// List of local K8s YAML files or remote URLs to deploy (in order).
Files []string `json:"files,omitempty"`
// Allow traversing directory above the current directory if needed for kustomization.
// Allow traversing directory above the current directory if needed for kustomization. (Defaults to false)
KustomizeAllowAnyDirectory bool `json:"kustomizeAllowAnyDirectory,omitempty"`
// List of local kustomization paths or remote URLs to include in the package.
Kustomizations []string `json:"kustomizations,omitempty"`
// Whether to not wait for manifest resources to be ready before continuing.
// Whether to not wait for manifest resources to be ready before continuing. (Defaults to true)
Wait *bool `json:"wait,omitempty"`
}

Expand Down
2 changes: 1 addition & 1 deletion src/api/v1beta1/package.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const (
ZarfInitConfig ZarfPackageKind = "ZarfInitConfig"
// ZarfPackageConfig is the default kind of Zarf package, primarily used during `zarf package`.
ZarfPackageConfig ZarfPackageKind = "ZarfPackageConfig"
ApiVersion string = "zarf.dev/v1beta1"
APIVersion string = "zarf.dev/v1beta1"
)

const (
Expand Down
9 changes: 5 additions & 4 deletions src/api/v1beta1/translate.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ func TranslateAlphaPackage(alphaPkg v1alpha1.ZarfPackage) (ZarfPackage, error) {
return ZarfPackage{}, fmt.Errorf("failed to unmarshal JSON to v1beta1 object: %w", err)
}

betaPkg.APIVersion = ApiVersion
betaPkg.APIVersion = APIVersion

betaPkg.Metadata.Annotations = make(map[string]string)
if alphaPkg.Metadata.Description != "" {
Expand Down Expand Up @@ -62,7 +62,6 @@ func TranslateAlphaPackage(alphaPkg v1alpha1.ZarfPackage) (ZarfPackage, error) {

for i := range betaPkg.Components {
betaPkg.Components[i].Optional = helpers.BoolPtr(!alphaPkg.Components[i].IsRequired())

for j := range betaPkg.Components[i].Charts {
oldUrl := alphaPkg.Components[i].Charts[j].URL
if helpers.IsOCIURL(oldUrl) {
Expand All @@ -74,14 +73,16 @@ func TranslateAlphaPackage(alphaPkg v1alpha1.ZarfPackage) (ZarfPackage, error) {
betaPkg.Components[i].Charts[j].Helm.Url = oldUrl
betaPkg.Components[i].Charts[j].Helm.RepoName = alphaPkg.Components[i].Charts[j].RepoName
}

betaPkg.Components[i].Charts[j].Local.Path = alphaPkg.Components[i].Charts[j].LocalPath
betaPkg.Components[i].Charts[j].Wait = helpers.BoolPtr(!alphaPkg.Components[i].Charts[j].NoWait)
}

for j := range betaPkg.Components[i].Manifests{
betaPkg.Components[i].Manifests[j].Wait = helpers.BoolPtr(!alphaPkg.Components[i].Manifests[j].NoWait)
}
betaPkg.Components[i].Actions.OnCreate = transformActionSet(betaPkg.Components[i].Actions.OnCreate, alphaPkg.Components[i].Actions.OnCreate)
betaPkg.Components[i].Actions.OnDeploy = transformActionSet(betaPkg.Components[i].Actions.OnDeploy, alphaPkg.Components[i].Actions.OnDeploy)
betaPkg.Components[i].Actions.OnRemove = transformActionSet(betaPkg.Components[i].Actions.OnRemove, alphaPkg.Components[i].Actions.OnRemove)

}

return betaPkg, nil
Expand Down
33 changes: 31 additions & 2 deletions src/api/v1beta1/translate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ func TestTranslate(t *testing.T) {
{
name: "test",
oldPkg: v1alpha1.ZarfPackage{
APIVersion: v1alpha1.ApiVersion,
APIVersion: v1alpha1.APIVersion,
Kind: v1alpha1.ZarfPackageConfig,
Components: []v1alpha1.ZarfComponent{
{
Expand All @@ -38,6 +38,17 @@ func TestTranslate(t *testing.T) {
Name: "not-optional",
Required: helpers.BoolPtr(true),
},
{
Name: "manifests",
Manifests: []v1alpha1.ZarfManifest{
{
NoWait: true,
},
{
NoWait: false,
},
},
},
{
Name: "actions",
Actions: v1alpha1.ZarfComponentActions{
Expand Down Expand Up @@ -95,10 +106,12 @@ func TestTranslate(t *testing.T) {
{
URL: "https://example.com/chart",
RepoName: "repo1",
NoWait: true,
},
{
URL: "https://example.com/chart.git",
GitPath: "path/to/chart2",
NoWait: false,
},
{
URL: "oci://example.com/chart",
Expand All @@ -111,7 +124,7 @@ func TestTranslate(t *testing.T) {
},
},
newPkg: ZarfPackage{
APIVersion: ApiVersion,
APIVersion: APIVersion,
Kind: ZarfPackageConfig,
Metadata: ZarfMetadata{
Annotations: map[string]string{},
Expand All @@ -125,6 +138,18 @@ func TestTranslate(t *testing.T) {
Name: "not-optional",
Optional: helpers.BoolPtr(false),
},
{
Name: "manifests",
Optional: helpers.BoolPtr(true),
Manifests: []ZarfManifest{
{
Wait: helpers.BoolPtr(false),
},
{
Wait: helpers.BoolPtr(true),
},
},
},
{
Name: "actions",
Optional: helpers.BoolPtr(true),
Expand Down Expand Up @@ -182,23 +207,27 @@ func TestTranslate(t *testing.T) {
Optional: helpers.BoolPtr(true),
Charts: []ZarfChart{
{
Wait: helpers.BoolPtr(false),
Helm: HelmRepoSource{
Url: "https://example.com/chart",
RepoName: "repo1",
},
},
{
Wait: helpers.BoolPtr(true),
Git: GitRepoSource{
Url: "https://example.com/chart.git",
Path: "path/to/chart2",
},
},
{
Wait: helpers.BoolPtr(true),
OCI: OCISource{
Url: "oci://example.com/chart",
},
},
{
Wait: helpers.BoolPtr(true),
Local: LocalRepoSource{
Path: "path/to/chart4",
},
Expand Down
2 changes: 1 addition & 1 deletion src/pkg/lint/schema_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ func TestZarfSchema(t *testing.T) {
{
name: "valid package",
pkg: v1alpha1.ZarfPackage{
APIVersion: v1alpha1.ApiVersion,
APIVersion: v1alpha1.APIVersion,
Kind: v1alpha1.ZarfInitConfig,
Metadata: v1alpha1.ZarfMetadata{
Name: "valid-name",
Expand Down

0 comments on commit 50bc505

Please sign in to comment.