Add --dry option to view the generated spec without saving (#1504)

This commit is contained in:
Ta-Ching Chen
2020-01-24 20:43:42 +08:00
committed by GitHub
parent 2338fbb06f
commit 520cc0e130
19 changed files with 128 additions and 65 deletions
+7 -3
View File
@@ -134,7 +134,7 @@ func CreatePackage(input cli.Input, client client.Interface, pkgName string, pkg
if len(specFile) > 0 { // we should do this in all cases, i think
pkgStatus = fv1.BuildStatusNone
}
deployment, err := CreateArchive(client, deployArchiveFiles, noZip, insecure, deployChecksum, specDir, specFile)
deployment, err := CreateArchive(client, input, deployArchiveFiles, noZip, insecure, deployChecksum, specDir, specFile)
if err != nil {
return nil, errors.Wrap(err, "error creating source archive")
}
@@ -144,7 +144,7 @@ func CreatePackage(input cli.Input, client client.Interface, pkgName string, pkg
}
}
if len(srcArchiveFiles) > 0 {
source, err := CreateArchive(client, srcArchiveFiles, false, insecure, srcChecksum, specDir, specFile)
source, err := CreateArchive(client, input, srcArchiveFiles, false, insecure, srcChecksum, specDir, specFile)
if err != nil {
return nil, errors.Wrap(err, "error creating deploy archive")
}
@@ -175,7 +175,11 @@ func CreatePackage(input cli.Input, client client.Interface, pkgName string, pkg
},
}
if len(specFile) > 0 {
if input.Bool(flagkey.SpecDry) {
return &pkg.ObjectMeta, spec.SpecDry(*pkg)
}
if input.Bool(flagkey.SpecSave) {
// if a package with the same spec exists, don't create a new spec file
fr, err := spec.ReadSpecs(util.GetSpecDir(input))
if err != nil {