Handle duplicate archive and package specs; handle multifile archives better (#1018)
Archives with multiple files should have all files in the inputs. Also clean up some inconsistent variable naming -- archive name, archive file path, and archive input files were all stored in incorrectly-named variables.
This commit is contained in:
committed by
Ta-Ching Chen
parent
f0c0936b87
commit
2699aa6069
+43
-2
@@ -123,7 +123,10 @@ type (
|
||||
)
|
||||
|
||||
func getSpecDir(c *cli.Context) string {
|
||||
specDir := c.String("specdir")
|
||||
specDir := ""
|
||||
if c != nil {
|
||||
specDir = c.String("specdir")
|
||||
}
|
||||
if len(specDir) == 0 {
|
||||
specDir = "specs"
|
||||
}
|
||||
@@ -854,7 +857,8 @@ func applyArchives(fclient *client.Client, specDir string, fr *FissionResources)
|
||||
} else {
|
||||
// doesn't exist, upload
|
||||
fmt.Printf("uploading archive %v\n", name)
|
||||
uploadedAr := createArchive(fclient, ar.URL, "")
|
||||
// ar.URL is actually a local filename at this stage
|
||||
uploadedAr := uploadArchive(fclient, ar.URL)
|
||||
archiveFiles[name] = *uploadedAr
|
||||
}
|
||||
}
|
||||
@@ -1779,3 +1783,40 @@ func specSave(resource interface{}, specFile string) error {
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Returns metadata if the given resource exists in the specs, nil
|
||||
// otherwise. compareMetadata and compareSpec control how the
|
||||
// equality check is performed.
|
||||
func (fr *FissionResources) specExists(resource interface{}, compareMetadata bool, compareSpec bool) *metav1.ObjectMeta {
|
||||
switch typedres := resource.(type) {
|
||||
case *ArchiveUploadSpec:
|
||||
for _, aus := range fr.archiveUploadSpecs {
|
||||
if compareMetadata && aus.Name != typedres.Name {
|
||||
continue
|
||||
}
|
||||
if compareSpec &&
|
||||
!(reflect.DeepEqual(aus.RootDir, typedres.RootDir) &&
|
||||
reflect.DeepEqual(aus.IncludeGlobs, typedres.IncludeGlobs) &&
|
||||
reflect.DeepEqual(aus.ExcludeGlobs, typedres.ExcludeGlobs)) {
|
||||
continue
|
||||
}
|
||||
return &metav1.ObjectMeta{Name: aus.Name}
|
||||
}
|
||||
return nil
|
||||
case *crd.Package:
|
||||
for _, p := range fr.packages {
|
||||
if compareMetadata && !reflect.DeepEqual(p.Metadata, typedres.Metadata) {
|
||||
continue
|
||||
}
|
||||
if compareSpec && !reflect.DeepEqual(p.Spec, typedres.Spec) {
|
||||
continue
|
||||
}
|
||||
return &p.Metadata
|
||||
}
|
||||
return nil
|
||||
|
||||
default:
|
||||
// XXX not implemented
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user