예제 #1
0
        public override void ExecuteCmdlet()
        {
            if (!this.IsParameterBound(c => c.TargetTag))
            {
                int index = SourceImage.IndexOf('@');
                this.TargetTag = new string[] { index > 0 ? SourceImage.Substring(0, index) : SourceImage };
            }

            PSImportImageParameters parameter = new PSImportImageParameters(source: new PSImportSource(sourceImage: SourceImage,
                                                                                                       resourceId: SourceRegistryResourceId,
                                                                                                       registryUri: SourceRegistryUri,
                                                                                                       credentials: this.IsParameterBound(c => c.Password) ? new PSImportSourceCredentials(Username, Password) : null),
                                                                            targetTags: new List <string>(TargetTag),
                                                                            untaggedTargetRepositories: this.IsParameterBound(c => c.UntaggedTargetRepository) ?  new List <string>(UntaggedTargetRepository) : null,
                                                                            mode: Mode);

            if (ShouldProcess(RegistryName, "Import image"))
            {
                RegistryClient.ImportImage(ResourceGroupName, RegistryName, parameter);
                WriteObject(true);
            }
        }