Esempio n. 1
0
        private void AddLayerToConfigAndManifest(BuilderLayer layer, ManifestV2 manifest, ImageV1 image)
        {
            image.rootfs.diff_ids.Add(layer.DiffId);
            image.history.Add(ImageV1History.Create(layer.Description, null));

            var(imageBytes, imageDigest) = ToJson(image);

            manifest.config.digest = imageDigest;
            manifest.config.size   = imageBytes.Length;
            manifest.layers.Add(new ManifestV2Layer
            {
                digest = layer.Digest,
                size   = layer.Size,
            });
        }
Esempio n. 2
0
        private void UpdateImageConfig(ImageV1 image)
        {
            var config         = image.config;
            var historyStrings = new List <string>();

            // do git labels before other labels, to enable users to overwrite them
            if (GitLabels.HasValue())
            {
                IDictionary <string, string> gitLabels = null;
                try
                {
                    gitLabels = Utils.GitLabels.GetLabels(GitLabels.Value(), GitLabelsPrefix.Value());
                }
                catch (Exception ex)
                {
                    _logger.LogWarning($"Failed to read git labels: {ex.Message}");
                }

                if (gitLabels != null)
                {
                    foreach (var l in gitLabels)
                    {
                        config.Labels        = config.Labels ?? new Dictionary <string, string>();
                        config.Labels[l.Key] = l.Value;
                        historyStrings.Add($"--gitLabels {l.Key}={l.Value}");
                    }
                }
            }

            foreach (var label in Label.Values)
            {
                config.Labels = config.Labels ?? new Dictionary <string, string>();
                var split = label.Split('=', 2);
                if (split.Length != 2)
                {
                    throw new Exception($"Invalid label {label}");
                }

                config.Labels[split[0]] = split[1];
                historyStrings.Add($"--label {split[0]}={split[1]}");
            }

            foreach (var var in Env.Values)
            {
                config.Env = config.Env ?? new List <string>();
                config.Env.Add(var);
                historyStrings.Add($"--env {var}");
            }

            if (WorkDir.HasValue())
            {
                config.WorkingDir = WorkDir.Value();
                historyStrings.Add($"--workdir {WorkDir.Value()}");
            }

            if (User.HasValue())
            {
                config.User = User.Value();
                historyStrings.Add($"--user {User.Value()}");
            }

            if (Cmd.HasValue())
            {
                config.Cmd = SplitCmd(Cmd.Value()).ToList();
                var cmdString = string.Join(", ", config.Cmd.Select(c => $"\"{c}\""));
                historyStrings.Add($"--cmd {cmdString}");
            }

            if (Entrypoint.HasValue())
            {
                config.Entrypoint = SplitCmd(Entrypoint.Value()).ToList();
                var epString = string.Join(", ", config.Entrypoint.Select(c => $"\"{c}\""));
                historyStrings.Add($"--entrypoint {epString}");
            }

            if (historyStrings.Any())
            {
                image.history.Add(ImageV1History.Create(string.Join(", ", historyStrings), true));
            }

            foreach (var h in historyStrings)
            {
                _logger.LogDebug(h);
            }
        }
Esempio n. 3
0
 private void UpdateConfigInManifest(ManifestV2 manifest, ImageV1 image)
 {
     var(imageBytes, imageDigest) = ToJson(image);
     manifest.config.digest       = imageDigest;
     manifest.config.size         = imageBytes.Length;
 }
    public static void RemoveAllUnrefImage()
    {
        List <string> selectFolder = new List <string>();

        foreach (string sceneGuid in Selection.assetGUIDs)
        {
            string path = AssetDatabase.GUIDToAssetPath(sceneGuid);
//            Debugger.Log("lua print : {0}", path);
            selectFolder.Add(path);
        }

        Dictionary <string, ImageV1> images = new Dictionary <string, ImageV1>();

        string[] imagesGuid = AssetDatabase.FindAssets("t:texture", selectFolder.ToArray());
        foreach (string iguid in imagesGuid)
        {
            string  path = AssetDatabase.GUIDToAssetPath(iguid);
            ImageV1 iv0  = new ImageV1();
            iv0.path = path;
            images.Add(path, iv0);
//            Debugger.Log("lua print: {0}", path);
        }

        string[] prefabFolder = new string[] { "Assets/Game/Arts_Modules", "Assets/Game/Resources" };
        string[] prefabGuid   = AssetDatabase.FindAssets("t:prefab", prefabFolder);
        foreach (string iguid in prefabGuid)
        {
            string path = AssetDatabase.GUIDToAssetPath(iguid);
//            images.Add(path);
//            Debugger.Log("lua print: {0}", path);
            GameObject  prefabObj  = (GameObject)AssetDatabase.LoadAssetAtPath(path, typeof(GameObject));
            GameObject  insObj     = GameObject.Instantiate(prefabObj);
            Component[] imageComps = insObj.GetComponentsInChildren <Image>(true);
            foreach (Component c in imageComps)
            {
                Image  img        = (Image)c;
                string spritePath = AssetDatabase.GetAssetPath(img.sprite);
                if (images.ContainsKey(spritePath))
                {
                    ImageV1 v = images[spritePath];
                    if (v.refPrefab.ContainsKey(path))
                    {
                        RefPrefab prefab = v.refPrefab[path];
                        prefab.refGameObject.Add(GetGameObjectPath(img.gameObject));
                    }
                    else
                    {
                        RefPrefab prefab = new RefPrefab();
                        prefab.prefabPath = path;
                        prefab.refGameObject.Add(GetGameObjectPath(img.gameObject));
                        v.refPrefab.Add(path, prefab);
                    }
                }
            }
            GameObject.DestroyImmediate(insObj);
        }

        foreach (ImageV1 img in images.Values)
        {
            Debug.LogFormat("lua print : path:{0}", img.path);
            Debug.LogFormat("lua print :   |count:{0}", img.refPrefab.Count);
            foreach (RefPrefab p in img.refPrefab.Values)
            {
                Debug.LogFormat("lua print :     |trefPath:{0}", p.prefabPath);
                foreach (string str in p.refGameObject)
                {
                    Debug.LogFormat("lua print :       |gameObject:{0}", str);
                }
            }
            Debug.Log("lua print : ------------------------------");
        }
        foreach (ImageV1 img in images.Values)
        {
            if (img.refPrefab.Count <= 0)
            {
                Debug.LogWarningFormat("delete file : {0}", img.path);
                AssetDatabase.DeleteAsset(img.path);
            }
        }
    }