Inedo Community Forums Forums
    • Recent
    • Tags
    • Popular
    • Login

    Welcome to the Inedo Forums! Check out the Forums Guide for help getting started.

    If you are experiencing any issues with the forum software, please visit the Contact Form on our website and let us know!

    Working Rafts_CreateOrUpdateRaftItem example for Otter

    Scheduled Pinned Locked Moved Support
    otter
    18 Posts 4 Posters 54 Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • S Offline
      scusson_9923
      last edited by

      Hi,

      Thanks for the example. However, I still get the error 'Invalid value for "Content_Bytes": Invalid cast from 'System.String' to 'Inedo.Data.VarBinaryInput'' with this body:

      API_Key = "xxxxx"
      Raft_Id = 1
      RaftItemType_Code = 4
      RaftItem_Name = "JobConfigs/test.yml"
      ModifiedOn_Date = Get-Date
      ModifiedBy_User_Name = "scusson"
      Content_Bytes = [System.Convert]::ToBase64String([IO.File]::ReadAllBytes("D:\foo\bar\test.yml"))
      

      It appears that the .yml is being detected as binary?

      Scott

      atrippA 1 Reply Last reply Reply Quote 0
      • atrippA Offline
        atripp inedo-engineer @scusson_9923
        last edited by

        Hi @scusson_9923 ,

        The Invalid cast from 'System.String' to 'Inedo.Data.VarBinaryInput'' isn't related to the content of the file, it's just a problem with wiring up the API to database. Basically a bug.

        I don't know why it works on my machine, but not in your instance. It's one of those "deep in the code" things that we'd have to investigate.

        Maybe try upgrading to latest version of Otter? I suspect there was a library upgrade/fix that might make this work.

        Thanks,
        Alana

        1 Reply Last reply Reply Quote 0
        • S Offline
          scusson_9923
          last edited by

          Hi Alana,

          I updated my instance to 2024.2 and still get the same error.

          Thanks,
          Scott

          dean-houstonD 1 Reply Last reply Reply Quote 0
          • dean-houstonD Offline
            dean-houston inedo-engineer @scusson_9923
            last edited by

            Hi @scusson_9923 ,

            This seems to be an issue related to release vs debug builds (works fine locally, but not when deplyoed to server), and we'll investigate and fix via OT-517 in an upcoming maintenance release (2024.4) - not sure on the exact schedule, but we're targeting the next couple weeks

            -- Dean

            S 1 Reply Last reply Reply Quote 0
            • S Offline
              scusson_9923 @dean-houston
              last edited by

              @dean-houston Thanks!

              1 Reply Last reply Reply Quote 0
              • gdivisG Offline
                gdivis inedo-engineer
                last edited by

                Hi Scott,

                This fix will be included in tomorrow's release (2024.4).

                Thanks!

                1 Reply Last reply Reply Quote 0
                • S Offline
                  scusson_9923
                  last edited by

                  Hi,

                  This functionality is fixed in 2024.4. However, the script gets created as type "Unknown". How can this be set and what types are valid?

                  Thanks,
                  Scott

                  dean-houstonD 1 Reply Last reply Reply Quote 0
                  • dean-houstonD Offline
                    dean-houston inedo-engineer @scusson_9923
                    last edited by

                    Hi @scusson_9923 ,

                    What is the file you are uploading? What happens when you upload through the UI?

                    Can you share the PowerShell snippet you're using?

                    What are you specifying for RaftItemType_Code?

                    -- Dean

                    1 Reply Last reply Reply Quote 0
                    • S Offline
                      scusson_9923
                      last edited by

                      Hi Dean,

                      Here is what I'm running:

                      Invoke-WebRequest -Method Post -Uri "https://<otter_server>/api/json/Rafts_CreateOrUpdateRaftItem" -Body @{
                      API_Key = "<apikey>"
                      Raft_Id = 1
                      RaftItemType_Code = 4
                      RaftItem_Name = "JobConfigs/test.yml"
                      ModifiedOn_Date = Get-Date
                      ModifiedBy_User_Name = "scusson"
                      Content_Bytes = [System.Convert]::ToBase64String([IO.File]::ReadAllBytes("D:\test.yml"))
                      }

                      If I add the text file (test.yml) thru the UI, it gets added as binary.

                      Thanks,
                      Scott

                      dean-houstonD 1 Reply Last reply Reply Quote 0
                      • dean-houstonD Offline
                        dean-houston inedo-engineer @scusson_9923
                        last edited by

                        Hi @scusson_9923,

                        In this case, you'll likely want to select 5 as the type.

                        For reference, here are the valid types:

                            //
                            // Summary:
                            //     Specifies the type of a raft item.
                            //
                            // Remarks:
                            //     All types except BinaryFile and TextFile are "regulated" and only allow well-known
                            //     files; for example,
                            public enum RaftItemType
                            {
                                //
                                // Summary:
                                //     A role configuration plan.
                                RoleConfigurationScript = 1,
                                //
                                // Summary:
                                //     [Uninclused] A Script with .otter syntax is prefered
                                OrchestrationPlan = 2,
                                //
                                // Summary:
                                //     [Uninclused] A Script with .otter syntax is prefered
                                Module = 3,
                                //
                                // Summary:
                                //     A script.
                                Script = 4,
                                //
                                // Summary:
                                //     An unclassified binary file.
                                //
                                // Remarks:
                                //     BinaryFiles cannot be edited in a text editor, compared, etc; they are always
                                //     treated as raw content
                                BinaryFile = 5,
                                //
                                // Summary:
                                //     A deployment plan.
                                DeploymentScript = 6,
                                //
                                // Summary:
                                //     An unclassified text file.
                                //
                                // Remarks:
                                //     TextFiles can be edited in UI , may have lines replaced on deploy, and can be
                                //     used as templates
                                TextFile = 7,
                                //
                                // Summary:
                                //     A pipeline.
                                Pipeline = 8,
                                //
                                // Summary:
                                //     [Uninclused] Feature is deprecated
                                ReleaseTemplate = 9,
                                //
                                // Summary:
                                //     A job template.
                                JobTemplate = 10,
                                //
                                // Summary:
                                //     Files used with build tools like Dockerfile.
                                BuildFile = 11
                            }
                        

                        I'm not sure if TextFile (7) will work; in Otter it was intended to be used as a text template, which means lines in it are replacement. You may need to play around and see what works.

                        -- Dean

                        1 Reply Last reply Reply Quote 0
                        • S Offline
                          scusson_9923
                          last edited by

                          Hi Dean,

                          Setting RaftItemType_Code = 7 in this instance worked for me. Appreciate the list of valid types. Thanks for all of your help!

                          Scott

                          1 Reply Last reply Reply Quote 0

                          Hello! It looks like you're interested in this conversation, but you don't have an account yet.

                          Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

                          With your input, this post could be even better 💗

                          Register Login
                          • 1 / 1
                          • First post
                            Last post
                          Inedo Website Home • Support Home • Code of Conduct • Forums Guide • Documentation